The VS Code of video editing, built for agents.
TypeScript
Refactor entity size propagation and transform logic for improved spatial handling
konstantin-paulusf925e36f131c
diff --git a/apps/web/src/components/dashboard/projects-view.tsx b/apps/web/src/components/dashboard/projects-view.tsxindex 6c5cfb72..41b47e2d 100644--- a/apps/web/src/components/dashboard/projects-view.tsx+++ b/apps/web/src/components/dashboard/projects-view.tsx@@ -221,7 +221,7 @@ export function DashboardProjectsView() {</Select>}>- <DashboardCardButton onClick={handleCreateProject} class="hover:bg-background">+ <DashboardCardButton onClick={handleCreateProject}><DashboardCardPreview class="bg-accent/50 group-hover:bg-accent group-hover:border-input"><Iconname="plus-add"diff --git a/apps/web/src/components/engine/api/resize.ts b/apps/web/src/components/engine/api/resize.tsindex 6c22bec9..97805441 100644--- a/apps/web/src/components/engine/api/resize.ts+++ b/apps/web/src/components/engine/api/resize.ts@@ -5,6 +5,7 @@import { hasComponent, query } from "bitecs";import { syncKeyframeTrack } from "./keyframe";import { removeComponent, setComponent } from "./events";+import { getParentEntity } from "./base";import { ChildOf, ConstraintType } from "../components";import type { EngineWorld } from "./world";@@ -77,9 +78,30 @@ export function propagateSize(world: EngineWorld, eid: number) {export function resolveConstraintOffsets(world: EngineWorld, eid: number): void {const c = world.components;+ let dimsEid: number | null = eid;+ // Sequences aren't spatial constructs — they mirror their parent's frame.+ while (dimsEid !== null && hasComponent(world, dimsEid, c.Sequential)) {+ dimsEid = getParentEntity(world, dimsEid);+ }+ if (dimsEid === null) return;++ resolveConstraintOffsetsAgainst(world, eid, dimsEid);+}++function resolveConstraintOffsetsAgainst(world: EngineWorld, eid: number, dimsEid: number): void {+ const c = world.components;++ // Sequential children are transparent: resolve their children against the+ // same spatial parent.+ for (const childEid of query(world, [ChildOf(eid), c.Sequential])) {+ resolveConstraintOffsetsAgainst(world, childEid, dimsEid);+ }+for (const childEid of query(world, [ChildOf(eid), c.Constraint])) {- const curParentW = c.Computed.width[eid];- const curParentH = c.Computed.height[eid];+ if (hasComponent(world, childEid, c.Sequential)) continue;++ const curParentW = c.Computed.width[dimsEid];+ const curParentH = c.Computed.height[dimsEid];const prevParentW = c.ConstraintCache.parentWidth[childEid];const prevParentH = c.ConstraintCache.parentHeight[childEid];diff --git a/apps/web/src/components/engine/components/components.ts b/apps/web/src/components/engine/components/components.tsindex 3a9420a4..e28253f7 100644--- a/apps/web/src/components/engine/components/components.ts+++ b/apps/web/src/components/engine/components/components.ts@@ -308,7 +308,7 @@ export const Computed = {offsetX: [] as number[],offsetY: [] as number[],// Local-space origin of the entity's bounding rect. Non-zero only for- // Group/Sequential containers whose children's AABB extends past (0, 0).+ // Group containers whose children's AABB extends past (0, 0)originX: [] as number[],originY: [] as number[],rotation: [] as number[],diff --git a/apps/web/src/components/engine/systems/transform.ts b/apps/web/src/components/engine/systems/transform.tsindex 753f96c4..79c1144d 100644--- a/apps/web/src/components/engine/systems/transform.ts+++ b/apps/web/src/components/engine/systems/transform.ts@@ -168,14 +168,27 @@ function cullEntity(world: EngineWorld, eid: number, parentEid: number | null):}/**- * Recompute a Group/Sequential entity's Computed bounds from the union of its- * children's transformed boxes. Leaf entities own an absolute Size and need no+ * Recompute a Group entity's Computed bounds from the union of its children's+ * transformed boxes. Sequences aren't spatial constructs — they mirror their+ * parent's frame instead (the walk is parent-first, so the parent's Computed+ * values are already settled). Leaf entities own an absolute Size and need no* resolution here.*/export function computeGroupBounds(world: EngineWorld, eid: number): void {const c = world.components;- if (hasComponent(world, eid, c.Group) || hasComponent(world, eid, c.Sequential)) {+ if (hasComponent(world, eid, c.Sequential)) {+ const parentEid = getParentEntity(world, eid);+ if (parentEid !== null) {+ c.Computed.width[eid] = c.Computed.width[parentEid];+ c.Computed.height[eid] = c.Computed.height[parentEid];+ c.Computed.originX[eid] = c.Computed.originX[parentEid] ?? 0;+ c.Computed.originY[eid] = c.Computed.originY[parentEid] ?? 0;+ return;+ }+ }++ if (hasComponent(world, eid, c.Group)) {let minX = Infinity;let minY = Infinity;let maxX = -Infinity;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.tsxindex fc15c396..7385be67 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@@ -58,7 +58,12 @@ export function TransformSettings(props: TransformSettingsProps) {};const supportsConstraints = createMemo(() => {- const parentEid = getParentEntity(world, eid());+ if (hasComponent(world, eid(), c.Sequential)) return false;++ let parentEid = getParentEntity(world, eid());+ while (parentEid !== null && hasComponent(world, parentEid, c.Sequential)) {+ parentEid = getParentEntity(world, parentEid);+ }if (parentEid === null) return false;const parentIsScene = hasComponent(world, parentEid, c.Scene);