mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-26 08:38:10 +00:00
Add button to attach IK rig
This commit is contained in:
@@ -1,12 +1,18 @@
|
|||||||
import { on } from "@storyteller/framework";
|
import { on } from "@storyteller/framework";
|
||||||
import * as studio from "@storyteller/studio";
|
import * as studio from "@storyteller/studio";
|
||||||
import {
|
import {
|
||||||
|
type EntitySelectEvent,
|
||||||
type SceneSavedEvent,
|
type SceneSavedEvent,
|
||||||
type SceneStateEvent,
|
type SceneStateEvent,
|
||||||
SceneState,
|
SceneState,
|
||||||
StudioMode,
|
StudioMode,
|
||||||
|
SceneElement,
|
||||||
} from "@storyteller/studio";
|
} from "@storyteller/studio";
|
||||||
import { StudioURLParams } from "@storyteller/studio-web";
|
import {
|
||||||
|
SceneHierarchyElement,
|
||||||
|
type SceneObject,
|
||||||
|
StudioURLParams,
|
||||||
|
} from "@storyteller/studio-web";
|
||||||
import { CanvasProvider } from "@storyteller/studio-web/canvas-provider";
|
import { CanvasProvider } from "@storyteller/studio-web/canvas-provider";
|
||||||
import { match } from "@storyteller/utility";
|
import { match } from "@storyteller/utility";
|
||||||
import { LitElement, html, nothing } from "lit";
|
import { LitElement, html, nothing } from "lit";
|
||||||
@@ -33,6 +39,9 @@ export class AppElement extends LitElement {
|
|||||||
@state() showHelp = false;
|
@state() showHelp = false;
|
||||||
@state() loading = true;
|
@state() loading = true;
|
||||||
|
|
||||||
|
@state() selection?: SceneObject;
|
||||||
|
|
||||||
|
#hierarchy = createRef<SceneHierarchyElement>();
|
||||||
#params = new StudioURLParams();
|
#params = new StudioURLParams();
|
||||||
#canvasProvider: Ref<CanvasProvider> = createRef();
|
#canvasProvider: Ref<CanvasProvider> = createRef();
|
||||||
|
|
||||||
@@ -72,6 +81,15 @@ export class AppElement extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@on("entity-select")
|
||||||
|
onEntitySelected({ detail: id }: EntitySelectEvent): void {
|
||||||
|
if (!id) {
|
||||||
|
this.selection = undefined;
|
||||||
|
} else {
|
||||||
|
this.selection = this.#hierarchy.value?.entityMap.get(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleHelp(): void {
|
toggleHelp(): void {
|
||||||
this.showHelp = !this.showHelp;
|
this.showHelp = !this.showHelp;
|
||||||
}
|
}
|
||||||
@@ -102,6 +120,15 @@ export class AppElement extends LitElement {
|
|||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</sts-button>
|
</sts-button>
|
||||||
|
<sts-button
|
||||||
|
icon="share-nodes"
|
||||||
|
?disabled=${this.selection?.type !== SceneElement.Skeleton}
|
||||||
|
@click=${() => {
|
||||||
|
console.log("Attach IK rig");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Attach IK Rig
|
||||||
|
</sts-button>
|
||||||
` : nothing}
|
` : nothing}
|
||||||
<sts-button
|
<sts-button
|
||||||
class=${classMap({ active: this.showHelp })}
|
class=${classMap({ active: this.showHelp })}
|
||||||
@@ -115,9 +142,16 @@ export class AppElement extends LitElement {
|
|||||||
|
|
||||||
<!-- Studio-mode-only elements -->
|
<!-- Studio-mode-only elements -->
|
||||||
${this.#params.mode === StudioMode.Editor ? html`
|
${this.#params.mode === StudioMode.Editor ? html`
|
||||||
<sts-transform-toolbar class="v-start h-center"></sts-transform-toolbar>
|
<sts-transform-toolbar
|
||||||
<sts-scene-hierarchy class="hierarchy v-start h-end"></sts-scene-hierarchy>
|
class="v-start h-center"
|
||||||
<sts-anim-editor class="timeline v-end h-start h-before-hierarchy"></sts-anim-editor>
|
></sts-transform-toolbar>
|
||||||
|
<sts-scene-hierarchy
|
||||||
|
class="hierarchy v-start h-end"
|
||||||
|
${ref(this.#hierarchy)}
|
||||||
|
></sts-scene-hierarchy>
|
||||||
|
<sts-anim-editor
|
||||||
|
class="timeline v-end h-start h-before-hierarchy"
|
||||||
|
></sts-anim-editor>
|
||||||
` : nothing}
|
` : nothing}
|
||||||
|
|
||||||
<!-- Dialogs and modals -->
|
<!-- Dialogs and modals -->
|
||||||
|
|||||||
@@ -31,6 +31,12 @@
|
|||||||
color: #FFFF;
|
color: #FFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host(.disabled),
|
||||||
|
:host(.disabled:hover) {
|
||||||
|
background: #0003;
|
||||||
|
color: #FFF6;
|
||||||
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
fill: currentColor;
|
fill: currentColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { on } from "@storyteller/framework";
|
import { on } from "@storyteller/framework";
|
||||||
import { LitElement, html, nothing, unsafeCSS } from "lit";
|
import { LitElement, type PropertyValues, html, nothing, unsafeCSS } from "lit";
|
||||||
import { customElement, property } from "lit/decorators.js";
|
import { customElement, property } from "lit/decorators.js";
|
||||||
|
|
||||||
import styles from "./button.element.scss?inline";
|
import styles from "./button.element.scss?inline";
|
||||||
@@ -11,10 +11,21 @@ export class ButtonElement extends LitElement {
|
|||||||
static override styles = unsafeCSS(styles);
|
static override styles = unsafeCSS(styles);
|
||||||
|
|
||||||
@property() icon?: string;
|
@property() icon?: string;
|
||||||
|
@property({ type: Boolean }) disabled = false;
|
||||||
|
|
||||||
override role = "button";
|
override role = "button";
|
||||||
override tabIndex = 0;
|
override tabIndex = 0;
|
||||||
|
|
||||||
|
protected override willUpdate(changes: PropertyValues<this>): void {
|
||||||
|
if (changes.has("disabled")) {
|
||||||
|
this.ariaDisabled = this.disabled ? "true" : null;
|
||||||
|
this.tabIndex = this.disabled ? -1 : 0;
|
||||||
|
this.classList.toggle("disabled", this.disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.willUpdate(changes);
|
||||||
|
}
|
||||||
|
|
||||||
@on("keydown")
|
@on("keydown")
|
||||||
onKeyDown(event: KeyboardEvent) {
|
onKeyDown(event: KeyboardEvent) {
|
||||||
if (/^( |Enter)$/.test(event.key)) {
|
if (/^( |Enter)$/.test(event.key)) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import fasCheck from "@fortawesome/fontawesome-pro/svgs/solid/check.svg?raw";
|
|||||||
import fasXmark from "@fortawesome/fontawesome-pro/svgs/solid/xmark.svg?raw";
|
import fasXmark from "@fortawesome/fontawesome-pro/svgs/solid/xmark.svg?raw";
|
||||||
import fasCircleCheck from "@fortawesome/fontawesome-pro/svgs/solid/circle-check.svg?raw";
|
import fasCircleCheck from "@fortawesome/fontawesome-pro/svgs/solid/circle-check.svg?raw";
|
||||||
import fasCircleXmark from "@fortawesome/fontawesome-pro/svgs/solid/circle-xmark.svg?raw";
|
import fasCircleXmark from "@fortawesome/fontawesome-pro/svgs/solid/circle-xmark.svg?raw";
|
||||||
|
import farShareNodes from "@fortawesome/fontawesome-pro/svgs/regular/share-nodes.svg?raw";
|
||||||
|
|
||||||
import styles from "./icon.element.scss?inline";
|
import styles from "./icon.element.scss?inline";
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ function renderSvg(iconId: string) {
|
|||||||
"question": () => fasQuestion,
|
"question": () => fasQuestion,
|
||||||
"rotate": () => farRotate,
|
"rotate": () => farRotate,
|
||||||
"scale": () => farScale,
|
"scale": () => farScale,
|
||||||
|
"share-nodes": () => farShareNodes,
|
||||||
"skeleton": () => farSkeleton,
|
"skeleton": () => farSkeleton,
|
||||||
"up-down-left-right": () => farUpDownLeftRight,
|
"up-down-left-right": () => farUpDownLeftRight,
|
||||||
"video": () => farVideo,
|
"video": () => farVideo,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import styles from "./scene-hierarchy.element.scss?inline";
|
|||||||
|
|
||||||
import "@storyteller/studio-ui/tree";
|
import "@storyteller/studio-ui/tree";
|
||||||
|
|
||||||
interface SceneObject extends Omit<studio.SceneObject, "icon"|"children"> {
|
export interface SceneObject extends Omit<studio.SceneObject, "children"> {
|
||||||
icon?: string;
|
icon?: string;
|
||||||
children: SceneObject[];
|
children: SceneObject[];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user