From 8fc0c968c2513f66e4c99fb8f2be62368513115d Mon Sep 17 00:00:00 2001 From: Lee-Orr Date: Wed, 20 Mar 2024 18:38:26 -0400 Subject: [PATCH] small changes --- .../src/app/anim-editor.element.ts | 23 ++++++++++++----- studio/src/anim/timeline_animation.rs | 25 ++++--------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/studio-frontend/src/app/anim-editor.element.ts b/studio-frontend/src/app/anim-editor.element.ts index 1e88bc6..f622a1f 100644 --- a/studio-frontend/src/app/anim-editor.element.ts +++ b/studio-frontend/src/app/anim-editor.element.ts @@ -1,6 +1,6 @@ import * as studio from "@storyteller/studio"; -import type { EntitySelectEvent, SeekTimeChanged, UpdateAnimationTargets } from "@storyteller/studio"; -import { bind, drag, on } from "@storyteller/framework"; +import type { EntitySelectEvent, SeekTimeChanged, UpdateAnimationTargets, Keyframe } from "@storyteller/studio"; +import { bind, drag, inject, on } from "@storyteller/framework"; import { LitElement, type PropertyValues, html, unsafeCSS, TemplateResult, PropertyValueMap } from "lit"; import { customElement, state } from "lit/decorators.js"; import { styleMap } from "lit/directives/style-map.js"; @@ -11,6 +11,7 @@ import "@storyteller/studio-ui/tree"; import "./anim-timeline.element"; import styles from "./anim-editor.element.scss?inline"; +import { SCENE_DATA_PROVIDER, type SceneDataProvider } from "@storyteller/studio-web/scene-data-provider"; const TRACK_ICONS : Record = { camera: "video", @@ -18,8 +19,18 @@ const TRACK_ICONS : Record = { light: "light" }; +function isOutsideEntity( + value?: { track: string } | { outsideEntity: string } +): value is { outsideEntity: string } { + if (value == null) return false; + return "outsideEntity" in value; +} + @customElement("sts-anim-editor") export class AnimEditorElement extends LitElement { + @inject(SCENE_DATA_PROVIDER) + sceneData?: SceneDataProvider; + static override styles = unsafeCSS(styles); @state() sidebarWidth = 256; @@ -33,7 +44,7 @@ export class AnimEditorElement extends LitElement { @state() playHead = 0; @state() playing = false; - @state() tracks : Record = {}; + @state() tracks : Record = {}; @state() track_ordered : string[] = []; @@ -243,7 +254,7 @@ export class AnimEditorElement extends LitElement { } const selected = typeof this.selected_track === "object" && "track" in this.selected_track ? this.selected_track.track : false; - const can_add_selected = typeof this.selected_track === "object" && "outside_entity" in this.selected_track ? this.selected_track.outside_entity : false; + const canAddSelected = typeof this.selected_track === "object" && "outside_entity" in this.selected_track ? this.selected_track.outside_entity : false; let length = this.timelineEnd - this.timelineStart; let clip_start = (this.clipStart - this.timelineStart) / length; @@ -252,7 +263,7 @@ export class AnimEditorElement extends LitElement { let timeline_css_variables = { '--track-count': `${this.trackCount()}`, - '--row-count': `calc(var(--track-count) + ${can_add_selected ? 3 : 2})`, + '--row-count': `calc(var(--track-count) + ${canAddSelected ? 3 : 2})`, '--clip-end': `${clip_end * 100}%`, '--clip-start': `${clip_start * 100}%` }; @@ -273,7 +284,7 @@ export class AnimEditorElement extends LitElement { `; }); - if (can_add_selected) { + if (canAddSelected) { tracklist.push(html` , + added: Record, removed: string[] } } @@ -639,17 +639,10 @@ mod wasm { } "#; - const CAMERA: &str = "camera"; - const TRANSFORM: &str = "transform"; - const LIGHT: &str = "light"; - const BONE: &str = "bone"; - const SKELETON: &str = "skeleton"; - const MESH: &str = "mesh"; - #[derive(Serialize, Deserialize)] struct AddedAnimationTargetRecordItem { name: Option, - target_type: String, + target_type: SceneElement, } #[derive(Serialize, Deserialize)] @@ -715,7 +708,7 @@ mod wasm { format!("{entity:?}"), AddedAnimationTargetRecordItem { name: name.map(|v| v.to_string()), - target_type: TRANSFORM.to_owned(), + target_type: SceneElement::Generic, }, ) }) @@ -724,7 +717,7 @@ mod wasm { format!("{entity:?}"), AddedAnimationTargetRecordItem { name: name.map(|v| v.to_string()), - target_type: CAMERA.to_owned(), + target_type: SceneElement::Camera, }, ) })) @@ -733,15 +726,7 @@ mod wasm { format!("{entity:?}"), AddedAnimationTargetRecordItem { name: name.map(|v| v.to_string()), - target_type: match element { - SceneElement::Generic => TRANSFORM, - SceneElement::Mesh => MESH, - SceneElement::Skeleton => SKELETON, - SceneElement::Bone => BONE, - SceneElement::Light => LIGHT, - SceneElement::Camera => CAMERA, - } - .to_string(), + target_type: *element, }, ) }))