mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
small changes
This commit is contained in:
@@ -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<string, string> = {
|
||||
camera: "video",
|
||||
@@ -18,8 +19,18 @@ const TRACK_ICONS : Record<string, string> = {
|
||||
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<string, {name?: string, target_type: string }> = {};
|
||||
@state() tracks : Record<string, {name?: string, target_type: studio.SceneElement }> = {};
|
||||
|
||||
@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`
|
||||
<sts-tree class=${`track`}
|
||||
role="button"
|
||||
|
||||
@@ -595,7 +595,7 @@ mod wasm {
|
||||
export interface UpdateAnimationTargets extends CustomEvent {
|
||||
type: "update-animation-targets",
|
||||
detail: {
|
||||
added: Record<string, { name?: string, target_type: 'camera' | 'transform' | 'light' | 'bone' | 'skeleton' | 'mesh' } >,
|
||||
added: Record<string, { name?: string, target_type: SceneElement } >,
|
||||
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<String>,
|
||||
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,
|
||||
},
|
||||
)
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user