Skip to content

The VS Code of video editing, built for agents.

TypeScript

Add animation management to Inspector with new animation types integration

konstantin-paulus0b232ea1c8c9
diff --git a/apps/web/src/components/sidebar-right/inspector/animation-types.ts b/apps/web/src/components/sidebar-right/inspector/animation-types.ts
new file mode 100644
index 00000000..8994b9cd
--- /dev/null
+++ b/apps/web/src/components/sidebar-right/inspector/animation-types.ts
@@ -0,0 +1,84 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { ANIMATION_TYPES } from "@diffusionstudio/reconciler";
+
+import type { AnimationType as AnimationName } from "@diffusionstudio/jsx";
+import type { AnimationType } from "@diffusionstudio/runtime";
+
+export type AnimationOption = {
+ name: AnimationName;
+ label: string;
+};
+
+/**
+ * Which nodes a group is offered on: a text animation needs glyphs to move,
+ * a gain needs something to hear. A group without a kind fits every node.
+ */
+export type AnimationGroupKind = "text" | "audio";
+
+export type AnimationGroup = {
+ label: string;
+ kind?: AnimationGroupKind;
+ options: AnimationOption[];
+};
+
+/** The presets, grouped as the type select shows them. */
+export const ANIMATION_GROUPS: AnimationGroup[] = [
+ {
+ label: "Fade",
+ options: [
+ { name: "fade", label: "Fade" },
+ { name: "slideLeft", label: "Slide left" },
+ { name: "slideRight", label: "Slide right" },
+ { name: "slideUp", label: "Slide up" },
+ { name: "slideDown", label: "Slide down" },
+ ],
+ },
+ {
+ label: "Scale",
+ options: [
+ { name: "grow", label: "Grow" },
+ { name: "shrink", label: "Shrink" },
+ { name: "spin", label: "Spin" },
+ { name: "twist", label: "Twist" },
+ ],
+ },
+ {
+ label: "Blur",
+ options: [{ name: "blur", label: "Blur" }],
+ },
+ {
+ label: "Text",
+ kind: "text",
+ options: [
+ { name: "appearWord", label: "Appear word" },
+ { name: "appearChar", label: "Appear character" },
+ { name: "scramble", label: "Scramble" },
+ ],
+ },
+ {
+ label: "Audio",
+ kind: "audio",
+ options: [{ name: "gain", label: "Volume" }],
+ },
+];
+
+const ALL_OPTIONS = ANIMATION_GROUPS.flatMap((group) => group.options);
+
+/** What the panel's plus authors: a fade, the one preset every node can play. */
+export const DEFAULT_ANIMATION: AnimationOption = ALL_OPTIONS[0]!;
+
+const BY_TYPE = new Map<AnimationType, AnimationOption>(
+ ALL_OPTIONS.map((option) => [ANIMATION_TYPES[option.name]!, option]),
+);
+
+/**
+ * The option for the type an `Animation` trait holds. Identity matters: the
+ * type select compares its value against the groups it was given, so this
+ * hands back the option itself rather than a copy.
+ */
+export function animationOption(type: AnimationType | undefined): AnimationOption {
+ return (type === undefined ? undefined : BY_TYPE.get(type)) ?? DEFAULT_ANIMATION;
+}
diff --git a/apps/web/src/components/sidebar-right/inspector/animations.tsx b/apps/web/src/components/sidebar-right/inspector/animations.tsx
index f9f36fa6..59380100 100644
--- a/apps/web/src/components/sidebar-right/inspector/animations.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/animations.tsx
@@ -2,19 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+import { For, Show, createMemo, createSignal } from "solid-js";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { ControlRow } from "@/components/ui/control-group";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuGroup,
- DropdownMenuGroupLabel,
- DropdownMenuItem,
- DropdownMenuPortal,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
import {
FloatingInspector,
FloatingInspectorContent,
@@ -29,102 +20,149 @@ import {
SelectContent,
SelectItem,
SelectPortal,
+ SelectSection,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { SliderInput } from "@/components/ui/slider-input";
-import { For, Show, createMemo, createSignal } from "solid-js";
+import { useTrait, useWorld } from "@diffusionstudio/koota-solid";
+import { Animation as AnimationElement } from "@diffusionstudio/reconciler";
+import {
+ Animation,
+ AnimationPhase,
+ Cache,
+ FrameRate,
+ Paint,
+ PaintType,
+ framesToSeconds,
+ getIntrinsicPaint,
+ isAudio,
+ isText,
+} from "@diffusionstudio/runtime";
+import { useDerived, useEditor } from "@/engine/hooks";
+import { ANIMATION_GROUPS, DEFAULT_ANIMATION, animationOption } from "./animation-types";
-import { useEntityState, AnimationType, AnimationPhase, PaintType, createEntity, deleteEntity, isAudio, isText, appendChild, setComponent } from "@/components/engine";
-import { useEngine } from "@/context/engine";
-import { secondsToFrames } from "@/components/engine/utils/time";
+import type { AnimationGroup, AnimationOption } from "./animation-types";
+import type { Entity } from "koota";
+/** `<animation>`'s defaults; a control left at one of these unsets its prop. */
+const DEFAULT_DURATION = 1;
+const DEFAULT_DELAY = 0;
+
+// Stable identity, so a node without animations does not resample every tick.
+const NO_ANIMATIONS: Entity[] = [];
+
+const phaseRank = (animation: Entity) =>
+ animation.get(Animation)?.phase === AnimationPhase.OUT ? 1 : 0;
+
+const sameOrder = (a: Entity[], b: Entity[]) =>
+ a.length === b.length && a.every((entity, index) => entity === b[index]);
type AnimationsSettingsProps = {
- selection: Set<number>;
+ selection: Entity[];
};
-const ANIMATION_LABELS: Record<AnimationType, string> = {
- [AnimationType.FADE]: "Fade",
- [AnimationType.GAIN]: "Volume",
- [AnimationType.GROW]: "Grow",
- [AnimationType.SHRINK]: "Shrink",
- [AnimationType.BLUR]: "Blur",
- [AnimationType.SLIDE_LEFT]: "Slide left",
- [AnimationType.SLIDE_RIGHT]: "Slide right",
- [AnimationType.SLIDE_UP]: "Slide up",
- [AnimationType.SLIDE_DOWN]: "Slide down",
- [AnimationType.SPIN]: "Spin",
- [AnimationType.TWIST]: "Twist",
- [AnimationType.APPEAR_WORD]: "Appear word",
- [AnimationType.APPEAR_CHAR]: "Appear character",
- [AnimationType.SCRAMBLE]: "Scramble",
-};
+/**
+ * The `<animation>` children of the selected node: the presets it plays over
+ * its head and tail. Rows are the ones playing in first and the ones playing
+ * out after, each in the file's order, which is the order they write in when
+ * two of them drive the same property.
+ *
+ * The plus authors a fade rather than asking which preset first: every
+ * animation is the same three settings under a different name, so which one
+ * it is, is a control in the inspector like the others.
+ */
+export function AnimationsSettings(props: AnimationsSettingsProps) {
+ const editor = useEditor();
+ const entity = () => props.selection[0]!;
+
+ let anchorRef!: HTMLDivElement;
+
+ const [picked, setPicked] = createSignal<Entity>();
+
+ // Cache is derived state, written without change events.
+ const animations = useDerived(() => {
+ const list = entity().get(Cache)?.animations ?? NO_ANIMATIONS;
+ // Sorting is stable, so the file's order survives within each phase.
+ return list.length < 2 ? list : [...list].sort((a, b) => phaseRank(a) - phaseRank(b));
+ }, sameOrder);
+
+ const handleAppendAnimation = () => {
+ const [animation] = editor.insertElement(entity(), () => (
+ <AnimationElement type={DEFAULT_ANIMATION.name} />
+ ));
+ // Which preset it is, is the one thing the default cannot answer, so the
+ // inspector opens on the new animation for it to be said.
+ if (animation) setPicked(animation);
+ };
+
+ // Read back off the list, so removing an animation closes the inspector on it.
+ const editing = createMemo(() => {
+ const animation = picked();
+ return animation !== undefined && animations().includes(animation) ? animation : undefined;
+ });
-type AnimationGroupKind = "text" | "audio";
-
-const ANIMATION_GROUPS: Array<{ label: string; types: AnimationType[]; kind?: AnimationGroupKind }> = [
- {
- label: "Fade",
- types: [
- AnimationType.FADE,
- AnimationType.SLIDE_LEFT,
- AnimationType.SLIDE_RIGHT,
- AnimationType.SLIDE_UP,
- AnimationType.SLIDE_DOWN,
- ],
- },
- {
- label: "Scale",
- types: [
- AnimationType.GROW,
- AnimationType.SHRINK,
- AnimationType.SPIN,
- AnimationType.TWIST,
- ],
- },
- {
- label: "Blur",
- types: [AnimationType.BLUR],
- },
- {
- label: "Text",
- kind: "text",
- types: [
- AnimationType.APPEAR_WORD,
- AnimationType.APPEAR_CHAR,
- AnimationType.SCRAMBLE,
- ],
- },
- {
- label: "Audio",
- kind: "audio",
- types: [AnimationType.GAIN],
- },
-];
+ return (
+ <>
+ <PanelSection
+ title="Animations"
+ ref={anchorRef}
+ actions={
+ <Tooltip>
+ <TooltipTrigger
+ as={Button}
+ size="icon"
+ variant="ghost"
+ class="text-muted-foreground"
+ onClick={handleAppendAnimation}
+ >
+ <Icon name="plus-add" />
+ </TooltipTrigger>
+ <TooltipContent>Add animation</TooltipContent>
+ </Tooltip>
+ }
+ >
+ <For each={animations()}>
+ {(animation) => (
+ <AnimationRow
+ animation={animation}
+ onSelect={() => setPicked(animation)}
+ onRemove={() => editor.remove(animation)}
+ />
+ )}
+ </For>
+ </PanelSection>
+
+ <Show when={editing() !== undefined}>
+ <AnimationInspector
+ animation={editing()!}
+ node={entity()}
+ anchorRef={anchorRef}
+ onClose={() => setPicked(undefined)}
+ />
+ </Show>
+ </>
+ );
+}
type AnimationRowProps = {
- animEid: number;
- onInspect(): void;
+ animation: Entity;
+ onSelect(): void;
onRemove(): void;
};
function AnimationRow(props: AnimationRowProps) {
- const { world } = useEngine();
- const c = world.components;
-
- const animationType = useEntityState(c.Animation.type, props.animEid, 0);
- const animationPhase = useEntityState(c.Animation.phase, props.animEid, 0);
+ const animation = useTrait(() => props.animation, Animation);
- const label = createMemo(() => ANIMATION_LABELS[animationType() as AnimationType]);
- const phaseLabel = createMemo(() => animationPhase() === AnimationPhase.OUT ? "OUT" : "IN");
+ const label = createMemo(() => animationOption(animation()?.type).label);
+ const phase = createMemo(() => (animation()?.phase === AnimationPhase.OUT ? "OUT" : "IN"));
return (
<ItemRow
+ label={phase()}
value={label()}
- label={phaseLabel()}
icon={<Icon name="preferences-adjust" />}
- onClick={props.onInspect}
+ onClick={props.onSelect}
>
<Tooltip>
<TooltipTrigger
@@ -142,218 +180,154 @@ function AnimationRow(props: AnimationRowProps) {
);
}
-export function AnimationsSettings(props: AnimationsSettingsProps) {
- const { world } = useEngine();
- const c = world.components;
-
- const [inspectingAnimation, setInspectingAnimation] = createSignal<number>();
+/** Whether `node` has anything to hear, which is what a gain animates. */
+function hasAudio(node: Entity): boolean {
+ if (isAudio(node) || getIntrinsicPaint(node) === PaintType.VIDEO) return true;
+ return (node.get(Cache)?.fills ?? []).some((fill) => fill.get(Paint)?.value === PaintType.VIDEO);
+}
- let inspectorAnchorRef: HTMLDivElement | undefined;
+type AnimationInspectorProps = {
+ animation: Entity;
+ node: Entity;
+ anchorRef: HTMLElement;
+ onClose(): void;
+};
- const eid = () => props.selection.values().next().value!;
- const animations = useEntityState(c.Cache.animations, eid, []);
- const fillEids = useEntityState(c.Cache.fills, eid, [] as number[]);
+/**
+ * One `<animation>`: which preset it is (the select in the header, where a
+ * title would be), whether it plays in or out, how long it takes and how
+ * long after the clip edge it starts. `type` is required and always written;
+ * the other three unset at their defaults.
+ */
+function AnimationInspector(props: AnimationInspectorProps) {
+ const world = useWorld();
+ const editor = useEditor();
- const availableGroups = createMemo(() => {
- // Captions are also text-geometry, so isText covers both.
- const isTextNode = isText(world, eid());
- const isAudioNode = isAudio(world, eid());
- const hasVideoFill = fillEids().some(fid => c.Paint[fid] === PaintType.VIDEO);
- const hasAudio = isAudioNode || hasVideoFill;
+ const animation = useTrait(() => props.animation, Animation);
+ const frameRate = useTrait(world, FrameRate);
- return ANIMATION_GROUPS.filter(group => {
- if (group.kind === "text") return isTextNode;
- if (group.kind === "audio") return hasAudio;
- return true;
- });
- });
+ const option = createMemo(() => animationOption(animation()?.type));
+ const fps = () => frameRate()?.value ?? 30;
+ const duration = createMemo(() => framesToSeconds(animation()?.duration ?? 0, fps()));
+ const delay = createMemo(() => framesToSeconds(animation()?.delay ?? 0, fps()));
+ const isOut = createMemo(() => animation()?.phase === AnimationPhase.OUT);
- const inAnimEids = createMemo(() =>
- animations().filter(animEid => c.Animation.phase[animEid] !== AnimationPhase.OUT)
- );
- const outAnimEids = createMemo(() =>
- animations().filter(animEid => c.Animation.phase[animEid] === AnimationPhase.OUT)
+ /**
+ * The groups this node can play, plus whichever one holds the current
+ * preset: a `gain` authored on a node that has since lost its audio still
+ * has to be shown, or the select would have no value to display.
+ */
+ const groups = createMemo(() =>
+ ANIMATION_GROUPS.filter(
+ (group) =>
+ group.kind === undefined ||
+ (group.kind === "text" ? isText(props.node) : hasAudio(props.node)) ||
+ group.options.includes(option()),
+ ),
);
- const handleAddAnimation = (type: AnimationType) => {
- world.history.transaction('Add animation', () => {
- const animEid = createEntity(world);
- setComponent(world, animEid, c.Animation, {
- duration: world.frameRate,
- type,
- phase: AnimationPhase.IN,
- });
- appendChild(world, animEid, eid());
- });
+ const handleTypeChange = (next: AnimationOption | null) => {
+ if (next === null || next.name === option().name) return;
+ editor.editProperty(props.animation, "type", next.name);
};
- const handleRemoveAnimation = (aid: number) => deleteEntity(world, aid);
- const handleInspectAnimation = (aid: number) => setInspectingAnimation(aid);
-
- // Read inspected animation's data reactively
- const inspectedPhase = useEntityState(c.Animation.phase, inspectingAnimation, 0);
- const inspectedDuration = useEntityState(c.Animation.duration, inspectingAnimation, world.frameRate);
- const inspectedDurationInSeconds = createMemo(() => inspectedDuration() / world.frameRate);
- const inspectedDelay = useEntityState(c.Animation.delay, inspectingAnimation, 0);
- const inspectedDelayInSeconds = createMemo(() => inspectedDelay() / world.frameRate);
-
- const handleDurationChange = (durationSec: number) => {
- const eid = inspectingAnimation();
- if (!eid) return;
- setComponent(world, eid, c.Animation, { duration: secondsToFrames(durationSec) });
+ const handlePhaseChange = (next: boolean) => {
+ editor.editProperty(props.animation, "phase", next ? "out" : false);
};
- const handleDelayChange = (delaySec: number) => {
- const eid = inspectingAnimation();
- if (!eid) return;
- setComponent(world, eid, c.Animation, { delay: secondsToFrames(delaySec) });
+ const handleDurationChange = (seconds: number) => {
+ const next = Math.round(seconds * 10) / 10;
+ editor.editProperty(props.animation, "duration", next === DEFAULT_DURATION ? false : next);
};
- const handlePhaseChange = (phase: AnimationPhase) => {
- const eid = inspectingAnimation();
- if (!eid) return;
- setComponent(world, eid, c.Animation, { phase });
+ const handleDelayChange = (seconds: number) => {
+ const next = Math.round(seconds * 10) / 10;
+ editor.editProperty(props.animation, "delay", next === DEFAULT_DELAY ? false : next);
};
return (
- <>
- <PanelSection
- title="Animations"
- ref={inspectorAnchorRef}
- actions={
- <DropdownMenu placement="bottom-end" modal>
- <Tooltip>
- <TooltipTrigger<typeof DropdownMenuTrigger>
- as={(triggerProps: object) => (
- <DropdownMenuTrigger<typeof Button>
- {...triggerProps}
- as={(buttonProps) => (
- <Button
- size="icon"
- variant="ghost"
- class="text-muted-foreground"
- {...buttonProps}
- >
- <Icon name="plus-add" />
- </Button>
- )}
- />
- )}
- />
- <TooltipContent>Add animation</TooltipContent>
- </Tooltip>
- <DropdownMenuPortal>
- <DropdownMenuContent>
- <For each={availableGroups()}>
- {(group, index) => (
- <>
- <Show when={index() > 0}>
- <DropdownMenuSeparator />
- </Show>
- <DropdownMenuGroup>
- <DropdownMenuGroupLabel>{group.label}</DropdownMenuGroupLabel>
- <For each={group.types}>
- {(type) => (
- <DropdownMenuItem onSelect={() => handleAddAnimation(type)}>
- {ANIMATION_LABELS[type]}
- </DropdownMenuItem>
- )}
- </For>
- </DropdownMenuGroup>
- </>
- )}
- </For>
- </DropdownMenuContent>
- </DropdownMenuPortal>
- </DropdownMenu>
- }
- >
- <For each={inAnimEids()}>
- {(animEid) => (
- <AnimationRow
- animEid={animEid}
- onInspect={() => handleInspectAnimation(animEid)}
- onRemove={() => handleRemoveAnimation(animEid)}
- />
+ <FloatingInspector open anchorRef={props.anchorRef} width={248}>
+ <FloatingInspectorHeader class="items-center justify-between px-2">
+ <Select<AnimationOption, AnimationGroup>
+ value={option()}
+ onChange={handleTypeChange}
+ options={groups()}
+ optionValue="name"
+ optionTextValue="label"
+ optionGroupChildren="options"
+ itemComponent={(itemProps) => (
+ <SelectItem item={itemProps.item}>{itemProps.item.rawValue.label}</SelectItem>
)}
- </For>
-
- <For each={outAnimEids()}>
- {(animEid) => (
- <AnimationRow
- animEid={animEid}
- onInspect={() => handleInspectAnimation(animEid)}
- onRemove={() => handleRemoveAnimation(animEid)}
- />
+ sectionComponent={(sectionProps) => (
+ <SelectSection>{sectionProps.section.rawValue.label}</SelectSection>
)}
- </For>
- </PanelSection>
+ >
+ <SelectTrigger>
+ <SelectValue<AnimationOption>>
+ {(state) => state.selectedOption()?.label}
+ </SelectValue>
+ </SelectTrigger>
+ <SelectPortal>
+ <SelectContent />
+ </SelectPortal>
+ </Select>
+ <Tooltip>
+ <TooltipTrigger
+ as={Button}
+ size="icon"
+ variant="ghost"
+ class="text-muted-foreground"
+ onClick={props.onClose}
+ >
+ <Icon name="close-remove" />
+ </TooltipTrigger>
+ <TooltipContent>Close</TooltipContent>
+ </Tooltip>
+ </FloatingInspectorHeader>
+ <FloatingInspectorSeparator />
+ <FloatingInspectorContent class="flex flex-col gap-2 p-4">
+ <ControlRow label="Phase">
+ <Select<boolean>
+ value={isOut()}
+ onChange={(value) => value !== null && handlePhaseChange(value)}
+ options={[false, true]}
+ itemComponent={(itemProps) => (
+ <SelectItem item={itemProps.item}>
+ {itemProps.item.rawValue ? "Out" : "In"}
+ </SelectItem>
+ )}
+ >
+ <SelectTrigger>
+ <SelectValue class="text-xs">{isOut() ? "Out" : "In"}</SelectValue>
+ </SelectTrigger>
+ <SelectPortal>
+ <SelectContent />
+ </SelectPortal>
+ </Select>
+ </ControlRow>
- <Show when={inspectingAnimation()}>
- <FloatingInspector open anchorRef={inspectorAnchorRef} width={248}>
- <FloatingInspectorHeader class="items-center justify-between px-2">
- <Select
- value={inspectedPhase()}
- options={[AnimationPhase.IN, AnimationPhase.OUT]}
- onChange={(value) => value !== null && handlePhaseChange(value)}
- itemComponent={(itemProps) => (
- <SelectItem item={itemProps.item}>
- {itemProps.item.rawValue === AnimationPhase.OUT ? "Out" : "In"}
- </SelectItem>
- )}
- >
- <SelectTrigger>
- <SelectValue>
- {inspectedPhase() === AnimationPhase.OUT ? "Out" : "In"}
- </SelectValue>
- </SelectTrigger>
- <SelectPortal>
- <SelectContent />
- </SelectPortal>
- </Select>
- <Tooltip>
- <TooltipTrigger
- as={Button}
- size="icon"
- variant="ghost"
- class="text-muted-foreground"
- onClick={() => setInspectingAnimation(undefined)}
- >
- <Icon name="close-remove" />
- </TooltipTrigger>
- <TooltipContent>Close</TooltipContent>
- </Tooltip>
- </FloatingInspectorHeader>
- <FloatingInspectorSeparator />
-
- <FloatingInspectorContent class="p-4 gap-2 flex flex-col">
- <ControlRow label="Duration">
- <SliderInput
- value={inspectedDurationInSeconds()}
- onChange={handleDurationChange}
- min={0.1}
- max={5}
- step={0.1}
- format={(v) => `${v.toFixed(1)}s`}
- onDragStart={() => world.history.startTransaction("Edit animation duration")}
- onDragEnd={() => world.history.commitTransaction()}
- />
- </ControlRow>
- <ControlRow label="Delay">
- <SliderInput
- value={inspectedDelayInSeconds()}
- onChange={handleDelayChange}
- min={0}
- max={5}
- step={0.1}
- format={(v) => `${v.toFixed(1)}s`}
- onDragStart={() => world.history.startTransaction("Edit animation delay")}
- onDragEnd={() => world.history.commitTransaction()}
- />
- </ControlRow>
- </FloatingInspectorContent>
- </FloatingInspector>
- </Show>
- </>
+ <ControlRow label="Duration">
+ <SliderInput
+ value={duration()}
+ onChange={handleDurationChange}
+ min={0.1}
+ max={5}
+ step={0.1}
+ format={(value) => `${value.toFixed(1)}s`}
+ />
+ </ControlRow>
+
+ <ControlRow label="Delay">
+ <SliderInput
+ value={delay()}
+ onChange={handleDelayChange}
+ min={0}
+ max={5}
+ step={0.1}
+ format={(value) => `${value.toFixed(1)}s`}
+ />
+ </ControlRow>
+ </FloatingInspectorContent>
+ </FloatingInspector>
);
}
diff --git a/apps/web/src/components/sidebar-right/inspector/inspector.tsx b/apps/web/src/components/sidebar-right/inspector/inspector.tsx
index 31c6eb60..fd46f0af 100644
--- a/apps/web/src/components/sidebar-right/inspector/inspector.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/inspector.tsx
@@ -34,7 +34,7 @@ import { TextPanel } from "./text";
import { StrokesSettings } from "./strokes";
import { ShadowsSettings } from "./shadows";
import { EffectsSettings } from "./effects";
-// import { AnimationsSettings } from "./animations";
+import { AnimationsSettings } from "./animations";
// import { TransitionSettings } from "./transition";
// import { MasksSettings } from "./masks";
// import { AudioSettings } from "./audio";
@@ -165,9 +165,9 @@ export function Inspector() {
<EffectsSettings selection={nodes()} />
</Show>
- {/* <Show when={includesTarget("shape", "text", "caption", "group", "mask")}>
+ <Show when={includesTarget("shape", "text", "caption", "group", "mask")}>
<AnimationsSettings selection={nodes()} />
- </Show> */}
+ </Show>
{/* <Show when={includesTarget("shape") && isSequenceChild()}>
<TransitionSettings selection={nodes()} />
diff --git a/packages/reconciler/src/document.ts b/packages/reconciler/src/document.ts
index 92164d88..d0b775db 100644
--- a/packages/reconciler/src/document.ts
+++ b/packages/reconciler/src/document.ts
@@ -249,7 +249,7 @@ const EASINGS: Record<string, string> = {
strong: 'spring(0.65,400)',
};
-const ANIMATION_TYPES: Record<string, AnimationType> = {
+export const ANIMATION_TYPES: Record<string, AnimationType> = {
fade: AnimationType.FADE,
gain: AnimationType.GAIN,
grow: AnimationType.GROW,
diff --git a/packages/runtime/MIGRATION.md b/packages/runtime/MIGRATION.md
index d2f8c443..1cb65841 100644
--- a/packages/runtime/MIGRATION.md
+++ b/packages/runtime/MIGRATION.md
@@ -76,7 +76,7 @@ Done:
| Draw tools + toolbar (armed tool is the `Tool` world trait) | `components/canvas/draw-overlay.tsx` |
| Input, HUD, camera, alignment | `engine/input/`, `engine/hud/`, `engine/align.ts` |
| Project config (per-scene export settings in package.json) | `engine/project-config.ts` |
-| Panels: header, background, scene template, asset info, time, appearance, alignment, export, layout, text, strokes, shadows, effects | `components/sidebar-right/inspector/` |
+| Panels: header, background, scene template, asset info, time, appearance, alignment, export, layout, text, strokes, shadows, effects, animations | `components/sidebar-right/inspector/` |
| Local font families (web fonts and loading are the runtime's) | `engine/fonts.ts` (`getLocalFonts`) |
Hosted JSX surface is `COMPOSITION_TAGS` (`packages/jsx/src/source.ts`): the structural tags, the media tags, `<captions>`, the paint family, `<stroke>`, `<shadow>`, `<effect>`, `<animation>`, `<keyframeTrack>`/`<keyframe>`, `<html>`/`<surface>`. `mask` is a `<rect>` prop, not a tag.
@@ -95,12 +95,14 @@ Conventions worth repeating when migrating the next panel:
- Reordering siblings is a swap through `editor.reparent`, not an index write: `ItemIndex` is the document's to assign (`insertNode` renumbers the whole sibling list), and a move needs an anchor, since `reparent` appends without one and refuses an append into the parent the element already has. So "move later" moves the *next* sibling in front of this one.
- A shared control that knows *which* prop it edits keyframes it itself, off an `Entity` (`ColorOpacityPicker`'s `keyframeTarget`, now koota's); only a control that cannot know takes the diamond as a slot (`ControlledTextField`, `ColorOpacityRow`). Moving one of these moves it whole: the bitecs panels still calling it lose their diamonds until they migrate, and its recent-colors palette now queries the koota world for them too (both providers are mounted).
-Still on bitecs: transform, caption-settings, fills, animations, transition, masks, audio, interpolation panels; the timeline's keyframe layer; the whole timeline UI.
+Still on bitecs: transform, caption-settings, fills, transition, masks, audio, interpolation panels; the timeline's keyframe layer; the whole timeline UI.
The stroke panel moved with the model: `StrokeStyle` is the stroke's, not the node's (as `<stroke width join cap miterLimit>` always was), so Weight/Join/Miter sit under each stroke's row instead of once per node. `<stroke>` is a solid paint that takes no paint children, so its picker is the color one alone, with no gradient or asset tab and no `FillPicker` behind it. `cap` still has no control (it shows only on open paths, and there are no icons for it).
The effects panel dropped its add menu: the plus authors an `<effect type="blur" value={8}>` outright and opens the inspector on it, where a select in the header (standing where a title would, as the export inspector's does) changes which filter it is. Every effect is the same one number under a different name, so the type is a control like any other rather than a question asked before the element exists. What that select has to answer for is the unit: `value` is px for `blur`, degrees for `hueRotate` and a 0-1 amount for the six others (`effect-types.ts` carries the table), so a switch within a unit keeps the value while one across it takes the new type's default and drops the `value` track, whose numbers meant the old unit. `type` and `value` are both required props and so are always written, never unset. `<effect>` gained `hidden` (`Pick<CompositeProps, "hidden">`, as `<shadow>` has it): the renderer already skipped a hidden effect, and the panel's row menu had no way to say so.
+The animations panel took the same plus: it authors `<animation type="fade">` (every node can play a fade) and opens the inspector, whose header select picks the preset out of the groups the node can play, `animation-types.ts` carrying them. The Text and Audio groups are offered on a text node and on one with something to hear (an audio clip, a video paint, a video fill), plus whichever group holds the preset already set, so an animation authored before the node lost its audio still has a value the select can show. `type` is required and always written; `phase`, `duration` and `delay` unset at "in", 1s and 0. Phase moved out of the header into a row of its own, since the header now names the animation. Rows list the in-animations before the out ones, each in the file's order, which is the order two animations on one property resolve in.
+
The shadow panel kept the shape it had: a row per `<shadow>` opening a floating inspector, since nothing in the shadow model moved the way the stroke's line style did. The one thing it says that the file does not is what "Add shadow" authors (`opacity` 0.25, `blur` 4, `offsetY` 4): `<shadow>`'s own defaults are all zero, which casts the silhouette back onto itself, so a shadow added from the panel has to spell out where it sits. Every control unsets at the prop's default (0 for the offsets and the blur, 1 for opacity); `color` is required and always written.
Two deliberate departures from the old text panel: `letterSpacing` is shown in px (the trait's unit and the prop's; the bitecs panel showed the same number as a percentage), and the font a text is set in — family, weight, size — is written out plainly rather than unset at its default, since a font is what a text *is* and not a modifier of it. `<captions>` has no host yet, so the caption half of the panel is unreachable and was carried over as it stood.