Skip to content

The VS Code of video editing, built for agents.

TypeScript

Enhance Inspector's Transform Settings for improved functionality and user experience

konstantin-paulus85c85852081a
diff --git a/apps/web/src/components/sidebar-right/inspector/inspector.tsx b/apps/web/src/components/sidebar-right/inspector/inspector.tsx
index 610b8829..cccb35c5 100644
--- a/apps/web/src/components/sidebar-right/inspector/inspector.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/inspector.tsx
@@ -27,7 +27,7 @@ import { AppearanceSettings } from "./appearance";
import { Alignment } from "./alignment";
import { ExportPanel } from "./export";
import { LayoutPanel } from "./layout";
-// import { TransformSettings } from "./transform";
+import { TransformSettings } from "./transform";
// import { CaptionSettings } from "./caption-settings";
import { TextPanel } from "./text";
import { FillsSettings } from "./fills";
@@ -129,9 +129,9 @@ export function Inspector() {
<TimeSettings selection={nodes()} />
</Show>
- {/* <Show when={includesTarget("shape", "text", "audio", "scene", "caption", "group", "mask", "adjustment")}>
+ <Show when={includesTarget("shape", "text", "audio", "scene", "caption", "group", "mask", "adjustment")}>
<TransformSettings selection={nodes()} />
- </Show> */}
+ </Show>
<Show when={includesTarget("shape", "text", "audio", "scene", "caption", "mask")}>
<LayoutPanel selection={nodes()} />
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/anchor-picker.tsx b/apps/web/src/components/sidebar-right/inspector/transform/anchor-picker.tsx
index a1f694e7..50c332a8 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/anchor-picker.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/transform/anchor-picker.tsx
@@ -6,34 +6,20 @@ import { createSignal, For, Show } from 'solid-js';
import { Icon } from '@/components/ui/icon';
import { anchorPositions } from './constants';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
-import { useEngine } from '@/context/engine';
-import { useEntityState, setComponent } from '@/components/engine';
-
import type { AnchorPosition } from './constants';
export type AnchorPointPickerProps = {
- nodeEid: number;
+ x: number;
+ y: number;
+ onPick(x: number, y: number): void;
};
export function AnchorPointPicker(props: AnchorPointPickerProps) {
- const { world } = useEngine();
- const c = world.components;
const [hoveredIndex, setHoveredIndex] = createSignal<number | null>(null);
- const anchorX = useEntityState(c.Anchor.x, props.nodeEid, 0.5);
- const anchorY = useEntityState(c.Anchor.y, props.nodeEid, 0.5);
-
const isActive = (pos: AnchorPosition) => {
- const ax = anchorX();
- const ay = anchorY();
- if (ax === undefined || ay === undefined) return false;
-
- return Math.abs(ax - pos.x) < 0.01 && Math.abs(ay - pos.y) < 0.01;
- };
-
- const assignAnchor = (x: number, y: number) => {
- setComponent(world, props.nodeEid, c.Anchor, { x, y });
+ return Math.abs(props.x - pos.x) < 0.01 && Math.abs(props.y - pos.y) < 0.01;
};
return (
@@ -51,7 +37,7 @@ export function AnchorPointPicker(props: AnchorPointPickerProps) {
class="w-full h-full relative rounded-md transition-colors flex items-center justify-center"
onMouseEnter={() => setHoveredIndex(index())}
onMouseLeave={() => setHoveredIndex(null)}
- onClick={() => assignAnchor(pos.x, pos.y)}
+ onClick={() => props.onPick(pos.x, pos.y)}
>
<Show
when={active() || hovered()}
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/anchor-row.tsx b/apps/web/src/components/sidebar-right/inspector/transform/anchor-row.tsx
index 3c52becd..8711ba50 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/anchor-row.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/transform/anchor-row.tsx
@@ -12,31 +12,37 @@ import {
ContextMenuContent,
ContextMenuItem,
} from "@/components/ui/context-menu";
+import { useTrait } from "@diffusionstudio/koota-solid";
+import { Anchor } from "@diffusionstudio/runtime";
import { AnchorPointPicker } from "./anchor-picker";
-import { useEngine } from "@/context/engine";
-import { useEntityState, setComponent } from "@/components/engine";
+import type { Entity } from "koota";
export type AnchorRowProps = {
- nodeEid: number;
+ node: Entity;
onRemoveAddon(): void;
};
+/**
+ * The pivot rotation, scale and skew turn about, as a fraction of the box.
+ * `Anchor` has no JSX spelling, so this writes the trait alone. Both axes go
+ * out on every write: the trait's own defaults are (0, 0) while a node
+ * without one pivots about its centre (the transform system reads an absent
+ * slot as 0.5), so adding it one axis at a time would jump the pivot to the
+ * corner.
+ */
export function AnchorRow(props: AnchorRowProps) {
- const { world } = useEngine();
- const c = world.components;
+ const anchor = useTrait(() => props.node, Anchor);
+ const anchorX = () => anchor()?.x ?? 0.5;
+ const anchorY = () => anchor()?.y ?? 0.5;
- const anchorX = useEntityState(c.Anchor.x, props.nodeEid, 0.5);
- const anchorY = useEntityState(c.Anchor.y, props.nodeEid, 0.5);
+ const isDefault = createMemo(() => anchorX() === 0.5 && anchorY() === 0.5);
- const isDefault = createMemo(() => (anchorX() === 0.5 && anchorY() === 0.5));
-
- const assignAnchor = (x: number | undefined, y: number | undefined) => {
- setComponent(world, props.nodeEid, c.Anchor, { x, y });
+ const assignAnchor = (x: number, y: number) => {
+ props.node.add(Anchor);
+ props.node.set(Anchor, { x, y });
};
- const handleResetToDefault = () => assignAnchor(0.5, 0.5);
-
return (
<ContextMenu>
<ContextMenuTrigger<typeof ControlRow>
@@ -50,7 +56,7 @@ export function AnchorRow(props: AnchorRowProps) {
<ControlledTextField
icon={<Icon name="prop-x-position" />}
value={Math.round(anchorX() * 100)}
- onNumber={(value) => assignAnchor(value / 100, undefined)}
+ onNumber={(value) => assignAnchor(value / 100, anchorY())}
step={1}
unit="%"
autoSelect
@@ -59,20 +65,17 @@ export function AnchorRow(props: AnchorRowProps) {
<ControlledTextField
icon={<Icon name="prop-y-position" />}
value={Math.round(anchorY() * 100)}
- onNumber={(value) => assignAnchor(undefined, value / 100)}
+ onNumber={(value) => assignAnchor(anchorX(), value / 100)}
step={1}
unit="%"
autoSelect
sliderEnabled
/>
</div>
- <AnchorPointPicker nodeEid={props.nodeEid} />
+ <AnchorPointPicker x={anchorX()} y={anchorY()} onPick={assignAnchor} />
</ContextMenuTrigger>
<ContextMenuContent>
- <ContextMenuItem
- disabled={isDefault()}
- onSelect={handleResetToDefault}
- >
+ <ContextMenuItem disabled={isDefault()} onSelect={() => assignAnchor(0.5, 0.5)}>
Reset to Default
</ContextMenuItem>
<ContextMenuItem onSelect={props.onRemoveAddon}>
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/constants.ts b/apps/web/src/components/sidebar-right/inspector/transform/constants.ts
index 2e7f8301..049b8cf7 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/constants.ts
+++ b/apps/web/src/components/sidebar-right/inspector/transform/constants.ts
@@ -2,7 +2,7 @@
* 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 { ConstraintType } from "@/components/engine";
+import { ConstraintType } from "@diffusionstudio/runtime";
export type Constraint = {
key: ConstraintType;
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/constraints-row.tsx b/apps/web/src/components/sidebar-right/inspector/transform/constraints-row.tsx
index 106099f1..8b528017 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/constraints-row.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/transform/constraints-row.tsx
@@ -12,36 +12,44 @@ import {
SelectPortal,
} from "@/components/ui/select";
import { horizontalConstraints, verticalConstraints } from "./constants";
-import { useEngine } from "@/context/engine";
-import { ConstraintType, useEntityState, setComponent } from "@/components/engine";
+import { useTrait } from "@diffusionstudio/koota-solid";
+import { Constraint, ConstraintType } from "@diffusionstudio/runtime";
+import type { Entity } from "koota";
type ConstraintsRowProps = {
- nodeEid: number;
+ node: Entity;
};
+/**
+ * How the node follows its scene's frame when that frame resizes. `Constraint`
+ * has no JSX spelling, so this writes the trait alone; the runtime seeds the
+ * cache it resolves against the first time it sees the node with one, so a
+ * constraint set here does not move anything until the frame changes.
+ */
export function ConstraintsRow(props: ConstraintsRowProps) {
- const { world } = useEngine();
- const c = world.components;
+ const constraint = useTrait(() => props.node, Constraint);
+ const horizontal = () => constraint()?.horizontal ?? ConstraintType.MIN;
+ const vertical = () => constraint()?.vertical ?? ConstraintType.MIN;
- const h = useEntityState(c.Constraint.horizontal, props.nodeEid, 0);
- const w = useEntityState(c.Constraint.vertical, props.nodeEid, 0);
+ const assign = (value: Partial<{ horizontal: ConstraintType; vertical: ConstraintType }>) => {
+ props.node.add(Constraint);
+ props.node.set(Constraint, value);
+ };
- const assignHorizontalConstraint = (value: ConstraintType | null) => {
+ const assignHorizontal = (value: ConstraintType | null) => {
if (value == null) return;
- setComponent(world, props.nodeEid, c.Constraint, { horizontal: value });
+ assign({ horizontal: value });
};
- const assignVerticalConstraint = (value: ConstraintType | null) => {
+
+ const assignVertical = (value: ConstraintType | null) => {
if (value == null) return;
- setComponent(world, props.nodeEid, c.Constraint, { vertical: value });
- };
- const assignCenterConstraints = () => {
- setComponent(world, props.nodeEid, c.Constraint, {
- horizontal: ConstraintType.CENTER,
- vertical: ConstraintType.CENTER,
- });
+ assign({ vertical: value });
};
+ const assignCenter = () => {
+ assign({ horizontal: ConstraintType.CENTER, vertical: ConstraintType.CENTER });
+ };
return (
<ControlRow
@@ -52,8 +60,8 @@ export function ConstraintsRow(props: ConstraintsRowProps) {
>
<div class="flex flex-col gap-2 min-w-0">
<Select<ConstraintType>
- value={h()}
- onChange={(value) => assignHorizontalConstraint(value)}
+ value={horizontal()}
+ onChange={(value) => assignHorizontal(value)}
options={horizontalConstraints.map((c) => c.key)}
itemComponent={(itemProps) => (
<SelectItem item={itemProps.item}>
@@ -75,8 +83,8 @@ export function ConstraintsRow(props: ConstraintsRowProps) {
</Select>
<Select<ConstraintType>
- value={w()}
- onChange={(value) => assignVerticalConstraint(value)}
+ value={vertical()}
+ onChange={(value) => assignVertical(value)}
options={verticalConstraints.map((c) => c.key)}
itemComponent={(itemProps) => (
<SelectItem item={itemProps.item}>
@@ -107,73 +115,73 @@ export function ConstraintsRow(props: ConstraintsRowProps) {
<div
class="group absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 -ml-[23px] cursor-pointer py-1"
- onClick={() => assignHorizontalConstraint(ConstraintType.MIN)}
+ onClick={() => assignHorizontal(ConstraintType.MIN)}
>
<div
class="w-2.5 h-0.5 rounded-sm"
classList={{
- "bg-primary": h() === ConstraintType.MIN || h() === ConstraintType.STRETCH,
- "bg-muted-foreground/40 group-hover:bg-muted-foreground/70": h() !== ConstraintType.MIN && h() !== ConstraintType.STRETCH
+ "bg-primary": horizontal() === ConstraintType.MIN || horizontal() === ConstraintType.STRETCH,
+ "bg-muted-foreground/40 group-hover:bg-muted-foreground/70": horizontal() !== ConstraintType.MIN && horizontal() !== ConstraintType.STRETCH
}}
/>
</div>
<div
class="group absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 ml-[23px] cursor-pointer py-1"
- onClick={() => assignHorizontalConstraint(ConstraintType.MAX)}
+ onClick={() => assignHorizontal(ConstraintType.MAX)}
>
<div
class="w-2.5 h-0.5 rounded-sm"
classList={{
- "bg-primary": h() === ConstraintType.MAX || h() === ConstraintType.STRETCH,
- "bg-muted-foreground/40 group-hover:bg-muted-foreground/70": h() !== ConstraintType.MAX && h() !== ConstraintType.STRETCH
+ "bg-primary": horizontal() === ConstraintType.MAX || horizontal() === ConstraintType.STRETCH,
+ "bg-muted-foreground/40 group-hover:bg-muted-foreground/70": horizontal() !== ConstraintType.MAX && horizontal() !== ConstraintType.STRETCH
}}
/>
</div>
<div
class="group absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 -mt-[23px] cursor-pointer px-1"
- onClick={() => assignVerticalConstraint(ConstraintType.MIN)}
+ onClick={() => assignVertical(ConstraintType.MIN)}
>
<div
class="w-0.5 h-2.5 rounded-sm"
classList={{
- "bg-primary": w() === ConstraintType.MIN || w() === ConstraintType.STRETCH,
- "bg-muted-foreground/40 group-hover:bg-muted-foreground/70": w() !== ConstraintType.MIN && w() !== ConstraintType.STRETCH
+ "bg-primary": vertical() === ConstraintType.MIN || vertical() === ConstraintType.STRETCH,
+ "bg-muted-foreground/40 group-hover:bg-muted-foreground/70": vertical() !== ConstraintType.MIN && vertical() !== ConstraintType.STRETCH
}}
/>
</div>
<div
class="group absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 mt-[23px] cursor-pointer px-1"
- onClick={() => assignVerticalConstraint(ConstraintType.MAX)}
+ onClick={() => assignVertical(ConstraintType.MAX)}
>
<div
class="w-0.5 h-2.5 rounded-sm"
classList={{
- "bg-primary": w() === ConstraintType.MAX || w() === ConstraintType.STRETCH,
- "bg-muted-foreground/40 group-hover:bg-muted-foreground/70": w() !== ConstraintType.MAX && w() !== ConstraintType.STRETCH
+ "bg-primary": vertical() === ConstraintType.MAX || vertical() === ConstraintType.STRETCH,
+ "bg-muted-foreground/40 group-hover:bg-muted-foreground/70": vertical() !== ConstraintType.MAX && vertical() !== ConstraintType.STRETCH
}}
/>
</div>
<div
class="group absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 cursor-pointer p-1"
- onClick={assignCenterConstraints}
+ onClick={assignCenter}
>
<div class="relative size-2.5">
<div
class="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-2.5 h-0.5 rounded-sm"
classList={{
- "bg-primary": h() === ConstraintType.CENTER,
- "bg-transparent group-hover:bg-muted-foreground/40": h() !== ConstraintType.CENTER
+ "bg-primary": horizontal() === ConstraintType.CENTER,
+ "bg-transparent group-hover:bg-muted-foreground/40": horizontal() !== ConstraintType.CENTER
}}
/>
<div
class="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-0.5 h-2.5 rounded-sm"
classList={{
- "bg-primary": w() === ConstraintType.CENTER,
- "bg-transparent group-hover:bg-muted-foreground/40": w() !== ConstraintType.CENTER
+ "bg-primary": vertical() === ConstraintType.CENTER,
+ "bg-transparent group-hover:bg-muted-foreground/40": vertical() !== ConstraintType.CENTER
}}
/>
</div>
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/offset-row.tsx b/apps/web/src/components/sidebar-right/inspector/transform/offset-row.tsx
index dd2d30ea..ace6e379 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/offset-row.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/transform/offset-row.tsx
@@ -12,38 +12,37 @@ import {
ContextMenuContent,
ContextMenuItem,
} from "@/components/ui/context-menu";
-import { useEngine } from "@/context/engine";
-import { useEntityState, addComponent, setComponent } from "@/components/engine";
-import { Keyframe } from "@/components/ui/keyframe-bitecs";
+import { Keyframe } from "@/components/ui/keyframe";
+import { useWorld } from "@diffusionstudio/koota-solid";
+import { Computed } from "@diffusionstudio/runtime";
+import { useDerived, useEditor } from "@/engine/hooks";
+import { syncKeyframe } from "@/engine/keyframes";
+import type { Entity } from "koota";
export type OffsetRowProps = {
- nodeEid: number;
+ node: Entity;
onRemoveAddon(): void;
};
+/** `offsetX`/`offsetY`: the render-time translation the slide animations drive, unset at 0. */
export function OffsetRow(props: OffsetRowProps) {
- const { world } = useEngine();
- const c = world.components;
+ const world = useWorld();
+ const editor = useEditor();
- const offsetX = useEntityState(c.Computed.offsetX, props.nodeEid, 0);
- const offsetY = useEntityState(c.Computed.offsetY, props.nodeEid, 0);
+ const offsetX = useDerived(() => props.node.get(Computed)?.offsetX ?? 0);
+ const offsetY = useDerived(() => props.node.get(Computed)?.offsetY ?? 0);
- const isDefault = createMemo(() => (offsetX() === 0 && offsetY() === 0));
+ const isDefault = createMemo(() => offsetX() === 0 && offsetY() === 0);
const updateOffsetX = (x: number) => {
- addComponent(world, props.nodeEid, c.Offset);
- setComponent(world, props.nodeEid, c.Offset, { x });
+ editor.editProperty(props.node, 'offsetX', x === 0 ? false : x);
+ syncKeyframe(world, editor, props.node, 'offsetX', x);
};
const updateOffsetY = (y: number) => {
- addComponent(world, props.nodeEid, c.Offset);
- setComponent(world, props.nodeEid, c.Offset, { y });
- };
-
- const handleResetToDefault = () => {
- updateOffsetX(0);
- updateOffsetY(0);
+ editor.editProperty(props.node, 'offsetY', y === 0 ? false : y);
+ syncKeyframe(world, editor, props.node, 'offsetY', y);
};
return (
@@ -60,7 +59,7 @@ export function OffsetRow(props: OffsetRowProps) {
step={1}
autoSelect
sliderEnabled
- keyframe={<Keyframe target={props.nodeEid} property="offset.x" />}
+ keyframe={<Keyframe target={props.node} property="offsetX" />}
/>
<ControlledTextField
icon={<Icon name="prop-y-position" />}
@@ -69,13 +68,16 @@ export function OffsetRow(props: OffsetRowProps) {
step={1}
autoSelect
sliderEnabled
- keyframe={<Keyframe target={props.nodeEid} property="offset.y" />}
+ keyframe={<Keyframe target={props.node} property="offsetY" />}
/>
</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem
disabled={isDefault()}
- onSelect={handleResetToDefault}
+ onSelect={() => {
+ updateOffsetX(0);
+ updateOffsetY(0);
+ }}
>
Reset to Default
</ContextMenuItem>
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/rotate-row.tsx b/apps/web/src/components/sidebar-right/inspector/transform/rotate-row.tsx
index 30027b2e..ababbd50 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/rotate-row.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/transform/rotate-row.tsx
@@ -13,41 +13,49 @@ import {
ContextMenuItem,
ContextMenuTrigger,
} from '@/components/ui/context-menu';
-import { useEngine } from '@/context/engine';
-import { useEntityState, setComponent } from '@/components/engine';
-import { Keyframe } from '@/components/ui/keyframe-bitecs';
+import { Keyframe } from '@/components/ui/keyframe';
+import { useTrait, useWorld } from '@diffusionstudio/koota-solid';
+import { Computed, Flip } from '@diffusionstudio/runtime';
+import { useDerived, useEditor } from '@/engine/hooks';
+import { syncKeyframe } from '@/engine/keyframes';
+import type { Entity } from 'koota';
type RotateRowProps = {
- nodeEid: number;
+ node: Entity;
onRemoveAddon(): void;
};
+/**
+ * `rotation` is a prop, unset at 0; the two flips are `Flip` alone, which the
+ * JSX has no word for, so a flipped node reads unflipped again after a
+ * recompile.
+ */
export function RotateRow(props: RotateRowProps) {
- const { world } = useEngine();
- const c = world.components;
+ const world = useWorld();
+ const editor = useEditor();
- const rotation = useEntityState(c.Computed.rotation, props.nodeEid, 0);
- const flipX = useEntityState(c.Flip.x, props.nodeEid, 1);
- const flipY = useEntityState(c.Flip.y, props.nodeEid, 1);
+ const rotation = useDerived(() => props.node.get(Computed)?.rotation ?? 0);
+ const flip = useTrait(() => props.node, Flip);
+ const flipX = () => flip()?.x ?? 1;
+ const flipY = () => flip()?.y ?? 1;
- const isDefault = createMemo(() => (rotation() === 0 && flipX() === 1 && flipY() === 1));
+ const isDefault = createMemo(() => rotation() === 0 && flipX() === 1 && flipY() === 1);
const updateRotation = (value: number) => {
- setComponent(world, props.nodeEid, c.Rotation, value);
+ editor.editProperty(props.node, 'rotation', value === 0 ? false : value);
+ syncKeyframe(world, editor, props.node, 'rotation', value);
};
- const toggleFlipX = () => {
- setComponent(world, props.nodeEid, c.Flip, { x: flipX() === 1 ? -1 : 1 });
- };
-
- const toggleFlipY = () => {
- setComponent(world, props.nodeEid, c.Flip, { y: flipY() === 1 ? -1 : 1 });
+ const setFlip = (axis: 'x' | 'y', value: -1 | 1) => {
+ props.node.add(Flip);
+ props.node.set(Flip, { [axis]: value });
};
const handleResetToDefault = () => {
updateRotation(0);
- setComponent(world, props.nodeEid, c.Flip, { x: 1, y: 1 });
+ setFlip('x', 1);
+ setFlip('y', 1);
};
return (
@@ -62,11 +70,11 @@ export function RotateRow(props: RotateRowProps) {
icon={<Icon name="rotate-angle" />}
value={rotation()}
onNumber={updateRotation}
- unit={'\u00B0'}
+ unit={'°'}
autoSelect
sliderEnabled
limitEvents
- keyframe={<Keyframe target={props.nodeEid} property="rotation" />}
+ keyframe={<Keyframe target={props.node} property="rotation" />}
/>
<div class="flex flex-1 gap-px rounded-md overflow-hidden">
<Tooltip>
@@ -74,7 +82,7 @@ export function RotateRow(props: RotateRowProps) {
as="button"
type="button"
class="flex-1 h-7 bg-input flex items-center justify-center hover:bg-input/80 text-foreground"
- onClick={() => updateRotation((rotation() ?? 0) + 90)}
+ onClick={() => updateRotation(rotation() + 90)}
>
<Icon name="rotate-90" class="size-5" />
</TooltipTrigger>
@@ -85,7 +93,7 @@ export function RotateRow(props: RotateRowProps) {
as="button"
type="button"
class="flex-1 h-7 bg-input flex items-center justify-center hover:bg-input/80 text-foreground"
- onClick={toggleFlipX}
+ onClick={() => setFlip('x', flipX() === 1 ? -1 : 1)}
>
<Icon name="flip-horizontal" class="size-5" />
</TooltipTrigger>
@@ -96,7 +104,7 @@ export function RotateRow(props: RotateRowProps) {
as="button"
type="button"
class="flex-1 h-7 bg-input flex items-center justify-center hover:bg-input/80 text-foreground"
- onClick={toggleFlipY}
+ onClick={() => setFlip('y', flipY() === 1 ? -1 : 1)}
>
<Icon name="flip-vertical" class="size-5" />
</TooltipTrigger>
@@ -106,10 +114,7 @@ export function RotateRow(props: RotateRowProps) {
</ContextMenuTrigger>
<ContextMenuContent>
- <ContextMenuItem
- disabled={isDefault()}
- onSelect={handleResetToDefault}
- >
+ <ContextMenuItem disabled={isDefault()} onSelect={handleResetToDefault}>
Reset to Default
</ContextMenuItem>
<ContextMenuItem onSelect={props.onRemoveAddon}>
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/scale-row.tsx b/apps/web/src/components/sidebar-right/inspector/transform/scale-row.tsx
index 784921d3..bc737884 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/scale-row.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/transform/scale-row.tsx
@@ -2,7 +2,7 @@
* 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 { createMemo, Show } from "solid-js";
+import { createMemo, createSignal, Show } from "solid-js";
import { ControlRow } from "@/components/ui/control-group";
import { Icon } from "@/components/ui/icon";
import { ControlledTextField } from "@/components/ui/text-field";
@@ -12,14 +12,17 @@ import {
ContextMenuContent,
ContextMenuItem,
} from "@/components/ui/context-menu";
-import { useEngine } from "@/context/engine";
-import { useEntityState, setComponent, useEntityTag, removeComponent, removeKeyframeTrack } from "@/components/engine";
-import { Keyframe } from "@/components/ui/keyframe-bitecs";
import { SegmentedIconTabs } from "@/components/ui/segmented-icon-tabs";
-import { hasComponent } from "bitecs";
+import { Keyframe } from "@/components/ui/keyframe";
+import { useWorld } from "@diffusionstudio/koota-solid";
+import { Computed, Scale, UniformScale } from "@diffusionstudio/runtime";
+import { useDerived, useEditor } from "@/engine/hooks";
+import { removeKeyframeTrack, syncKeyframe } from "@/engine/keyframes";
+
+import type { Entity } from "koota";
export type ScaleRowProps = {
- nodeEid: number;
+ node: Entity;
onRemoveAddon(): void;
};
@@ -38,53 +41,62 @@ const SCALE_MODE_ITEMS = [
},
] as const;
+/**
+ * Uniform scale is `scale`, per-axis scale is `scaleX`/`scaleY`, and the two
+ * are exclusive the way the corner radii are: `scale` wins over the pair
+ * wherever both are set (motion system), so a mode switch drops the other
+ * mode's props and its tracks. Uniform unsets at 1, since a scale of 1 is no
+ * scale at all; the axes are written out, which is what says the node is on
+ * separate scale in the first place.
+ */
export function ScaleRow(props: ScaleRowProps) {
- const { world } = useEngine();
- const c = world.components;
+ const world = useWorld();
+ const editor = useEditor();
- const eid = () => props.nodeEid;
- const mixedScale = useEntityTag(c.Scale, eid);
+ const scaleX = useDerived(() => props.node.get(Computed)?.scaleX ?? 1);
+ const scaleY = useDerived(() => props.node.get(Computed)?.scaleY ?? 1);
- const scaleX = useEntityState(c.Computed.scaleX, eid, 1);
- const scaleY = useEntityState(c.Computed.scaleY, eid, 1);
- const scaleMode = createMemo(() => mixedScale() ? 'separate' : 'uniform');
+ const [scaleMode, setScaleMode] = createSignal<ScaleMode>(
+ !props.node.has(UniformScale) && props.node.has(Scale) ? 'separate' : 'uniform'
+ );
- const isDefault = createMemo(() => (scaleX() === 1 && scaleY() === 1));
+ const isDefault = createMemo(() => scaleX() === 1 && scaleY() === 1);
- const scale = createMemo(() => {
- if (scaleY() !== scaleX()) {
- return "Mixed";
+ const handleUniformScaleChange = (value: number) => {
+ removeKeyframeTrack(world, editor, props.node, 'scaleX');
+ removeKeyframeTrack(world, editor, props.node, 'scaleY');
+ if (props.node.has(Scale)) {
+ editor.editProperty(props.node, 'scaleX', false);
+ editor.editProperty(props.node, 'scaleY', false);
}
- return Math.round(scaleX() * 100);
- });
+ editor.editProperty(props.node, 'scale', value === 1 ? false : value);
+ syncKeyframe(world, editor, props.node, 'scale', value);
- const updateScaleX = (x: number) => setComponent(world, props.nodeEid, c.Scale, { x });
- const updateScaleY = (y: number) => setComponent(world, props.nodeEid, c.Scale, { y });
- const updateScale = (scale: number) => {
- if (hasComponent(world, props.nodeEid, c.UniformScale)) {
- setComponent(world, props.nodeEid, c.UniformScale, scale)
- } else {
- setComponent(world, props.nodeEid, c.Scale, { x: scale, y: scale });
- }
+ setScaleMode('uniform');
+ };
+
+ const handleSeparateScaleChange = (axis: 'scaleX' | 'scaleY', value: number) => {
+ removeKeyframeTrack(world, editor, props.node, 'scale');
+ editor.editProperty(props.node, axis, value);
+ syncKeyframe(world, editor, props.node, axis, value);
};
const handleScaleModeChange = (mode: ScaleMode) => {
if (mode === 'uniform') {
- world.history.transaction('Change scale mode to uniform', () => {
- removeComponent(world, props.nodeEid, c.Scale);
- setComponent(world, props.nodeEid, c.UniformScale, scaleX());
- removeKeyframeTrack(world, props.nodeEid, 'scale.x');
- removeKeyframeTrack(world, props.nodeEid, 'scale.y');
- });
+ handleUniformScaleChange(scaleX());
+ return;
}
- if (mode === 'separate') {
- world.history.transaction('Change scale mode to separate', () => {
- removeComponent(world, props.nodeEid, c.UniformScale);
- setComponent(world, props.nodeEid, c.Scale, { x: scaleX(), y: scaleY() });
- removeKeyframeTrack(world, props.nodeEid, 'scale');
- });
+ // Read before the uniform scale goes, which resets both axes to 1.
+ const x = scaleX();
+ const y = scaleY();
+ setScaleMode('separate');
+ removeKeyframeTrack(world, editor, props.node, 'scale');
+ if (props.node.has(UniformScale)) {
+ editor.editProperty(props.node, 'scale', false);
}
+ editor.editProperty(props.node, 'scaleX', x);
+ editor.editProperty(props.node, 'scaleY', y);
};
return (
@@ -96,53 +108,47 @@ export function ScaleRow(props: ScaleRowProps) {
>
<ControlledTextField
icon={<Icon name="scale-size" />}
- value={scale()}
- onNumber={(value) => updateScale(value / 100)}
+ value={scaleMode() === 'separate' ? 'Mixed' : Math.round(scaleX() * 100)}
+ onNumber={(value) => handleUniformScaleChange(value / 100)}
step={1}
unit="%"
autoSelect
sliderEnabled
limitEvents
- keyframe={<Keyframe target={props.nodeEid} property="scale" />}
+ keyframe={<Keyframe target={props.node} property="scale" />}
/>
<SegmentedIconTabs
value={() => scaleMode()}
onChange={handleScaleModeChange}
items={SCALE_MODE_ITEMS}
/>
- <Show when={mixedScale()}>
+ <Show when={scaleMode() === 'separate'}>
<ControlledTextField
icon={<Icon name="prop-x-position" />}
value={Math.round(scaleX() * 100)}
- onNumber={(value) => updateScaleX(value / 100)}
+ onNumber={(value) => handleSeparateScaleChange('scaleX', value / 100)}
step={1}
unit="%"
autoSelect
sliderEnabled
limitEvents
- keyframe={<Keyframe target={props.nodeEid} property="scale.x" />}
+ keyframe={<Keyframe target={props.node} property="scaleX" />}
/>
<ControlledTextField
icon={<Icon name="prop-y-position" />}
value={Math.round(scaleY() * 100)}
- onNumber={(value) => updateScaleY(value / 100)}
+ onNumber={(value) => handleSeparateScaleChange('scaleY', value / 100)}
step={1}
unit="%"
autoSelect
sliderEnabled
limitEvents
- keyframe={<Keyframe target={props.nodeEid} property="scale.y" />}
+ keyframe={<Keyframe target={props.node} property="scaleY" />}
/>
</Show>
</ContextMenuTrigger>
<ContextMenuContent>
- <ContextMenuItem
- disabled={isDefault()}
- onSelect={() => {
- updateScaleX(1);
- updateScaleY(1);
- }}
- >
+ <ContextMenuItem disabled={isDefault()} onSelect={() => handleUniformScaleChange(1)}>
Reset to Default
</ContextMenuItem>
<ContextMenuItem onSelect={props.onRemoveAddon}>
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/skew-row.tsx b/apps/web/src/components/sidebar-right/inspector/transform/skew-row.tsx
index 3e2958ca..02871e96 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/skew-row.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/transform/skew-row.tsx
@@ -12,31 +12,30 @@ import {
ContextMenuContent,
ContextMenuItem,
} from "@/components/ui/context-menu";
-import { useEngine } from "@/context/engine";
-import { useEntityState, setComponent } from "@/components/engine";
-import { Keyframe } from "@/components/ui/keyframe-bitecs";
+import { Computed, Skew } from "@diffusionstudio/runtime";
+import { useDerived } from "@/engine/hooks";
+import type { Entity } from "koota";
export type SkewRowProps = {
- nodeEid: number;
+ node: Entity;
onRemoveAddon(): void;
};
+/**
+ * `Skew` has no JSX spelling, so this writes the trait alone and a skew is
+ * gone on the next recompile. It also has no keyframe diamonds: a track can
+ * only name a prop, and there is none to name.
+ */
export function SkewRow(props: SkewRowProps) {
- const { world } = useEngine();
- const c = world.components;
+ const skewX = useDerived(() => props.node.get(Computed)?.skewX ?? 0);
+ const skewY = useDerived(() => props.node.get(Computed)?.skewY ?? 0);
- const skewX = useEntityState(c.Computed.skewX, props.nodeEid, 0);
- const skewY = useEntityState(c.Computed.skewY, props.nodeEid, 0);
+ const isDefault = createMemo(() => skewX() === 0 && skewY() === 0);
- const isDefault = createMemo(() => (skewX() === 0 && skewY() === 0));
-
- const updateSkewX = (x: number) => {
- setComponent(world, props.nodeEid, c.Skew, { x });
- };
-
- const updateSkewY = (y: number) => {
- setComponent(world, props.nodeEid, c.Skew, { y });
+ const updateSkew = (axis: 'x' | 'y', value: number) => {
+ props.node.add(Skew);
+ props.node.set(Skew, { [axis]: value });
};
return (
@@ -49,32 +48,30 @@ export function SkewRow(props: SkewRowProps) {
<ControlledTextField
icon={<Icon name="prop-x-position" />}
value={skewX()}
- onNumber={updateSkewX}
+ onNumber={(value) => updateSkew('x', value)}
step={1}
unit="°"
autoSelect
sliderEnabled
limitEvents
- keyframe={<Keyframe target={props.nodeEid} property="skew.x" />}
/>
<ControlledTextField
icon={<Icon name="prop-y-position" />}
value={skewY()}
- onNumber={updateSkewY}
+ onNumber={(value) => updateSkew('y', value)}
step={1}
unit="°"
autoSelect
sliderEnabled
limitEvents
- keyframe={<Keyframe target={props.nodeEid} property="skew.y" />}
/>
</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem
disabled={isDefault()}
onSelect={() => {
- updateSkewX(0);
- updateSkewY(0);
+ updateSkew('x', 0);
+ updateSkew('y', 0);
}}
>
Reset to Default
diff --git a/apps/web/src/components/sidebar-right/inspector/transform/transform-settings.tsx b/apps/web/src/components/sidebar-right/inspector/transform/transform-settings.tsx
index 64e3b56d..5a6bc319 100644
--- a/apps/web/src/components/sidebar-right/inspector/transform/transform-settings.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/transform/transform-settings.tsx
@@ -15,68 +15,93 @@ import {
DropdownMenuContent,
DropdownMenuItem,
} from "@/components/ui/dropdown-menu";
+import { Keyframe } from "@/components/ui/keyframe";
+import { useWorld } from "@diffusionstudio/koota-solid";
+import {
+ Computed,
+ getParentEntity,
+ isAdjustmentLayer,
+ isScene,
+ isSequence,
+} from "@diffusionstudio/runtime";
+import { useDerived, useEditor } from "@/engine/hooks";
+import { syncKeyframe } from "@/engine/keyframes";
import { RotateRow } from "./rotate-row";
import { AnchorRow } from "./anchor-row";
import { OffsetRow } from "./offset-row";
import { ScaleRow } from "./scale-row";
import { SkewRow } from "./skew-row";
import { ConstraintsRow } from "./constraints-row";
-import { useEngine } from "@/context/engine";
-import { useEntityState, getParentEntity, setComponent } from "@/components/engine";
import { createStoredSignal } from "@/lib/store";
import { store } from "@/init";
-import { Keyframe } from "@/components/ui/keyframe-bitecs";
-import { hasComponent } from "bitecs";
+import type { Entity } from "koota";
type TransformSettingsProps = {
- selection: Set<number>;
+ selection: Entity[];
};
type TransformAddon = 'rotate' | 'anchor' | 'offset' | 'scale' | 'skew' | 'constraints';
type TransformAddons = Partial<Record<TransformAddon, boolean>>;
+/**
+ * Where a node sits and how it is transformed there. Position, rotation,
+ * offset and scale are props (`x`/`y`, `rotation`, `offsetX`/`offsetY`,
+ * `scale` or `scaleX`/`scaleY`) written through the editor; anchor, flip,
+ * skew and constraints have no JSX spelling and are written to their traits
+ * alone, so they do not survive a recompile. The rows below Position are
+ * opt-in and which ones are shown is app state, kept per user rather than
+ * per node.
+ */
export function TransformSettings(props: TransformSettingsProps) {
- const { world } = useEngine();
- const c = world.components;
-
- const eid = () => props.selection.values().next().value!;
+ const world = useWorld();
+ const editor = useEditor();
+ const entity = () => props.selection[0]!;
const [addons, setAddons] = createStoredSignal(
store.define<TransformAddons>('transform.addons', {})
);
- const posX = useEntityState(c.Computed.positionX, eid, 0);
- const posY = useEntityState(c.Computed.positionY, eid, 0);
+ const positionX = useDerived(() => entity().get(Computed)?.positionX ?? 0);
+ const positionY = useDerived(() => entity().get(Computed)?.positionY ?? 0);
- const updatePosX = (x: number) => {
- setComponent(world, eid(), c.Position, { x });
+ // Position is where the node is rather than a modifier of it, so it is
+ // written out even at 0, the way a drag on the canvas writes it.
+ const updatePositionX = (x: number) => {
+ editor.editProperty(entity(), 'x', x);
+ syncKeyframe(world, editor, entity(), 'x', x);
};
- const updatePosY = (y: number) => {
- setComponent(world, eid(), c.Position, { y });
+ const updatePositionY = (y: number) => {
+ editor.editProperty(entity(), 'y', y);
+ syncKeyframe(world, editor, entity(), 'y', y);
};
+ // Mirrors the runtime's own rule (see resolveConstraintOffsets): a sequence
+ // is not a spatial parent, so look above it, and constraints only mean
+ // something against a scene's frame.
const supportsConstraints = createMemo(() => {
- if (hasComponent(world, eid(), c.Sequential)) return false;
+ const node = entity();
+ if (isSequence(node) || isAdjustmentLayer(node)) return false;
- let parentEid = getParentEntity(world, eid());
- while (parentEid !== null && hasComponent(world, parentEid, c.Sequential)) {
- parentEid = getParentEntity(world, parentEid);
+ let parent = getParentEntity(node);
+ while (parent !== null && isSequence(parent)) {
+ parent = getParentEntity(parent);
}
- if (parentEid === null) return false;
-
- const parentIsScene = hasComponent(world, parentEid, c.Scene);
- const isAdjustmentLayer = hasComponent(world, eid(), c.AdjustmentLayer);
- return parentIsScene && !isAdjustmentLayer;
+ return parent !== null && isScene(parent);
});
+ const showAddon = (addon: TransformAddon) => addons()[addon] === true;
+ const toggleAddon = (addon: TransformAddon, on: boolean) => {
+ setAddons({ ...addons(), [addon]: on });
+ };
+
return (
<PanelSection
title="Transform"
actions={
- <Show when={!addons().rotate || !addons().anchor || !addons().offset || !addons().scale || !addons().skew || !addons().constraints}>
+ <Show when={!showAddon('rotate') || !showAddon('anchor') || !showAddon('offset') || !showAddon('scale') || !showAddon('skew') || !showAddon('constraints')}>
<DropdownMenu placement="bottom-end">
<Tooltip>
<TooltipTrigger<typeof DropdownMenuTrigger>
@@ -94,33 +119,33 @@ export function TransformSettings(props: TransformSettingsProps) {
<TooltipContent>Add transform</TooltipContent>
</Tooltip>
<DropdownMenuContent>
- <Show when={!addons().rotate}>
- <DropdownMenuItem onSelect={() => setAddons({ ...addons(), rotate: true })}>
+ <Show when={!showAddon('rotate')}>
+ <DropdownMenuItem onSelect={() => toggleAddon('rotate', true)}>
Rotate
</DropdownMenuItem>
</Show>
- <Show when={!addons().constraints}>
- <DropdownMenuItem onSelect={() => setAddons({ ...addons(), constraints: true })}>
+ <Show when={!showAddon('constraints')}>
+ <DropdownMenuItem onSelect={() => toggleAddon('constraints', true)}>
Constraints
</DropdownMenuItem>
</Show>
- <Show when={!addons().anchor}>
- <DropdownMenuItem onSelect={() => setAddons({ ...addons(), anchor: true })}>
+ <Show when={!showAddon('anchor')}>
+ <DropdownMenuItem onSelect={() => toggleAddon('anchor', true)}>
Anchor
</DropdownMenuItem>
</Show>
- <Show when={!addons().offset}>
- <DropdownMenuItem onSelect={() => setAddons({ ...addons(), offset: true })}>
+ <Show when={!showAddon('offset')}>
+ <DropdownMenuItem onSelect={() => toggleAddon('offset', true)}>
Offset
</DropdownMenuItem>
</Show>
- <Show when={!addons().scale}>
- <DropdownMenuItem onSelect={() => setAddons({ ...addons(), scale: true })}>
+ <Show when={!showAddon('scale')}>
+ <DropdownMenuItem onSelect={() => toggleAddon('scale', true)}>
Scale
</DropdownMenuItem>
</Show>
- <Show when={!addons().skew}>
- <DropdownMenuItem onSelect={() => setAddons({ ...addons(), skew: true })}>
+ <Show when={!showAddon('skew')}>
+ <DropdownMenuItem onSelect={() => toggleAddon('skew', true)}>
Skew
</DropdownMenuItem>
</Show>
@@ -133,9 +158,9 @@ export function TransformSettings(props: TransformSettingsProps) {
<div class="grid grid-cols-2 gap-2">
<ControlledTextField
icon={<Icon name="prop-x-position" />}
- keyframe={<Keyframe target={eid()} property="position.x" />}
- value={posX()}
- onNumber={updatePosX}
+ keyframe={<Keyframe target={entity()} property="x" />}
+ value={positionX()}
+ onNumber={updatePositionX}
step={1}
autoSelect
sliderEnabled
@@ -143,9 +168,9 @@ export function TransformSettings(props: TransformSettingsProps) {
/>
<ControlledTextField
icon={<Icon name="prop-y-position" />}
- keyframe={<Keyframe target={eid()} property="position.y" />}
- value={posY()}
- onNumber={updatePosY}
+ keyframe={<Keyframe target={entity()} property="y" />}
+ value={positionY()}
+ onNumber={updatePositionY}
step={1}
autoSelect
sliderEnabled
@@ -154,43 +179,28 @@ export function TransformSettings(props: TransformSettingsProps) {
</div>
</ControlRow>
- <Show when={addons().constraints && supportsConstraints()}>
- <ConstraintsRow nodeEid={eid()} />
+ <Show when={showAddon('constraints') && supportsConstraints()}>
+ <ConstraintsRow node={entity()} />
</Show>
- <Show when={addons().rotate}>
- <RotateRow
- nodeEid={eid()}
- onRemoveAddon={() => setAddons({ ...addons(), rotate: false })}
- />
+ <Show when={showAddon('rotate')}>
+ <RotateRow node={entity()} onRemoveAddon={() => toggleAddon('rotate', false)} />
</Show>
- <Show when={addons().anchor}>
- <AnchorRow
- nodeEid={eid()}
- onRemoveAddon={() => setAddons({ ...addons(), anchor: false })}
- />
+ <Show when={showAddon('anchor')}>
+ <AnchorRow node={entity()} onRemoveAddon={() => toggleAddon('anchor', false)} />
</Show>
- <Show when={addons().offset}>
- <OffsetRow
- nodeEid={eid()}
- onRemoveAddon={() => setAddons({ ...addons(), offset: false })}
- />
+ <Show when={showAddon('offset')}>
+ <OffsetRow node={entity()} onRemoveAddon={() => toggleAddon('offset', false)} />
</Show>
- <Show when={addons().scale}>
- <ScaleRow
- nodeEid={eid()}
- onRemoveAddon={() => setAddons({ ...addons(), scale: false })}
- />
+ <Show when={showAddon('scale')}>
+ <ScaleRow node={entity()} onRemoveAddon={() => toggleAddon('scale', false)} />
</Show>
- <Show when={addons().skew}>
- <SkewRow
- nodeEid={eid()}
- onRemoveAddon={() => setAddons({ ...addons(), skew: false })}
- />
+ <Show when={showAddon('skew')}>
+ <SkewRow node={entity()} onRemoveAddon={() => toggleAddon('skew', false)} />
</Show>
</PanelSection>
);
diff --git a/packages/runtime/MIGRATION.md b/packages/runtime/MIGRATION.md
index 0c7faf61..b74b498e 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, animations, transition, masks, audio, fills | `components/sidebar-right/inspector/` |
+| Panels: header, background, scene template, asset info, time, appearance, alignment, export, layout, text, strokes, shadows, effects, animations, transition, masks, audio, fills, transform | `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,7 +95,7 @@ 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, interpolation panels; the timeline's keyframe layer; the whole timeline UI.
+Still on bitecs: caption-settings and 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).
@@ -121,6 +121,16 @@ The shadow panel kept the shape it had: a row per `<shadow>` opening a floating
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.
+The transform panel is where the props run out: position, rotation, offset and scale are props like any other, but **anchor, flip, skew and constraints have no JSX spelling**, so those four rows write their traits alone and are gone on the next recompile, the way `KeepAspectRatio` and `ClipsContent` are. Two things follow from that. The skew row lost its keyframe diamonds: `skew.x`/`skew.y` are runtime property paths (the motion system does animate them), but `TRACK_PROPERTIES` maps no prop name onto them, so no `<keyframeTrack>` can name a skew and a diamond there would have toggled nothing. And `Anchor`'s trait defaults are (0, 0) while a node *without* the trait pivots about its centre (`computeLocalMatrix` reads an absent slot as 0.5), so the row writes both axes on every edit: adding the trait one axis at a time would move the pivot to the corner. The picker went presentational (it takes the anchor and an `onPick`) so that fallback is spelled once.
+
+`x`/`y` are written out even at 0, as the canvas writes them on a drag: where a node sits is what it is, the way a size is. Everything else in the panel unsets at its default, `rotation` included, so the row's "Reset to Default" removes the attribute where the canvas's rotate handle would write `rotation={0}`.
+
+Uniform versus per-axis scale is the corner-radius pattern again: uniform is `scale`, separate is `scaleX`/`scaleY`, `scale` wins wherever both are set (the motion system's rule), and a mode switch drops the other mode's props *and* its tracks. Uniform unsets at 1; the axes are written out even at 1, since that is what says the node is on separate scale at all. The `world.history.transaction` that wrapped the switch went with the history layer the koota side does not have.
+
+Fixed while the panel moved: the motion system mirrored an animated uniform scale onto `scaleY` only for a node that also had `UniformScale`, but the panel unsets `scale` at 1, so keyframing uniform scale at 100% (the ordinary case) minted a `scale` track on a node with no `UniformScale` and squashed it horizontally as the track played. A `scale` track *is* the uniform scale, whether or not the prop is authored alongside it, so the mirror now follows the track too.
+
+The constraints row behaves as it did, but its "does this node take constraints at all" test now mirrors `resolveConstraintOffsets`: a sequence is not a spatial parent, so look above it, and the answer is yes only against a scene's frame. Setting one moves nothing until that frame changes, because the runtime seeds `ConstraintCache` the first time it sees the node with a `Constraint`.
+
**Left stale on purpose** (deferred to a docs/examples pass): the eight `examples/*.tsx` still open with `<rect scene="...">` and no `<stage>`, so `tsc -p examples --noEmit` fails on them, and `reference/jsx/*` still describes the pre-`<stage>` model and `key` as the `syncTo` target. `reference/jsx` is stale as a whole; patching rows piecemeal would hide that.
## Remaining work
diff --git a/packages/runtime/src/systems/motion.ts b/packages/runtime/src/systems/motion.ts
index 6800d23b..5255a2b1 100644
--- a/packages/runtime/src/systems/motion.ts
+++ b/packages/runtime/src/systems/motion.ts
@@ -230,6 +230,7 @@ export function motionSystem(world: World): void {
}
// 2: Keyframe tracks
+ let uniformScale = entity.has(UniformScale);
for (const track of keyframeTracks) {
const tid = track.id();
const property = keyframeTrack.property[tid] as PropertyPath;
@@ -238,10 +239,13 @@ export function motionSystem(world: World): void {
const result = sampleTrack(world, keyframes, localFrame, property);
if (result === null || target == null) continue;
worldProps[property].computed[target.id()] = result;
+ // A 'scale' track is the uniform scale whether or not the node also
+ // authors the prop, so it scales both axes like UniformScale does.
+ if (property === 'scale' && target === entity) uniformScale = true;
}
// Uniform scale is authored/animated as scaleX only; mirror it onto scaleY.
- if (entity.has(UniformScale)) {
+ if (uniformScale) {
computed.scaleY[eid] = computed.scaleX[eid];
}
}