@framefields/node-compositor 0.0.0-stage → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.turbo/turbo-build.log +22 -0
  2. package/.turbo/turbo-test.log +21 -0
  3. package/CHANGELOG.md +34 -0
  4. package/LICENCE +202 -0
  5. package/SKILL.md +370 -0
  6. package/dist/index-B0ir9Z7o.d.mts +139 -0
  7. package/dist/index-B0ir9Z7o.d.mts.map +1 -0
  8. package/dist/index.d.mts +230 -0
  9. package/dist/index.d.mts.map +1 -0
  10. package/dist/index.mjs +674 -0
  11. package/dist/index.mjs.map +1 -0
  12. package/dist/renderer.d.mts +2 -0
  13. package/dist/renderer.mjs +3 -0
  14. package/dist/renderers-DoYYCzgA.mjs +3326 -0
  15. package/dist/renderers-DoYYCzgA.mjs.map +1 -0
  16. package/package.json +51 -3
  17. package/src/index.ts +2 -0
  18. package/src/renderers/audio-processor.ts +123 -0
  19. package/src/renderers/container-bg.test.ts +22 -0
  20. package/src/renderers/container-bg.ts +15 -0
  21. package/src/renderers/index.ts +9 -0
  22. package/src/renderers/transform.test.ts +120 -0
  23. package/src/renderers/transform.ts +101 -0
  24. package/src/renderers/transform3d.test.ts +290 -0
  25. package/src/renderers/transform3d.ts +428 -0
  26. package/src/renderers/webgpu-renderer.ts +4038 -0
  27. package/src/shared/audio-reactive.test.ts +224 -0
  28. package/src/shared/bezier-solver.test.ts +92 -0
  29. package/src/shared/bezier-solver.ts +257 -0
  30. package/src/shared/compiler.test.ts +1309 -0
  31. package/src/shared/compiler.ts +996 -0
  32. package/src/shared/config.ts +44 -0
  33. package/src/shared/index.ts +3 -0
  34. package/src/shared/kinetic-typography.test.ts +138 -0
  35. package/src/shared/presets.test.ts +217 -0
  36. package/src/shared/presets.ts +644 -0
  37. package/src/shared/processor.ts +105 -0
  38. package/tsconfig.json +13 -0
  39. package/tsdown.config.ts +13 -0
  40. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderers-DoYYCzgA.mjs","names":["oneMinusU","cache","n","wrapped","op","durationSec","scale","texW","texH","groupExcludes","groupTex","groupView","br","activeGroupTex","activeGroupView","borderResult","compositeExcludes","deflickerOpts","relightOpts","hasKineticAnimators"],"sources":["../src/shared/bezier-solver.ts","../src/shared/compiler.ts","../src/renderers/container-bg.ts","../src/renderers/transform.ts","../src/renderers/transform3d.ts","../src/renderers/webgpu-renderer.ts","../src/renderers/audio-processor.ts","../src/renderers/index.ts"],"sourcesContent":["/**\n * Cubic Bezier and Speed Curve Solver for Motion Graphics\n * Provides analytical/Newton-Raphson solvers for unit easing curves and 2D spatial trajectory splines.\n */\n\nexport interface Point2D {\n\tx: number;\n\ty: number;\n}\n\nexport interface SpatialKeyframePoint {\n\tframe: number;\n\tx: number;\n\ty: number;\n\tspatialTangentIn?: Point2D;\n\tspatialTangentOut?: Point2D;\n}\n\nexport interface SplineSegment {\n\tp0: Point2D;\n\tc1: Point2D;\n\tc2: Point2D;\n\tp1: Point2D;\n\tstartFrame: number;\n\tendFrame: number;\n}\n\n/**\n * Solves a cubic bezier curve defined by control points (x1, y1) and (x2, y2)\n * for a given progress parameter t in [0, 1].\n */\nexport function solveCubicBezier(\n\tx1: number,\n\ty1: number,\n\tx2: number,\n\ty2: number,\n\tt: number,\n): number {\n\tif (t <= 0) return 0;\n\tif (t >= 1) return 1;\n\n\t// Check for linear edge case\n\tif (x1 === y1 && x2 === y2) return t;\n\n\t// Find u such that x(u) = t\n\t// x(u) = 3*(1-u)^2 * u * x1 + 3*(1-u) * u^2 * x2 + u^3\n\t// dx/du = 3*(1-u)^2 * x1 + 6*(1-u)*u * (x2 - x1) + 3*u^2 * (1 - x2)\n\tlet u = t; // initial guess\n\tfor (let i = 0; i < 8; i++) {\n\t\tconst oneMinusU = 1 - u;\n\t\tconst oneMinusU2 = oneMinusU * oneMinusU;\n\t\tconst u2 = u * u;\n\n\t\tconst currentX =\n\t\t\t3 * oneMinusU2 * u * x1 + 3 * oneMinusU * u2 * x2 + u2 * u;\n\t\tconst diff = currentX - t;\n\t\tif (Math.abs(diff) < 1e-6) break;\n\n\t\tconst dx =\n\t\t\t3 * oneMinusU2 * x1 +\n\t\t\t6 * oneMinusU * u * (x2 - x1) +\n\t\t\t3 * u2 * (1 - x2);\n\n\t\tif (Math.abs(dx) < 1e-6) break;\n\t\tu -= diff / dx;\n\t\tu = Math.max(0, Math.min(1, u));\n\t}\n\n\t// Bisection fallback if Newton didn't converge within bounds\n\tconst oneMinusU = 1 - u;\n\tconst checkX =\n\t\t3 * oneMinusU * oneMinusU * u * x1 +\n\t\t3 * oneMinusU * u * u * x2 +\n\t\tu * u * u;\n\n\tif (Math.abs(checkX - t) > 1e-3) {\n\t\tlet low = 0;\n\t\tlet high = 1;\n\t\tu = t;\n\t\tfor (let i = 0; i < 16; i++) {\n\t\t\tconst mid = (low + high) * 0.5;\n\t\t\tconst oMid = 1 - mid;\n\t\t\tconst xMid =\n\t\t\t\t3 * oMid * oMid * mid * x1 +\n\t\t\t\t3 * oMid * mid * mid * x2 +\n\t\t\t\tmid * mid * mid;\n\t\t\tif (Math.abs(xMid - t) < 1e-5) {\n\t\t\t\tu = mid;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (xMid < t) low = mid;\n\t\t\telse high = mid;\n\t\t\tu = mid;\n\t\t}\n\t}\n\n\t// Evaluate y(u)\n\tconst oU = 1 - u;\n\treturn (\n\t\t3 * oU * oU * u * y1 +\n\t\t3 * oU * u * u * y2 +\n\t\tu * u * u\n\t);\n}\n\n/**\n * Calculates the instantaneous speed (derivative |dy/dt|) at parameter t in [0, 1].\n */\nexport function solveBezierDerivative(\n\tx1: number,\n\ty1: number,\n\tx2: number,\n\ty2: number,\n\tt: number,\n): number {\n\tconst clampedT = Math.max(0, Math.min(1, t));\n\tconst eps = 1e-4;\n\tconst t0 = Math.max(0, clampedT - eps);\n\tconst t1 = Math.min(1, clampedT + eps);\n\tconst dt = t1 - t0;\n\tif (dt <= 0) return 0;\n\n\tconst y0 = solveCubicBezier(x1, y1, x2, y2, t0);\n\tconst y1Val = solveCubicBezier(x1, y1, x2, y2, t1);\n\treturn Math.abs((y1Val - y0) / dt);\n}\n\n/**\n * Generates an array of samples along the cubic bezier curve for visualization.\n */\nexport function sampleBezierCurve(\n\tx1: number,\n\ty1: number,\n\tx2: number,\n\ty2: number,\n\tsteps = 60,\n): Array<{ t: number; value: number; speed: number }> {\n\tconst samples: Array<{ t: number; value: number; speed: number }> = [];\n\tfor (let i = 0; i <= steps; i++) {\n\t\tconst t = i / steps;\n\t\tconst value = solveCubicBezier(x1, y1, x2, y2, t);\n\t\tconst speed = solveBezierDerivative(x1, y1, x2, y2, t);\n\t\tsamples.push({ t, value, speed });\n\t}\n\treturn samples;\n}\n\n/**\n * Converts Catmull-Rom four-point configuration to cubic Bezier control points.\n */\nexport function catmullRomToBezier(\n\tp0: Point2D,\n\tp1: Point2D,\n\tp2: Point2D,\n\tp3: Point2D,\n): { c1: Point2D; c2: Point2D } {\n\treturn {\n\t\tc1: {\n\t\t\tx: p1.x + (p2.x - p0.x) / 6,\n\t\t\ty: p1.y + (p2.y - p0.y) / 6,\n\t\t},\n\t\tc2: {\n\t\t\tx: p2.x - (p3.x - p1.x) / 6,\n\t\t\ty: p2.y - (p3.y - p1.y) / 6,\n\t\t},\n\t};\n}\n\n/**\n * Builds smooth Bezier spline segments between an ordered array of spatial keyframes.\n * Respects custom spatial tangents if authored; otherwise uses smooth Catmull-Rom.\n */\nexport function buildSpatialSplineSegments(\n\tpoints: SpatialKeyframePoint[],\n): SplineSegment[] {\n\tif (points.length < 2) return [];\n\n\tconst segments: SplineSegment[] = [];\n\n\tfor (let i = 0; i < points.length - 1; i++) {\n\t\tconst curr = points[i];\n\t\tconst next = points[i + 1];\n\n\t\tlet c1: Point2D;\n\t\tlet c2: Point2D;\n\n\t\tif (curr.spatialTangentOut) {\n\t\t\tc1 = {\n\t\t\t\tx: curr.x + curr.spatialTangentOut.x,\n\t\t\t\ty: curr.y + curr.spatialTangentOut.y,\n\t\t\t};\n\t\t} else {\n\t\t\t// Natural Catmull-Rom tangent\n\t\t\tconst prev = i > 0 ? points[i - 1] : curr;\n\t\t\tconst pNextNext = i + 2 < points.length ? points[i + 2] : next;\n\t\t\tconst cr = catmullRomToBezier(prev, curr, next, pNextNext);\n\t\t\tc1 = cr.c1;\n\t\t}\n\n\t\tif (next.spatialTangentIn) {\n\t\t\tc2 = {\n\t\t\t\tx: next.x + next.spatialTangentIn.x,\n\t\t\t\ty: next.y + next.spatialTangentIn.y,\n\t\t\t};\n\t\t} else {\n\t\t\tconst prev = i > 0 ? points[i - 1] : curr;\n\t\t\tconst pNextNext = i + 2 < points.length ? points[i + 2] : next;\n\t\t\tconst cr = catmullRomToBezier(prev, curr, next, pNextNext);\n\t\t\tc2 = cr.c2;\n\t\t}\n\n\t\tsegments.push({\n\t\t\tp0: { x: curr.x, y: curr.y },\n\t\t\tc1,\n\t\t\tc2,\n\t\t\tp1: { x: next.x, y: next.y },\n\t\t\tstartFrame: curr.frame,\n\t\t\tendFrame: next.frame,\n\t\t});\n\t}\n\n\treturn segments;\n}\n\n/**\n * Samples points along a cubic bezier segment between p0 and p1 with control points c1, c2.\n */\nexport function sampleCubicBezierSegment(\n\tp0: Point2D,\n\tc1: Point2D,\n\tc2: Point2D,\n\tp1: Point2D,\n\tsteps = 20,\n): Point2D[] {\n\tconst pts: Point2D[] = [];\n\tfor (let i = 0; i <= steps; i++) {\n\t\tconst u = i / steps;\n\t\tconst oU = 1 - u;\n\t\tconst oU2 = oU * oU;\n\t\tconst oU3 = oU2 * oU;\n\t\tconst u2 = u * u;\n\t\tconst u3 = u2 * u;\n\n\t\tconst x =\n\t\t\toU3 * p0.x +\n\t\t\t3 * oU2 * u * c1.x +\n\t\t\t3 * oU * u2 * c2.x +\n\t\t\tu3 * p1.x;\n\t\tconst y =\n\t\t\toU3 * p0.y +\n\t\t\t3 * oU2 * u * c1.y +\n\t\t\t3 * oU * u2 * c2.y +\n\t\t\tu3 * p1.y;\n\t\tpts.push({ x, y });\n\t}\n\treturn pts;\n}\n","import { resolveLayerDuration } from \"@framefields/compositions\";\nimport {\n\ttype AnimationTrack,\n\tcollectNodeOps,\n\ttype EaseRef,\n\tevaluateTrackAtFrame,\n\ttype LayerAnimationSpec,\n} from \"@framefields/compositions/program\";\nimport {\n\tDEFAULT_DURATION_MS,\n\tgetActiveMediaMetadata,\n\treportRenderDiagnostic,\n\ttype VirtualMediaData,\n} from \"@framefields/core\";\nimport gsapModule from \"gsap\";\nimport { solveCubicBezier } from \"./bezier-solver.js\";\n\nconst gsap = (gsapModule as any).timeline\n\t? gsapModule\n\t: (gsapModule as any).default || gsapModule;\n\nexport interface LayerStub {\n\tid: string;\n\tinputHandleId: string;\n\ttrackId?: string;\n\tx: number;\n\ty: number;\n\tscale: number;\n\trotation: number;\n\topacity: number;\n\tvolume: number;\n\twidth?: number;\n\theight?: number;\n\thidden: boolean;\n\tmuted: boolean;\n\ttext?: number;\n\tfontSize?: number;\n\tfill?: string;\n\tborderColor?: string;\n\tbackgroundColor?: string;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tperspective?: number;\n\tperspectiveOriginX?: number;\n\tperspectiveOriginY?: number;\n\ttranslateZ?: number;\n\tbackfaceVisibility?: \"visible\" | \"hidden\";\n\ttransformStyle?: \"flat\" | \"preserve-3d\";\n\t// 3D Layer Props\n\tis3D?: boolean;\n\tz?: number;\n\tscaleZ?: number;\n\ttwoSided?: boolean;\n\t// 3D Material Props\n\tmaterial?: \"lit\" | \"unlit\" | \"toon\";\n\tshininess?: number;\n\troughness?: number;\n\tspecularIntensity?: number;\n\tambientIntensity?: number;\n\tmetallic?: number;\n\t// 3D Camera Props\n\tcameraX?: number;\n\tcameraY?: number;\n\tcameraZ?: number;\n\ttargetX?: number;\n\ttargetY?: number;\n\ttargetZ?: number;\n\tcameraPitch?: number;\n\tcameraYaw?: number;\n\tcameraRoll?: number;\n\tcameraFov?: number;\n\tcameraZoom?: number;\n\tfocalLength?: number;\n\tfocusDistance?: number;\n\tfStop?: number;\n\tmaxBlurRadius?: number;\n\tshakeTranslation?: number;\n\tshakeRotation?: number;\n\torbitRadius?: number;\n\torbitAzimuth?: number;\n\torbitElevation?: number;\n\t// 3D Model Props\n\tanimationProgress?: number;\n\tanimationTime?: number;\n\tanimationSpeed?: number;\n\twireframe?: boolean;\n\tscaleX?: number;\n\tscaleY?: number;\n\t// 3D Light Props\n\tlightType?: string;\n\tintensity?: number;\n\tradius?: number;\n\tangle?: number;\n\tpenumbra?: number;\n\tdecay?: number;\n\t[key: string]: unknown;\n}\n\nexport type CompilerVirtualMedia = {\n\tmetadata?: Partial<VirtualMediaData[\"metadata\"]>;\n\toperation?: Partial<VirtualMediaData[\"operation\"]> & Record<string, any>;\n\tchildren?: CompilerNodeVM[];\n};\n\n/** A node op inside the render tree (CompositorLayer). */\nexport type CompilerNodeVM = CompilerVirtualMedia;\n\nexport interface CompileResult {\n\ttl: gsap.core.Timeline;\n\ttargetsById: Record<string, LayerStub>;\n\t/** Node ops the timeline was compiled from (tree order). */\n\tnodes: CompilerNodeVM[];\n}\n\n// L2: compiled timelines and their LayerStubs are cached per cacheKey and\n// SHARED across frames — `tl.seek()` mutates the stubs in place. This is safe\n// because frame rendering is strictly single-threaded per renderId, and the\n// 10s TTL bounds staleness. Do NOT render two frames of the same renderId\n// concurrently without cloning `tl` + stubs first.\nconst cache = new Map<string, { cacheTime: number; value: CompileResult }>();\n\n// L1: hashing the layer ops stringifies every keyframe of every layer, which\n// costs tens of ms per frame on a full film. Programs are rebuilt (not mutated)\n// when a composition changes, so that hash is memoized on the children array:\n// the operation itself is shallow-copied each frame to bake in signal values,\n// but `children` keeps its identity. Signals are cheap to key and may be plain\n// data mutated in place, so they are re-keyed on every call.\nconst nodesHashMemo = new WeakMap<\n\tobject,\n\t{\n\t\twidth: number;\n\t\theight: number;\n\t\tfps: number;\n\t\tdurationSec: number;\n\t\thash: string;\n\t}\n>();\n\n/** Entries untouched for this long are dropped (and their timeline killed). */\nconst CACHE_TTL_MS = 10000;\n/** Max compiled timelines retained per cache. */\nconst TIMELINE_CACHE_MAX = 50;\nconst LAYER_TIMELINE_CACHE_MAX = 50;\n\nfunction fnv1a(str: string): string {\n\tlet hash = 2166136261;\n\tfor (let i = 0; i < str.length; i++) {\n\t\thash ^= str.charCodeAt(i);\n\t\thash +=\n\t\t\t(hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);\n\t}\n\treturn (hash >>> 0).toString(16);\n}\n\n// Signal objects carry per-frame caches (last frame, last value), so hashing\n// their contents gives a new key every frame: the timeline would recompile\n// each frame and the cache would never hit. Key live signals by identity.\nconst signalIds = new WeakMap<object, number>();\nlet nextSignalId = 0;\n\nfunction signalsKey(signals: unknown): string {\n\tif (!signals || typeof signals !== \"object\") return stableStringify(signals);\n\treturn Object.keys(signals)\n\t\t.sort()\n\t\t.map((name) => {\n\t\t\tconst s = (signals as Record<string, unknown>)[name];\n\t\t\tif (\n\t\t\t\ts &&\n\t\t\t\ttypeof s === \"object\" &&\n\t\t\t\ttypeof (s as { get?: unknown }).get === \"function\"\n\t\t\t) {\n\t\t\t\tlet id = signalIds.get(s);\n\t\t\t\tif (id === undefined) {\n\t\t\t\t\tid = nextSignalId++;\n\t\t\t\t\tsignalIds.set(s, id);\n\t\t\t\t}\n\t\t\t\treturn `${JSON.stringify(name)}:#${id}`;\n\t\t\t}\n\t\t\treturn `${JSON.stringify(name)}:${stableStringify(s)}`;\n\t\t})\n\t\t.join(\",\");\n}\n\n/**\n * Paused gsap timelines stay attached to gsap's global timeline until killed,\n * so anything dropped from a cache must be killed or it is never collected.\n */\nfunction release(value: { tl: gsap.core.Timeline }): void {\n\tvalue.tl.kill();\n}\n\n/**\n * Make room for one insertion: drop and kill TTL-expired entries, then evict\n * the least-recently-used entry if the cache is at capacity. Every dropped\n * timeline MUST be killed — see `release`.\n */\nfunction evictForInsert<T extends { tl: gsap.core.Timeline }>(\n\tcache: Map<string, { cacheTime: number; value: T }>,\n\tmaxSize: number,\n): void {\n\tconst now = Date.now();\n\tfor (const [key, entry] of cache.entries()) {\n\t\tif (now - entry.cacheTime > CACHE_TTL_MS) {\n\t\t\tcache.delete(key);\n\t\t\trelease(entry.value);\n\t\t}\n\t}\n\tif (cache.size >= maxSize) {\n\t\tconst oldestKey = cache.keys().next().value;\n\t\tif (oldestKey !== undefined) {\n\t\t\tconst oldest = cache.get(oldestKey);\n\t\t\tcache.delete(oldestKey);\n\t\t\tif (oldest) release(oldest.value);\n\t\t}\n\t}\n}\n\nfunction stableStringify(obj: any): string {\n\tif (obj === null) return \"null\";\n\tif (obj === undefined) return \"undefined\";\n\tif (typeof obj !== \"object\") return JSON.stringify(obj);\n\tif (ArrayBuffer.isView(obj)) {\n\t\treturn `[TypedArray:${(obj as ArrayBufferView).byteLength}]`;\n\t}\n\tif (Array.isArray(obj)) {\n\t\treturn \"[\" + obj.map(stableStringify).join(\",\") + \"]\";\n\t}\n\tconst sortedKeys = Object.keys(obj).sort();\n\tconst parts = sortedKeys.map((key) => {\n\t\treturn `${JSON.stringify(key)}:${stableStringify(obj[key])}`;\n\t});\n\treturn \"{\" + parts.join(\",\") + \"}\";\n}\n\nexport function getCachedTimeline(cacheKey: string): CompileResult | undefined {\n\tconst entry = cache.get(cacheKey);\n\tif (entry) {\n\t\tif (Date.now() - entry.cacheTime > CACHE_TTL_MS) {\n\t\t\tcache.delete(cacheKey);\n\t\t\trelease(entry.value);\n\t\t\treturn undefined;\n\t\t}\n\t\tentry.cacheTime = Date.now();\n\t\tcache.delete(cacheKey);\n\t\tcache.set(cacheKey, entry);\n\t\treturn entry.value;\n\t}\n\treturn undefined;\n}\n\nexport function setCachedTimeline(cacheKey: string, value: CompileResult) {\n\tevictForInsert(cache, TIMELINE_CACHE_MAX);\n\tcache.set(cacheKey, { cacheTime: Date.now(), value });\n}\n\nexport function mappedEase(\n\tease?: EaseRef,\n\tdurationFrames?: number,\n\tfps = 24,\n): string | ((p: number) => number) {\n\tif (!ease) return \"none\";\n\tconst { name, dir, params } = ease;\n\tif (name === \"none\") return \"none\";\n\n\t// Custom closed-form Spring ease solver\n\tif ((name as string) === \"spring\") {\n\t\tconst damping = Math.max(0.001, params?.[0] ?? 10);\n\t\tconst stiffness = Math.max(0.001, params?.[1] ?? 100);\n\t\tconst mass = Math.max(0.001, params?.[2] ?? 1);\n\n\t\treturn (p: number) => {\n\t\t\tconst safeFps = fps > 0 ? fps : 24;\n\t\t\tconst durSec =\n\t\t\t\tdurationFrames && durationFrames > 0 ? durationFrames / safeFps : 1.0;\n\t\t\tconst t = p * durSec;\n\n\t\t\tconst m = mass;\n\t\t\tconst k = stiffness;\n\t\t\tconst c = damping;\n\n\t\t\tconst w0 = Math.sqrt(k / m);\n\t\t\tconst zeta = c / (2 * Math.sqrt(k * m));\n\n\t\t\tlet x = 0;\n\t\t\tif (zeta < 1) {\n\t\t\t\tconst wd = w0 * Math.sqrt(1 - zeta * zeta);\n\t\t\t\tconst A = -1;\n\t\t\t\tconst B = (-zeta * w0) / wd;\n\t\t\t\tx =\n\t\t\t\t\tMath.exp(-zeta * w0 * t) *\n\t\t\t\t\t(A * Math.cos(wd * t) + B * Math.sin(wd * t));\n\t\t\t} else if (zeta === 1) {\n\t\t\t\tconst A = -1;\n\t\t\t\tconst B = -w0;\n\t\t\t\tx = Math.exp(-w0 * t) * (A + B * t);\n\t\t\t} else {\n\t\t\t\tconst r1 = -w0 * (zeta - Math.sqrt(zeta * zeta - 1));\n\t\t\t\tconst r2 = -w0 * (zeta + Math.sqrt(zeta * zeta - 1));\n\t\t\t\tconst C1 = -1 / (1 - r1 / r2);\n\t\t\t\tconst C2 = -1 - C1;\n\t\t\t\tx = C1 * Math.exp(r1 * t) + C2 * Math.exp(r2 * t);\n\t\t\t}\n\t\t\treturn 1 + x;\n\t\t};\n\t}\n\n\tif ((name as string) === \"cubic\") {\n\t\tconst x1 = params?.[0] ?? 0.25;\n\t\tconst y1 = params?.[1] ?? 0.1;\n\t\tconst x2 = params?.[2] ?? 0.25;\n\t\tconst y2 = params?.[3] ?? 1.0;\n\t\treturn (p: number) => solveCubicBezier(x1, y1, x2, y2, p);\n\t}\n\n\tif ((name as string) === \"hold\") {\n\t\t// GSAP rounds time to 1e-7 s, so on its own end frame a short segment's\n\t\t// progress can land ~1e-5 under 1; 1e-4 of a segment is safe slack for the\n\t\t// jump (it would only fire a frame early on segments over 10,000 frames).\n\t\treturn (p: number) => (p >= 1 - 1e-4 ? 1 : 0);\n\t}\n\n\tconst easeName = name as string;\n\tlet suffix = \"\";\n\tif (params && params.length > 0) {\n\t\tsuffix = `(${params.join(\", \")})`;\n\t} else if (name === \"back\") {\n\t\tsuffix = \"(1.7)\";\n\t} else if (name === \"elastic\") {\n\t\tsuffix = \"(1, 0.3)\";\n\t}\n\n\treturn `${easeName}.${dir}${suffix}`;\n}\n\nfunction compileTrackToTimeline(\n\ttl: gsap.core.Timeline,\n\tstub: Record<string, any>,\n\ttrack: AnimationTrack,\n\tstartFrame: number,\n\tfps: number,\n\tdurationFrames: number,\n\tsignals?: Record<string, any>,\n): { dropped: number; maxAuthoredFrame: number } {\n\tconst prop = track.prop;\n\tconst source = track.source ?? { type: \"keyframe\" };\n\n\tif (source.type !== \"keyframe\") {\n\t\tconst endF = Number.isFinite(durationFrames)\n\t\t\t? durationFrames\n\t\t\t: Math.round(fps * 5);\n\t\tconst frameStepSec = 1 / fps;\n\t\tconst kfList: Array<Record<string, unknown>> = [];\n\n\t\tconst firstVal = evaluateTrackAtFrame(track, startFrame, fps, {\n\t\t\tstartFrame,\n\t\t\tbaseValues: stub,\n\t\t\tsignals,\n\t\t});\n\t\tstub[prop] = firstVal;\n\t\tkfList.push({\n\t\t\t[prop]: firstVal,\n\t\t\tduration: 0,\n\t\t});\n\n\t\tfor (let f = 1; f <= endF; f++) {\n\t\t\tconst val = evaluateTrackAtFrame(track, startFrame + f, fps, {\n\t\t\t\tstartFrame,\n\t\t\t\tbaseValues: stub,\n\t\t\t\tsignals,\n\t\t\t});\n\t\t\tkfList.push({\n\t\t\t\t[prop]: val,\n\t\t\t\tduration: frameStepSec,\n\t\t\t\tease: \"none\",\n\t\t\t});\n\t\t}\n\n\t\ttl.to(\n\t\t\tstub,\n\t\t\t{\n\t\t\t\tkeyframes: kfList,\n\t\t\t\trepeat: track.repeat ?? 0,\n\t\t\t\tyoyo: !!track.yoyo,\n\t\t\t\tlazy: false,\n\t\t\t\toverwrite: false,\n\t\t\t\timmediateRender: false,\n\t\t\t},\n\t\t\tstartFrame / fps,\n\t\t);\n\n\t\treturn { dropped: 0, maxAuthoredFrame: 0 };\n\t}\n\n\tconst sortedKeyframes = [...track.keyframes].sort(\n\t\t(a, b) => a.frame - b.frame,\n\t);\n\t// M8: keyframes outside the clip window [0, durationFrames] cannot play —\n\t// keep the clamp (the renderer's temporal gate clips the same window) but\n\t// REPORT it: an author who keys past the node's duration otherwise gets a\n\t// silent static mid-animation with no diagnostic.\n\tconst validKeyframes = sortedKeyframes.filter(\n\t\t(kf) => kf.frame >= 0 && kf.frame <= durationFrames,\n\t);\n\tconst dropped = sortedKeyframes.length - validKeyframes.length;\n\tconst maxAuthoredFrame =\n\t\tdropped > 0 ? sortedKeyframes[sortedKeyframes.length - 1].frame : 0;\n\n\tif (validKeyframes.length === 0) {\n\t\treturn { dropped, maxAuthoredFrame };\n\t}\n\n\tconst isDiscrete = prop === \"hidden\" || prop === \"muted\";\n\n\tif (isDiscrete) {\n\t\tfor (const kf of validKeyframes) {\n\t\t\tconst absoluteSec = (startFrame + kf.frame) / fps;\n\t\t\ttl.set(\n\t\t\t\tstub,\n\t\t\t\t{\n\t\t\t\t\t[prop]: kf.value,\n\t\t\t\t\timmediateRender: false,\n\t\t\t\t},\n\t\t\t\tabsoluteSec,\n\t\t\t);\n\t\t}\n\t} else {\n\t\tconst repeat = track.repeat ?? 0;\n\t\tconst yoyo = !!track.yoyo;\n\n\t\tif (validKeyframes.length === 1) {\n\t\t\tconst kf0 = validKeyframes[0];\n\t\t\tconst absoluteSec = (startFrame + kf0.frame) / fps;\n\t\t\ttl.set(\n\t\t\t\tstub,\n\t\t\t\t{\n\t\t\t\t\t[prop]: kf0.value,\n\t\t\t\t\timmediateRender: false,\n\t\t\t\t},\n\t\t\t\tabsoluteSec,\n\t\t\t);\n\t\t} else if (validKeyframes.length === 2) {\n\t\t\tconst kf0 = validKeyframes[0];\n\t\t\tconst kf1 = validKeyframes[1];\n\t\t\tconst val0 = kf0.value;\n\t\t\tconst val1 = kf1.value;\n\t\t\tconst startSec = (startFrame + kf0.frame) / fps;\n\t\t\tconst durSec = (kf1.frame - kf0.frame) / fps;\n\t\t\tconst trackDurationFrames = track.durationFrames ?? kf1.frame - kf0.frame;\n\t\t\tconst easeRef = kf1.ease ?? kf0.ease;\n\t\t\tconst easeVal = mappedEase(easeRef, trackDurationFrames, fps);\n\n\t\t\tif (val0 === stub[prop]) {\n\t\t\t\ttl.to(\n\t\t\t\t\tstub,\n\t\t\t\t\t{\n\t\t\t\t\t\t[prop]: val1,\n\t\t\t\t\t\tduration: durSec,\n\t\t\t\t\t\tease: easeVal,\n\t\t\t\t\t\trepeat,\n\t\t\t\t\t\tyoyo,\n\t\t\t\t\t\tlazy: false,\n\t\t\t\t\t\toverwrite: false,\n\t\t\t\t\t\timmediateRender: false,\n\t\t\t\t\t},\n\t\t\t\t\tstartSec,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttl.fromTo(\n\t\t\t\t\tstub,\n\t\t\t\t\t{\n\t\t\t\t\t\t[prop]: val0,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t[prop]: val1,\n\t\t\t\t\t\tduration: durSec,\n\t\t\t\t\t\tease: easeVal,\n\t\t\t\t\t\trepeat,\n\t\t\t\t\t\tyoyo,\n\t\t\t\t\t\tlazy: false,\n\t\t\t\t\t\toverwrite: false,\n\t\t\t\t\t\timmediateRender: false,\n\t\t\t\t\t},\n\t\t\t\t\tstartSec,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst kf0 = validKeyframes[0];\n\t\t\tconst startSec = (startFrame + kf0.frame) / fps;\n\n\t\t\tconst kfList: Array<Record<string, unknown>> = [];\n\t\t\tkfList.push({\n\t\t\t\t[prop]: kf0.value,\n\t\t\t\tduration: 0,\n\t\t\t});\n\n\t\t\tfor (let i = 1; i < validKeyframes.length; i++) {\n\t\t\t\tconst prevKf = validKeyframes[i - 1];\n\t\t\t\tconst currKf = validKeyframes[i];\n\t\t\t\tconst deltaFrames = currKf.frame - prevKf.frame;\n\t\t\t\tconst durSec = deltaFrames / fps;\n\t\t\t\tconst easeVal = mappedEase(currKf.ease, deltaFrames, fps);\n\n\t\t\t\tkfList.push({\n\t\t\t\t\t[prop]: currKf.value,\n\t\t\t\t\tduration: durSec,\n\t\t\t\t\tease: easeVal,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\ttl.to(\n\t\t\t\tstub,\n\t\t\t\t{\n\t\t\t\t\tkeyframes: kfList,\n\t\t\t\t\trepeat,\n\t\t\t\t\tyoyo,\n\t\t\t\t\tlazy: false,\n\t\t\t\t\toverwrite: false,\n\t\t\t\t\timmediateRender: false,\n\t\t\t\t},\n\t\t\t\tstartSec,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn { dropped, maxAuthoredFrame };\n}\n\n// ── M8: truncated-track diagnostics ───────────────────────────────────\n\nexport interface TruncationInfo {\n\tlayerId: string;\n\ttrackId: string;\n\tprop: string;\n\tdropped: number;\n\tmaxAuthoredFrame: number;\n}\n\n/**\n * Dedupe per compiled cache key — a fresh render of the same broken doc SHOULD\n * re-warn. Single-frame renders are the exception: each `renderFrame` call has\n * its own `img-` render id, so probing a doc frame by frame would repeat the\n * warning on every frame; those dedupe per document instead.\n */\nconst truncationWarnedKeys = new Set<string>();\nconst TRUNCATION_WARNED_CAP = 100;\n\nfunction warnTruncationOnce(cacheKey: string, truncations: TruncationInfo[]) {\n\tif (truncationWarnedKeys.has(cacheKey)) return;\n\tif (truncationWarnedKeys.size >= TRUNCATION_WARNED_CAP) {\n\t\ttruncationWarnedKeys.clear();\n\t}\n\ttruncationWarnedKeys.add(cacheKey);\n\n\tconst details = truncations\n\t\t.map(\n\t\t\t(t) =>\n\t\t\t\t`'${t.prop}' (track '${t.trackId}') on '${t.layerId}': ${t.dropped} keyframe(s) past the clip window (last authored frame ${t.maxAuthoredFrame})`,\n\t\t)\n\t\t.join(\"; \");\n\tconsole.warn(\n\t\t`[compositor] ${truncations.length} track(s) truncated — animation tails will not play: ${details}. Extend durationFrames or move those keyframes.`,\n\t);\n}\n\nfunction hashNodes(\n\tnodeOps: CompilerNodeVM[],\n\twidth: number,\n\theight: number,\n\tfps: number,\n\tdurationSec: number,\n): string {\n\tconst irHashInput = stableStringify({\n\t\tnodes: nodeOps.map((vm) => {\n\t\t\tconst lop = (vm?.operation || {}) as any;\n\t\t\treturn {\n\t\t\t\tid: lop.id,\n\t\t\t\tanimation: lop.animation,\n\t\t\t\tstartFrame: lop.startFrame,\n\t\t\t\tdurationFrames: lop.durationFrames,\n\t\t\t\tx: lop.x,\n\t\t\t\ty: lop.y,\n\t\t\t\tscale: lop.scale,\n\t\t\t\trotation: lop.rotation,\n\t\t\t\topacity: lop.opacity,\n\t\t\t\tvolume: lop.volume,\n\t\t\t\twidth: lop.width,\n\t\t\t\theight: lop.height,\n\t\t\t\thidden: lop.hidden,\n\t\t\t\tmuted: lop.muted,\n\t\t\t\tbackgroundColor: lop.backgroundColor,\n\t\t\t\tfill: lop.fill,\n\t\t\t\tborderColor: lop.borderColor,\n\t\t\t\ttextBackgroundColor: lop.textBackgroundColor,\n\t\t\t\trotateX: lop.rotateX,\n\t\t\t\trotateY: lop.rotateY,\n\t\t\t\trotateZ: lop.rotateZ,\n\t\t\t\tperspective: lop.perspective,\n\t\t\t\tperspectiveOriginX: lop.perspectiveOriginX,\n\t\t\t\tperspectiveOriginY: lop.perspectiveOriginY,\n\t\t\t\ttranslateZ: lop.translateZ,\n\t\t\t\tbackfaceVisibility: lop.backfaceVisibility,\n\t\t\t\ttransformStyle: lop.transformStyle,\n\t\t\t\tis3D: lop.is3D,\n\t\t\t\tz: lop.z,\n\t\t\t\tscaleZ: lop.scaleZ,\n\t\t\t\ttwoSided: lop.twoSided,\n\t\t\t\tcameraX: lop.cameraX,\n\t\t\t\tcameraY: lop.cameraY,\n\t\t\t\tcameraZ: lop.cameraZ,\n\t\t\t\ttargetX: lop.targetX,\n\t\t\t\ttargetY: lop.targetY,\n\t\t\t\ttargetZ: lop.targetZ,\n\t\t\t\tcameraPitch: lop.cameraPitch,\n\t\t\t\tcameraYaw: lop.cameraYaw,\n\t\t\t\tcameraRoll: lop.cameraRoll,\n\t\t\t\tcameraFov: lop.cameraFov,\n\t\t\t\tcameraZoom: lop.cameraZoom,\n\t\t\t\tfocalLength: lop.focalLength,\n\t\t\t\tfocusDistance: lop.focusDistance,\n\t\t\t\tfStop: lop.fStop,\n\t\t\t\tmaxBlurRadius: lop.maxBlurRadius,\n\t\t\t\tshakeTranslation: lop.shakeTranslation,\n\t\t\t\tshakeRotation: lop.shakeRotation,\n\t\t\t\torbitRadius: lop.orbitRadius,\n\t\t\t\torbitAzimuth: lop.orbitAzimuth,\n\t\t\t\torbitElevation: lop.orbitElevation,\n\t\t\t\t// 3D Material Props\n\t\t\t\tmaterial: lop.material,\n\t\t\t\tshininess: lop.shininess,\n\t\t\t\troughness: lop.roughness,\n\t\t\t\tspecularIntensity: lop.specularIntensity,\n\t\t\t\tambientIntensity: lop.ambientIntensity,\n\t\t\t\tmetallic: lop.metallic,\n\t\t\t\t// 3D Light Props\n\t\t\t\tlightType: lop.lightType,\n\t\t\t\tintensity: lop.intensity,\n\t\t\t\tradius: lop.radius,\n\t\t\t\tangle: lop.angle,\n\t\t\t\tpenumbra: lop.penumbra,\n\t\t\t\t// 3D Model Props\n\t\t\t\tanimationProgress: lop.animationProgress,\n\t\t\t\tanimationTime: lop.animationTime,\n\t\t\t\tanimationSpeed: lop.animationSpeed,\n\t\t\t\twireframe: lop.wireframe,\n\t\t\t\tscaleX: lop.scaleX,\n\t\t\t\tscaleY: lop.scaleY,\n\t\t\t\t// The LayerStub bakes fontSize (compiler.ts:425) and both the\n\t\t\t\t// layout measure and the text draw prefer the stub's value\n\t\t\t\t// over the live op — a fontSize change MUST bust the cache or\n\t\t\t\t// the rendered text keeps the stale size for the whole TTL.\n\t\t\t\tfontSize: lop.fontSize,\n\t\t\t\ttext: lop.text,\n\t\t\t};\n\t\t}),\n\t\twidth,\n\t\theight,\n\t\tfps,\n\t\tdurationSec,\n\t});\n\treturn fnv1a(irHashInput);\n}\n\nexport function compileTimeline(\n\trenderId: string,\n\tvirtualMedia: CompilerVirtualMedia | null | undefined,\n\toptions: { fps: number; durationSec: number },\n): CompileResult {\n\tconst fps = options.fps;\n\tconst durationSec = options.durationSec;\n\tconst width = virtualMedia?.metadata?.width ?? 1920;\n\tconst height = virtualMedia?.metadata?.height ?? 1080;\n\n\t// Collect node ops from the render tree (pre-order: parents first).\n\tconst nodeOps = collectNodeOps((virtualMedia?.children as any) ?? []);\n\n\t// LRU cache check\n\tconst memoKey = virtualMedia?.children as object | undefined;\n\tconst memo = memoKey ? nodesHashMemo.get(memoKey) : undefined;\n\tlet nodesHash: string;\n\tif (\n\t\tmemo &&\n\t\tmemo.width === width &&\n\t\tmemo.height === height &&\n\t\tmemo.fps === fps &&\n\t\tmemo.durationSec === durationSec\n\t) {\n\t\tnodesHash = memo.hash;\n\t} else {\n\t\tnodesHash = hashNodes(nodeOps, width, height, fps, durationSec);\n\t\tif (memoKey) {\n\t\t\tnodesHashMemo.set(memoKey, {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\tfps,\n\t\t\t\tdurationSec,\n\t\t\t\thash: nodesHash,\n\t\t\t});\n\t\t}\n\t}\n\tconst irHash = fnv1a(\n\t\t`${nodesHash}|${signalsKey((virtualMedia as any)?.operation?.signals ?? (virtualMedia as any)?.signals)}`,\n\t);\n\tconst cacheKey = `${renderId}_${irHash}`;\n\n\tconst cached = getCachedTimeline(cacheKey);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\n\tconst tl = gsap.timeline({ paused: true, smoothChildTiming: false });\n\tconst targetsById: Record<string, LayerStub> = {};\n\tconst signals =\n\t\t(virtualMedia as any)?.operation?.signals ??\n\t\t(virtualMedia as any)?.signals ??\n\t\t{};\n\n\tnodeOps.forEach((vm, index: number) => {\n\t\tconst lop = (vm?.operation || {}) as any;\n\t\tconst layerId = lop.id || lop.inputHandleId || `layer_${index}`;\n\n\t\tconst stub: LayerStub = {\n\t\t\tid: layerId,\n\t\t\tinputHandleId: lop.inputHandleId || `layer_${index}`,\n\t\t\ttrackId: layerId,\n\t\t\tx:\n\t\t\t\tlop.kind === \"camera\" || lop.kind === \"light\"\n\t\t\t\t\t? (lop.x ?? lop.cameraX)\n\t\t\t\t\t: (lop.x ?? 0),\n\t\t\ty:\n\t\t\t\tlop.kind === \"camera\" || lop.kind === \"light\"\n\t\t\t\t\t? (lop.y ?? lop.cameraY)\n\t\t\t\t\t: (lop.y ?? 0),\n\t\t\tscale: lop.scale ?? 1,\n\t\t\trotation: lop.rotation ?? 0,\n\t\t\topacity: lop.opacity ?? 1,\n\t\t\tvolume: lop.volume ?? 1,\n\t\t\twidth: lop.width,\n\t\t\theight: lop.height,\n\t\t\thidden: !!lop.hidden,\n\t\t\tmuted: !!lop.muted,\n\t\t\trotateX: lop.rotateX ?? 0,\n\t\t\trotateY: lop.rotateY ?? 0,\n\t\t\trotateZ: lop.rotateZ ?? 0,\n\t\t\tperspective: lop.perspective ?? 0,\n\t\t\tperspectiveOriginX: lop.perspectiveOriginX ?? 0.5,\n\t\t\tperspectiveOriginY: lop.perspectiveOriginY ?? 0.5,\n\t\t\ttranslateZ: lop.translateZ ?? 0,\n\t\t\tbackfaceVisibility: lop.backfaceVisibility ?? \"visible\",\n\t\t\ttransformStyle: lop.transformStyle ?? \"flat\",\n\t\t\tfontSize: lop.fontSize,\n\t\t\ttext: 1,\n\t\t\tfill: lop.fill,\n\t\t\tfillColor: lop.fillColor ?? lop.fill,\n\t\t\tstrokeColor: lop.strokeColor ?? lop.stroke,\n\t\t\tstrokeWidth: lop.strokeWidth,\n\t\t\tletterSpacing: lop.letterSpacing,\n\t\t\tfirstMargin: lop.firstMargin ?? lop.pathOptions?.firstMargin,\n\t\t\tlastMargin: lop.lastMargin ?? lop.pathOptions?.lastMargin,\n\t\t\tbaselineShift: lop.baselineShift ?? lop.pathOptions?.baselineShift,\n\t\t\toffset: lop.offset,\n\t\t\trangeStart: lop.rangeStart,\n\t\t\trangeEnd: lop.rangeEnd,\n\t\t\tanimators: lop.animators,\n\t\t\tpathOptions: lop.pathOptions,\n\t\t\ttypewriter: lop.typewriter,\n\t\t\tmarquee: lop.marquee,\n\t\t\t// 3D Layer Props\n\t\t\tis3D:\n\t\t\t\tlop.is3D ??\n\t\t\t\t(lop.kind === \"camera\" || lop.kind === \"light\" || lop.kind === \"model3d\"\n\t\t\t\t\t? true\n\t\t\t\t\t: false),\n\t\t\tz: lop.z ?? (lop.kind === \"camera\" ? (lop.z ?? -1500) : 0),\n\t\t\tscaleZ: lop.scaleZ ?? 1,\n\t\t\ttwoSided: lop.twoSided ?? true,\n\t\t\t// 3D Material Props\n\t\t\tmaterial: lop.material,\n\t\t\tshininess: lop.shininess,\n\t\t\troughness: lop.roughness,\n\t\t\tspecularIntensity: lop.specularIntensity,\n\t\t\tambientIntensity: lop.ambientIntensity,\n\t\t\tmetallic: lop.metallic,\n\t\t\t// 3D Model Props\n\t\t\tanimationProgress: lop.animationProgress ?? 0,\n\t\t\tanimationTime: lop.animationTime ?? 0,\n\t\t\tanimationSpeed: lop.animationSpeed ?? 1,\n\t\t\twireframe: lop.wireframe ?? false,\n\t\t\tscaleX: lop.scaleX ?? 1,\n\t\t\tscaleY: lop.scaleY ?? 1,\n\t\t\t// 3D Camera Props\n\t\t\tcameraX: lop.cameraX ?? (lop.kind === \"camera\" ? lop.x : undefined),\n\t\t\tcameraY: lop.cameraY ?? (lop.kind === \"camera\" ? lop.y : undefined),\n\t\t\tcameraZ: lop.cameraZ ?? (lop.kind === \"camera\" ? lop.z : undefined),\n\t\t\ttargetX: lop.targetX,\n\t\t\ttargetY: lop.targetY,\n\t\t\ttargetZ: lop.targetZ,\n\t\t\tcameraPitch: lop.cameraPitch ?? lop.pitch ?? 0,\n\t\t\tcameraYaw: lop.cameraYaw ?? lop.yaw ?? 0,\n\t\t\tcameraRoll: lop.cameraRoll ?? lop.roll ?? 0,\n\t\t\tcameraFov: lop.cameraFov ?? lop.lens?.fov ?? 50,\n\t\t\tcameraZoom: lop.cameraZoom ?? lop.lens?.zoom ?? 1,\n\t\t\tfocalLength: lop.focalLength ?? lop.lens?.focalLength ?? 50,\n\t\t\tfocusDistance: lop.focusDistance ?? lop.dof?.focusDistance,\n\t\t\tfStop: lop.fStop ?? lop.dof?.fStop ?? 2.8,\n\t\t\tmaxBlurRadius: lop.maxBlurRadius ?? lop.dof?.maxBlurRadius ?? 24,\n\t\t\tshakeTranslation:\n\t\t\t\tlop.shakeTranslation ??\n\t\t\t\t(lop.shake?.enabled ? (lop.shake?.translationAmplitude ?? 0) : 0),\n\t\t\tshakeRotation:\n\t\t\t\tlop.shakeRotation ??\n\t\t\t\t(lop.shake?.enabled ? (lop.shake?.rotationAmplitude ?? 0) : 0),\n\t\t\torbitRadius: lop.orbitRadius,\n\t\t\torbitAzimuth: lop.orbitAzimuth,\n\t\t\torbitElevation: lop.orbitElevation,\n\t\t\t// 3D Light Props\n\t\t\tlightType: lop.lightType,\n\t\t\tintensity: lop.intensity ?? (lop.kind === \"light\" ? 1 : undefined),\n\t\t\tradius: lop.radius,\n\t\t\tangle: lop.angle,\n\t\t\tpenumbra: lop.penumbra,\n\t\t\tdecay: lop.decay,\n\t\t};\n\n\t\tfor (const track of lop.animation?.tracks ?? []) {\n\t\t\tconst source = track.source ?? { type: \"keyframe\" };\n\t\t\tif (source.type !== \"keyframe\") {\n\t\t\t\t(stub as Record<string, unknown>)[track.prop] = evaluateTrackAtFrame(\n\t\t\t\t\ttrack,\n\t\t\t\t\tlop.startFrame ?? 0,\n\t\t\t\t\tfps,\n\t\t\t\t\t{ startFrame: lop.startFrame ?? 0, baseValues: stub, signals },\n\t\t\t\t);\n\t\t\t} else if (track.keyframes && track.keyframes.length > 0) {\n\t\t\t\tconst kf0 = track.keyframes[0];\n\t\t\t\tconst seeded = stub as Record<string, unknown>;\n\t\t\t\tif (kf0.frame === 0) {\n\t\t\t\t\tseeded[track.prop] = kf0.value;\n\t\t\t\t} else if (seeded[track.prop] === undefined) {\n\t\t\t\t\t// GSAP only tweens props that exist on its target; props the stub\n\t\t\t\t\t// doesn't model (trimEnd, borderWidth, …) start from the node's own\n\t\t\t\t\t// value, else hold the first key until it's reached.\n\t\t\t\t\tseeded[track.prop] = lop[track.prop] ?? kf0.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttargetsById[layerId] = stub;\n\t});\n\n\t// M8: keyframes beyond the clip window are clamped, but silently — a track\n\t// whose tail was truncated plays a static value with no diagnostic. Collect\n\t// them here and warn ONCE per compiled cache key (per-frame seeks hit the\n\t// cache, so this is naturally once per render/preview session).\n\tconst truncations: TruncationInfo[] = [];\n\n\tnodeOps.forEach((vm) => {\n\t\tconst lop = (vm?.operation || {}) as any;\n\t\tconst layerId = lop.id || lop.inputHandleId;\n\t\tconst stub = layerId ? targetsById[layerId] : undefined;\n\t\tif (!stub) return;\n\n\t\tconst startFrame = lop.startFrame ?? 0;\n\t\tlet durationFrames = lop.durationFrames;\n\t\tif (durationFrames === undefined) {\n\t\t\tconst child = vm.children?.[0];\n\t\t\tconst childMeta = child ? getActiveMediaMetadata(child as any) : null;\n\t\t\tconst composeDuration =\n\t\t\t\t(virtualMedia as any)?.metadata?.durationMs ?? DEFAULT_DURATION_MS;\n\t\t\tconst layerType =\n\t\t\t\tlop.type ??\n\t\t\t\t(lop.kind === \"text\"\n\t\t\t\t\t? \"Text\"\n\t\t\t\t\t: lop.kind === \"media\"\n\t\t\t\t\t\t? child\n\t\t\t\t\t\t\t? (child.operation as any)?.dataType\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t: undefined);\n\t\t\tconst durationMs = resolveLayerDuration(\n\t\t\t\tundefined,\n\t\t\t\tchildMeta?.durationMs ?? undefined,\n\t\t\t\tcomposeDuration,\n\t\t\t\tlayerType,\n\t\t\t);\n\t\t\tdurationFrames = Math.max(1, Math.round((durationMs / 1000) * fps));\n\t\t}\n\n\t\tfor (const track of lop.animation?.tracks ?? []) {\n\t\t\tconst { dropped, maxAuthoredFrame } = compileTrackToTimeline(\n\t\t\t\ttl,\n\t\t\t\tstub,\n\t\t\t\ttrack,\n\t\t\t\tstartFrame,\n\t\t\t\tfps,\n\t\t\t\tdurationFrames,\n\t\t\t\tsignals,\n\t\t\t);\n\t\t\tif (dropped > 0) {\n\t\t\t\ttruncations.push({\n\t\t\t\t\tlayerId,\n\t\t\t\t\ttrackId: track.id,\n\t\t\t\t\tprop: track.prop,\n\t\t\t\t\tdropped,\n\t\t\t\t\tmaxAuthoredFrame,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n\tif (truncations.length > 0) {\n\t\twarnTruncationOnce(\n\t\t\trenderId.startsWith(\"img-\") ? `frame_${irHash}` : cacheKey,\n\t\t\ttruncations,\n\t\t);\n\t\tfor (const t of truncations) {\n\t\t\treportRenderDiagnostic(renderId, {\n\t\t\t\tseverity: \"warning\",\n\t\t\t\tcode: \"animation_truncated\",\n\t\t\t\tlayerId: t.layerId,\n\t\t\t\tmessage: `'${t.prop}' on '${t.layerId}': ${t.dropped} keyframe(s) past the clip window (last authored frame ${t.maxAuthoredFrame}) never play`,\n\t\t\t});\n\t\t}\n\t}\n\n\ttl.seek(1e-6);\n\ttl.seek(0);\n\n\tconst compileResult: CompileResult = {\n\t\ttl,\n\t\ttargetsById,\n\t\tnodes: nodeOps,\n\t};\n\n\tsetCachedTimeline(cacheKey, compileResult);\n\n\treturn compileResult;\n}\n\nconst layerTimelineCache = new Map<\n\tstring,\n\t{\n\t\tcacheTime: number;\n\t\tvalue: {\n\t\t\ttl: gsap.core.Timeline;\n\t\t\tstub: { volume: number; muted: boolean };\n\t\t};\n\t}\n>();\n\nexport function compileLayerTimeline(\n\tlayerId: string,\n\tanimation: LayerAnimationSpec | undefined,\n\tbaseVolume: number,\n\tbaseMuted: boolean,\n\tfps: number,\n): { tl: gsap.core.Timeline; stub: { volume: number; muted: boolean } } {\n\tconst irHashInput = stableStringify({\n\t\tanimation,\n\t\tbaseVolume,\n\t\tbaseMuted,\n\t\tfps,\n\t});\n\tconst irHash = fnv1a(irHashInput);\n\tconst cacheKey = `layer_${layerId}_${irHash}`;\n\n\tconst cached = layerTimelineCache.get(cacheKey);\n\tif (cached) {\n\t\tif (Date.now() - cached.cacheTime <= CACHE_TTL_MS) {\n\t\t\tcached.cacheTime = Date.now();\n\t\t\treturn cached.value;\n\t\t}\n\t\tlayerTimelineCache.delete(cacheKey);\n\t\trelease(cached.value);\n\t}\n\n\tconst tl = gsap.timeline({ paused: true, smoothChildTiming: false });\n\tconst stub = {\n\t\tvolume: baseVolume,\n\t\tmuted: baseMuted,\n\t};\n\n\tconst tracks: AnimationTrack[] = animation?.tracks ?? [];\n\tfor (const track of tracks) {\n\t\tconst prop = track.prop;\n\t\tif (prop !== \"volume\" && prop !== \"muted\") continue;\n\t\tcompileTrackToTimeline(tl, stub, track, 0, fps, Infinity);\n\t}\n\n\ttl.seek(1e-6);\n\ttl.seek(0);\n\n\tconst result = { tl, stub };\n\tevictForInsert(layerTimelineCache, LAYER_TIMELINE_CACHE_MAX);\n\tlayerTimelineCache.set(cacheKey, { cacheTime: Date.now(), value: result });\n\treturn result;\n}\n","/**\n * Which container kinds paint their own background.\n *\n * flex/block/box all accept an optional `background` in the program schema.\n * The renderer must draw the rounded background pass for ALL of them (the old\n * code only painted `box`, so flex/block backgrounds were silently dropped and\n * their \"transparent-optimized\" fast path skipped the fill entirely).\n */\nexport function shouldPaintContainerBackground(\n\tkind: string | undefined,\n\tbackground?: string | null,\n): boolean {\n\tif (!background) return false;\n\treturn kind === \"flex\" || kind === \"block\" || kind === \"box\";\n}\n","/**\n * Minimal pure 2D affine matrix (same 6-number layout as DOMMatrix:\n * [a, b, c, d, e, f] with x' = a·x + c·y + e, y' = b·x + d·y + f).\n *\n * DOM-free on purpose — WebGPU node renderers build DOMMatrix chains before\n * pushing transforms, but DOMMatrix is not available in Node (unit tests /\n * headless layout), so the anchor math that decides WHERE a layer pivots is\n * implemented here as pure functions and only materialized into a DOMMatrix\n * at the render boundary via `toDOMMatrix`.\n */\nexport interface Matrix2D {\n\ta: number;\n\tb: number;\n\tc: number;\n\td: number;\n\te: number;\n\tf: number;\n}\n\nexport const IDENTITY: Matrix2D = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };\n\nexport function translate(tx: number, ty: number): Matrix2D {\n\treturn { a: 1, b: 0, c: 0, d: 1, e: tx, f: ty };\n}\n\n/** Rotation in degrees (screen convention: positive = clockwise, y-down). */\nexport function rotate(degrees: number): Matrix2D {\n\tconst rad = (degrees * Math.PI) / 180;\n\tconst cos = Math.cos(rad);\n\tconst sin = Math.sin(rad);\n\treturn { a: cos, b: sin, c: -sin, d: cos, e: 0, f: 0 };\n}\n\nexport function scale(sx: number, sy: number = sx): Matrix2D {\n\treturn { a: sx, b: 0, c: 0, d: sy, e: 0, f: 0 };\n}\n\n/** m1 ∘ m2 (m2 applied first — matches DOMMatrix.multiply ordering). */\nexport function multiply(m1: Matrix2D, m2: Matrix2D): Matrix2D {\n\treturn {\n\t\ta: m1.a * m2.a + m1.c * m2.b,\n\t\tb: m1.b * m2.a + m1.d * m2.b,\n\t\tc: m1.a * m2.c + m1.c * m2.d,\n\t\td: m1.b * m2.c + m1.d * m2.d,\n\t\te: m1.a * m2.e + m1.c * m2.f + m1.e,\n\t\tf: m1.b * m2.e + m1.d * m2.f + m1.f,\n\t};\n}\n\nexport function transformPoint(\n\tm: Matrix2D,\n\tx: number,\n\ty: number,\n): { x: number; y: number } {\n\treturn { x: m.a * x + m.c * y + m.e, y: m.b * x + m.d * y + m.f };\n}\n\n/** Materialize into a DOMMatrix for the renderer's transform stack. */\nexport function toDOMMatrix(m: Matrix2D): DOMMatrix {\n\treturn new DOMMatrix([m.a, m.b, m.c, m.d, m.e, m.f]);\n}\n\n/**\n * Layer transform matrix with anchor-aware pivot semantics.\n *\n * The composition node box is drawn at (0, 0, width, height) in local space\n * and positioned at `x`/`y`. `anchorX`/`anchorY` (0–1 fractions of the box)\n * select the pivot point that scale/rotation are applied AROUND:\n *\n * position → pivot → rotate → scale → un-pivot\n *\n * With the default center anchor (0.5, 0.5) a `scale: 2` animation grows the\n * node symmetrically from its middle instead of from its top-left corner.\n * The pivot point itself is invariant under rotation and scale.\n */\nexport function buildLayerMatrix(params: {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n\trotation: number;\n\tscale: number;\n\tanchorX?: number;\n\tanchorY?: number;\n}): Matrix2D {\n\tconst ax = params.anchorX ?? 0.5;\n\tconst ay = params.anchorY ?? 0.5;\n\tconst px = ax * params.width;\n\tconst py = ay * params.height;\n\n\treturn multiply(\n\t\ttranslate(params.x, params.y),\n\t\tmultiply(\n\t\t\ttranslate(px, py),\n\t\t\tmultiply(\n\t\t\t\trotate(params.rotation),\n\t\t\t\tmultiply(scale(params.scale), translate(-px, -py)),\n\t\t\t),\n\t\t),\n\t);\n}\n","/**\n * Pure 4x4 matrix and perspective projection mathematics for 3D layout containers.\n * Column-major 4x4 representation matching WebGPU standard conventions.\n */\n\nexport type Matrix4x4 = [\n\tnumber,\n\tnumber,\n\tnumber,\n\tnumber, // col 0\n\tnumber,\n\tnumber,\n\tnumber,\n\tnumber, // col 1\n\tnumber,\n\tnumber,\n\tnumber,\n\tnumber, // col 2\n\tnumber,\n\tnumber,\n\tnumber,\n\tnumber, // col 3\n];\n\nexport interface Point2D {\n\tx: number;\n\ty: number;\n}\n\nexport interface Point3D {\n\tx: number;\n\ty: number;\n\tz: number;\n}\n\nexport interface Quad2D {\n\ttopLeft: Point2D;\n\ttopRight: Point2D;\n\tbottomLeft: Point2D;\n\tbottomRight: Point2D;\n}\n\nexport interface Layer3DMatrixConfig {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n\trotateXDeg?: number;\n\trotateYDeg?: number;\n\trotateZDeg?: number;\n\tscaleX?: number;\n\tscaleY?: number;\n\tperspectivePx?: number;\n\toriginXRatio?: number;\n\toriginYRatio?: number;\n\ttranslateZPx?: number;\n}\n\nexport const Transform3DMath = {\n\t/**\n\t * Creates a 4x4 identity matrix.\n\t */\n\tidentity(): Matrix4x4 {\n\t\treturn [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n\t},\n\n\t/**\n\t * Multiplies two 4x4 matrices: out = A x B.\n\t */\n\tmultiply(a: Matrix4x4, b: Matrix4x4): Matrix4x4 {\n\t\tconst out = new Array(16) as Matrix4x4;\n\t\tfor (let row = 0; row < 4; row++) {\n\t\t\tfor (let col = 0; col < 4; col++) {\n\t\t\t\tout[col * 4 + row] =\n\t\t\t\t\ta[0 * 4 + row] * b[col * 4 + 0] +\n\t\t\t\t\ta[1 * 4 + row] * b[col * 4 + 1] +\n\t\t\t\t\ta[2 * 4 + row] * b[col * 4 + 2] +\n\t\t\t\t\ta[3 * 4 + row] * b[col * 4 + 3];\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t},\n\n\t/**\n\t * Translation matrix in 3D.\n\t */\n\ttranslate(tx: number, ty: number, tz = 0): Matrix4x4 {\n\t\treturn [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, tx, ty, tz, 1];\n\t},\n\n\t/**\n\t * Scale matrix in 3D.\n\t */\n\tscale(sx: number, sy: number, sz = 1): Matrix4x4 {\n\t\treturn [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];\n\t},\n\n\t/**\n\t * Rotation around X axis (pitch) in radians.\n\t */\n\trotateX(rad: number): Matrix4x4 {\n\t\tconst c = Math.cos(rad);\n\t\tconst s = Math.sin(rad);\n\t\treturn [1, 0, 0, 0, 0, c, s, 0, 0, -s, c, 0, 0, 0, 0, 1];\n\t},\n\n\t/**\n\t * Rotation around Y axis (yaw) in radians.\n\t */\n\trotateY(rad: number): Matrix4x4 {\n\t\tconst c = Math.cos(rad);\n\t\tconst s = Math.sin(rad);\n\t\treturn [c, 0, -s, 0, 0, 1, 0, 0, s, 0, c, 0, 0, 0, 0, 1];\n\t},\n\n\t/**\n\t * Rotation around Z axis (roll) in radians.\n\t */\n\trotateZ(rad: number): Matrix4x4 {\n\t\tconst c = Math.cos(rad);\n\t\tconst s = Math.sin(rad);\n\t\treturn [c, s, 0, 0, -s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n\t},\n\n\t/**\n\t * Perspective projection matrix.\n\t * If `d <= 0`, returns identity (orthographic projection).\n\t * In standard CSS/computer graphics coordinate system:\n\t * M[11] = -1 / d (in column-major index 11 is row 3, col 2).\n\t */\n\tperspective(d: number): Matrix4x4 {\n\t\tif (d <= 0) return Transform3DMath.identity();\n\t\tconst m = Transform3DMath.identity();\n\t\tm[11] = -1 / d;\n\t\treturn m;\n\t},\n\n\t/**\n\t * Computes the complete 3D composite transform for a layer.\n\t *\n\t * Order of operations:\n\t * 1. Move origin to perspective origin / pivot anchor.\n\t * 2. Apply perspective projection matrix P(d).\n\t * 3. Apply translation (translateZ).\n\t * 4. Apply 3D rotations: RotateZ * RotateY * RotateX (Euler angle order).\n\t * 5. Move origin back from pivot anchor.\n\t * 6. Apply scale (scaleX, scaleY).\n\t */\n\tbuildLayer3DMatrix(config: Layer3DMatrixConfig): Matrix4x4 {\n\t\tconst {\n\t\t\tx,\n\t\t\ty,\n\t\t\twidth,\n\t\t\theight,\n\t\t\trotateXDeg = 0,\n\t\t\trotateYDeg = 0,\n\t\t\trotateZDeg = 0,\n\t\t\tscaleX = 1,\n\t\t\tscaleY = 1,\n\t\t\tperspectivePx = 0,\n\t\t\toriginXRatio = 0.5,\n\t\t\toriginYRatio = 0.5,\n\t\t\ttranslateZPx = 0,\n\t\t} = config;\n\n\t\tconst pivotX = x + width * originXRatio;\n\t\tconst pivotY = y + height * originYRatio;\n\n\t\tconst rxRad = (rotateXDeg * Math.PI) / 180;\n\t\tconst ryRad = (rotateYDeg * Math.PI) / 180;\n\t\tconst rzRad = (rotateZDeg * Math.PI) / 180;\n\n\t\tlet m = Transform3DMath.identity();\n\n\t\t// 1. Move to pivot center\n\t\tm = Transform3DMath.multiply(\n\t\t\tm,\n\t\t\tTransform3DMath.translate(pivotX, pivotY, 0),\n\t\t);\n\n\t\t// 2. Perspective\n\t\tif (perspectivePx > 0) {\n\t\t\tm = Transform3DMath.multiply(\n\t\t\t\tm,\n\t\t\t\tTransform3DMath.perspective(perspectivePx),\n\t\t\t);\n\t\t}\n\n\t\t// 3. Depth translation\n\t\tif (translateZPx !== 0) {\n\t\t\tm = Transform3DMath.multiply(\n\t\t\t\tm,\n\t\t\t\tTransform3DMath.translate(0, 0, translateZPx),\n\t\t\t);\n\t\t}\n\n\t\t// 4. Rotations (Z, Y, X)\n\t\tif (rzRad !== 0) {\n\t\t\tm = Transform3DMath.multiply(m, Transform3DMath.rotateZ(rzRad));\n\t\t}\n\t\tif (ryRad !== 0) {\n\t\t\tm = Transform3DMath.multiply(m, Transform3DMath.rotateY(ryRad));\n\t\t}\n\t\tif (rxRad !== 0) {\n\t\t\tm = Transform3DMath.multiply(m, Transform3DMath.rotateX(rxRad));\n\t\t}\n\n\t\t// 5. Un-pivot relative to layer top-left\n\t\tm = Transform3DMath.multiply(\n\t\t\tm,\n\t\t\tTransform3DMath.translate(\n\t\t\t\t-width * originXRatio,\n\t\t\t\t-height * originYRatio,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\n\t\t// 6. Scale\n\t\tif (scaleX !== 1 || scaleY !== 1) {\n\t\t\tm = Transform3DMath.multiply(m, Transform3DMath.scale(scaleX, scaleY, 1));\n\t\t}\n\n\t\treturn m;\n\t},\n\n\t/**\n\t * Projects a 3D point (x, y, z, 1) through a 4x4 matrix, including perspective division by W.\n\t */\n\tprojectPoint(m: Matrix4x4, p: Point3D): Point2D {\n\t\tconst x = p.x;\n\t\tconst y = p.y;\n\t\tconst z = p.z;\n\n\t\tconst X = m[0] * x + m[4] * y + m[8] * z + m[12];\n\t\tconst Y = m[1] * x + m[5] * y + m[9] * z + m[13];\n\t\tconst W = m[3] * x + m[7] * y + m[11] * z + m[15];\n\n\t\tconst wInv = Math.abs(W) > 1e-6 ? 1 / W : 1.0;\n\t\treturn {\n\t\t\tx: X * wInv,\n\t\t\ty: Y * wInv,\n\t\t};\n\t},\n\n\t/**\n\t * Projects the 4 corner vertices of a flat 2D rectangle (0,0, w, h) through the 3D matrix.\n\t * Produces the target Quad2D for the WebGPU homography/corner-pin renderer.\n\t */\n\tprojectRectangleCorners(\n\t\tmatrix: Matrix4x4,\n\t\twidth: number,\n\t\theight: number,\n\t): Quad2D {\n\t\treturn {\n\t\t\ttopLeft: Transform3DMath.projectPoint(matrix, { x: 0, y: 0, z: 0 }),\n\t\t\ttopRight: Transform3DMath.projectPoint(matrix, { x: width, y: 0, z: 0 }),\n\t\t\tbottomLeft: Transform3DMath.projectPoint(matrix, {\n\t\t\t\tx: 0,\n\t\t\t\ty: height,\n\t\t\t\tz: 0,\n\t\t\t}),\n\t\t\tbottomRight: Transform3DMath.projectPoint(matrix, {\n\t\t\t\tx: width,\n\t\t\t\ty: height,\n\t\t\t\tz: 0,\n\t\t\t}),\n\t\t};\n\t},\n\n\t/**\n\t * Computes the signed area of the projected quad to check whether the layer is facing away\n\t * (backface culling).\n\t * If signedArea < 0 in screen space (y-down), the surface normal points away from the camera.\n\t */\n\tcomputeSignedArea(quad: Quad2D): number {\n\t\tconst { topLeft: p0, topRight: p1, bottomRight: p2, bottomLeft: p3 } = quad;\n\t\treturn (\n\t\t\t0.5 *\n\t\t\t(p0.x * p1.y -\n\t\t\t\tp1.x * p0.y +\n\t\t\t\t(p1.x * p2.y - p2.x * p1.y) +\n\t\t\t\t(p2.x * p3.y - p3.x * p2.y) +\n\t\t\t\t(p3.x * p0.y - p0.x * p3.y))\n\t\t);\n\t},\n};\n\n/**\n * Computes an 8-parameter 3x3 homography matrix mapping destination coordinates (quad)\n * to normalized source coordinates (unit square [0, 1]^2).\n *\n * The homography H maps destination (x, y) to source (u, v):\n * u = (h00*x + h01*y + h02) / (h20*x + h21*y + h22)\n * v = (h10*x + h11*y + h12) / (h20*x + h21*y + h22)\n *\n * Resulting array: [h00, h01, h02, h10, h11, h12, h20, h21, 1.0]\n */\nexport function solveHomography(\n\tdstPoints: Point2D[],\n\tsrcPoints: Point2D[] = [\n\t\t{ x: 0.0, y: 0.0 }, // TL\n\t\t{ x: 1.0, y: 0.0 }, // TR\n\t\t{ x: 0.0, y: 1.0 }, // BL\n\t\t{ x: 1.0, y: 1.0 }, // BR\n\t],\n): number[] {\n\tconst A: number[][] = [];\n\tconst B: number[] = [];\n\n\tfor (let i = 0; i < 4; i++) {\n\t\tconst xi = dstPoints[i]?.x ?? 0;\n\t\tconst yi = dstPoints[i]?.y ?? 0;\n\t\tconst ui = srcPoints[i]?.x ?? 0;\n\t\tconst vi = srcPoints[i]?.y ?? 0;\n\n\t\tA.push([xi, yi, 1.0, 0.0, 0.0, 0.0, -xi * ui, -yi * ui]);\n\t\tB.push(ui);\n\n\t\tA.push([0.0, 0.0, 0.0, xi, yi, 1.0, -xi * vi, -yi * vi]);\n\t\tB.push(vi);\n\t}\n\n\tconst n = 8;\n\tfor (let i = 0; i < n; i++) {\n\t\t// Find pivot row\n\t\tlet maxRow = i;\n\t\tlet maxVal = Math.abs(A[i][i]);\n\t\tfor (let k = i + 1; k < n; k++) {\n\t\t\tif (Math.abs(A[k][i]) > maxVal) {\n\t\t\t\tmaxVal = Math.abs(A[k][i]);\n\t\t\t\tmaxRow = k;\n\t\t\t}\n\t\t}\n\n\t\t// Swap rows in A and B\n\t\tconst tempRow = A[i];\n\t\tA[i] = A[maxRow];\n\t\tA[maxRow] = tempRow;\n\n\t\tconst tempB = B[i];\n\t\tB[i] = B[maxRow];\n\t\tB[maxRow] = tempB;\n\n\t\tconst pivot = A[i][i];\n\t\tif (Math.abs(pivot) < 1e-12) {\n\t\t\tA[i][i] = pivot < 0 ? -1e-12 : 1e-12;\n\t\t}\n\n\t\tfor (let k = i + 1; k < n; k++) {\n\t\t\tconst factor = A[k][i] / A[i][i];\n\t\t\tfor (let j = i; j < n; j++) {\n\t\t\t\tA[k][j] -= factor * A[i][j];\n\t\t\t}\n\t\t\tB[k] -= factor * B[i];\n\t\t}\n\t}\n\n\t// Back-substitution\n\tconst h = new Array(8).fill(0.0);\n\tfor (let i = n - 1; i >= 0; i--) {\n\t\tlet sum = B[i];\n\t\tfor (let j = i + 1; j < n; j++) {\n\t\t\tsum -= A[i][j] * h[j];\n\t\t}\n\t\th[i] = sum / A[i][i];\n\t}\n\n\treturn [h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7], 1.0];\n}\n\nexport interface Transform3DPropsLike {\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\ttranslateZ?: number;\n\tperspective?: number;\n\tperspectiveOriginX?: number;\n\tperspectiveOriginY?: number;\n\tanimation?: { tracks?: Array<{ prop: string }> };\n\t[key: string]: unknown;\n}\n\n/**\n * Checks whether a layer operation or compiled stub activates the 3D perspective path.\n */\nexport function has3DTransform(\n\ttarget?: Transform3DPropsLike,\n\tlop?: Transform3DPropsLike,\n): boolean {\n\tconst rx = target?.rotateX ?? lop?.rotateX ?? 0;\n\tconst ry = target?.rotateY ?? lop?.rotateY ?? 0;\n\tconst rz = target?.rotateZ ?? lop?.rotateZ ?? 0;\n\tconst tz = target?.translateZ ?? lop?.translateZ ?? 0;\n\tconst p = target?.perspective ?? lop?.perspective ?? 0;\n\n\tif (\n\t\trx !== 0 ||\n\t\try !== 0 ||\n\t\ttz !== 0 ||\n\t\t(p > 0 && (rx !== 0 || ry !== 0 || tz !== 0 || rz !== 0))\n\t) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\t(target?.rotateZ !== undefined && target.rotateZ !== 0) ||\n\t\t(lop?.rotateZ !== undefined && lop.rotateZ !== 0)\n\t) {\n\t\treturn true;\n\t}\n\n\tconst tracks = lop?.animation?.tracks;\n\tif (tracks && tracks.length > 0) {\n\t\tfor (const t of tracks) {\n\t\t\tif (\n\t\t\t\tt.prop === \"rotateX\" ||\n\t\t\t\tt.prop === \"rotateY\" ||\n\t\t\t\tt.prop === \"rotateZ\" ||\n\t\t\t\tt.prop === \"translateZ\" ||\n\t\t\t\tt.prop === \"perspective\"\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n","/// <reference types=\"webgpu\" />\nimport { resolveMediaSourceUrl } from \"@framefields/client-utils\";\nimport { decodeAudioSource } from \"@framefields/compositions\";\nimport {\n\tcollectNodeOps,\n\tcomputeLayout,\n\tinitLayout,\n\ttype LayoutNode,\n\ttype Rect,\n} from \"@framefields/compositions/program\";\nimport type { MeshAudioDeformConfig } from \"@framefields/core\";\nimport {\n\tDEFAULT_DURATION_MS,\n\tgetActiveMediaMetadata,\n\ttype VirtualMediaData,\n} from \"@framefields/core\";\nimport type { WebGPUNodeRenderer } from \"@framefields/node-sdk\";\nimport { measureText } from \"@framefields/renderers\";\nimport { TemporalDeflickerPipeline } from \"@framefields/tensor-webgpu\";\nimport {\n\tAudioLatentTrackCache,\n\ttype BlendMode,\n\tCamera3D,\n\ttype Camera3DPose,\n\ttype Color,\n\ttype DrawMesh3DOpts,\n\ttype DrawQuad3DOpts,\n\ttype ExtrudedTextGeometryOptions,\n\ttype GPUMeshBuffers,\n\tgenerateExtrudedTextGeometry,\n\tjointMatrices,\n\ttype Light3DOptions,\n\ttype Mat4,\n\tMatrix4Math,\n\ttype Mesh3DData,\n\ttype Model3DData,\n\tmeasureMaxCaptionHeight,\n\tparseColor,\n\tposeNodes,\n\ttype RenderContextValue,\n\tRenderer3D,\n\tScreenSpaceRelightPipeline,\n\ttype ShapeFillConfig,\n\ttype ShapeGeometryConfig,\n\tSlugFontCache,\n\ttype SlugGlyphBatch,\n\tsrtLoader,\n\tVector3Math,\n} from \"@framefields/webgpu-renderers\";\n\nimport { compileTimeline } from \"../shared/compiler.js\";\nimport type { CompositorOperation } from \"../shared/config.js\";\nimport { shouldPaintContainerBackground } from \"./container-bg.js\";\nimport { buildLayerMatrix, toDOMMatrix } from \"./transform.js\";\nimport {\n\thas3DTransform,\n\ttype Quad2D,\n\tsolveHomography,\n\tTransform3DMath,\n} from \"./transform3d.js\";\n\n// Layout depends on the document tree (whose `children` array keeps its\n// identity between frames), the viewport, media sizes and the few layout\n// props a timeline can animate. A film's tree holds every scene, so\n// re-running Yoga each frame is costly when none of those changed.\nconst LAYOUT_PROPS = [\n\t\"width\",\n\t\"height\",\n\t\"gap\",\n\t\"padding\",\n\t\"fontSize\",\n\t\"letterSpacing\",\n] as const;\nconst layoutMemo = new WeakMap<\n\tobject,\n\t{ key: string; rects: Record<string, Rect> }\n>();\n\nfunction layoutKey(\n\twidth: number,\n\theight: number,\n\ttargetsById: Record<string, any>,\n\tmediaDims: Map<string, { width: number; height: number }>,\n): string {\n\tconst parts: unknown[] = [width, height];\n\tfor (const id in targetsById) {\n\t\tconst t = targetsById[id];\n\t\tfor (const k of LAYOUT_PROPS)\n\t\t\tif (t[k] !== undefined) parts.push(id, k, t[k]);\n\t}\n\tfor (const [id, d] of mediaDims) parts.push(id, d.width, d.height);\n\treturn JSON.stringify(parts);\n}\n\nconst compositorHomographyWgsl = `\nstruct HomographyUniforms {\n\tmatrix_row0 : vec4<f32>,\n\tmatrix_row1 : vec4<f32>,\n\tmatrix_row2 : vec4<f32>,\n\tparams : vec4<f32>, // params.x = opacity\n};\n\n@group(0) @binding(0) var<uniform> u : HomographyUniforms;\n@group(1) @binding(0) var tex : texture_2d<f32>;\n@group(1) @binding(1) var samp : sampler;\n\nstruct VSOut {\n\t@builtin(position) pos : vec4<f32>,\n\t@location(0) uv : vec2<f32>,\n};\n\n@vertex fn vs(@builtin(vertex_index) vi: u32) -> VSOut {\n\tvar pos = array<vec2<f32>, 4>(\n\t\tvec2<f32>(-1.0, 1.0),\n\t\tvec2<f32>(1.0, 1.0),\n\t\tvec2<f32>(-1.0, -1.0),\n\t\tvec2<f32>(1.0, -1.0)\n\t);\n\tvar uv = array<vec2<f32>, 4>(\n\t\tvec2<f32>(0.0, 0.0),\n\t\tvec2<f32>(1.0, 0.0),\n\t\tvec2<f32>(0.0, 1.0),\n\t\tvec2<f32>(1.0, 1.0)\n\t);\n\treturn VSOut(vec4<f32>(pos[vi], 0.0, 1.0), uv[vi]);\n}\n\n@fragment fn fs(in : VSOut) -> @location(0) vec4<f32> {\n\tlet x = in.uv.x;\n\tlet y = in.uv.y;\n\n\tlet d = u.matrix_row2.x * x + u.matrix_row2.y * y + u.matrix_row2.z;\n\tif (d <= 1e-6) {\n\t\treturn vec4<f32>(0.0);\n\t}\n\n\tlet src_u = (u.matrix_row0.x * x + u.matrix_row0.y * y + u.matrix_row0.z) / d;\n\tlet src_v = (u.matrix_row1.x * x + u.matrix_row1.y * y + u.matrix_row1.z) / d;\n\n\tif (src_u < 0.0 || src_u > 1.0 || src_v < 0.0 || src_v > 1.0) {\n\t\treturn vec4<f32>(0.0);\n\t}\n\n\tlet color = textureSampleLevel(tex, samp, vec2<f32>(src_u, src_v), 0.0);\n\treturn color * u.params.x;\n}\n`;\n\ninterface DeviceHomographyResources {\n\tpipeline: GPURenderPipeline;\n\tuniformLayout: GPUBindGroupLayout;\n\ttextureLayout: GPUBindGroupLayout;\n}\n\nconst deviceHomographyCache = new WeakMap<\n\tGPUDevice,\n\tDeviceHomographyResources\n>();\n\nfunction getHomographyResources(\n\tdevice: GPUDevice,\n\tformat: GPUTextureFormat,\n): DeviceHomographyResources {\n\tlet res = deviceHomographyCache.get(device);\n\tif (!res) {\n\t\tconst uniformLayout = device.createBindGroupLayout({\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tbinding: 0,\n\t\t\t\t\tvisibility: GPUShaderStage.FRAGMENT,\n\t\t\t\t\tbuffer: { type: \"uniform\" },\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\n\t\tconst textureLayout = device.createBindGroupLayout({\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tbinding: 0,\n\t\t\t\t\tvisibility: GPUShaderStage.FRAGMENT,\n\t\t\t\t\ttexture: { sampleType: \"float\" },\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tbinding: 1,\n\t\t\t\t\tvisibility: GPUShaderStage.FRAGMENT,\n\t\t\t\t\tsampler: { type: \"filtering\" },\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\n\t\tconst module = device.createShaderModule({\n\t\t\tlabel: \"compositor_homography.wgsl\",\n\t\t\tcode: compositorHomographyWgsl,\n\t\t});\n\n\t\tconst pipeline = device.createRenderPipeline({\n\t\t\tlabel: \"CompositorHomographyPipeline\",\n\t\t\tlayout: device.createPipelineLayout({\n\t\t\t\tbindGroupLayouts: [uniformLayout, textureLayout],\n\t\t\t}),\n\t\t\tvertex: {\n\t\t\t\tmodule,\n\t\t\t\tentryPoint: \"vs\",\n\t\t\t},\n\t\t\tfragment: {\n\t\t\t\tmodule,\n\t\t\t\tentryPoint: \"fs\",\n\t\t\t\ttargets: [\n\t\t\t\t\t{\n\t\t\t\t\t\tformat,\n\t\t\t\t\t\tblend: {\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\tsrcFactor: \"one\",\n\t\t\t\t\t\t\t\tdstFactor: \"one-minus-src-alpha\",\n\t\t\t\t\t\t\t\toperation: \"add\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\talpha: {\n\t\t\t\t\t\t\t\tsrcFactor: \"one\",\n\t\t\t\t\t\t\t\tdstFactor: \"one-minus-src-alpha\",\n\t\t\t\t\t\t\t\toperation: \"add\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tprimitive: {\n\t\t\t\ttopology: \"triangle-strip\",\n\t\t\t},\n\t\t});\n\n\t\tres = { pipeline, uniformLayout, textureLayout };\n\t\tdeviceHomographyCache.set(device, res);\n\t}\n\treturn res;\n}\n\nconst audioTrackLatentCache = new Map<string, AudioLatentTrackCache>();\nconst deviceRenderer3DCache = new WeakMap<GPUDevice, Map<string, Renderer3D>>();\n\n/** One Renderer3D per device, target format and MSAA sample count. */\nfunction getRenderer3D(\n\tdevice: GPUDevice,\n\tformat: GPUTextureFormat,\n\tsampleCount: number,\n): Renderer3D {\n\tlet byConfig = deviceRenderer3DCache.get(device);\n\tif (!byConfig) {\n\t\tbyConfig = new Map();\n\t\tdeviceRenderer3DCache.set(device, byConfig);\n\t}\n\tconst key = `${format}|${sampleCount}`;\n\tlet r3d = byConfig.get(key);\n\tif (!r3d) {\n\t\tr3d = new Renderer3D(device, format, sampleCount);\n\t\tbyConfig.set(key, r3d);\n\t}\n\treturn r3d;\n}\n\nconst deviceRelightPipelineCache = new WeakMap<\n\tGPUDevice,\n\tScreenSpaceRelightPipeline\n>();\n\nfunction getScreenSpaceRelightPipeline(\n\tdevice: GPUDevice,\n\tformat: GPUTextureFormat,\n): ScreenSpaceRelightPipeline {\n\tlet relight = deviceRelightPipelineCache.get(device);\n\tif (!relight || relight.format !== format) {\n\t\trelight = new ScreenSpaceRelightPipeline(device, format);\n\t\tdeviceRelightPipelineCache.set(device, relight);\n\t}\n\treturn relight;\n}\n\nconst deviceDeflickerPipelineCache = new WeakMap<\n\tGPUDevice,\n\tMap<string, TemporalDeflickerPipeline>\n>();\n\nfunction getTemporalDeflickerPipeline(\n\tdevice: GPUDevice,\n\tlayerKey: string,\n): TemporalDeflickerPipeline {\n\tlet map = deviceDeflickerPipelineCache.get(device);\n\tif (!map) {\n\t\tmap = new Map();\n\t\tdeviceDeflickerPipelineCache.set(device, map);\n\t}\n\tlet pipe = map.get(layerKey);\n\tif (!pipe) {\n\t\tpipe = new TemporalDeflickerPipeline(device);\n\t\tmap.set(layerKey, pipe);\n\t}\n\treturn pipe;\n}\n\nfunction resolveVal(\n\tval: unknown,\n\tfallback: number,\n\tframe: number,\n\tfps: number,\n): number {\n\tif (val === undefined || val === null) return fallback;\n\tif (typeof val === \"number\") return Number.isFinite(val) ? val : fallback;\n\tif (typeof val === \"object\" && val !== null) {\n\t\tif (\n\t\t\t\"get\" in (val as Record<string, unknown>) &&\n\t\t\ttypeof (val as { get: unknown }).get === \"function\"\n\t\t) {\n\t\t\ttry {\n\t\t\t\tconst res = (val as { get: (ctx?: unknown) => unknown }).get({\n\t\t\t\t\tframe,\n\t\t\t\t\tfps,\n\t\t\t\t\ttime: fps > 0 ? frame / fps : 0,\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tdurationMs: 0,\n\t\t\t\t\tprogress: 0,\n\t\t\t\t\tdeltaTime: fps > 0 ? 1 / fps : 0,\n\t\t\t\t});\n\t\t\t\tconst n = Number(res);\n\t\t\t\tif (Number.isFinite(n)) return n;\n\t\t\t} catch {\n\t\t\t\t// fallback\n\t\t\t}\n\t\t}\n\t\tif (\"value\" in (val as Record<string, unknown>)) {\n\t\t\tconst n = Number((val as { value: unknown }).value);\n\t\t\tif (Number.isFinite(n)) return n;\n\t\t}\n\t}\n\tif (typeof val === \"function\") {\n\t\ttry {\n\t\t\tconst n = Number(val({ frame, fps, time: fps > 0 ? frame / fps : 0 }));\n\t\t\tif (Number.isFinite(n)) return n;\n\t\t} catch {\n\t\t\t// fallback\n\t\t}\n\t}\n\tconst n = Number(val);\n\treturn Number.isFinite(n) ? n : fallback;\n}\n\nfunction synthesizeRelightLights(\n\trelightOpts: Record<string, unknown>,\n\tsceneLights: Light3DOptions[],\n\tbounds: { x: number; y: number; width: number; height: number },\n\tshiftedFrame: number,\n\tfps: number,\n): Light3DOptions[] {\n\tif (\n\t\tsceneLights.length > 0 ||\n\t\t(relightOpts.lightType === undefined &&\n\t\t\trelightOpts.intensity === undefined &&\n\t\t\trelightOpts.lightPosX === undefined)\n\t) {\n\t\treturn sceneLights;\n\t}\n\n\tconst lightTypeStr = String(relightOpts.lightType ?? \"point\").toLowerCase();\n\tconst lightKind: Light3DOptions[\"lightType\"] =\n\t\tlightTypeStr === \"directional\"\n\t\t\t? \"directional\"\n\t\t\t: lightTypeStr === \"spot\"\n\t\t\t\t? \"spot\"\n\t\t\t\t: \"point\";\n\n\tconst rawIntensity = relightOpts.intensity ?? 1.0;\n\tconst intensity = resolveVal(rawIntensity, 1.0, shiftedFrame, fps);\n\n\tconst normX = resolveVal(relightOpts.lightPosX, 0.5, shiftedFrame, fps);\n\tconst normY = resolveVal(relightOpts.lightPosY, 0.5, shiftedFrame, fps);\n\tconst normZ = resolveVal(relightOpts.lightPosZ, 0.25, shiftedFrame, fps);\n\tconst normRadius = resolveVal(\n\t\trelightOpts.lightRadius,\n\t\t0.75,\n\t\tshiftedFrame,\n\t\tfps,\n\t);\n\n\tconst lightX = bounds.x + normX * bounds.width;\n\tconst lightY = bounds.y + normY * bounds.height;\n\tconst lightZ = normZ * Math.max(bounds.width, bounds.height);\n\tconst lightRadius = normRadius * Math.max(bounds.width, bounds.height);\n\n\tconst synthLight: Light3DOptions = {\n\t\tlightType: lightKind,\n\t\tcolor: (relightOpts.lightColor as string) ?? \"#ffffff\",\n\t\tintensity,\n\t\tx: lightX,\n\t\ty: lightY,\n\t\tz: lightZ,\n\t\tradius: lightRadius,\n\t\tdecay: 1.0,\n\t};\n\n\tconst ambientInt = resolveVal(\n\t\trelightOpts.ambientIntensity,\n\t\t0.15,\n\t\tshiftedFrame,\n\t\tfps,\n\t);\n\tconst synthAmbient: Light3DOptions = {\n\t\tlightType: \"ambient\",\n\t\tcolor: (relightOpts.ambientColor as string) ?? \"#ffffff\",\n\t\tintensity: ambientInt,\n\t};\n\n\treturn [synthAmbient, synthLight];\n}\n\nfunction drawProjectedQuad(\n\tctx: RenderContextValue,\n\tencoder: GPUCommandEncoder,\n\tdestView: GPUTextureView,\n\tsourceTex: GPUTexture,\n\tquad: Quad2D,\n\tdestWidth: number,\n\tdestHeight: number,\n\topacity: number,\n): void {\n\tconst area = Math.abs(Transform3DMath.computeSignedArea(quad));\n\tif (area < 1e-4) {\n\t\treturn;\n\t}\n\n\tconst minX = Math.max(\n\t\t0,\n\t\tMath.min(\n\t\t\tdestWidth,\n\t\t\tMath.floor(\n\t\t\t\tMath.min(\n\t\t\t\t\tquad.topLeft.x,\n\t\t\t\t\tquad.topRight.x,\n\t\t\t\t\tquad.bottomLeft.x,\n\t\t\t\t\tquad.bottomRight.x,\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n\tconst minY = Math.max(\n\t\t0,\n\t\tMath.min(\n\t\t\tdestHeight,\n\t\t\tMath.floor(\n\t\t\t\tMath.min(\n\t\t\t\t\tquad.topLeft.y,\n\t\t\t\t\tquad.topRight.y,\n\t\t\t\t\tquad.bottomLeft.y,\n\t\t\t\t\tquad.bottomRight.y,\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n\tconst maxX = Math.max(\n\t\t0,\n\t\tMath.min(\n\t\t\tdestWidth,\n\t\t\tMath.ceil(\n\t\t\t\tMath.max(\n\t\t\t\t\tquad.topLeft.x,\n\t\t\t\t\tquad.topRight.x,\n\t\t\t\t\tquad.bottomLeft.x,\n\t\t\t\t\tquad.bottomRight.x,\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n\tconst maxY = Math.max(\n\t\t0,\n\t\tMath.min(\n\t\t\tdestHeight,\n\t\t\tMath.ceil(\n\t\t\t\tMath.max(\n\t\t\t\t\tquad.topLeft.y,\n\t\t\t\t\tquad.topRight.y,\n\t\t\t\t\tquad.bottomLeft.y,\n\t\t\t\t\tquad.bottomRight.y,\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n\n\tconst scissorW = maxX - minX;\n\tconst scissorH = maxY - minY;\n\tif (scissorW <= 0 || scissorH <= 0) {\n\t\treturn;\n\t}\n\n\tconst dstPoints = [\n\t\t{ x: quad.topLeft.x / destWidth, y: quad.topLeft.y / destHeight },\n\t\t{ x: quad.topRight.x / destWidth, y: quad.topRight.y / destHeight },\n\t\t{ x: quad.bottomLeft.x / destWidth, y: quad.bottomLeft.y / destHeight },\n\t\t{ x: quad.bottomRight.x / destWidth, y: quad.bottomRight.y / destHeight },\n\t];\n\n\tconst h = solveHomography(dstPoints);\n\tfor (const val of h) {\n\t\tif (!Number.isFinite(val)) return;\n\t}\n\n\tconst uniformData = new Float32Array(16);\n\tuniformData[0] = h[0];\n\tuniformData[1] = h[1];\n\tuniformData[2] = h[2];\n\tuniformData[3] = 0;\n\n\tuniformData[4] = h[3];\n\tuniformData[5] = h[4];\n\tuniformData[6] = h[5];\n\tuniformData[7] = 0;\n\n\tuniformData[8] = h[6];\n\tuniformData[9] = h[7];\n\tuniformData[10] = h[8];\n\tuniformData[11] = 0;\n\n\tuniformData[12] = opacity;\n\tuniformData[13] = 0;\n\tuniformData[14] = 0;\n\tuniformData[15] = 0;\n\n\tconst { pipeline, uniformLayout, textureLayout } = getHomographyResources(\n\t\tctx.device,\n\t\tctx.renderer.format,\n\t);\n\n\tconst sampler = ctx.renderer.samplerCache.getSampler(ctx.device);\n\tconst uniformBuffer = ctx.renderer.getTemporaryBuffer(uniformData);\n\n\tconst uniformBindGroup = ctx.device.createBindGroup({\n\t\tlayout: uniformLayout,\n\t\tentries: [{ binding: 0, resource: { buffer: uniformBuffer } }],\n\t});\n\n\tconst textureBindGroup = ctx.renderer.bindGroupCache.getBindGroup(\n\t\tctx.device,\n\t\ttextureLayout,\n\t\tsourceTex,\n\t\tsampler,\n\t);\n\n\tconst renderPass = encoder.beginRenderPass({\n\t\tcolorAttachments: [\n\t\t\t{\n\t\t\t\tview: destView,\n\t\t\t\tloadOp: \"load\",\n\t\t\t\tstoreOp: \"store\",\n\t\t\t},\n\t\t],\n\t});\n\n\trenderPass.setPipeline(pipeline);\n\trenderPass.setScissorRect(minX, minY, scissorW, scissorH);\n\trenderPass.setBindGroup(0, uniformBindGroup);\n\trenderPass.setBindGroup(1, textureBindGroup);\n\trenderPass.draw(4);\n\trenderPass.end();\n}\n\nfunction computeContainerScissor(\n\tmatrix: DOMMatrix,\n\twidth: number,\n\theight: number,\n): Rect {\n\tconst corners = [\n\t\tmatrix.transformPoint(new DOMPoint(0, 0)),\n\t\tmatrix.transformPoint(new DOMPoint(width, 0)),\n\t\tmatrix.transformPoint(new DOMPoint(0, height)),\n\t\tmatrix.transformPoint(new DOMPoint(width, height)),\n\t];\n\tconst xs = corners.map((p) => p.x);\n\tconst ys = corners.map((p) => p.y);\n\tconst minX = Math.min(...xs);\n\tconst minY = Math.min(...ys);\n\tconst maxX = Math.max(...xs);\n\tconst maxY = Math.max(...ys);\n\treturn {\n\t\tx: Math.round(minX),\n\t\ty: Math.round(minY),\n\t\twidth: Math.max(0, Math.round(maxX - minX)),\n\t\theight: Math.max(0, Math.round(maxY - minY)),\n\t};\n}\n\nexport const CompositorWebGPURenderer: WebGPUNodeRenderer = async (args) => {\n\tconst {\n\t\tctx,\n\t\tpass,\n\t\ttargetView,\n\t\ttargetTexture,\n\t\ttargetWidth,\n\t\ttargetHeight,\n\t\tencoder,\n\t\tprops,\n\t\tdrawChild,\n\t} = args;\n\tconst { virtualMedia, fps, frame } = props;\n\tconst op = virtualMedia.operation as any;\n\n\tif (!op) return;\n\n\t// Always end the incoming pass as we will be creating our own\n\tpass.end();\n\n\tif (op.op === \"CompositorLayer\") {\n\t\tconsole.warn(\n\t\t\t\"CompositorWebGPURenderer called directly with legacy CompositorLayer operation. This is a bug.\",\n\t\t);\n\t\t(args as any).pass = ctx.renderer.beginFrame(\n\t\t\tencoder,\n\t\t\ttargetView,\n\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\ttargetWidth,\n\t\t\ttargetHeight,\n\t\t\t\"load\",\n\t\t);\n\t\treturn;\n\t}\n\n\tif (op.op === \"Compositor\") {\n\t\tconst vop = op as CompositorOperation;\n\t\t// 4x MSAA in the 3D pass unless the document opts out (antialias3d: false).\n\t\tconst sampleCount3d = vop.antialias3d === false ? 1 : 4;\n\t\tconst containerWidth = props.containerWidth ?? ctx.surface.width;\n\t\tconst containerHeight = props.containerHeight ?? ctx.surface.height;\n\n\t\tconst nativeWidth = vop.width ?? containerWidth;\n\t\tconst nativeHeight = vop.height ?? containerHeight;\n\t\tconst opacity =\n\t\t\ttypeof (vop as any).opacity === \"number\" ? (vop as any).opacity : 1;\n\n\t\tconst isVideoMode =\n\t\t\tprops.isVideoMode ??\n\t\t\t(vop.mode === \"Video\" ||\n\t\t\t\tvop.dataType === \"Video\" ||\n\t\t\t\tvirtualMedia?.metadata?.durationMs != null);\n\n\t\tconst inheritedSeekOffset = props.inheritedSeekOffset ?? 0;\n\t\tconst shiftedFrame = Math.max(\n\t\t\t0,\n\t\t\tframe != null && fps != null\n\t\t\t\t? frame + Math.round(inheritedSeekOffset * fps)\n\t\t\t\t: (frame ?? 0),\n\t\t);\n\n\t\t// 1. Create a temporary texture at native resolution\n\t\tconst compTex = ctx.renderer.getTemporaryTexture(\n\t\t\tnativeWidth,\n\t\t\tnativeHeight,\n\t\t\t[...(props.excludeTextures || []), targetTexture],\n\t\t);\n\t\tconst compView = compTex.createView();\n\n\t\tconst composeDuration =\n\t\t\tvirtualMedia?.metadata?.durationMs ?? DEFAULT_DURATION_MS;\n\t\tconst durationSec = composeDuration / 1000;\n\t\tconst { tl, targetsById } = compileTimeline(\n\t\t\tprops.renderId,\n\t\t\tvirtualMedia as any,\n\t\t\t{ fps: fps ?? 24, durationSec },\n\t\t);\n\t\ttl.seek(shiftedFrame / (fps ?? 24));\n\n\t\tconst r3d = getRenderer3D(\n\t\t\tctx.device,\n\t\t\tctx.renderer.format ?? \"rgba8unorm\",\n\t\t\tsampleCount3d,\n\t\t);\n\t\tr3d.resetPools();\n\n\t\tconst relightPipe = getScreenSpaceRelightPipeline(\n\t\t\tctx.device,\n\t\t\tctx.renderer.format ?? \"rgba8unorm\",\n\t\t);\n\t\trelightPipe.resetPools();\n\n\t\t// 2. Initial clear\n\t\tconst clearColor = parseColor(vop.backgroundColor);\n\t\tconst clearPass = ctx.renderer.beginFrame(\n\t\t\tencoder,\n\t\t\tcompView,\n\t\t\tclearColor,\n\t\t\tnativeWidth,\n\t\t\tnativeHeight,\n\t\t\t\"clear\",\n\t\t);\n\t\tclearPass.end();\n\n\t\t// 3. Draw all children into the native texture\n\t\tlet currentCompTex = compTex;\n\n\t\tctx.renderer.pushScissor({\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\twidth: nativeWidth,\n\t\t\theight: nativeHeight,\n\t\t});\n\t\tctx.renderer.pushIdentity();\n\t\t// 3. Layout pass — deterministic geometry from the document (v2).\n\t\t// Animated layout props (width/height/gap/padding) are sampled per\n\t\t// frame from the compiled timeline into the tree via targetsById.\n\t\tawait initLayout();\n\t\tconst mediaDims = new Map<string, { width: number; height: number }>();\n\t\tfor (const vm of collectNodeOps(virtualMedia.children)) {\n\t\t\tconst lop = vm.operation as any;\n\t\t\tif (lop.kind === \"media\") {\n\t\t\t\tconst meta = getActiveMediaMetadata(vm.children?.[0] as any);\n\t\t\t\tif (meta?.width && meta?.height) {\n\t\t\t\t\tmediaDims.set(lop.id, { width: meta.width, height: meta.height });\n\t\t\t\t} else if (\n\t\t\t\t\tlop.dataType === \"Caption\" ||\n\t\t\t\t\t(vm.children?.[0]?.operation as any)?.dataType === \"Caption\" ||\n\t\t\t\t\t(vm.children?.[0]?.operation as any)?.srtText !== undefined\n\t\t\t\t) {\n\t\t\t\t\tconst lopWidth = targetsById[lop.id]?.width ?? lop.width;\n\t\t\t\t\tconst autoWidth =\n\t\t\t\t\t\ttypeof lopWidth === \"number\"\n\t\t\t\t\t\t\t? lopWidth\n\t\t\t\t\t\t\t: Math.round(nativeWidth * 0.8);\n\t\t\t\t\tconst lopHeight = targetsById[lop.id]?.height ?? lop.height;\n\t\t\t\t\tlet autoHeight = typeof lopHeight === \"number\" ? lopHeight : 160;\n\t\t\t\t\tconst contentVM = vm.children?.[0];\n\t\t\t\t\tconst src =\n\t\t\t\t\t\tresolveMediaSourceUrl(contentVM) ??\n\t\t\t\t\t\t(contentVM?.operation as any)?.url ??\n\t\t\t\t\t\t(contentVM?.operation as any)?.src ??\n\t\t\t\t\t\t(contentVM?.operation as any)?.srtText ??\n\t\t\t\t\t\tlop.src ??\n\t\t\t\t\t\tlop.url;\n\t\t\t\t\tif (typeof lopHeight !== \"number\" && src) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst captions = await srtLoader.load(src);\n\t\t\t\t\t\t\tif (captions && captions.length > 0) {\n\t\t\t\t\t\t\t\tautoHeight = measureMaxCaptionHeight(captions, lop, autoWidth);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {}\n\t\t\t\t\t}\n\t\t\t\t\tmediaDims.set(lop.id, { width: autoWidth, height: autoHeight });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst frameResolveNode = (vm: any): LayoutNode => {\n\t\t\tconst lop = vm?.operation ?? {};\n\t\t\tconst target = targetsById[lop.id];\n\t\t\tconst pick = (k: string) =>\n\t\t\t\ttarget && target[k] !== undefined ? target[k] : lop[k];\n\t\t\tconst node: any = {\n\t\t\t\t...lop,\n\t\t\t\twidth: pick(\"width\"),\n\t\t\t\theight: pick(\"height\"),\n\t\t\t\tgap: pick(\"gap\"),\n\t\t\t\tpadding: pick(\"padding\"),\n\t\t\t\tfontSize: pick(\"fontSize\"),\n\t\t\t\tletterSpacing: pick(\"letterSpacing\"),\n\t\t\t};\n\t\t\tnode.children = (vm?.children ?? []).map(frameResolveNode);\n\t\t\tif (!node.children.length) node.children = undefined;\n\t\t\treturn node;\n\t\t};\n\t\tconst layoutRoots = (): LayoutNode[] =>\n\t\t\t(virtualMedia.children ?? [])\n\t\t\t\t.map(frameResolveNode)\n\t\t\t\t.filter(\n\t\t\t\t\t(node: any) => node?.kind !== \"camera\" && node?.kind !== \"light\",\n\t\t\t\t);\n\t\tconst memoTree = virtualMedia.children as object | undefined;\n\t\tconst memoKey = layoutKey(\n\t\t\tnativeWidth,\n\t\t\tnativeHeight,\n\t\t\ttargetsById,\n\t\t\tmediaDims,\n\t\t);\n\t\tconst memo = memoTree ? layoutMemo.get(memoTree) : undefined;\n\t\tconst { rects } =\n\t\t\tmemo?.key === memoKey\n\t\t\t\t? memo\n\t\t\t\t: await computeLayout({\n\t\t\t\t\t\tlayout: layoutRoots(),\n\t\t\t\t\t\tviewport: { width: nativeWidth, height: nativeHeight },\n\t\t\t\t\t\tmeasure: (node, constraintWidth) => {\n\t\t\t\t\t\t\tif (node.kind === \"text\") {\n\t\t\t\t\t\t\t\tconst textStyle = {\n\t\t\t\t\t\t\t\t\tfontSize: node.fontSize ?? 48,\n\t\t\t\t\t\t\t\t\tfontWeight: node.fontWeight,\n\t\t\t\t\t\t\t\t\tfontFamily: node.fontFamily,\n\t\t\t\t\t\t\t\t\tletterSpacing: node.letterSpacing,\n\t\t\t\t\t\t\t\t\tlineHeight: node.lineHeight,\n\t\t\t\t\t\t\t\t\tpadding: node.padding,\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tif (constraintWidth !== undefined) {\n\t\t\t\t\t\t\t\t\tconst isAuto = typeof node.width !== \"number\";\n\t\t\t\t\t\t\t\t\tconst wrapped = measureText(node.text ?? \"\", {\n\t\t\t\t\t\t\t\t\t\t...textStyle,\n\t\t\t\t\t\t\t\t\t\twidth: isAuto ? undefined : constraintWidth,\n\t\t\t\t\t\t\t\t\t\tkeepNaturalWidth: true,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\twidth: isAuto\n\t\t\t\t\t\t\t\t\t\t\t? Math.ceil(wrapped.width)\n\t\t\t\t\t\t\t\t\t\t\t: Math.min(constraintWidth, Math.ceil(wrapped.width)),\n\t\t\t\t\t\t\t\t\t\theight: Math.ceil(wrapped.height),\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst natural = measureText(node.text ?? \"\", textStyle);\n\t\t\t\t\t\t\t\tif (typeof node.width !== \"number\") {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\twidth: Math.ceil(natural.width),\n\t\t\t\t\t\t\t\t\t\theight: Math.ceil(natural.height),\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst wrapped = measureText(node.text ?? \"\", {\n\t\t\t\t\t\t\t\t\t...textStyle,\n\t\t\t\t\t\t\t\t\twidth: node.width,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\twidth: Math.ceil(wrapped.width),\n\t\t\t\t\t\t\t\t\theight: Math.ceil(wrapped.height),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (node.kind === \"media\") return mediaDims.get(node.id) ?? null;\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\tif (memoTree && memo?.key !== memoKey)\n\t\t\tlayoutMemo.set(memoTree, { key: memoKey, rects });\n\t\t// 4. 3D Camera and Multiplane Setup\n\t\tconst allNodeOps = collectNodeOps(virtualMedia.children ?? []);\n\t\t// A film can cut between cameras: the active one is the camera whose\n\t\t// window holds this frame, and the latest to start wins (a cut list).\n\t\tconst cameraVMs = allNodeOps.filter(\n\t\t\t(vm) => (vm.operation as any)?.kind === \"camera\",\n\t\t);\n\t\tconst cameraVM = isVideoMode\n\t\t\t? cameraVMs\n\t\t\t\t\t.filter((vm) => {\n\t\t\t\t\t\tconst op = vm.operation as any;\n\t\t\t\t\t\tconst start = op.startFrame ?? 0;\n\t\t\t\t\t\tconst dur = op.durationFrames;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tshiftedFrame >= start &&\n\t\t\t\t\t\t\t(dur === undefined || shiftedFrame < start + dur)\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t\t.sort(\n\t\t\t\t\t\t(a, b) =>\n\t\t\t\t\t\t\t((b.operation as any).startFrame ?? 0) -\n\t\t\t\t\t\t\t((a.operation as any).startFrame ?? 0),\n\t\t\t\t\t)[0]\n\t\t\t: cameraVMs[0];\n\t\tconst lightVMs = allNodeOps.filter(\n\t\t\t(vm) => (vm.operation as any)?.kind === \"light\",\n\t\t);\n\t\tconst has3DLayer = allNodeOps.some((vm) => {\n\t\t\tconst lop = vm.operation as any;\n\t\t\tconst target = lop.id ? targetsById[lop.id] : undefined;\n\t\t\treturn (\n\t\t\t\tlop.kind !== \"camera\" &&\n\t\t\t\tlop.kind !== \"light\" &&\n\t\t\t\t(Boolean(target?.is3D ?? lop.is3D) || (target?.z ?? lop.z ?? 0) !== 0)\n\t\t\t);\n\t\t});\n\t\tconst is3DScene = Boolean(cameraVM || has3DLayer || lightVMs.length > 0);\n\n\t\tlet camera: Camera3DPose | null = null;\n\t\tlet dofEnabled = false;\n\t\tconst sceneLights: Light3DOptions[] = [];\n\n\t\tif (is3DScene) {\n\t\t\tconst camOp = cameraVM?.operation as any;\n\t\t\tconst camStub = camOp?.id ? targetsById[camOp.id] : undefined;\n\t\t\tconst fov = camStub?.cameraFov ?? camOp?.lens?.fov ?? 50;\n\t\t\tcamera = Camera3D.createDefaultCamera(nativeWidth, nativeHeight, fov);\n\t\t\tcamera.near = camOp?.lens?.near ?? 1.0;\n\t\t\tcamera.far = camOp?.lens?.far ?? 50000.0;\n\t\t\tcamera.zoom = camStub?.cameraZoom ?? camOp?.lens?.zoom ?? 1.0;\n\n\t\t\tconst defaultEye = camera.eye;\n\t\t\tconst defaultTarget = camera.target;\n\n\t\t\t// Eye\n\t\t\tconst eyeX = camStub?.cameraX ?? camStub?.x ?? camOp?.x ?? defaultEye[0];\n\t\t\tconst eyeY = camStub?.cameraY ?? camStub?.y ?? camOp?.y ?? defaultEye[1];\n\t\t\tconst eyeZ = camStub?.cameraZ ?? camStub?.z ?? camOp?.z ?? defaultEye[2];\n\t\t\tcamera.eye = [eyeX, eyeY, eyeZ];\n\n\t\t\t// Target\n\t\t\tconst hasCustomTarget =\n\t\t\t\tcamStub?.targetX !== undefined ||\n\t\t\t\tcamStub?.targetY !== undefined ||\n\t\t\t\tcamStub?.targetZ !== undefined ||\n\t\t\t\tcamOp?.targetX !== undefined ||\n\t\t\t\tcamOp?.targetY !== undefined ||\n\t\t\t\tcamOp?.targetZ !== undefined;\n\t\t\tif (hasCustomTarget) {\n\t\t\t\tcamera.target = [\n\t\t\t\t\tcamStub?.targetX ?? camOp?.targetX ?? defaultTarget[0],\n\t\t\t\t\tcamStub?.targetY ?? camOp?.targetY ?? defaultTarget[1],\n\t\t\t\t\tcamStub?.targetZ ?? camOp?.targetZ ?? defaultTarget[2],\n\t\t\t\t];\n\t\t\t} else {\n\t\t\t\t// Pure truck / pedestal shifts target along with eye\n\t\t\t\tcamera.target = [eyeX, eyeY, 0];\n\t\t\t}\n\n\t\t\t// Orientation (Pitch / Yaw / Roll)\n\t\t\tconst pitch = camStub?.cameraPitch ?? camOp?.pitch ?? 0;\n\t\t\tconst yaw = camStub?.cameraYaw ?? camOp?.yaw ?? 0;\n\t\t\tconst roll = camStub?.cameraRoll ?? camOp?.roll ?? 0;\n\t\t\tif (pitch !== 0 || yaw !== 0 || roll !== 0) {\n\t\t\t\tcamera = Camera3D.applyOrientation(camera, pitch, yaw, roll);\n\t\t\t}\n\n\t\t\t// Orbit turntable\n\t\t\tconst orbitAzimuth = camStub?.orbitAzimuth;\n\t\t\tconst orbitElevation = camStub?.orbitElevation;\n\t\t\tconst orbitRadius = camStub?.orbitRadius;\n\t\t\tif (\n\t\t\t\torbitAzimuth !== undefined ||\n\t\t\t\torbitElevation !== undefined ||\n\t\t\t\torbitRadius !== undefined\n\t\t\t) {\n\t\t\t\tconst radius =\n\t\t\t\t\torbitRadius ?? Vector3Math.distance(camera.eye, camera.target);\n\t\t\t\tcamera.eye = Camera3D.orbit(\n\t\t\t\t\tcamera.target,\n\t\t\t\t\tradius,\n\t\t\t\t\torbitAzimuth ?? 0,\n\t\t\t\t\torbitElevation ?? 0,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Procedural Handheld Shake\n\t\t\tconst shakeTrans =\n\t\t\t\tcamStub?.shakeTranslation ??\n\t\t\t\t(camOp?.shake?.enabled ? camOp?.shake?.translationAmplitude : 0) ??\n\t\t\t\t0;\n\t\t\tconst shakeRot =\n\t\t\t\tcamStub?.shakeRotation ??\n\t\t\t\t(camOp?.shake?.enabled ? camOp?.shake?.rotationAmplitude : 0) ??\n\t\t\t\t0;\n\t\t\tif (shakeTrans > 0 || shakeRot > 0) {\n\t\t\t\tconst t = shiftedFrame / (fps ?? 24);\n\t\t\t\tcamera = Camera3D.applyCameraShake(camera, t, {\n\t\t\t\t\ttranslationAmplitude: shakeTrans,\n\t\t\t\t\trotationAmplitude: shakeRot,\n\t\t\t\t\tfrequency: camOp?.shake?.frequency ?? 1.5,\n\t\t\t\t\toctaves: camOp?.shake?.octaves ?? 3,\n\t\t\t\t\tseed: camOp?.shake?.seed ?? 42,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Depth of Field\n\t\t\tdofEnabled = Boolean(\n\t\t\t\tcamOp?.dof?.enabled || camStub?.focusDistance !== undefined,\n\t\t\t);\n\t\t\tif (dofEnabled) {\n\t\t\t\tcamera.focusDistance =\n\t\t\t\t\tcamStub?.focusDistance ??\n\t\t\t\t\tcamOp?.dof?.focusDistance ??\n\t\t\t\t\tVector3Math.distance(camera.eye, camera.target);\n\t\t\t\tcamera.fStop = camStub?.fStop ?? camOp?.dof?.fStop ?? 2.8;\n\t\t\t\tcamera.maxBlurRadius =\n\t\t\t\t\tcamStub?.maxBlurRadius ?? camOp?.dof?.maxBlurRadius ?? 24;\n\t\t\t}\n\n\t\t\t// Collect Active Lights\n\t\t\tfor (const lvm of lightVMs) {\n\t\t\t\tconst lop = lvm.operation as any;\n\t\t\t\tconst targetId = lop.id || lop.inputHandleId;\n\t\t\t\tconst target = targetId ? targetsById[targetId] : undefined;\n\t\t\t\tif (target?.hidden || lop.hidden) continue;\n\n\t\t\t\tif (isVideoMode) {\n\t\t\t\t\tconst startFrame = lop.startFrame ?? 0;\n\t\t\t\t\tconst durationFrames = lop.durationFrames;\n\t\t\t\t\tif (shiftedFrame < startFrame) continue;\n\t\t\t\t\tif (\n\t\t\t\t\t\tdurationFrames !== undefined &&\n\t\t\t\t\t\tshiftedFrame >= startFrame + durationFrames\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst lightType = (target?.lightType ?? lop.lightType ?? \"point\") as\n\t\t\t\t\t| \"ambient\"\n\t\t\t\t\t| \"directional\"\n\t\t\t\t\t| \"point\"\n\t\t\t\t\t| \"spot\";\n\t\t\t\tconst rawColor = target?.color ?? lop.color ?? \"#ffffff\";\n\t\t\t\tconst color = parseColor(rawColor);\n\t\t\t\tconst intensity = target?.intensity ?? lop.intensity ?? 1.0;\n\t\t\t\tconst x = target?.x ?? lop.x ?? 0;\n\t\t\t\tconst y = target?.y ?? lop.y ?? 0;\n\t\t\t\tconst z = target?.z ?? lop.z ?? 0;\n\t\t\t\tconst targetX = target?.targetX ?? lop.targetX ?? 0;\n\t\t\t\tconst targetY = target?.targetY ?? lop.targetY ?? 0;\n\t\t\t\tconst targetZ = target?.targetZ ?? lop.targetZ ?? 0;\n\t\t\t\tconst radius = target?.radius ?? lop.radius ?? 1000;\n\t\t\t\tconst angle = target?.angle ?? lop.angle ?? 45;\n\t\t\t\tconst penumbra = target?.penumbra ?? lop.penumbra ?? 0.2;\n\t\t\t\tconst decay = target?.decay ?? lop.decay ?? 1;\n\n\t\t\t\tsceneLights.push({\n\t\t\t\t\ttype: lightType,\n\t\t\t\t\tcolor,\n\t\t\t\t\tintensity,\n\t\t\t\t\tposition: [x, y, z],\n\t\t\t\t\ttarget: [targetX, targetY, targetZ],\n\t\t\t\t\tradius,\n\t\t\t\t\tangle,\n\t\t\t\t\tpenumbra,\n\t\t\t\t\tdecay,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\ttype Pending3DItem =\n\t\t\t| { kind: \"quad\"; texture: GPUTexture; opts: DrawQuad3DOpts }\n\t\t\t| {\n\t\t\t\t\t// A text layer's glyphs, drawn natively on its plane.\n\t\t\t\t\tkind: \"slug\";\n\t\t\t\t\ttexture?: undefined;\n\t\t\t\t\tbatches: SlugGlyphBatch[];\n\t\t\t\t\topts: DrawQuad3DOpts;\n\t\t\t\t\t/** Passes already on this plane (its backdrop quad) */\n\t\t\t\t\tstackBase: number;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tkind: \"mesh\";\n\t\t\t\t\tmesh: Mesh3DData;\n\t\t\t\t\ttexture?: GPUTexture;\n\t\t\t\t\topts: DrawMesh3DOpts;\n\t\t\t\t\tmeshBuffers?: GPUMeshBuffers;\n\t\t\t };\n\t\tconst pending3DItems: Pending3DItem[] = [];\n\n\t\tconst flush3DPass = (\n\t\t\tcurTex: GPUTexture,\n\t\t\tcurView: GPUTextureView,\n\t\t\tcurExcludes: GPUTexture[],\n\t\t): { finalTex: GPUTexture; finalView: GPUTextureView } => {\n\t\t\tif (pending3DItems.length === 0 || !camera) {\n\t\t\t\treturn { finalTex: curTex, finalView: curView };\n\t\t\t}\n\n\t\t\tconst r3d = getRenderer3D(\n\t\t\t\tctx.device,\n\t\t\t\tctx.renderer.format ?? \"rgba8unorm\",\n\t\t\t\tsampleCount3d,\n\t\t\t);\n\n\t\t\t// Execute audio mesh deformation compute passes before beginning render pass\n\t\t\tfor (const item of pending3DItems) {\n\t\t\t\tif (item.kind === \"mesh\" && item.opts.audioDeform) {\n\t\t\t\t\titem.meshBuffers = r3d.deformMesh(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\titem.mesh,\n\t\t\t\t\t\titem.opts.audioDeform,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst itemTextures = pending3DItems\n\t\t\t\t.map((q) => (q.kind === \"quad\" ? q.texture : q.texture))\n\t\t\t\t.filter((t): t is GPUTexture => Boolean(t));\n\n\t\t\tconst scene3dTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\tnativeWidth,\n\t\t\t\tnativeHeight,\n\t\t\t\t[curTex, targetTexture, ...curExcludes, ...itemTextures],\n\t\t\t);\n\t\t\tconst scene3dView = scene3dTex.createView();\n\n\t\t\tlet linearDepthTex: GPUTexture | undefined;\n\t\t\tlet linearDepthView: GPUTextureView | undefined;\n\t\t\tif (dofEnabled) {\n\t\t\t\tlinearDepthTex = r3d.getOrCreateLinearDepthTexture(\n\t\t\t\t\tnativeWidth,\n\t\t\t\t\tnativeHeight,\n\t\t\t\t);\n\t\t\t\tlinearDepthView = linearDepthTex.createView();\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tpass: pass3d,\n\t\t\t\tcameraBindGroup,\n\t\t\t\tcameraBuffer,\n\t\t\t\tlightsBindGroup,\n\t\t\t} = r3d.beginPass(\n\t\t\t\tencoder,\n\t\t\t\tscene3dView,\n\t\t\t\tnativeWidth,\n\t\t\t\tnativeHeight,\n\t\t\t\tcamera,\n\t\t\t\t\"clear\",\n\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\tlinearDepthView,\n\t\t\t\tsceneLights,\n\t\t\t);\n\n\t\t\tfor (const item of pending3DItems) {\n\t\t\t\tif (item.kind === \"quad\") {\n\t\t\t\t\tr3d.drawTextureQuad(\n\t\t\t\t\t\tpass3d,\n\t\t\t\t\t\tcameraBindGroup,\n\t\t\t\t\t\tlightsBindGroup,\n\t\t\t\t\t\titem.texture,\n\t\t\t\t\t\titem.opts,\n\t\t\t\t\t\tdofEnabled,\n\t\t\t\t\t);\n\t\t\t\t} else if (item.kind === \"slug\") {\n\t\t\t\t\tr3d.drawSlugText(\n\t\t\t\t\t\tpass3d,\n\t\t\t\t\t\tcameraBindGroup,\n\t\t\t\t\t\tlightsBindGroup,\n\t\t\t\t\t\titem.batches,\n\t\t\t\t\t\titem.opts,\n\t\t\t\t\t\titem.stackBase,\n\t\t\t\t\t\tdofEnabled,\n\t\t\t\t\t);\n\t\t\t\t} else if (item.kind === \"mesh\") {\n\t\t\t\t\tr3d.drawMesh3D(\n\t\t\t\t\t\tpass3d,\n\t\t\t\t\t\tcameraBindGroup,\n\t\t\t\t\t\tlightsBindGroup,\n\t\t\t\t\t\titem.meshBuffers ?? item.mesh,\n\t\t\t\t\t\titem.texture,\n\t\t\t\t\t\titem.opts,\n\t\t\t\t\t\tdofEnabled,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpass3d.end();\n\n\t\t\tlet final3dTex = scene3dTex;\n\t\t\tif (dofEnabled && linearDepthTex) {\n\t\t\t\tconst dofResultTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\t\tnativeWidth,\n\t\t\t\t\tnativeHeight,\n\t\t\t\t\t[curTex, targetTexture, scene3dTex, ...curExcludes],\n\t\t\t\t);\n\t\t\t\tr3d.applyDepthOfField(\n\t\t\t\t\tencoder,\n\t\t\t\t\tscene3dTex,\n\t\t\t\t\tlinearDepthTex,\n\t\t\t\t\tdofResultTex.createView(),\n\t\t\t\t\tcameraBuffer,\n\t\t\t\t);\n\t\t\t\tfinal3dTex = dofResultTex;\n\t\t\t}\n\n\t\t\tconst nextTex = ctx.renderer.composite(\n\t\t\t\tencoder,\n\t\t\t\tcurTex,\n\t\t\t\tfinal3dTex,\n\t\t\t\t\"normal\",\n\t\t\t\t[targetTexture, ...curExcludes],\n\t\t\t);\n\t\t\tpending3DItems.length = 0;\n\t\t\treturn { finalTex: nextTex, finalView: nextTex.createView() };\n\t\t};\n\n\t\t// 5. Draw the node tree into the native texture (z-sorted per level).\n\t\tlet nodeIndex = 0;\n\n\t\tconst renderNodeTree = async (\n\t\t\tvms: VirtualMediaData[],\n\t\t\tinitialTex: GPUTexture,\n\t\t\tinitialView: GPUTextureView,\n\t\t\texcludes: GPUTexture[],\n\t\t\taccumulatedOpacity = 1.0,\n\t\t\tparentMatrix = new DOMMatrix(),\n\t\t\tparentRect: Rect | null = null,\n\t\t\ttargetW: number = nativeWidth,\n\t\t\ttargetH: number = nativeHeight,\n\t\t\tparent3DMatrix: Mat4 | null = null,\n\t\t\tisRootScene = false,\n\t\t): Promise<{ finalTex: GPUTexture; finalView: GPUTextureView }> => {\n\t\t\tconst sorted = [...vms].sort((a, b) => {\n\t\t\t\tconst za = (a.operation as any)?.zIndex ?? 0;\n\t\t\t\tconst zb = (b.operation as any)?.zIndex ?? 0;\n\t\t\t\treturn za - zb;\n\t\t\t});\n\t\t\tlet activeTex = initialTex;\n\t\t\tlet activeView = initialView;\n\t\t\tlet activeExcludes = excludes;\n\t\t\tfor (const child of sorted) {\n\t\t\t\tconst lop = child.operation as any;\n\t\t\t\tif (lop.kind === \"camera\" || lop.kind === \"light\") continue;\n\t\t\t\tconst targetId = lop.id || lop.inputHandleId;\n\t\t\t\tconst target = targetId ? targetsById[targetId] : undefined;\n\t\t\t\tconst isChild3D =\n\t\t\t\t\tBoolean(target?.is3D ?? lop.is3D) ||\n\t\t\t\t\tBoolean(camera && ((target?.z ?? lop.z ?? 0) !== 0 || lop.is3D)) ||\n\t\t\t\t\tBoolean(parent3DMatrix);\n\n\t\t\t\tif (isRootScene && !isChild3D && pending3DItems.length > 0) {\n\t\t\t\t\tconst flushed = flush3DPass(activeTex, activeView, activeExcludes);\n\t\t\t\t\tif (flushed.finalTex !== activeTex) {\n\t\t\t\t\t\tactiveExcludes = [...activeExcludes, flushed.finalTex];\n\t\t\t\t\t}\n\t\t\t\t\tactiveTex = flushed.finalTex;\n\t\t\t\t\tactiveView = flushed.finalView;\n\t\t\t\t}\n\n\t\t\t\tif (lop.op !== \"CompositorLayer\") {\n\t\t\t\t\tawait drawChild(\n\t\t\t\t\t\tchild,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontainerWidth: targetW,\n\t\t\t\t\t\t\tcontainerHeight: targetH,\n\t\t\t\t\t\t\trenderId: `${props.renderId}-c${nodeIndex}-${lop.op}`,\n\t\t\t\t\t\t\tfps,\n\t\t\t\t\t\t\tisVideoMode,\n\t\t\t\t\t\t\tframe: shiftedFrame,\n\t\t\t\t\t\t\t// The child's effect passes must not borrow textures still in use here.\n\t\t\t\t\t\t\texcludeTextures: [targetTexture, ...activeExcludes],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tactiveView,\n\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tnodeIndex += 1;\n\t\t\t\tconst res = await renderLayerVM(\n\t\t\t\t\tchild,\n\t\t\t\t\tnodeIndex,\n\t\t\t\t\tactiveTex,\n\t\t\t\t\tactiveView,\n\t\t\t\t\tactiveExcludes,\n\t\t\t\t\taccumulatedOpacity,\n\t\t\t\t\tparentMatrix,\n\t\t\t\t\tparentRect,\n\t\t\t\t\ttargetW,\n\t\t\t\t\ttargetH,\n\t\t\t\t\tparent3DMatrix,\n\t\t\t\t\tisRootScene,\n\t\t\t\t);\n\t\t\t\tif (res) {\n\t\t\t\t\tif (res.finalTex !== activeTex) {\n\t\t\t\t\t\tactiveExcludes = [...activeExcludes, res.finalTex];\n\t\t\t\t\t}\n\t\t\t\t\tactiveTex = res.finalTex;\n\t\t\t\t\tactiveView = res.finalView;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isRootScene && pending3DItems.length > 0) {\n\t\t\t\tconst flushed = flush3DPass(activeTex, activeView, activeExcludes);\n\t\t\t\tif (flushed.finalTex !== activeTex) {\n\t\t\t\t\tactiveExcludes = [...activeExcludes, flushed.finalTex];\n\t\t\t\t}\n\t\t\t\tactiveTex = flushed.finalTex;\n\t\t\t\tactiveView = flushed.finalView;\n\t\t\t}\n\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\t\t};\n\n\t\tconst renderLayerVM = async (\n\t\t\tnodeVM: VirtualMediaData,\n\t\t\ti: number,\n\t\t\tdestTex: GPUTexture,\n\t\t\tdestView: GPUTextureView,\n\t\t\tbaseExcludes: GPUTexture[],\n\t\t\taccumulatedOpacity: number,\n\t\t\tparentMatrix: DOMMatrix,\n\t\t\tparentRect: Rect | null,\n\t\t\ttargetW: number = nativeWidth,\n\t\t\ttargetH: number = nativeHeight,\n\t\t\tparent3DMatrix: Mat4 | null = null,\n\t\t\tisRootScene = false,\n\t\t): Promise<\n\t\t\t{ finalTex: GPUTexture; finalView: GPUTextureView } | undefined\n\t\t> => {\n\t\t\t// Textures queued for the pending 3D flush are still live: a later\n\t\t\t// layer of the same size must not be handed one from the pool.\n\t\t\tconst excludes = [\n\t\t\t\t...baseExcludes,\n\t\t\t\t...pending3DItems\n\t\t\t\t\t.map((q) => q.texture)\n\t\t\t\t\t.filter((t): t is GPUTexture => Boolean(t)),\n\t\t\t];\n\t\t\tconst lop = nodeVM.operation as any;\n\t\t\tif (lop.kind === \"camera\" || lop.kind === \"light\") return;\n\t\t\tconst targetId = lop.id || lop.inputHandleId;\n\t\t\tconst target = targetId ? targetsById[targetId] : undefined;\n\t\t\tif (target?.hidden || lop.hidden) return;\n\n\t\t\tconst kind = lop.kind;\n\t\t\tconst isContainer = kind === \"flex\" || kind === \"block\" || kind === \"box\";\n\n\t\t\t// Temporal gate (video mode): clip-relative duration.\n\t\t\tif (isVideoMode) {\n\t\t\t\tconst startFrame = lop.startFrame ?? 0;\n\t\t\t\tconst durationFrames = lop.durationFrames;\n\t\t\t\tif (shiftedFrame < startFrame) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tdurationFrames !== undefined &&\n\t\t\t\t\tshiftedFrame >= startFrame + durationFrames\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (kind === \"model3d\") {\n\t\t\t\tconst r3d = getRenderer3D(\n\t\t\t\t\tctx.device,\n\t\t\t\t\tctx.renderer.format ?? \"rgba8unorm\",\n\t\t\t\t\tsampleCount3d,\n\t\t\t\t);\n\t\t\t\tlet modelSrc = lop.modelData ?? lop.src;\n\n\t\t\t\tif (!modelSrc && lop.text3dOptions) {\n\t\t\t\t\t// The node's Layer3D.extrudedText options: geometry options plus a family name.\n\t\t\t\t\tconst tOpts = lop.text3dOptions as Omit<\n\t\t\t\t\t\tExtrudedTextGeometryOptions,\n\t\t\t\t\t\t\"font\"\n\t\t\t\t\t> & { fontFamily?: string };\n\t\t\t\t\tconst font =\n\t\t\t\t\t\t(tOpts.fontFamily\n\t\t\t\t\t\t\t? SlugFontCache.getParsed(tOpts.fontFamily)\n\t\t\t\t\t\t\t: null) ??\n\t\t\t\t\t\tSlugFontCache.getParsed(\"Inter\") ??\n\t\t\t\t\t\tSlugFontCache.getParsed(\"Unbounded\") ??\n\t\t\t\t\t\tSlugFontCache.getFirstParsed();\n\t\t\t\t\tif (font) {\n\t\t\t\t\t\tconst res = generateExtrudedTextGeometry({\n\t\t\t\t\t\t\t...tOpts,\n\t\t\t\t\t\t\t// SlugFontCache holds fontkit fonts under a narrower type.\n\t\t\t\t\t\t\tfont: font as unknown as ExtrudedTextGeometryOptions[\"font\"],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tmodelSrc = res.modelData;\n\t\t\t\t\t\tlop.modelData = modelSrc;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!modelSrc) return;\n\n\t\t\t\tlet model: Model3DData | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tmodel =\n\t\t\t\t\t\ttypeof modelSrc === \"object\" &&\n\t\t\t\t\t\tmodelSrc !== null &&\n\t\t\t\t\t\t\"meshes\" in modelSrc\n\t\t\t\t\t\t\t? (modelSrc as Model3DData)\n\t\t\t\t\t\t\t: r3d.loadModel(modelSrc, lop.modelFormat ?? \"auto\", {\n\t\t\t\t\t\t\t\t\tcenter: lop.center,\n\t\t\t\t\t\t\t\t\tnormalizeSize: lop.normalizeSize,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(\"Failed to load 3D model:\", err);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!model || model.meshes.length === 0) return;\n\n\t\t\t\tconst posX = target?.x ?? lop.x ?? 0;\n\t\t\t\tconst posY = target?.y ?? lop.y ?? 0;\n\t\t\t\tconst posZ = target?.z ?? lop.z ?? 0;\n\n\t\t\t\tconst rotX = target?.rotateX ?? lop.rotateX ?? 0;\n\t\t\t\tconst rotY = target?.rotateY ?? lop.rotateY ?? 0;\n\t\t\t\tconst rotZ =\n\t\t\t\t\t(target?.rotateZ ?? lop.rotateZ ?? 0) !== 0\n\t\t\t\t\t\t? (target?.rotateZ ?? lop.rotateZ ?? 0)\n\t\t\t\t\t\t: (target?.rotation ?? lop.rotation ?? 0);\n\n\t\t\t\tconst sc = target?.scale ?? lop.scale ?? 1;\n\t\t\t\tconst scX = (target?.scaleX ?? lop.scaleX ?? 1) * sc;\n\t\t\t\tconst scY = (target?.scaleY ?? lop.scaleY ?? 1) * sc;\n\t\t\t\tconst scZ = (target?.scaleZ ?? lop.scaleZ ?? 1) * sc;\n\n\t\t\t\tlet localM = Matrix4Math.identity();\n\t\t\t\tlocalM = Matrix4Math.multiply(\n\t\t\t\t\tlocalM,\n\t\t\t\t\tMatrix4Math.translate(posX, posY, posZ),\n\t\t\t\t);\n\n\t\t\t\tconst rxRad = (rotX * Math.PI) / 180;\n\t\t\t\tconst ryRad = (rotY * Math.PI) / 180;\n\t\t\t\tconst rzRad = (rotZ * Math.PI) / 180;\n\n\t\t\t\tif (rzRad !== 0)\n\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateZ(rzRad));\n\t\t\t\tif (ryRad !== 0)\n\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateY(ryRad));\n\t\t\t\tif (rxRad !== 0)\n\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateX(rxRad));\n\n\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.scale(scX, scY, scZ));\n\n\t\t\t\tconst finalModelMatrix = parent3DMatrix\n\t\t\t\t\t? Matrix4Math.multiply(parent3DMatrix, localM)\n\t\t\t\t\t: localM;\n\n\t\t\t\tconst colorParsed =\n\t\t\t\t\ttarget?.colorTint || target?.color || lop.colorTint || lop.color\n\t\t\t\t\t\t? parseColor(\n\t\t\t\t\t\t\t\ttarget?.colorTint ??\n\t\t\t\t\t\t\t\t\ttarget?.color ??\n\t\t\t\t\t\t\t\t\tlop.colorTint ??\n\t\t\t\t\t\t\t\t\tlop.color,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tconst colorTint: [number, number, number, number] = colorParsed\n\t\t\t\t\t? [colorParsed.r, colorParsed.g, colorParsed.b, colorParsed.a]\n\t\t\t\t\t: [1, 1, 1, 1];\n\n\t\t\t\tconst modelOpacity =\n\t\t\t\t\t(target?.opacity ?? lop.opacity ?? 1) * accumulatedOpacity;\n\n\t\t\t\t// Animation evaluation\n\t\t\t\tlet skinningMatrices: Float32Array | undefined;\n\t\t\t\tconst animProgress =\n\t\t\t\t\ttarget?.animationProgress ?? lop.animationProgress ?? 0;\n\t\t\t\tconst animTime = target?.animationTime ?? lop.animationTime ?? 0;\n\t\t\t\tconst animSpeed = target?.animationSpeed ?? lop.animationSpeed ?? 1.0;\n\t\t\t\tconst clip =\n\t\t\t\t\t(lop.animationName\n\t\t\t\t\t\t? model.animations.find((a) => a.name === lop.animationName)\n\t\t\t\t\t\t: undefined) ?? model.animations[0];\n\t\t\t\tlet clipSec = 0;\n\t\t\t\tif (clip && clip.duration > 0) {\n\t\t\t\t\tclipSec =\n\t\t\t\t\t\tanimProgress > 0\n\t\t\t\t\t\t\t? animProgress * clip.duration\n\t\t\t\t\t\t\t: animTime + ((shiftedFrame ?? 0) / (fps || 30)) * animSpeed;\n\t\t\t\t\tif (lop.loop ?? true) clipSec %= clip.duration;\n\t\t\t\t}\n\n\t\t\t\t// A scene graph (glTF) is posed node by node: unskinned meshes ride\n\t\t\t\t// their node, skinned ones take their skin's joint matrices.\n\t\t\t\tconst sceneRoot = Matrix4Math.multiply(\n\t\t\t\t\tfinalModelMatrix,\n\t\t\t\t\tmodel.rootTransform ?? Matrix4Math.identity(),\n\t\t\t\t);\n\t\t\t\tconst posed = model.nodes ? poseNodes(model, clip, clipSec) : undefined;\n\t\t\t\tconst skinCache = new Map<number, Float32Array>();\n\t\t\t\tconst placeMesh = (\n\t\t\t\t\tmesh: Mesh3DData,\n\t\t\t\t): { matrix: Mat4; joints?: Float32Array } => {\n\t\t\t\t\tif (!posed) return { matrix: sceneRoot };\n\t\t\t\t\tif (mesh.skin !== undefined) {\n\t\t\t\t\t\tlet joints = skinCache.get(mesh.skin);\n\t\t\t\t\t\tif (!joints) {\n\t\t\t\t\t\t\tjoints = jointMatrices(model, mesh.skin, posed);\n\t\t\t\t\t\t\tskinCache.set(mesh.skin, joints);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { matrix: sceneRoot, joints };\n\t\t\t\t\t}\n\t\t\t\t\tif (mesh.node !== undefined)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tmatrix: Matrix4Math.multiply(sceneRoot, posed[mesh.node]!),\n\t\t\t\t\t\t};\n\t\t\t\t\treturn { matrix: sceneRoot };\n\t\t\t\t};\n\n\t\t\t\tif (!posed && clip && clip.duration > 0) {\n\t\t\t\t\tconst currentSec = clipSec;\n\t\t\t\t\tif (model.skeleton && model.skeleton.bones.length > 0) {\n\t\t\t\t\t\tconst numBones = Math.min(128, model.skeleton.bones.length);\n\t\t\t\t\t\tskinningMatrices = new Float32Array(128 * 16);\n\t\t\t\t\t\tfor (let b = 0; b < 128; b++) {\n\t\t\t\t\t\t\tskinningMatrices[b * 16] = 1;\n\t\t\t\t\t\t\tskinningMatrices[b * 16 + 5] = 1;\n\t\t\t\t\t\t\tskinningMatrices[b * 16 + 10] = 1;\n\t\t\t\t\t\t\tskinningMatrices[b * 16 + 15] = 1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const track of clip.tracks) {\n\t\t\t\t\t\t\tconst boneIdx = model.skeleton.boneIndicesByName[track.nodeName];\n\t\t\t\t\t\t\tif (boneIdx !== undefined && boneIdx < numBones) {\n\t\t\t\t\t\t\t\tconst times = track.times;\n\t\t\t\t\t\t\t\tlet sampleIdx = 0;\n\t\t\t\t\t\t\t\tfor (let k = 0; k < times.length - 1; k++) {\n\t\t\t\t\t\t\t\t\tif (currentSec >= times[k]! && currentSec <= times[k + 1]!) {\n\t\t\t\t\t\t\t\t\t\tsampleIdx = k;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst t0 = times[sampleIdx] ?? 0;\n\t\t\t\t\t\t\t\tconst t1 = times[sampleIdx + 1] ?? t0;\n\t\t\t\t\t\t\t\tconst alpha = t1 > t0 ? (currentSec - t0) / (t1 - t0) : 0;\n\n\t\t\t\t\t\t\t\tif (track.translations) {\n\t\t\t\t\t\t\t\t\tconst x0 = track.translations[sampleIdx * 3] ?? 0;\n\t\t\t\t\t\t\t\t\tconst y0 = track.translations[sampleIdx * 3 + 1] ?? 0;\n\t\t\t\t\t\t\t\t\tconst z0 = track.translations[sampleIdx * 3 + 2] ?? 0;\n\t\t\t\t\t\t\t\t\tconst x1 = track.translations[(sampleIdx + 1) * 3] ?? x0;\n\t\t\t\t\t\t\t\t\tconst y1 = track.translations[(sampleIdx + 1) * 3 + 1] ?? y0;\n\t\t\t\t\t\t\t\t\tconst z1 = track.translations[(sampleIdx + 1) * 3 + 2] ?? z0;\n\t\t\t\t\t\t\t\t\tconst curX = x0 + (x1 - x0) * alpha;\n\t\t\t\t\t\t\t\t\tconst curY = y0 + (y1 - y0) * alpha;\n\t\t\t\t\t\t\t\t\tconst curZ = z0 + (z1 - z0) * alpha;\n\n\t\t\t\t\t\t\t\t\tconst boneMat = Matrix4Math.translate(curX, curY, curZ);\n\t\t\t\t\t\t\t\t\tconst bone = model.skeleton.bones[boneIdx];\n\t\t\t\t\t\t\t\t\tconst skinMat = bone\n\t\t\t\t\t\t\t\t\t\t? Matrix4Math.multiply(boneMat, bone.inverseBindMatrix)\n\t\t\t\t\t\t\t\t\t\t: boneMat;\n\t\t\t\t\t\t\t\t\tskinningMatrices.set(skinMat, boneIdx * 16);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Blended materials draw after everything opaque behind them.\n\t\t\t\tconst isBlend = (m: Mesh3DData) =>\n\t\t\t\t\tm.materialName\n\t\t\t\t\t\t? model.materials[m.materialName]?.alphaMode === \"blend\"\n\t\t\t\t\t\t: false;\n\t\t\t\tconst drawOrder = [...model.meshes].sort(\n\t\t\t\t\t(a, b) => Number(isBlend(a)) - Number(isBlend(b)),\n\t\t\t\t);\n\t\t\t\tfor (const mesh of drawOrder) {\n\t\t\t\t\tconst mat = mesh.materialName\n\t\t\t\t\t\t? model.materials[mesh.materialName]\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst placed = placeMesh(mesh);\n\t\t\t\t\tconst meshSkin = placed.joints ?? skinningMatrices;\n\n\t\t\t\t\tlet meshColorTint: [number, number, number, number];\n\t\t\t\t\tif (colorParsed) {\n\t\t\t\t\t\tif (mat?.diffuseColor) {\n\t\t\t\t\t\t\tmeshColorTint = [\n\t\t\t\t\t\t\t\tmat.diffuseColor[0] * colorTint[0],\n\t\t\t\t\t\t\t\tmat.diffuseColor[1] * colorTint[1],\n\t\t\t\t\t\t\t\tmat.diffuseColor[2] * colorTint[2],\n\t\t\t\t\t\t\t\t(mat.diffuseColor[3] ?? 1.0) * colorTint[3],\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmeshColorTint = colorTint;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mat?.diffuseColor) {\n\t\t\t\t\t\tmeshColorTint = mat.diffuseColor;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmeshColorTint = [0.8, 0.8, 0.85, 1.0];\n\t\t\t\t\t}\n\n\t\t\t\t\t// Audio latent 3D mesh deformation\n\t\t\t\t\tconst audioDeformConfig = (target?.audioDeform ?? lop.audioDeform) as\n\t\t\t\t\t\t| MeshAudioDeformConfig\n\t\t\t\t\t\t| undefined;\n\n\t\t\t\t\tlet meshAudioDeform: DrawMesh3DOpts[\"audioDeform\"];\n\t\t\t\t\tif (audioDeformConfig) {\n\t\t\t\t\t\tconst currentSec = (shiftedFrame ?? 0) / (fps || 30);\n\t\t\t\t\t\tconst timeMs = currentSec * 1000;\n\n\t\t\t\t\t\tlet latentBuffer = (audioDeformConfig as any).latentBuffer as\n\t\t\t\t\t\t\t| GPUBuffer\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tif (!latentBuffer && (audioDeformConfig as any).audioBuffer) {\n\t\t\t\t\t\t\tlatentBuffer = (audioDeformConfig as any)\n\t\t\t\t\t\t\t\t.audioBuffer as GPUBuffer;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!latentBuffer) {\n\t\t\t\t\t\t\tconst directAudio = (audioDeformConfig as any).audioData as\n\t\t\t\t\t\t\t\t| Float32Array[]\n\t\t\t\t\t\t\t\t| { channels: Float32Array[]; sampleRate: number }\n\t\t\t\t\t\t\t\t| undefined;\n\n\t\t\t\t\t\t\tif (directAudio) {\n\t\t\t\t\t\t\t\tconst cacheKey = (lop.id ?? \"audio-mesh\") + \"-direct-audio\";\n\t\t\t\t\t\t\t\tlet trackCache = audioTrackLatentCache.get(cacheKey);\n\t\t\t\t\t\t\t\tif (!trackCache) {\n\t\t\t\t\t\t\t\t\tconst chs = Array.isArray(directAudio)\n\t\t\t\t\t\t\t\t\t\t? directAudio\n\t\t\t\t\t\t\t\t\t\t: directAudio.channels;\n\t\t\t\t\t\t\t\t\tconst sRate = Array.isArray(directAudio)\n\t\t\t\t\t\t\t\t\t\t? 48000\n\t\t\t\t\t\t\t\t\t\t: directAudio.sampleRate;\n\t\t\t\t\t\t\t\t\tconst totalF = Math.max(\n\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\tMath.ceil(((chs[0]?.length ?? 0) / sRate) * (fps || 30)) +\n\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\ttrackCache = new AudioLatentTrackCache(\n\t\t\t\t\t\t\t\t\t\tchs,\n\t\t\t\t\t\t\t\t\t\tsRate,\n\t\t\t\t\t\t\t\t\t\tfps || 30,\n\t\t\t\t\t\t\t\t\t\ttotalF,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\taudioTrackLatentCache.set(cacheKey, trackCache);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlatentBuffer = trackCache.getGpuBuffer(\n\t\t\t\t\t\t\t\t\tctx.device,\n\t\t\t\t\t\t\t\t\tshiftedFrame ?? 0,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!latentBuffer && audioDeformConfig.audioTrackId) {\n\t\t\t\t\t\t\tconst trackId = audioDeformConfig.audioTrackId;\n\t\t\t\t\t\t\tlet foundAudioUrl: string | undefined;\n\t\t\t\t\t\t\tconst searchVms = (list: VirtualMediaData[]) => {\n\t\t\t\t\t\t\t\tfor (const v of list) {\n\t\t\t\t\t\t\t\t\tconst op = v.operation as Record<string, unknown> | undefined;\n\t\t\t\t\t\t\t\t\tif (op) {\n\t\t\t\t\t\t\t\t\t\tif (op.id === trackId || op.inputHandleId === trackId) {\n\t\t\t\t\t\t\t\t\t\t\tfoundAudioUrl =\n\t\t\t\t\t\t\t\t\t\t\t\t(op.inputHandleId as string) ||\n\t\t\t\t\t\t\t\t\t\t\t\t(op.src as string) ||\n\t\t\t\t\t\t\t\t\t\t\t\t(op.url as string);\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (v.children) searchVms(v.children);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tif (virtualMedia.children) searchVms(virtualMedia.children);\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!foundAudioUrl &&\n\t\t\t\t\t\t\t\t(trackId.endsWith(\".mp3\") ||\n\t\t\t\t\t\t\t\t\ttrackId.endsWith(\".wav\") ||\n\t\t\t\t\t\t\t\t\ttrackId.endsWith(\".ogg\"))\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tfoundAudioUrl = trackId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (foundAudioUrl) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tlet trackCache = audioTrackLatentCache.get(foundAudioUrl);\n\t\t\t\t\t\t\t\t\tif (!trackCache) {\n\t\t\t\t\t\t\t\t\t\tconst decoded = await decodeAudioSource(foundAudioUrl);\n\t\t\t\t\t\t\t\t\t\tif (decoded && decoded.channels.length > 0) {\n\t\t\t\t\t\t\t\t\t\t\tconst sRate = decoded.sampleRate || 48000;\n\t\t\t\t\t\t\t\t\t\t\tconst ch0Len = decoded.channels[0]?.length ?? 0;\n\t\t\t\t\t\t\t\t\t\t\tconst durationSec =\n\t\t\t\t\t\t\t\t\t\t\t\t(decoded as any).durationSec ?? ch0Len / sRate;\n\t\t\t\t\t\t\t\t\t\t\tconst totalF = Math.max(\n\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\tMath.ceil(durationSec * (fps || 30)) + 10,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\ttrackCache = new AudioLatentTrackCache(\n\t\t\t\t\t\t\t\t\t\t\t\tdecoded.channels,\n\t\t\t\t\t\t\t\t\t\t\t\tsRate,\n\t\t\t\t\t\t\t\t\t\t\t\tfps || 30,\n\t\t\t\t\t\t\t\t\t\t\t\ttotalF,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\taudioTrackLatentCache.set(foundAudioUrl, trackCache);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (trackCache) {\n\t\t\t\t\t\t\t\t\t\tlatentBuffer = trackCache.getGpuBuffer(\n\t\t\t\t\t\t\t\t\t\t\tctx.device,\n\t\t\t\t\t\t\t\t\t\t\tshiftedFrame ?? 0,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t\t\t\"[webgpu-renderer] Failed to decode audio for deformWithAudio:\",\n\t\t\t\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (latentBuffer) {\n\t\t\t\t\t\t\tlet amplitudeMultiplier =\n\t\t\t\t\t\t\t\taudioDeformConfig.amplitudeMultiplier ?? 1.0;\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\ttypeof amplitudeMultiplier !== \"number\" &&\n\t\t\t\t\t\t\t\ttypeof (amplitudeMultiplier as any)?.get === \"function\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconst frameCtx = {\n\t\t\t\t\t\t\t\t\tframe: shiftedFrame ?? 0,\n\t\t\t\t\t\t\t\t\tfps: fps || 30,\n\t\t\t\t\t\t\t\t\ttime: currentSec,\n\t\t\t\t\t\t\t\t\tduration: 0,\n\t\t\t\t\t\t\t\t\tdurationMs: 0,\n\t\t\t\t\t\t\t\t\tprogress: 0,\n\t\t\t\t\t\t\t\t\tdeltaTime: 1 / (fps || 30),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tamplitudeMultiplier = Number(\n\t\t\t\t\t\t\t\t\t(amplitudeMultiplier as any).get(frameCtx),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\ttypeof amplitudeMultiplier !== \"number\" &&\n\t\t\t\t\t\t\t\ttypeof (amplitudeMultiplier as any)?.value === \"number\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tamplitudeMultiplier = (amplitudeMultiplier as any).value;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tmeshAudioDeform = {\n\t\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t\t...audioDeformConfig,\n\t\t\t\t\t\t\t\t\tamplitudeMultiplier: Number.isFinite(\n\t\t\t\t\t\t\t\t\t\tamplitudeMultiplier as number,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t? (amplitudeMultiplier as number)\n\t\t\t\t\t\t\t\t\t\t: 1.0,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tlatentBuffer,\n\t\t\t\t\t\t\t\ttimeMs,\n\t\t\t\t\t\t\t\tsampleRate: 48000,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst meshOpts: DrawMesh3DOpts = {\n\t\t\t\t\t\tmodelMatrix: placed.matrix,\n\t\t\t\t\t\topacity: modelOpacity * (mat?.opacity ?? 1.0),\n\t\t\t\t\t\tcolorTint: meshColorTint,\n\t\t\t\t\t\ttwoSided: target?.twoSided ?? lop.twoSided ?? mat?.twoSided ?? true,\n\t\t\t\t\t\twireframe: Boolean(target?.wireframe ?? lop.wireframe),\n\t\t\t\t\t\tisSkinned: Boolean(\n\t\t\t\t\t\t\tmeshSkin || (mesh.jointIndices && mesh.jointWeights),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tskinningMatrices: meshSkin,\n\t\t\t\t\t\tmaterial: target?.material ?? lop.material ?? mat?.shading ?? \"lit\",\n\t\t\t\t\t\tshadeColor: mat?.shadeColor,\n\t\t\t\t\t\talphaCutoff: mat?.alphaCutoff,\n\t\t\t\t\t\ttextureWrap: mat?.textureWrap,\n\t\t\t\t\t\tshininess:\n\t\t\t\t\t\t\ttarget?.shininess ?? lop.shininess ?? mat?.shininess ?? 32,\n\t\t\t\t\t\troughness: target?.roughness ?? lop.roughness ?? mat?.roughness,\n\t\t\t\t\t\tspecularIntensity:\n\t\t\t\t\t\t\ttarget?.specularIntensity ?? lop.specularIntensity ?? 0.5,\n\t\t\t\t\t\tambientIntensity:\n\t\t\t\t\t\t\ttarget?.ambientIntensity ?? lop.ambientIntensity ?? 1.0,\n\t\t\t\t\t\tmetallic: target?.metallic ?? lop.metallic ?? mat?.metallic,\n\t\t\t\t\t\taudioDeform: meshAudioDeform,\n\t\t\t\t\t};\n\n\t\t\t\t\tpending3DItems.push({\n\t\t\t\t\t\tkind: \"mesh\",\n\t\t\t\t\t\tmesh,\n\t\t\t\t\t\ttexture: mat ? await r3d.materialTexture(mat) : undefined,\n\t\t\t\t\t\topts: meshOpts,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn { finalTex: destTex, finalView: destView };\n\t\t\t}\n\n\t\t\tconst rect = rects[lop.id];\n\t\t\tif (!rect) {\n\t\t\t\tif (isContainer) {\n\t\t\t\t\treturn await renderNodeTree(\n\t\t\t\t\t\tnodeVM.children ?? [],\n\t\t\t\t\t\tdestTex,\n\t\t\t\t\t\tdestView,\n\t\t\t\t\t\texcludes,\n\t\t\t\t\t\taccumulatedOpacity,\n\t\t\t\t\t\tparentMatrix,\n\t\t\t\t\t\tparentRect,\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\tparent3DMatrix,\n\t\t\t\t\t\tisRootScene,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Affine = layout rect + animated delta (CSS-transform semantics: a\n\t\t\t// track on x/y translates the node within/out of its laid-out slot).\n\t\t\tconst baseX = lop.x ?? 0;\n\t\t\tconst baseY = lop.y ?? 0;\n\t\t\tconst sampledX = target?.x ?? baseX;\n\t\t\tconst sampledY = target?.y ?? baseY;\n\n\t\t\tlet localX = 0;\n\t\t\tlet localY = 0;\n\t\t\tif (parentRect) {\n\t\t\t\tconst localLayoutX = rect.x - parentRect.x;\n\t\t\t\tconst localLayoutY = rect.y - parentRect.y;\n\t\t\t\tlocalX = localLayoutX + (sampledX - baseX);\n\t\t\t\tlocalY = localLayoutY + (sampledY - baseY);\n\t\t\t} else {\n\t\t\t\tlocalX = rect.x + (sampledX - baseX);\n\t\t\t\tlocalY = rect.y + (sampledY - baseY);\n\t\t\t}\n\n\t\t\tconst scale = target?.scale ?? lop.scale ?? 1;\n\t\t\tconst rotation = target?.rotation ?? lop.rotation ?? 0;\n\t\t\tconst layerOpacity =\n\t\t\t\t(target?.opacity ?? lop.opacity ?? 1) * accumulatedOpacity;\n\n\t\t\tconst rawAnimators = target?.animators ?? lop.animators;\n\t\t\tconst isPathText =\n\t\t\t\tkind === \"text\" && Boolean(lop.pathOptions || target?.pathOptions);\n\t\t\tconst hasKineticAnimators =\n\t\t\t\tkind === \"text\" &&\n\t\t\t\tArray.isArray(rawAnimators) &&\n\t\t\t\trawAnimators.length > 0;\n\t\t\tconst hasFormation =\n\t\t\t\tkind === \"text\" &&\n\t\t\t\tArray.isArray(rawAnimators) &&\n\t\t\t\trawAnimators.some((a: unknown) => {\n\t\t\t\t\tconst anim = a as\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tprops?: { formation?: unknown };\n\t\t\t\t\t\t\t\tformation?: unknown;\n\t\t\t\t\t\t }\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\treturn (\n\t\t\t\t\t\tanim?.props?.formation !== undefined ||\n\t\t\t\t\t\tanim?.formation !== undefined\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\tlet padX = 0;\n\t\t\tlet padY = 0;\n\t\t\tif (hasFormation) {\n\t\t\t\tlet formationRadius = 0;\n\t\t\t\tlet formationPitch = 0;\n\t\t\t\tfor (const a of rawAnimators as unknown[]) {\n\t\t\t\t\tconst anim = a as\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tprops?: { formation?: { radius?: number; pitch?: number } };\n\t\t\t\t\t\t\t\tformation?: { radius?: number; pitch?: number };\n\t\t\t\t\t\t }\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tconst f = anim?.props?.formation ?? anim?.formation;\n\t\t\t\t\tif (f) {\n\t\t\t\t\t\tif (typeof f.radius === \"number\") {\n\t\t\t\t\t\t\tformationRadius = Math.max(formationRadius, f.radius);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (typeof f.pitch === \"number\") {\n\t\t\t\t\t\t\tformationPitch = Math.max(formationPitch, f.pitch);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpadX = Math.max(160, Math.ceil(formationRadius + 100));\n\t\t\t\tpadY = Math.max(\n\t\t\t\t\t100,\n\t\t\t\t\tMath.ceil(formationRadius + formationPitch * 15 + 100),\n\t\t\t\t);\n\t\t\t} else if (!isPathText && hasKineticAnimators) {\n\t\t\t\tpadX = Math.max(80, Math.ceil(rect.width * 0.2));\n\t\t\t\tpadY = Math.max(50, Math.ceil(rect.height * 0.5));\n\t\t\t}\n\t\t\t// Path text draws into a canvas-sized layer so glyphs following a path\n\t\t\t// beyond the node box aren't clipped. Path coordinates stay local to\n\t\t\t// the node (like every other child), so the layer still sits at the\n\t\t\t// node's layout position.\n\t\t\tconst layerW = isPathText ? targetW : rect.width + padX * 2;\n\t\t\tconst layerH = isPathText ? targetH : rect.height + padY * 2;\n\t\t\tif (!isPathText && hasKineticAnimators) {\n\t\t\t\tlocalX -= padX;\n\t\t\t\tlocalY -= padY;\n\t\t\t}\n\t\t\t// Anchor-aware pivot (H2): scale/rotation happen AROUND the node's\n\t\t\t// anchor point (0.5/0.5 = center) instead of its top-left corner.\n\t\t\t// For path text the anchor is a point of the node box, not of the\n\t\t\t// oversized layer, so a badge spins around its own centre.\n\t\t\tconst anchorX = lop.anchorX ?? 0.5;\n\t\t\tconst anchorY = lop.anchorY ?? 0.5;\n\t\t\tconst localMatrix = toDOMMatrix(\n\t\t\t\tbuildLayerMatrix({\n\t\t\t\t\tx: localX,\n\t\t\t\t\ty: localY,\n\t\t\t\t\twidth: layerW,\n\t\t\t\t\theight: layerH,\n\t\t\t\t\trotation,\n\t\t\t\t\tscale,\n\t\t\t\t\tanchorX: isPathText ? (anchorX * rect.width) / layerW : anchorX,\n\t\t\t\t\tanchorY: isPathText ? (anchorY * rect.height) / layerH : anchorY,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst layerMatrix = parentMatrix.multiply(localMatrix);\n\t\t\tconst blendMode = (lop.blendMode as BlendMode) || \"normal\";\n\n\t\t\tlet activeTex = destTex;\n\t\t\tlet activeView = destView;\n\n\t\t\tconst is3D = has3DTransform(target, lop);\n\t\t\tconst rotateX = target?.rotateX ?? lop.rotateX ?? 0;\n\t\t\tconst rotateY = target?.rotateY ?? lop.rotateY ?? 0;\n\t\t\tconst rotateZ = target?.rotateZ ?? lop.rotateZ ?? 0;\n\t\t\tconst translateZ = target?.translateZ ?? lop.translateZ ?? 0;\n\t\t\tconst perspective = target?.perspective ?? lop.perspective ?? 0;\n\t\t\tconst perspectiveOriginX =\n\t\t\t\ttarget?.perspectiveOriginX ??\n\t\t\t\tlop.perspectiveOriginX ??\n\t\t\t\tlop.anchorX ??\n\t\t\t\t0.5;\n\t\t\tconst perspectiveOriginY =\n\t\t\t\ttarget?.perspectiveOriginY ??\n\t\t\t\tlop.perspectiveOriginY ??\n\t\t\t\tlop.anchorY ??\n\t\t\t\t0.5;\n\t\t\tconst backfaceVisibility =\n\t\t\t\ttarget?.backfaceVisibility ?? lop.backfaceVisibility ?? \"visible\";\n\n\t\t\tlet quad3D: Quad2D | null = null;\n\t\t\tif (is3D) {\n\t\t\t\tconst m3d = Transform3DMath.buildLayer3DMatrix({\n\t\t\t\t\tx: localX,\n\t\t\t\t\ty: localY,\n\t\t\t\t\twidth: layerW,\n\t\t\t\t\theight: layerH,\n\t\t\t\t\trotateXDeg: rotateX,\n\t\t\t\t\trotateYDeg: rotateY,\n\t\t\t\t\trotateZDeg: rotateZ !== 0 ? rotateZ : rotation,\n\t\t\t\t\tscaleX: scale,\n\t\t\t\t\tscaleY: scale,\n\t\t\t\t\tperspectivePx: perspective,\n\t\t\t\t\toriginXRatio: perspectiveOriginX,\n\t\t\t\t\toriginYRatio: perspectiveOriginY,\n\t\t\t\t\ttranslateZPx: translateZ,\n\t\t\t\t});\n\n\t\t\t\tlet q = Transform3DMath.projectRectangleCorners(m3d, layerW, layerH);\n\t\t\t\tif (!parentMatrix.isIdentity) {\n\t\t\t\t\tq = {\n\t\t\t\t\t\ttopLeft: parentMatrix.transformPoint(\n\t\t\t\t\t\t\tnew DOMPoint(q.topLeft.x, q.topLeft.y),\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttopRight: parentMatrix.transformPoint(\n\t\t\t\t\t\t\tnew DOMPoint(q.topRight.x, q.topRight.y),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tbottomLeft: parentMatrix.transformPoint(\n\t\t\t\t\t\t\tnew DOMPoint(q.bottomLeft.x, q.bottomLeft.y),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tbottomRight: parentMatrix.transformPoint(\n\t\t\t\t\t\t\tnew DOMPoint(q.bottomRight.x, q.bottomRight.y),\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tbackfaceVisibility === \"hidden\" &&\n\t\t\t\t\tTransform3DMath.computeSignedArea(q) < 0\n\t\t\t\t) {\n\t\t\t\t\treturn; // Culled by backface visibility\n\t\t\t\t}\n\n\t\t\t\tquad3D = q;\n\t\t\t}\n\n\t\t\tconst isTrue3D =\n\t\t\t\tBoolean(target?.is3D ?? lop.is3D) ||\n\t\t\t\tBoolean(camera && ((target?.z ?? lop.z ?? 0) !== 0 || lop.is3D));\n\n\t\t\t// Container rendering\n\t\t\tif (isContainer) {\n\t\t\t\tif (lop.transformStyle === \"preserve-3d\" && isTrue3D) {\n\t\t\t\t\tlet current3DMatrix: Mat4 = Matrix4Math.identity();\n\t\t\t\t\tconst containerX =\n\t\t\t\t\t\tparent3DMatrix !== null\n\t\t\t\t\t\t\t? (target?.x ?? lop.x ?? 0)\n\t\t\t\t\t\t\t: (target?.x ?? lop.x ?? localX + layerW * 0.5);\n\t\t\t\t\tconst containerY =\n\t\t\t\t\t\tparent3DMatrix !== null\n\t\t\t\t\t\t\t? (target?.y ?? lop.y ?? 0)\n\t\t\t\t\t\t\t: (target?.y ?? lop.y ?? localY + layerH * 0.5);\n\t\t\t\t\tconst containerZ = target?.z ?? lop.z ?? 0;\n\t\t\t\t\tcurrent3DMatrix = Matrix4Math.multiply(\n\t\t\t\t\t\tcurrent3DMatrix,\n\t\t\t\t\t\tMatrix4Math.translate(containerX, containerY, containerZ),\n\t\t\t\t\t);\n\t\t\t\t\tconst rxRad = ((target?.rotateX ?? lop.rotateX ?? 0) * Math.PI) / 180;\n\t\t\t\t\tconst ryRad = ((target?.rotateY ?? lop.rotateY ?? 0) * Math.PI) / 180;\n\t\t\t\t\tconst rzRad =\n\t\t\t\t\t\t((target?.rotateZ ?? lop.rotateZ ?? 0) !== 0\n\t\t\t\t\t\t\t? (target?.rotateZ ?? lop.rotateZ ?? 0)\n\t\t\t\t\t\t\t: rotation) *\n\t\t\t\t\t\t(Math.PI / 180);\n\t\t\t\t\tif (rzRad !== 0)\n\t\t\t\t\t\tcurrent3DMatrix = Matrix4Math.multiply(\n\t\t\t\t\t\t\tcurrent3DMatrix,\n\t\t\t\t\t\t\tMatrix4Math.rotateZ(rzRad),\n\t\t\t\t\t\t);\n\t\t\t\t\tif (ryRad !== 0)\n\t\t\t\t\t\tcurrent3DMatrix = Matrix4Math.multiply(\n\t\t\t\t\t\t\tcurrent3DMatrix,\n\t\t\t\t\t\t\tMatrix4Math.rotateY(ryRad),\n\t\t\t\t\t\t);\n\t\t\t\t\tif (rxRad !== 0)\n\t\t\t\t\t\tcurrent3DMatrix = Matrix4Math.multiply(\n\t\t\t\t\t\t\tcurrent3DMatrix,\n\t\t\t\t\t\t\tMatrix4Math.rotateX(rxRad),\n\t\t\t\t\t\t);\n\t\t\t\t\tconst csX = (target?.scaleX ?? lop.scaleX ?? 1) * scale;\n\t\t\t\t\tconst csY = (target?.scaleY ?? lop.scaleY ?? 1) * scale;\n\t\t\t\t\tconst csZ = (target?.scaleZ ?? lop.scaleZ ?? 1) * scale;\n\t\t\t\t\tif (csX !== 1 || csY !== 1 || csZ !== 1)\n\t\t\t\t\t\tcurrent3DMatrix = Matrix4Math.multiply(\n\t\t\t\t\t\t\tcurrent3DMatrix,\n\t\t\t\t\t\t\tMatrix4Math.scale(csX, csY, csZ),\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif (parent3DMatrix) {\n\t\t\t\t\t\tcurrent3DMatrix = Matrix4Math.multiply(\n\t\t\t\t\t\t\tparent3DMatrix,\n\t\t\t\t\t\t\tcurrent3DMatrix,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (nodeVM.children && nodeVM.children.length > 0) {\n\t\t\t\t\t\tconst res = await renderNodeTree(\n\t\t\t\t\t\t\tnodeVM.children,\n\t\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\t\tactiveView,\n\t\t\t\t\t\t\texcludes,\n\t\t\t\t\t\t\tlayerOpacity,\n\t\t\t\t\t\t\tnew DOMMatrix(),\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\tlayerW,\n\t\t\t\t\t\t\tlayerH,\n\t\t\t\t\t\t\tcurrent3DMatrix,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tactiveTex = res.finalTex;\n\t\t\t\t\t\tactiveView = res.finalView;\n\t\t\t\t\t}\n\t\t\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\t\t\t\t}\n\n\t\t\t\tif (isTrue3D) {\n\t\t\t\t\tconst texW = Math.max(1, Math.ceil(layerW));\n\t\t\t\t\tconst texH = Math.max(1, Math.ceil(layerH));\n\t\t\t\t\tconst groupExcludes = [\n\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\ttargetTexture,\n\t\t\t\t\t\t...excludes,\n\t\t\t\t\t\t...pending3DItems\n\t\t\t\t\t\t\t.map((q) => q.texture)\n\t\t\t\t\t\t\t.filter((t): t is GPUTexture => Boolean(t)),\n\t\t\t\t\t];\n\t\t\t\t\tconst groupTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\t\t\ttexW,\n\t\t\t\t\t\ttexH,\n\t\t\t\t\t\tgroupExcludes,\n\t\t\t\t\t);\n\t\t\t\t\tconst groupView = groupTex.createView();\n\n\t\t\t\t\tconst groupClearPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tgroupView,\n\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\ttexW,\n\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\"clear\",\n\t\t\t\t\t);\n\t\t\t\t\tgroupClearPass.end();\n\n\t\t\t\t\tconst br = Math.min(\n\t\t\t\t\t\tlop.borderRadius ?? lop.strokeRadius ?? 0,\n\t\t\t\t\t\tlayerW / 2,\n\t\t\t\t\t\tlayerH / 2,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (shouldPaintContainerBackground(kind, lop.background)) {\n\t\t\t\t\t\tconst bgPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tgroupView,\n\t\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\t\ttexW,\n\t\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\t\"load\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tctx.renderer.drawRect(\n\t\t\t\t\t\t\tbgPass,\n\t\t\t\t\t\t\t{ x: 0, y: 0, width: layerW, height: layerH },\n\t\t\t\t\t\t\tlop.background,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t{ opacity: 1 },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbgPass.end();\n\t\t\t\t\t}\n\n\t\t\t\t\tlet activeGroupTex = groupTex;\n\t\t\t\t\tlet activeGroupView = groupView;\n\t\t\t\t\tif (nodeVM.children && nodeVM.children.length > 0) {\n\t\t\t\t\t\tconst res = await renderNodeTree(\n\t\t\t\t\t\t\tnodeVM.children,\n\t\t\t\t\t\t\tgroupTex,\n\t\t\t\t\t\t\tgroupView,\n\t\t\t\t\t\t\t[groupTex, ...groupExcludes],\n\t\t\t\t\t\t\t1.0,\n\t\t\t\t\t\t\tnew DOMMatrix(),\n\t\t\t\t\t\t\trect,\n\t\t\t\t\t\t\ttexW,\n\t\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tactiveGroupTex = res.finalTex;\n\t\t\t\t\t\tactiveGroupView = res.finalView;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst borderResult =\n\t\t\t\t\t\t!isTrue3D && lop.borderWidth !== undefined && lop.borderColor\n\t\t\t\t\t\t\t? createBorderTexture(\n\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\t\t\tlayerW,\n\t\t\t\t\t\t\t\t\tlayerH,\n\t\t\t\t\t\t\t\t\tbr,\n\t\t\t\t\t\t\t\t\tlop.borderWidth,\n\t\t\t\t\t\t\t\t\tlop.borderColor,\n\t\t\t\t\t\t\t\t\tlop.strokeAlign ?? \"inside\",\n\t\t\t\t\t\t\t\t\t[activeGroupTex, ...groupExcludes],\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: null;\n\n\t\t\t\t\tif (borderResult) {\n\t\t\t\t\t\tconst borderPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tactiveGroupView,\n\t\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\t\ttexW,\n\t\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\t\"load\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\t\t\tborderPass,\n\t\t\t\t\t\t\tborderResult.borderTex,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tx: borderResult.ox,\n\t\t\t\t\t\t\t\ty: borderResult.oy,\n\t\t\t\t\t\t\t\twidth: borderResult.ow,\n\t\t\t\t\t\t\t\theight: borderResult.oh,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ opacity: 1 },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tborderPass.end();\n\t\t\t\t\t}\n\n\t\t\t\t\tlet modelMatrix: Mat4 | undefined;\n\t\t\t\t\tif (parent3DMatrix) {\n\t\t\t\t\t\tlet localM = Matrix4Math.identity();\n\t\t\t\t\t\tconst childX = target?.x ?? lop.x ?? 0;\n\t\t\t\t\t\tconst childY = target?.y ?? lop.y ?? 0;\n\t\t\t\t\t\tconst childZ = target?.z ?? lop.z ?? 0;\n\t\t\t\t\t\tlocalM = Matrix4Math.multiply(\n\t\t\t\t\t\t\tlocalM,\n\t\t\t\t\t\t\tMatrix4Math.translate(childX, childY, childZ),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst rxRad =\n\t\t\t\t\t\t\t((target?.rotateX ?? lop.rotateX ?? 0) * Math.PI) / 180;\n\t\t\t\t\t\tconst ryRad =\n\t\t\t\t\t\t\t((target?.rotateY ?? lop.rotateY ?? 0) * Math.PI) / 180;\n\t\t\t\t\t\tconst rzRad =\n\t\t\t\t\t\t\t((target?.rotateZ ?? lop.rotateZ ?? 0) !== 0\n\t\t\t\t\t\t\t\t? (target?.rotateZ ?? lop.rotateZ ?? 0)\n\t\t\t\t\t\t\t\t: rotation) *\n\t\t\t\t\t\t\t(Math.PI / 180);\n\t\t\t\t\t\tif (rzRad !== 0)\n\t\t\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateZ(rzRad));\n\t\t\t\t\t\tif (ryRad !== 0)\n\t\t\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateY(ryRad));\n\t\t\t\t\t\tif (rxRad !== 0)\n\t\t\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateX(rxRad));\n\n\t\t\t\t\t\tconst sx = layerW * scale;\n\t\t\t\t\t\tconst sy = layerH * scale;\n\t\t\t\t\t\tconst sz = target?.scaleZ ?? lop.scaleZ ?? 1;\n\t\t\t\t\t\tlocalM = Matrix4Math.multiply(\n\t\t\t\t\t\t\tlocalM,\n\t\t\t\t\t\t\tMatrix4Math.scale(sx, sy, sz),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst ax = lop.anchorX ?? 0.5;\n\t\t\t\t\t\tconst ay = lop.anchorY ?? 0.5;\n\t\t\t\t\t\tconst pivotX = 0.5 - ax;\n\t\t\t\t\t\tconst pivotY = 0.5 - ay;\n\t\t\t\t\t\tif (pivotX !== 0 || pivotY !== 0) {\n\t\t\t\t\t\t\tlocalM = Matrix4Math.multiply(\n\t\t\t\t\t\t\t\tlocalM,\n\t\t\t\t\t\t\t\tMatrix4Math.translate(pivotX, pivotY, 0),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmodelMatrix = Matrix4Math.multiply(parent3DMatrix, localM);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst quadOpts: DrawQuad3DOpts = {\n\t\t\t\t\t\tposition: [\n\t\t\t\t\t\t\tlocalX + layerW * 0.5,\n\t\t\t\t\t\t\tlocalY + layerH * 0.5,\n\t\t\t\t\t\t\ttarget?.z ?? lop.z ?? 0,\n\t\t\t\t\t\t],\n\t\t\t\t\t\twidth: layerW,\n\t\t\t\t\t\theight: layerH,\n\t\t\t\t\t\ttextureExtent: [\n\t\t\t\t\t\t\tlayerW / activeGroupTex.width,\n\t\t\t\t\t\t\tlayerH / activeGroupTex.height,\n\t\t\t\t\t\t],\n\t\t\t\t\t\trotation: [\n\t\t\t\t\t\t\ttarget?.rotateX ?? lop.rotateX ?? 0,\n\t\t\t\t\t\t\ttarget?.rotateY ?? lop.rotateY ?? 0,\n\t\t\t\t\t\t\t(target?.rotateZ ?? lop.rotateZ ?? 0) !== 0\n\t\t\t\t\t\t\t\t? (target?.rotateZ ?? lop.rotateZ ?? 0)\n\t\t\t\t\t\t\t\t: rotation,\n\t\t\t\t\t\t],\n\t\t\t\t\t\tscale: [scale, scale, target?.scaleZ ?? lop.scaleZ ?? 1],\n\t\t\t\t\t\tanchor: [lop.anchorX ?? 0.5, lop.anchorY ?? 0.5],\n\t\t\t\t\t\tborderRadius: br,\n\t\t\t\t\t\tborderWidth: lop.borderWidth,\n\t\t\t\t\t\tborderColor: lop.borderColor,\n\t\t\t\t\t\topacity: layerOpacity,\n\t\t\t\t\t\ttwoSided: target?.twoSided ?? lop.twoSided ?? true,\n\t\t\t\t\t\tmaterial: target?.material ?? lop.material,\n\t\t\t\t\t\tshininess: target?.shininess ?? lop.shininess,\n\t\t\t\t\t\troughness: target?.roughness ?? lop.roughness,\n\t\t\t\t\t\tspecularIntensity:\n\t\t\t\t\t\t\ttarget?.specularIntensity ?? lop.specularIntensity,\n\t\t\t\t\t\tambientIntensity: target?.ambientIntensity ?? lop.ambientIntensity,\n\t\t\t\t\t\tmetallic: target?.metallic ?? lop.metallic,\n\t\t\t\t\t\t...(modelMatrix && { modelMatrix }),\n\t\t\t\t\t};\n\n\t\t\t\t\tpending3DItems.push({\n\t\t\t\t\t\tkind: \"quad\",\n\t\t\t\t\t\ttexture: activeGroupTex,\n\t\t\t\t\t\topts: quadOpts,\n\t\t\t\t\t});\n\t\t\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\t\t\t\t}\n\n\t\t\t\tif (is3D && quad3D) {\n\t\t\t\t\tconst texW = Math.max(1, Math.ceil(layerW));\n\t\t\t\t\tconst texH = Math.max(1, Math.ceil(layerH));\n\t\t\t\t\tconst groupExcludes = [activeTex, targetTexture, ...excludes];\n\t\t\t\t\tconst groupTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\t\t\ttexW,\n\t\t\t\t\t\ttexH,\n\t\t\t\t\t\tgroupExcludes,\n\t\t\t\t\t);\n\t\t\t\t\tconst groupView = groupTex.createView();\n\n\t\t\t\t\tconst groupClearPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tgroupView,\n\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\ttexW,\n\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\"clear\",\n\t\t\t\t\t);\n\t\t\t\t\tgroupClearPass.end();\n\n\t\t\t\t\tconst br = Math.min(\n\t\t\t\t\t\tlop.borderRadius ?? lop.strokeRadius ?? 0,\n\t\t\t\t\t\tlayerW / 2,\n\t\t\t\t\t\tlayerH / 2,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (shouldPaintContainerBackground(kind, lop.background)) {\n\t\t\t\t\t\tconst bgPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tgroupView,\n\t\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\t\ttexW,\n\t\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\t\"load\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tctx.renderer.drawRect(\n\t\t\t\t\t\t\tbgPass,\n\t\t\t\t\t\t\t{ x: 0, y: 0, width: layerW, height: layerH },\n\t\t\t\t\t\t\tlop.background,\n\t\t\t\t\t\t\tbr,\n\t\t\t\t\t\t\t{ opacity: 1 },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbgPass.end();\n\t\t\t\t\t}\n\n\t\t\t\t\tlet activeGroupTex = groupTex;\n\t\t\t\t\tlet activeGroupView = groupView;\n\t\t\t\t\tif (nodeVM.children && nodeVM.children.length > 0) {\n\t\t\t\t\t\tconst res = await renderNodeTree(\n\t\t\t\t\t\t\tnodeVM.children,\n\t\t\t\t\t\t\tgroupTex,\n\t\t\t\t\t\t\tgroupView,\n\t\t\t\t\t\t\t[groupTex, ...groupExcludes],\n\t\t\t\t\t\t\t1.0,\n\t\t\t\t\t\t\tnew DOMMatrix(),\n\t\t\t\t\t\t\trect,\n\t\t\t\t\t\t\ttexW,\n\t\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tactiveGroupTex = res.finalTex;\n\t\t\t\t\t\tactiveGroupView = res.finalView;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst borderResult =\n\t\t\t\t\t\tlop.borderWidth !== undefined && lop.borderColor\n\t\t\t\t\t\t\t? createBorderTexture(\n\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\t\t\tlayerW,\n\t\t\t\t\t\t\t\t\tlayerH,\n\t\t\t\t\t\t\t\t\tbr,\n\t\t\t\t\t\t\t\t\tlop.borderWidth,\n\t\t\t\t\t\t\t\t\tlop.borderColor,\n\t\t\t\t\t\t\t\t\tlop.strokeAlign ?? \"inside\",\n\t\t\t\t\t\t\t\t\t[activeGroupTex, ...groupExcludes],\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: null;\n\n\t\t\t\t\tif (borderResult) {\n\t\t\t\t\t\tconst borderPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tactiveGroupView,\n\t\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\t\ttexW,\n\t\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\t\"load\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\t\t\tborderPass,\n\t\t\t\t\t\t\tborderResult.borderTex,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tx: borderResult.ox,\n\t\t\t\t\t\t\t\ty: borderResult.oy,\n\t\t\t\t\t\t\t\twidth: borderResult.ow,\n\t\t\t\t\t\t\t\theight: borderResult.oh,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ opacity: 1 },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tborderPass.end();\n\t\t\t\t\t}\n\n\t\t\t\t\tconst container3DShutter =\n\t\t\t\t\t\ttarget?.motionBlurShutter ?? lop.motionBlurShutter ?? 0;\n\t\t\t\t\tif (container3DShutter > 0 && fps && shiftedFrame !== undefined) {\n\t\t\t\t\t\tconst currentT = shiftedFrame / fps;\n\t\t\t\t\t\tconst prevT = (shiftedFrame - 1) / fps;\n\t\t\t\t\t\ttl.seek(prevT);\n\t\t\t\t\t\tconst prevTarget = targetId ? targetsById[targetId] : undefined;\n\t\t\t\t\t\tconst prevX = prevTarget?.x ?? baseX;\n\t\t\t\t\t\tconst prevY = prevTarget?.y ?? baseY;\n\t\t\t\t\t\ttl.seek(currentT);\n\n\t\t\t\t\t\tconst vx = sampledX - prevX;\n\t\t\t\t\t\tconst vy = sampledY - prevY;\n\n\t\t\t\t\t\tif (Math.hypot(vx, vy) > 0.5) {\n\t\t\t\t\t\t\tactiveGroupTex = ctx.renderer.applyMotionBlur(\n\t\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\t\t\tvx,\n\t\t\t\t\t\t\t\tvy,\n\t\t\t\t\t\t\t\tcontainer3DShutter,\n\t\t\t\t\t\t\t\t16,\n\t\t\t\t\t\t\t\t[activeTex, targetTexture, ...excludes],\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tactiveGroupView = activeGroupTex.createView();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (blendMode === \"normal\" || blendMode === \"source-over\") {\n\t\t\t\t\t\tdrawProjectedQuad(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tactiveView,\n\t\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\t\tquad3D,\n\t\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\t\tlayerOpacity,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst compositeExcludes = [\n\t\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\t\ttargetTexture,\n\t\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\t\t...excludes,\n\t\t\t\t\t\t];\n\t\t\t\t\t\tif (borderResult) compositeExcludes.push(borderResult.borderTex);\n\t\t\t\t\t\tconst layerTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\t\tcompositeExcludes,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst layerView = layerTex.createView();\n\t\t\t\t\t\tconst layerClearPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tlayerView,\n\t\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\t\t\"clear\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlayerClearPass.end();\n\n\t\t\t\t\t\tdrawProjectedQuad(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tlayerView,\n\t\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\t\tquad3D,\n\t\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\t\tlayerOpacity,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tactiveTex = ctx.renderer.composite(\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\t\tlayerTex,\n\t\t\t\t\t\t\tblendMode,\n\t\t\t\t\t\t\t[targetTexture, ...excludes],\n\t\t\t\t\t\t);\n\t\t\t\t\t\tactiveView = activeTex.createView();\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\t\t\t\t}\n\t\t\t\tconst shouldClip = lop.overflow !== \"visible\";\n\t\t\t\tconst scissorRect = shouldClip\n\t\t\t\t\t? computeContainerScissor(layerMatrix, layerW, layerH)\n\t\t\t\t\t: null;\n\t\t\t\t// A scissor clips to the box; rounded corners need a mask pass.\n\t\t\t\tconst clipRadius = shouldClip\n\t\t\t\t\t? Math.min(\n\t\t\t\t\t\t\ttarget?.borderRadius ?? lop.borderRadius ?? 0,\n\t\t\t\t\t\t\tlayerW / 2,\n\t\t\t\t\t\t\tlayerH / 2,\n\t\t\t\t\t\t)\n\t\t\t\t\t: 0;\n\n\t\t\t\t// Transparent optimized flex/block — only when there is no\n\t\t\t\t// background to paint (a flex/block with a background takes the\n\t\t\t\t// group-texture path below).\n\t\t\t\tif (\n\t\t\t\t\t(kind === \"flex\" || kind === \"block\") &&\n\t\t\t\t\tclipRadius <= 0 &&\n\t\t\t\t\t!shouldPaintContainerBackground(kind, lop.background) &&\n\t\t\t\t\tlayerOpacity === 1 &&\n\t\t\t\t\tblendMode === \"normal\" &&\n\t\t\t\t\t!lop.borderWidth &&\n\t\t\t\t\t!lop.borderColor &&\n\t\t\t\t\t(typeof lop.relighting !== \"object\" || !lop.relighting) &&\n\t\t\t\t\t(typeof lop.relight !== \"object\" || !lop.relight) &&\n\t\t\t\t\t(typeof target?.relighting !== \"object\" || !target?.relighting) &&\n\t\t\t\t\t(typeof target?.relight !== \"object\" || !target?.relight) &&\n\t\t\t\t\t(typeof lop.deflicker !== \"object\" || !lop.deflicker) &&\n\t\t\t\t\t(typeof target?.deflicker !== \"object\" || !target?.deflicker)\n\t\t\t\t) {\n\t\t\t\t\tif (scissorRect) {\n\t\t\t\t\t\tctx.renderer.pushScissor(scissorRect);\n\t\t\t\t\t}\n\t\t\t\t\tconst res = await renderNodeTree(\n\t\t\t\t\t\tnodeVM.children ?? [],\n\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\tactiveView,\n\t\t\t\t\t\texcludes,\n\t\t\t\t\t\taccumulatedOpacity,\n\t\t\t\t\t\tlayerMatrix,\n\t\t\t\t\t\trect,\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tisRootScene,\n\t\t\t\t\t);\n\t\t\t\t\tif (scissorRect) {\n\t\t\t\t\t\tctx.renderer.popScissor();\n\t\t\t\t\t}\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\n\t\t\t\t// Otherwise, draw container background + children + border onto a temporary group texture,\n\t\t\t\t// and composite/blend the group texture onto destTex.\n\t\t\t\tconst groupExcludes = [activeTex, targetTexture, ...excludes];\n\t\t\t\tconst groupTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\t\ttargetW,\n\t\t\t\t\ttargetH,\n\t\t\t\t\tgroupExcludes,\n\t\t\t\t);\n\t\t\t\tconst groupView = groupTex.createView();\n\n\t\t\t\tconst groupClearPass = ctx.renderer.beginFrame(\n\t\t\t\t\tencoder,\n\t\t\t\t\tgroupView,\n\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\ttargetW,\n\t\t\t\t\ttargetH,\n\t\t\t\t\t\"clear\",\n\t\t\t\t);\n\t\t\t\tgroupClearPass.end();\n\n\t\t\t\tconst br = Math.min(\n\t\t\t\t\ttarget?.borderRadius ?? lop.borderRadius ?? lop.strokeRadius ?? 0,\n\t\t\t\t\tlayerW / 2,\n\t\t\t\t\tlayerH / 2,\n\t\t\t\t);\n\n\t\t\t\t// Background fill pass — any container kind (flex/block/box).\n\t\t\t\tif (shouldPaintContainerBackground(kind, lop.background)) {\n\t\t\t\t\tconst bgPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tgroupView,\n\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\t\"load\",\n\t\t\t\t\t);\n\t\t\t\t\tctx.renderer.pushTransform(layerMatrix);\n\t\t\t\t\tctx.renderer.drawRect(\n\t\t\t\t\t\tbgPass,\n\t\t\t\t\t\t{ x: 0, y: 0, width: layerW, height: layerH },\n\t\t\t\t\t\tlop.background,\n\t\t\t\t\t\tbr,\n\t\t\t\t\t\t{ opacity: layerOpacity },\n\t\t\t\t\t);\n\t\t\t\t\tctx.renderer.popTransform();\n\t\t\t\t\tbgPass.end();\n\t\t\t\t}\n\n\t\t\t\tlet activeGroupTex = groupTex;\n\t\t\t\tlet activeGroupView = groupView;\n\t\t\t\tif (nodeVM.children && nodeVM.children.length > 0) {\n\t\t\t\t\tif (scissorRect) {\n\t\t\t\t\t\tctx.renderer.pushScissor(scissorRect);\n\t\t\t\t\t}\n\t\t\t\t\tconst res = await renderNodeTree(\n\t\t\t\t\t\tnodeVM.children,\n\t\t\t\t\t\tgroupTex,\n\t\t\t\t\t\tgroupView,\n\t\t\t\t\t\t[groupTex, ...groupExcludes],\n\t\t\t\t\t\tlayerOpacity,\n\t\t\t\t\t\tlayerMatrix,\n\t\t\t\t\t\trect,\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t\tif (scissorRect) {\n\t\t\t\t\t\tctx.renderer.popScissor();\n\t\t\t\t\t}\n\t\t\t\t\tactiveGroupTex = res.finalTex;\n\t\t\t\t\tactiveGroupView = res.finalView;\n\t\t\t\t}\n\n\t\t\t\t// overflow: hidden with a border radius: keep only what falls\n\t\t\t\t// inside the rounded box (background and children alike).\n\t\t\t\tif (clipRadius > 0) {\n\t\t\t\t\tconst maskTex = ctx.renderer.getTemporaryTexture(targetW, targetH, [\n\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\t...groupExcludes,\n\t\t\t\t\t]);\n\t\t\t\t\tconst maskPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tmaskTex.createView(),\n\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\t\"clear\",\n\t\t\t\t\t);\n\t\t\t\t\tctx.renderer.pushTransform(layerMatrix);\n\t\t\t\t\tctx.renderer.drawRect(\n\t\t\t\t\t\tmaskPass,\n\t\t\t\t\t\t{ x: 0, y: 0, width: layerW, height: layerH },\n\t\t\t\t\t\t\"#ffffff\",\n\t\t\t\t\t\tclipRadius,\n\t\t\t\t\t);\n\t\t\t\t\tctx.renderer.popTransform();\n\t\t\t\t\tmaskPass.end();\n\t\t\t\t\tactiveGroupTex = ctx.renderer.composite(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\tmaskTex,\n\t\t\t\t\t\t\"mask-in\",\n\t\t\t\t\t\t[activeGroupTex, maskTex, ...groupExcludes],\n\t\t\t\t\t);\n\t\t\t\t\tactiveGroupView = activeGroupTex.createView();\n\t\t\t\t}\n\n\t\t\t\tconst borderResult =\n\t\t\t\t\tlop.borderWidth !== undefined && lop.borderColor\n\t\t\t\t\t\t? createBorderTexture(\n\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\t\tlayerW,\n\t\t\t\t\t\t\t\tlayerH,\n\t\t\t\t\t\t\t\tbr,\n\t\t\t\t\t\t\t\tlop.borderWidth,\n\t\t\t\t\t\t\t\tlop.borderColor,\n\t\t\t\t\t\t\t\tlop.strokeAlign ?? \"inside\",\n\t\t\t\t\t\t\t\t[activeGroupTex, ...groupExcludes],\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: null;\n\n\t\t\t\tif (borderResult) {\n\t\t\t\t\tconst borderPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tactiveGroupView,\n\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\t\"load\",\n\t\t\t\t\t);\n\t\t\t\t\tctx.renderer.pushTransform(layerMatrix);\n\t\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\t\tborderPass,\n\t\t\t\t\t\tborderResult.borderTex,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx: borderResult.ox,\n\t\t\t\t\t\t\ty: borderResult.oy,\n\t\t\t\t\t\t\twidth: borderResult.ow,\n\t\t\t\t\t\t\theight: borderResult.oh,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ opacity: layerOpacity },\n\t\t\t\t\t);\n\t\t\t\t\tctx.renderer.popTransform();\n\t\t\t\t\tborderPass.end();\n\t\t\t\t}\n\n\t\t\t\tconst containerShutter =\n\t\t\t\t\ttarget?.motionBlurShutter ?? lop.motionBlurShutter ?? 0;\n\t\t\t\tif (containerShutter > 0 && fps && shiftedFrame !== undefined) {\n\t\t\t\t\tconst currentT = shiftedFrame / fps;\n\t\t\t\t\tconst prevT = (shiftedFrame - 1) / fps;\n\t\t\t\t\ttl.seek(prevT);\n\t\t\t\t\tconst prevTarget = targetId ? targetsById[targetId] : undefined;\n\t\t\t\t\tconst prevX = prevTarget?.x ?? baseX;\n\t\t\t\t\tconst prevY = prevTarget?.y ?? baseY;\n\t\t\t\t\ttl.seek(currentT);\n\n\t\t\t\t\tconst vx = sampledX - prevX;\n\t\t\t\t\tconst vy = sampledY - prevY;\n\n\t\t\t\t\tif (Math.hypot(vx, vy) > 0.5) {\n\t\t\t\t\t\tactiveGroupTex = ctx.renderer.applyMotionBlur(\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\t\tvx,\n\t\t\t\t\t\t\tvy,\n\t\t\t\t\t\t\tcontainerShutter,\n\t\t\t\t\t\t\t16,\n\t\t\t\t\t\t\t[activeTex, targetTexture, ...excludes],\n\t\t\t\t\t\t);\n\t\t\t\t\t\tactiveGroupView = activeGroupTex.createView();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Temporal De-flickering & Optical Flow Warping\n\t\t\t\tconst deflickerFromEffects = Array.isArray(lop.effects)\n\t\t\t\t\t? lop.effects.find(\n\t\t\t\t\t\t\t(e: unknown) =>\n\t\t\t\t\t\t\t\t(e as { op?: string })?.op === \"TemporalDeflicker\" ||\n\t\t\t\t\t\t\t\t(e as { op?: string })?.op === \"Deflicker\" ||\n\t\t\t\t\t\t\t\t(e as { constructor?: { name?: string } })?.constructor\n\t\t\t\t\t\t\t\t\t?.name === \"TemporalDeflicker\",\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst rawDeflicker =\n\t\t\t\t\ttarget?.deflicker ?? lop.deflicker ?? deflickerFromEffects;\n\t\t\t\tconst deflickerOpts =\n\t\t\t\t\ttypeof rawDeflicker === \"object\" && rawDeflicker !== null\n\t\t\t\t\t\t? rawDeflicker\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (deflickerOpts) {\n\t\t\t\t\tconst deflickerPipe = getTemporalDeflickerPipeline(\n\t\t\t\t\t\tctx.device,\n\t\t\t\t\t\tlop.id || `layer_${i}`,\n\t\t\t\t\t);\n\t\t\t\t\tif (shiftedFrame === 0) {\n\t\t\t\t\t\tdeflickerPipe.reset();\n\t\t\t\t\t}\n\t\t\t\t\tactiveGroupTex = deflickerPipe.execute(\n\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\tdeflickerOpts,\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t);\n\t\t\t\t\tactiveGroupView = activeGroupTex.createView();\n\t\t\t\t}\n\n\t\t\t\t// Screen-Space 3D Relighting\n\t\t\t\tconst relightEffect = Array.isArray(lop.effects)\n\t\t\t\t\t? lop.effects.find(\n\t\t\t\t\t\t\t(e: unknown) =>\n\t\t\t\t\t\t\t\t(e as { op?: string })?.op === \"Relight3D\" ||\n\t\t\t\t\t\t\t\t(e as { constructor?: { name?: string } })?.constructor\n\t\t\t\t\t\t\t\t\t?.name === \"Relight3D\",\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst rawRelight =\n\t\t\t\t\ttarget?.relighting ??\n\t\t\t\t\tlop.relighting ??\n\t\t\t\t\t(typeof lop.relight === \"object\" ? lop.relight : undefined) ??\n\t\t\t\t\trelightEffect;\n\t\t\t\tconst relightOpts =\n\t\t\t\t\ttypeof rawRelight === \"object\" && rawRelight !== null\n\t\t\t\t\t\t? rawRelight\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (relightOpts) {\n\t\t\t\t\tconst relightPipeline = getScreenSpaceRelightPipeline(\n\t\t\t\t\t\tctx.device,\n\t\t\t\t\t\tctx.renderer.format ?? \"rgba8unorm\",\n\t\t\t\t\t);\n\t\t\t\t\tconst r3dInstance = getRenderer3D(\n\t\t\t\t\t\tctx.device,\n\t\t\t\t\t\tctx.renderer.format ?? \"rgba8unorm\",\n\t\t\t\t\t\tsampleCount3d,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst activeLights = synthesizeRelightLights(\n\t\t\t\t\t\trelightOpts as Record<string, unknown>,\n\t\t\t\t\t\tsceneLights,\n\t\t\t\t\t\trect,\n\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst lightsBuffer =\n\t\t\t\t\t\tr3dInstance.getOrCreateLightsBuffer(activeLights);\n\n\t\t\t\t\tconst relitTex = ctx.renderer.getTemporaryTexture(targetW, targetH, [\n\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\ttargetTexture,\n\t\t\t\t\t\t...excludes,\n\t\t\t\t\t]);\n\t\t\t\t\tconst relitView = relitTex.createView();\n\n\t\t\t\t\tconst normalTex = relightOpts.normalTexture ?? relightOpts.normalMap;\n\n\t\t\t\t\trelightPipeline.execute(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\trelitView,\n\t\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\t\tnormalTex,\n\t\t\t\t\t\tlightsBuffer,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tviewportWidth: targetW,\n\t\t\t\t\t\t\tviewportHeight: targetH,\n\t\t\t\t\t\t\tlayerX: 0,\n\t\t\t\t\t\t\tlayerY: 0,\n\t\t\t\t\t\t\troughness: resolveVal(\n\t\t\t\t\t\t\t\ttarget?.roughness ??\n\t\t\t\t\t\t\t\t\ttarget?.relightRoughness ??\n\t\t\t\t\t\t\t\t\trelightOpts.specularRoughness ??\n\t\t\t\t\t\t\t\t\trelightOpts.roughness,\n\t\t\t\t\t\t\t\t0.35,\n\t\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tspecularStrength: resolveVal(\n\t\t\t\t\t\t\t\ttarget?.specularStrength ??\n\t\t\t\t\t\t\t\t\ttarget?.relightSpecularStrength ??\n\t\t\t\t\t\t\t\t\trelightOpts.specularStrength,\n\t\t\t\t\t\t\t\t0.7,\n\t\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tmetallic: resolveVal(\n\t\t\t\t\t\t\t\ttarget?.metallic ??\n\t\t\t\t\t\t\t\t\ttarget?.relightMetallic ??\n\t\t\t\t\t\t\t\t\trelightOpts.metallic,\n\t\t\t\t\t\t\t\t0.0,\n\t\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tambientIntensity: resolveVal(\n\t\t\t\t\t\t\t\ttarget?.ambientIntensity ??\n\t\t\t\t\t\t\t\t\ttarget?.relightAmbientIntensity ??\n\t\t\t\t\t\t\t\t\trelightOpts.ambientIntensity,\n\t\t\t\t\t\t\t\t0.15,\n\t\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tdepthScale: resolveVal(\n\t\t\t\t\t\t\t\ttarget?.depthScale ??\n\t\t\t\t\t\t\t\t\ttarget?.relightDepthScale ??\n\t\t\t\t\t\t\t\t\trelightOpts.depthScale,\n\t\t\t\t\t\t\t\t1.0,\n\t\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\topacity: 1.0,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"clear\",\n\t\t\t\t\t);\n\n\t\t\t\t\tactiveGroupTex = relitTex;\n\t\t\t\t\tactiveGroupView = relitView;\n\t\t\t\t}\n\n\t\t\t\t// Always composite container groups using the composite shader\n\t\t\t\tconst compositeExcludes = [activeTex, targetTexture, ...excludes];\n\t\t\t\tif (borderResult) compositeExcludes.push(borderResult.borderTex);\n\t\t\t\tconst nextDestTex = ctx.renderer.composite(\n\t\t\t\t\tencoder,\n\t\t\t\t\tactiveTex,\n\t\t\t\t\tactiveGroupTex,\n\t\t\t\t\tblendMode,\n\t\t\t\t\tcompositeExcludes,\n\t\t\t\t);\n\t\t\t\tactiveTex = nextDestTex;\n\t\t\t\tactiveView = activeTex.createView();\n\n\t\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\t\t\t}\n\n\t\t\t// Leaf layers (text/media)\n\t\t\tif (!(layerW > 0 && layerH > 0))\n\t\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\n\t\t\tconst br = Math.min(\n\t\t\t\tlop.borderRadius ?? lop.strokeRadius ?? 0,\n\t\t\t\tlayerW / 2,\n\t\t\t\tlayerH / 2,\n\t\t\t);\n\t\t\tconst texW = Math.ceil(layerW);\n\t\t\tconst texH = Math.ceil(layerH);\n\n\t\t\t// Suspend any parent container scissors while rendering isolated offscreen localTex\n\t\t\tconst savedScissors = ctx.renderer.suspendScissors?.() ?? [];\n\n\t\t\tconst localTex = ctx.renderer.getTemporaryTexture(texW, texH, [\n\t\t\t\tactiveTex,\n\t\t\t\ttargetTexture,\n\t\t\t\t...excludes,\n\t\t\t]);\n\t\t\tconst localView = localTex.createView();\n\n\t\t\tconst localClearPass = ctx.renderer.beginFrame(\n\t\t\t\tencoder,\n\t\t\t\tlocalView,\n\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\ttexW,\n\t\t\t\ttexH,\n\t\t\t\t\"clear\",\n\t\t\t);\n\t\t\tlocalClearPass.end();\n\n\t\t\t// Content: media → bound source VM; text → synthetic text op.\n\t\t\tlet content: VirtualMediaData | undefined;\n\t\t\tlet isCaption = false;\n\t\t\tif (kind === \"media\") {\n\t\t\t\tcontent = nodeVM.children?.[0];\n\t\t\t\tisCaption =\n\t\t\t\t\tcontent?.operation?.dataType === \"Caption\" ||\n\t\t\t\t\tlop.dataType === \"Caption\" ||\n\t\t\t\t\t(content?.operation as any)?.srtText !== undefined;\n\t\t\t} else if (kind === \"text\") {\n\t\t\t\tconst fullText = lop.text ?? \"\";\n\t\t\t\tlet displayText = fullText;\n\n\t\t\t\t// Kinetic typography animators (Section 5)\n\t\t\t\tlet resolvedAnimators = rawAnimators;\n\t\t\t\tif (Array.isArray(rawAnimators) && rawAnimators.length > 0) {\n\t\t\t\t\tresolvedAnimators = rawAnimators.map((animator: any, idx: number) => {\n\t\t\t\t\t\tconst a = {\n\t\t\t\t\t\t\t...animator,\n\t\t\t\t\t\t\ttransform: { ...(animator.transform ?? {}) },\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (idx === 0) {\n\t\t\t\t\t\t\tconst offsetVal =\n\t\t\t\t\t\t\t\ttypeof target?.offset === \"number\"\n\t\t\t\t\t\t\t\t\t? target.offset\n\t\t\t\t\t\t\t\t\t: typeof target?.animatorOffset === \"number\"\n\t\t\t\t\t\t\t\t\t\t? target.animatorOffset\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\tconst rangeStartVal =\n\t\t\t\t\t\t\t\ttypeof target?.rangeStart === \"number\"\n\t\t\t\t\t\t\t\t\t? target.rangeStart\n\t\t\t\t\t\t\t\t\t: typeof target?.animatorRangeStart === \"number\"\n\t\t\t\t\t\t\t\t\t\t? target.animatorRangeStart\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\tconst rangeEndVal =\n\t\t\t\t\t\t\t\ttypeof target?.rangeEnd === \"number\"\n\t\t\t\t\t\t\t\t\t? target.rangeEnd\n\t\t\t\t\t\t\t\t\t: typeof target?.animatorRangeEnd === \"number\"\n\t\t\t\t\t\t\t\t\t\t? target.animatorRangeEnd\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\tif (offsetVal !== undefined) a.offset = offsetVal;\n\t\t\t\t\t\t\tif (rangeStartVal !== undefined) a.rangeStart = rangeStartVal;\n\t\t\t\t\t\t\tif (rangeEndVal !== undefined) a.rangeEnd = rangeEndVal;\n\n\t\t\t\t\t\t\tif (Array.isArray(a.selectors)) {\n\t\t\t\t\t\t\t\ta.selectors = a.selectors.map((s: any) => {\n\t\t\t\t\t\t\t\t\tif (s.type === \"range\") {\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\t\t\t\t...(offsetVal !== undefined ? { offset: offsetVal } : {}),\n\t\t\t\t\t\t\t\t\t\t\t...(rangeStartVal !== undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? { start: rangeStartVal }\n\t\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t\t...(rangeEndVal !== undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? { end: rangeEndVal }\n\t\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn s;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn a;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst hasKineticAnimators =\n\t\t\t\t\tArray.isArray(resolvedAnimators) && resolvedAnimators.length > 0;\n\t\t\t\tconst hasTypewriter = Boolean(lop.typewriter || target?.typewriter);\n\n\t\t\t\t// Check if there is an active text track or progress value evaluated by GSAP\n\t\t\t\tconst textTrack = lop.animation?.tracks?.find(\n\t\t\t\t\t(t: { prop: string }) => t.prop === \"text\",\n\t\t\t\t);\n\t\t\t\tconst hasTextAnimation =\n\t\t\t\t\t!hasKineticAnimators &&\n\t\t\t\t\t!hasTypewriter &&\n\t\t\t\t\t(textTrack !== undefined || typeof target?.text === \"number\");\n\n\t\t\t\tif (hasTextAnimation && fullText.length > 0) {\n\t\t\t\t\tconst progress =\n\t\t\t\t\t\ttypeof target?.text === \"number\"\n\t\t\t\t\t\t\t? Math.max(0, Math.min(1, target.text))\n\t\t\t\t\t\t\t: 1;\n\n\t\t\t\t\tif (progress >= 1) {\n\t\t\t\t\t\tdisplayText = fullText;\n\t\t\t\t\t} else if (progress <= 0) {\n\t\t\t\t\t\tdisplayText = \"\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Determine preset style (default to typewriter)\n\t\t\t\t\t\tconst presetType =\n\t\t\t\t\t\t\ttextTrack?.keyframes?.find(\n\t\t\t\t\t\t\t\t(k: { presetType?: string }) => k.presetType,\n\t\t\t\t\t\t\t)?.presetType ?? \"typewriter\";\n\n\t\t\t\t\t\tconst textNumeric =\n\t\t\t\t\t\t\ttypeof target?.text === \"number\" ? target.text : null;\n\t\t\t\t\t\tconst isDirectCount = textNumeric !== null && textNumeric > 1.0001;\n\n\t\t\t\t\t\tif (presetType === \"word-reveal\" || presetType === \"karaoke\") {\n\t\t\t\t\t\t\tconst tokens = fullText.split(/(\\s+)/);\n\t\t\t\t\t\t\tconst wordIndices: number[] = [];\n\t\t\t\t\t\t\ttokens.forEach((token: string, idx: number) => {\n\t\t\t\t\t\t\t\tif (token.trim().length > 0) wordIndices.push(idx);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst visibleWordCount =\n\t\t\t\t\t\t\t\tisDirectCount && textNumeric !== null\n\t\t\t\t\t\t\t\t\t? Math.min(wordIndices.length, Math.round(textNumeric))\n\t\t\t\t\t\t\t\t\t: Math.round(wordIndices.length * progress);\n\t\t\t\t\t\t\tif (visibleWordCount === 0) {\n\t\t\t\t\t\t\t\tdisplayText = \"\";\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst lastTokenIdx =\n\t\t\t\t\t\t\t\t\twordIndices[\n\t\t\t\t\t\t\t\t\t\tMath.min(wordIndices.length - 1, visibleWordCount - 1)\n\t\t\t\t\t\t\t\t\t]!;\n\t\t\t\t\t\t\t\tdisplayText = tokens.slice(0, lastTokenIdx + 1).join(\"\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (presetType === \"line-reveal\") {\n\t\t\t\t\t\t\tconst lines = fullText.split(\"\\n\");\n\t\t\t\t\t\t\tconst visibleLineCount =\n\t\t\t\t\t\t\t\tisDirectCount && textNumeric !== null\n\t\t\t\t\t\t\t\t\t? Math.min(lines.length, Math.round(textNumeric))\n\t\t\t\t\t\t\t\t\t: Math.round(lines.length * progress);\n\t\t\t\t\t\t\tdisplayText = lines\n\t\t\t\t\t\t\t\t.slice(0, Math.max(0, visibleLineCount))\n\t\t\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// typewriter (character-level reveal)\n\t\t\t\t\t\t\tconst visibleChars =\n\t\t\t\t\t\t\t\tisDirectCount && textNumeric !== null\n\t\t\t\t\t\t\t\t\t? Math.min(fullText.length, Math.round(textNumeric))\n\t\t\t\t\t\t\t\t\t: Math.round(fullText.length * progress);\n\t\t\t\t\t\t\tdisplayText = fullText.slice(0, visibleChars);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcontent = {\n\t\t\t\t\tmetadata: {},\n\t\t\t\t\toperation: {\n\t\t\t\t\t\top: \"text\",\n\t\t\t\t\t\ttext: displayText,\n\t\t\t\t\t\tanimators: resolvedAnimators,\n\t\t\t\t\t\tpathOptions: target?.pathOptions ?? lop.pathOptions,\n\t\t\t\t\t\ttypewriter: target?.typewriter ?? lop.typewriter,\n\t\t\t\t\t\tmarquee: target?.marquee ?? (lop as { marquee?: unknown }).marquee,\n\t\t\t\t\t\ttextProgress:\n\t\t\t\t\t\t\ttypeof target?.text === \"number\" ? target.text : undefined,\n\t\t\t\t\t\tfirstMargin: target?.firstMargin ?? lop.firstMargin,\n\t\t\t\t\t\tlastMargin: target?.lastMargin ?? lop.lastMargin,\n\t\t\t\t\t\tbaselineShift: target?.baselineShift ?? lop.baselineShift,\n\t\t\t\t\t\tsignals:\n\t\t\t\t\t\t\t(virtualMedia as any)?.operation?.signals ??\n\t\t\t\t\t\t\t(virtualMedia as any)?.signals,\n\t\t\t\t\t\tfontSize: target?.fontSize ?? lop.fontSize,\n\t\t\t\t\t\tfontFamily: lop.fontFamily,\n\t\t\t\t\t\tfontStyle: lop.fontStyle,\n\t\t\t\t\t\tfontWeight: lop.fontWeight,\n\t\t\t\t\t\tfill: target?.fill ?? target?.color ?? lop.fill,\n\t\t\t\t\t\talign:\n\t\t\t\t\t\t\tlop.align === \"start\"\n\t\t\t\t\t\t\t\t? \"left\"\n\t\t\t\t\t\t\t\t: lop.align === \"end\"\n\t\t\t\t\t\t\t\t\t? \"right\"\n\t\t\t\t\t\t\t\t\t: lop.align,\n\t\t\t\t\t\tverticalAlign: lop.verticalAlign,\n\t\t\t\t\t\tletterSpacing: target?.letterSpacing ?? lop.letterSpacing,\n\t\t\t\t\t\tlineHeight: lop.lineHeight,\n\t\t\t\t\t\tpadding: lop.padding,\n\t\t\t\t\t\ttextBackgroundColor:\n\t\t\t\t\t\t\ttarget?.textBackgroundColor ??\n\t\t\t\t\t\t\ttarget?.background ??\n\t\t\t\t\t\t\tlop.background,\n\t\t\t\t\t\tborderRadius: lop.borderRadius,\n\t\t\t\t\t\tstroke: target?.stroke ?? target?.strokeColor ?? lop.stroke,\n\t\t\t\t\t\tstrokeWidth: target?.strokeWidth ?? lop.strokeWidth,\n\t\t\t\t\t\tstrokeAlign: lop.strokeAlign,\n\t\t\t\t\t\ttextShadow: lop.textShadow,\n\t\t\t\t\t\tshadows: lop.shadows,\n\t\t\t\t\t\tx: isPathText ? 0 : padX,\n\t\t\t\t\t\ty: isPathText ? 0 : padY,\n\t\t\t\t\t\twidth: isPathText\n\t\t\t\t\t\t\t? targetW\n\t\t\t\t\t\t\t: lop.width !== undefined\n\t\t\t\t\t\t\t\t? rect.width\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\theight: isPathText\n\t\t\t\t\t\t\t? targetH\n\t\t\t\t\t\t\t: lop.height !== undefined\n\t\t\t\t\t\t\t\t? rect.height\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t},\n\t\t\t\t\tchildren: [],\n\t\t\t\t} as unknown as VirtualMediaData;\n\t\t\t}\n\n\t\t\t// A true-3D text layer hands its glyphs to the 3D pass as outlines, to\n\t\t\t// be resolved per screen pixel on its plane: a texture of the text\n\t\t\t// blurs up close and aliases at a glancing angle. Whatever else the\n\t\t\t// layer draws (a backdrop, emoji) still lands in its texture.\n\t\t\tlet glyphBatches: SlugGlyphBatch[] | null = null;\n\t\t\tlet layerHasRaster = true;\n\t\t\tif (content) {\n\t\t\t\tconst contentMeta = getActiveMediaMetadata(content);\n\t\t\t\tconst contentDurationMs = contentMeta?.durationMs ?? composeDuration;\n\t\t\t\tconst layerDurationFrames = Math.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.round((contentDurationMs / 1000) * (fps ?? 24)),\n\t\t\t\t);\n\t\t\t\tconst layerDurationInMS = (layerDurationFrames / (fps ?? 24)) * 1000;\n\t\t\t\tconst contentIsImageCompositor =\n\t\t\t\t\tcontent.operation?.op === \"Compositor\" &&\n\t\t\t\t\tcontent.operation?.dataType === \"Image\";\n\n\t\t\t\tconst captureGlyphs = isTrue3D && kind === \"text\";\n\t\t\t\tconst rasterDrawsBefore = ctx.renderer.rasterDrawCount;\n\t\t\t\tif (captureGlyphs) ctx.renderer.slugPipeline.beginCapture();\n\t\t\t\ttry {\n\t\t\t\t\tawait drawChild(\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontainerWidth: layerW,\n\t\t\t\t\t\t\tcontainerHeight: layerH,\n\t\t\t\t\t\t\trenderId: `${props.renderId}-l${i}`,\n\t\t\t\t\t\t\tdurationMs: layerDurationInMS,\n\t\t\t\t\t\t\topacity: 1.0,\n\t\t\t\t\t\t\tfps,\n\t\t\t\t\t\t\t// A media layer's effect chain (decode → passes) allocates from the\n\t\t\t\t\t\t\t// shared pool: keep it off the destination this layer composites onto,\n\t\t\t\t\t\t\t// or the raw frame lands there wherever the clip does not cover it.\n\t\t\t\t\t\t\texcludeTextures: [activeTex, targetTexture, ...excludes],\n\t\t\t\t\t\t\tisVideoMode: isVideoMode && !contentIsImageCompositor,\n\t\t\t\t\t\t\t...(isVideoMode && {\n\t\t\t\t\t\t\t\tframe:\n\t\t\t\t\t\t\t\t\tMath.max(0, shiftedFrame - (lop.startFrame ?? 0)) +\n\t\t\t\t\t\t\t\t\t(lop.mediaStartFrame ??\n\t\t\t\t\t\t\t\t\t\tlop.trimStartFrames ??\n\t\t\t\t\t\t\t\t\t\t(lop.trimStartSec != null\n\t\t\t\t\t\t\t\t\t\t\t? Math.round(lop.trimStartSec * (fps ?? 24))\n\t\t\t\t\t\t\t\t\t\t\t: 0)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...(isCaption && {\n\t\t\t\t\t\t\t\tfontFamily: lop.fontFamily,\n\t\t\t\t\t\t\t\tfontSize: target?.fontSize ?? lop.fontSize,\n\t\t\t\t\t\t\t\tfontWeight: lop.fontWeight,\n\t\t\t\t\t\t\t\tfontStyle: lop.fontStyle,\n\t\t\t\t\t\t\t\tfill: lop.fill,\n\t\t\t\t\t\t\t\tcolor: lop.fill,\n\t\t\t\t\t\t\t\talign:\n\t\t\t\t\t\t\t\t\tlop.align === \"start\"\n\t\t\t\t\t\t\t\t\t\t? \"left\"\n\t\t\t\t\t\t\t\t\t\t: lop.align === \"end\"\n\t\t\t\t\t\t\t\t\t\t\t? \"right\"\n\t\t\t\t\t\t\t\t\t\t\t: (lop.align ?? \"center\"),\n\t\t\t\t\t\t\t\tverticalAlign: lop.verticalAlign ?? lop.textAlignVertical,\n\t\t\t\t\t\t\t\tlineHeight: lop.lineHeight,\n\t\t\t\t\t\t\t\tletterSpacing: lop.letterSpacing,\n\t\t\t\t\t\t\t\ttextBackgroundColor: lop.background ?? lop.textBackgroundColor,\n\t\t\t\t\t\t\t\tborderRadius: lop.borderRadius ?? lop.strokeRadius,\n\t\t\t\t\t\t\t\tstrokeRadius: lop.strokeRadius ?? lop.borderRadius,\n\t\t\t\t\t\t\t\tstroke: lop.stroke,\n\t\t\t\t\t\t\t\tstrokeWidth: lop.strokeWidth,\n\t\t\t\t\t\t\t\tshadows: lop.shadows,\n\t\t\t\t\t\t\t\tpadding: lop.padding,\n\t\t\t\t\t\t\t\tmaxWidth: lop.maxWidth ?? layerW,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlocalView,\n\t\t\t\t\t\tlocalTex,\n\t\t\t\t\t\ttexW,\n\t\t\t\t\t\ttexH,\n\t\t\t\t\t);\n\t\t\t\t} finally {\n\t\t\t\t\tif (captureGlyphs) {\n\t\t\t\t\t\tglyphBatches = ctx.renderer.slugPipeline.endCapture();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlayerHasRaster = ctx.renderer.rasterDrawCount !== rasterDrawsBefore;\n\t\t\t} else if (kind === \"shape\") {\n\t\t\t\tconst shapePass = ctx.renderer.beginFrame(\n\t\t\t\t\tencoder,\n\t\t\t\t\tlocalView,\n\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\ttexW,\n\t\t\t\t\ttexH,\n\t\t\t\t\t\"load\",\n\t\t\t\t);\n\n\t\t\t\tconst shapeType = lop.shapeType ?? lop.shape ?? \"rect\";\n\t\t\t\tconst shapeConfig: ShapeGeometryConfig = {\n\t\t\t\t\tshapeType,\n\t\t\t\t\twidth: layerW,\n\t\t\t\t\theight: layerH,\n\t\t\t\t\tpath: lop.d ?? lop.path,\n\t\t\t\t\tcornerRadius:\n\t\t\t\t\t\ttarget?.cornerRadius ??\n\t\t\t\t\t\tlop.cornerRadius ??\n\t\t\t\t\t\tlop.borderRadius ??\n\t\t\t\t\t\tlop.radius ??\n\t\t\t\t\t\t0,\n\t\t\t\t\tstarPoints: lop.starPoints ?? 5,\n\t\t\t\t\tstarInnerRadiusRatio:\n\t\t\t\t\t\ttarget?.starInnerRadiusRatio ?? lop.starInnerRadiusRatio ?? 0.5,\n\t\t\t\t\tpolygonSides: lop.polygonSides ?? 5,\n\t\t\t\t};\n\n\t\t\t\tconst fillType = lop.fillType ?? \"solid\";\n\t\t\t\tconst fillColor =\n\t\t\t\t\ttarget?.fillColor ??\n\t\t\t\t\ttarget?.fill ??\n\t\t\t\t\tlop.fillColor ??\n\t\t\t\t\tlop.fill ??\n\t\t\t\t\t\"#38bdf8\";\n\t\t\t\tconst color2 =\n\t\t\t\t\ttarget?.gradientEndColor ??\n\t\t\t\t\tlop.gradientEndColor ??\n\t\t\t\t\tlop.fillColor2 ??\n\t\t\t\t\t\"#9333ea\";\n\n\t\t\t\tlet startX = lop.fillStartX;\n\t\t\t\tlet startY = lop.fillStartY;\n\t\t\t\tlet endX = lop.fillEndX;\n\t\t\t\tlet endY = lop.fillEndY;\n\t\t\t\tif (\n\t\t\t\t\tfillType === \"linear\" &&\n\t\t\t\t\tstartX === undefined &&\n\t\t\t\t\tlop.gradientAngle !== undefined\n\t\t\t\t) {\n\t\t\t\t\tconst rad = (lop.gradientAngle * Math.PI) / 180;\n\t\t\t\t\tconst cx = layerW / 2;\n\t\t\t\t\tconst cy = layerH / 2;\n\t\t\t\t\t// Edge to edge along the angle (0° left→right, 90° top→bottom),\n\t\t\t\t\t// matching the shape generator's SVG gradients.\n\t\t\t\t\tconst half =\n\t\t\t\t\t\t(Math.abs(layerW * Math.cos(rad)) +\n\t\t\t\t\t\t\tMath.abs(layerH * Math.sin(rad))) /\n\t\t\t\t\t\t2;\n\t\t\t\t\tstartX = cx - Math.cos(rad) * half;\n\t\t\t\t\tstartY = cy - Math.sin(rad) * half;\n\t\t\t\t\tendX = cx + Math.cos(rad) * half;\n\t\t\t\t\tendY = cy + Math.sin(rad) * half;\n\t\t\t\t}\n\n\t\t\t\tconst fillConfig: ShapeFillConfig = {\n\t\t\t\t\ttype: fillType,\n\t\t\t\t\tcolor: fillColor,\n\t\t\t\t\tcolor2,\n\t\t\t\t\tstartX,\n\t\t\t\t\tstartY,\n\t\t\t\t\tendX,\n\t\t\t\t\tendY,\n\t\t\t\t\tcx: lop.fillCx,\n\t\t\t\t\tcy: lop.fillCy,\n\t\t\t\t\tradius: lop.fillRadius,\n\t\t\t\t};\n\n\t\t\t\tconst strokeWidth = target?.strokeWidth ?? lop.strokeWidth ?? 0;\n\t\t\t\tconst strokeColor =\n\t\t\t\t\ttarget?.strokeColor ?? lop.strokeColor ?? lop.stroke ?? \"#ffffff\";\n\t\t\t\tconst strokeLineCap = lop.strokeLineCap ?? \"round\";\n\t\t\t\tconst strokeDashArray = lop.strokeDashArray;\n\t\t\t\tconst strokeDashOffset =\n\t\t\t\t\ttarget?.strokeDashOffset ?? lop.strokeDashOffset ?? 0;\n\t\t\t\tconst trimStart = target?.trimStart ?? lop.trimStart ?? 0;\n\t\t\t\tconst trimEnd = target?.trimEnd ?? lop.trimEnd ?? 1;\n\t\t\t\tconst trimOffset = target?.trimOffset ?? lop.trimOffset ?? 0;\n\n\t\t\t\tctx.renderer.drawShape(\n\t\t\t\t\tshapePass,\n\t\t\t\t\tshapeConfig,\n\t\t\t\t\tfillConfig,\n\t\t\t\t\tstrokeWidth > 0\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: strokeColor,\n\t\t\t\t\t\t\t\twidth: strokeWidth,\n\t\t\t\t\t\t\t\tcap: strokeLineCap,\n\t\t\t\t\t\t\t\ttrimStart,\n\t\t\t\t\t\t\t\ttrimEnd,\n\t\t\t\t\t\t\t\ttrimOffset,\n\t\t\t\t\t\t\t\tdashArray: strokeDashArray,\n\t\t\t\t\t\t\t\tdashOffset: strokeDashOffset,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t);\n\n\t\t\t\tshapePass.end();\n\t\t\t}\n\n\t\t\t// Temporal De-flickering & Optical Flow Warping\n\t\t\tconst leafDeflickerEffect = Array.isArray(lop.effects)\n\t\t\t\t? lop.effects.find(\n\t\t\t\t\t\t(e: unknown) =>\n\t\t\t\t\t\t\t(e as { op?: string })?.op === \"TemporalDeflicker\" ||\n\t\t\t\t\t\t\t(e as { constructor?: { name?: string } })?.constructor?.name ===\n\t\t\t\t\t\t\t\t\"TemporalDeflicker\",\n\t\t\t\t\t)\n\t\t\t\t: undefined;\n\t\t\tconst deflickerOpts =\n\t\t\t\ttarget?.deflicker ?? lop.deflicker ?? leafDeflickerEffect;\n\n\t\t\t// Screen-Space 3D Relighting\n\t\t\tconst leafRelightEffect = Array.isArray(lop.effects)\n\t\t\t\t? lop.effects.find(\n\t\t\t\t\t\t(e: unknown) =>\n\t\t\t\t\t\t\t(e as { op?: string })?.op === \"Relight3D\" ||\n\t\t\t\t\t\t\t(e as { constructor?: { name?: string } })?.constructor?.name ===\n\t\t\t\t\t\t\t\t\"Relight3D\",\n\t\t\t\t\t)\n\t\t\t\t: undefined;\n\t\t\tconst rawLeafRelight =\n\t\t\t\ttarget?.relighting ??\n\t\t\t\tlop.relighting ??\n\t\t\t\t(typeof lop.relight === \"object\" ? lop.relight : undefined) ??\n\t\t\t\tleafRelightEffect;\n\t\t\tconst relightOpts =\n\t\t\t\ttypeof rawLeafRelight === \"object\" && rawLeafRelight !== null\n\t\t\t\t\t? rawLeafRelight\n\t\t\t\t\t: undefined;\n\n\t\t\t// Directional velocity motion blur\n\t\t\tconst shutterAngle =\n\t\t\t\ttarget?.motionBlurShutter ?? lop.motionBlurShutter ?? 0;\n\n\t\t\t// Effects work on the layer's pixels: glyphs held back for the 3D\n\t\t\t// pass are drawn into its texture after all.\n\t\t\tif (\n\t\t\t\tglyphBatches &&\n\t\t\t\tglyphBatches.length > 0 &&\n\t\t\t\t(deflickerOpts || relightOpts || shutterAngle > 0)\n\t\t\t) {\n\t\t\t\tconst glyphPass = ctx.renderer.beginFrame(\n\t\t\t\t\tencoder,\n\t\t\t\t\tlocalView,\n\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\ttexW,\n\t\t\t\t\ttexH,\n\t\t\t\t\t\"load\",\n\t\t\t\t);\n\t\t\t\tctx.renderer.slugPipeline.drawBatches(\n\t\t\t\t\tglyphPass,\n\t\t\t\t\tglyphBatches,\n\t\t\t\t\ttexW,\n\t\t\t\t\ttexH,\n\t\t\t\t);\n\t\t\t\tglyphPass.end();\n\t\t\t\tglyphBatches = null;\n\t\t\t\tlayerHasRaster = true;\n\t\t\t}\n\n\t\t\tlet finalTex = localTex;\n\t\t\tif (!isTrue3D && br > 0 && !isCaption && kind !== \"shape\") {\n\t\t\t\tconst maskTex = ctx.renderer.getTemporaryTexture(texW, texH, [\n\t\t\t\t\tlocalTex,\n\t\t\t\t\tactiveTex,\n\t\t\t\t\ttargetTexture,\n\t\t\t\t\t...excludes,\n\t\t\t\t]);\n\t\t\t\tconst maskView = maskTex.createView();\n\t\t\t\tconst maskClearPass = ctx.renderer.beginFrame(\n\t\t\t\t\tencoder,\n\t\t\t\t\tmaskView,\n\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\ttexW,\n\t\t\t\t\ttexH,\n\t\t\t\t\t\"clear\",\n\t\t\t\t);\n\t\t\t\tmaskClearPass.end();\n\n\t\t\t\tconst maskPass = ctx.renderer.beginFrame(\n\t\t\t\t\tencoder,\n\t\t\t\t\tmaskView,\n\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\ttexW,\n\t\t\t\t\ttexH,\n\t\t\t\t\t\"load\",\n\t\t\t\t);\n\t\t\t\tctx.renderer.drawRect(\n\t\t\t\t\tmaskPass,\n\t\t\t\t\t{ x: 0, y: 0, width: layerW, height: layerH },\n\t\t\t\t\t{ r: 1, g: 1, b: 1, a: 1 },\n\t\t\t\t\tbr,\n\t\t\t\t);\n\t\t\t\tmaskPass.end();\n\n\t\t\t\tfinalTex = ctx.renderer.composite(\n\t\t\t\t\tencoder,\n\t\t\t\t\tlocalTex,\n\t\t\t\t\tmaskTex,\n\t\t\t\t\t\"mask-in\",\n\t\t\t\t\t[activeTex, targetTexture, ...excludes],\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Temporal De-flickering & Optical Flow Warping\n\t\t\tif (deflickerOpts) {\n\t\t\t\tconst deflickerPipe = getTemporalDeflickerPipeline(\n\t\t\t\t\tctx.device,\n\t\t\t\t\tlop.id || `layer_${i}`,\n\t\t\t\t);\n\t\t\t\tif (shiftedFrame === 0) {\n\t\t\t\t\tdeflickerPipe.reset();\n\t\t\t\t}\n\t\t\t\tfinalTex = deflickerPipe.execute(finalTex, deflickerOpts, encoder);\n\t\t\t}\n\n\t\t\t// Screen-Space 3D Relighting\n\t\t\tif (relightOpts) {\n\t\t\t\tconst relightPipeline = getScreenSpaceRelightPipeline(\n\t\t\t\t\tctx.device,\n\t\t\t\t\tctx.renderer.format ?? \"rgba8unorm\",\n\t\t\t\t);\n\t\t\t\tconst r3dInstance = getRenderer3D(\n\t\t\t\t\tctx.device,\n\t\t\t\t\tctx.renderer.format ?? \"rgba8unorm\",\n\t\t\t\t\tsampleCount3d,\n\t\t\t\t);\n\t\t\t\tconst activeLights = synthesizeRelightLights(\n\t\t\t\t\trelightOpts as Record<string, unknown>,\n\t\t\t\t\tsceneLights,\n\t\t\t\t\t{ x: sampledX, y: sampledY, width: texW, height: texH },\n\t\t\t\t\tshiftedFrame,\n\t\t\t\t\tfps ?? 24,\n\t\t\t\t);\n\t\t\t\tconst lightsBuffer = r3dInstance.getOrCreateLightsBuffer(activeLights);\n\n\t\t\t\tconst relitTex = ctx.renderer.getTemporaryTexture(texW, texH, [\n\t\t\t\t\tfinalTex,\n\t\t\t\t\tactiveTex,\n\t\t\t\t\ttargetTexture,\n\t\t\t\t\t...excludes,\n\t\t\t\t]);\n\t\t\t\tconst relitView = relitTex.createView();\n\n\t\t\t\tconst normalTex = relightOpts.normalTexture ?? relightOpts.normalMap;\n\n\t\t\t\trelightPipeline.execute(\n\t\t\t\t\tencoder,\n\t\t\t\t\trelitView,\n\t\t\t\t\tfinalTex,\n\t\t\t\t\tnormalTex,\n\t\t\t\t\tlightsBuffer,\n\t\t\t\t\t{\n\t\t\t\t\t\tviewportWidth: texW,\n\t\t\t\t\t\tviewportHeight: texH,\n\t\t\t\t\t\tlayerX: sampledX,\n\t\t\t\t\t\tlayerY: sampledY,\n\t\t\t\t\t\troughness: resolveVal(\n\t\t\t\t\t\t\ttarget?.roughness ??\n\t\t\t\t\t\t\t\ttarget?.relightRoughness ??\n\t\t\t\t\t\t\t\trelightOpts.specularRoughness ??\n\t\t\t\t\t\t\t\trelightOpts.roughness,\n\t\t\t\t\t\t\t0.35,\n\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tspecularStrength: resolveVal(\n\t\t\t\t\t\t\ttarget?.specularStrength ??\n\t\t\t\t\t\t\t\ttarget?.relightSpecularStrength ??\n\t\t\t\t\t\t\t\trelightOpts.specularStrength,\n\t\t\t\t\t\t\t0.7,\n\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmetallic: resolveVal(\n\t\t\t\t\t\t\ttarget?.metallic ??\n\t\t\t\t\t\t\t\ttarget?.relightMetallic ??\n\t\t\t\t\t\t\t\trelightOpts.metallic,\n\t\t\t\t\t\t\t0.0,\n\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tambientIntensity: resolveVal(\n\t\t\t\t\t\t\ttarget?.ambientIntensity ??\n\t\t\t\t\t\t\t\ttarget?.relightAmbientIntensity ??\n\t\t\t\t\t\t\t\trelightOpts.ambientIntensity,\n\t\t\t\t\t\t\t0.15,\n\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdepthScale: resolveVal(\n\t\t\t\t\t\t\ttarget?.depthScale ??\n\t\t\t\t\t\t\t\ttarget?.relightDepthScale ??\n\t\t\t\t\t\t\t\trelightOpts.depthScale,\n\t\t\t\t\t\t\t1.0,\n\t\t\t\t\t\t\tshiftedFrame,\n\t\t\t\t\t\t\tfps ?? 24,\n\t\t\t\t\t\t),\n\t\t\t\t\t\topacity: 1.0,\n\t\t\t\t\t},\n\t\t\t\t\t\"clear\",\n\t\t\t\t);\n\n\t\t\t\tfinalTex = relitTex;\n\t\t\t}\n\n\t\t\t// Directional velocity motion blur (last: the shutter integrates the final look)\n\t\t\tlet blurPadX = 0;\n\t\t\tlet blurPadY = 0;\n\t\t\tif (shutterAngle > 0 && fps && shiftedFrame !== undefined) {\n\t\t\t\tconst currentT = shiftedFrame / fps;\n\t\t\t\tconst prevT = (shiftedFrame - 1) / fps;\n\t\t\t\ttl.seek(prevT);\n\t\t\t\tconst prevTarget = targetId ? targetsById[targetId] : undefined;\n\t\t\t\tconst prevX = prevTarget?.x ?? baseX;\n\t\t\t\tconst prevY = prevTarget?.y ?? baseY;\n\t\t\t\ttl.seek(currentT);\n\n\t\t\t\tconst vx = sampledX - prevX;\n\t\t\t\tconst vy = sampledY - prevY;\n\n\t\t\t\tif (Math.hypot(vx, vy) > 0.5) {\n\t\t\t\t\t// The blur only samples inside its texture: give flat layers room\n\t\t\t\t\t// to streak past their own bounds instead of smearing edge pixels.\n\t\t\t\t\tif (!isTrue3D && !(is3D && quad3D)) {\n\t\t\t\t\t\tconst reach = shutterAngle / 360;\n\t\t\t\t\t\tblurPadX = Math.ceil(Math.abs(vx) * reach);\n\t\t\t\t\t\tblurPadY = Math.ceil(Math.abs(vy) * reach);\n\t\t\t\t\t\tconst paddedTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\t\t\t\ttexW + blurPadX * 2,\n\t\t\t\t\t\t\ttexH + blurPadY * 2,\n\t\t\t\t\t\t\t[finalTex, activeTex, targetTexture, ...excludes],\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst padPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tpaddedTex.createView(),\n\t\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\t\tpaddedTex.width,\n\t\t\t\t\t\t\tpaddedTex.height,\n\t\t\t\t\t\t\t\"clear\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\t\t\tpadPass,\n\t\t\t\t\t\t\tfinalTex,\n\t\t\t\t\t\t\t{ x: blurPadX, y: blurPadY, width: texW, height: texH },\n\t\t\t\t\t\t\t{ opacity: 1.0 },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpadPass.end();\n\t\t\t\t\t\tfinalTex = paddedTex;\n\t\t\t\t\t}\n\t\t\t\t\t// ~1 tap per 2 px of streak so fast moves smear instead of ghosting.\n\t\t\t\t\tconst streakPx = Math.hypot(vx, vy) * (shutterAngle / 360) * 2;\n\t\t\t\t\tconst samples = Math.min(128, Math.max(16, Math.ceil(streakPx / 2)));\n\t\t\t\t\tfinalTex = ctx.renderer.applyMotionBlur(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tfinalTex,\n\t\t\t\t\t\tvx,\n\t\t\t\t\t\tvy,\n\t\t\t\t\t\tshutterAngle,\n\t\t\t\t\t\tsamples,\n\t\t\t\t\t\t[activeTex, targetTexture, ...excludes],\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst borderExcludes = [\n\t\t\t\tlocalTex,\n\t\t\t\tfinalTex,\n\t\t\t\tactiveTex,\n\t\t\t\ttargetTexture,\n\t\t\t\t...excludes,\n\t\t\t];\n\t\t\tconst borderResult =\n\t\t\t\t!isTrue3D && lop.borderWidth !== undefined && lop.borderColor\n\t\t\t\t\t? createBorderTexture(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\tencoder,\n\t\t\t\t\t\t\tlayerW,\n\t\t\t\t\t\t\tlayerH,\n\t\t\t\t\t\t\tbr,\n\t\t\t\t\t\t\tlop.borderWidth,\n\t\t\t\t\t\t\tlop.borderColor,\n\t\t\t\t\t\t\tlop.strokeAlign ?? \"inside\",\n\t\t\t\t\t\t\tborderExcludes,\n\t\t\t\t\t\t)\n\t\t\t\t\t: null;\n\n\t\t\t// Restore parent container scissors before compositing onto container/screen activeView\n\t\t\tif (savedScissors.length > 0) {\n\t\t\t\tctx.renderer.resumeScissors?.(savedScissors);\n\t\t\t}\n\n\t\t\tif (isTrue3D) {\n\t\t\t\tconst renderedTex = finalTex;\n\t\t\t\tif (borderResult) {\n\t\t\t\t\tconst borderPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\trenderedTex.createView(),\n\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\ttexW,\n\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\"load\",\n\t\t\t\t\t);\n\t\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\t\tborderPass,\n\t\t\t\t\t\tborderResult.borderTex,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx: borderResult.ox,\n\t\t\t\t\t\t\ty: borderResult.oy,\n\t\t\t\t\t\t\twidth: borderResult.ow,\n\t\t\t\t\t\t\theight: borderResult.oh,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ opacity: 1.0 },\n\t\t\t\t\t);\n\t\t\t\t\tborderPass.end();\n\t\t\t\t}\n\n\t\t\t\tlet modelMatrix: Mat4 | undefined;\n\t\t\t\tif (parent3DMatrix) {\n\t\t\t\t\tlet localM = Matrix4Math.identity();\n\t\t\t\t\tconst childX = target?.x ?? lop.x ?? 0;\n\t\t\t\t\tconst childY = target?.y ?? lop.y ?? 0;\n\t\t\t\t\tconst childZ = target?.z ?? lop.z ?? 0;\n\t\t\t\t\tlocalM = Matrix4Math.multiply(\n\t\t\t\t\t\tlocalM,\n\t\t\t\t\t\tMatrix4Math.translate(childX, childY, childZ),\n\t\t\t\t\t);\n\t\t\t\t\tconst rxRad = ((target?.rotateX ?? lop.rotateX ?? 0) * Math.PI) / 180;\n\t\t\t\t\tconst ryRad = ((target?.rotateY ?? lop.rotateY ?? 0) * Math.PI) / 180;\n\t\t\t\t\tconst rzRad =\n\t\t\t\t\t\t((target?.rotateZ ?? lop.rotateZ ?? 0) !== 0\n\t\t\t\t\t\t\t? (target?.rotateZ ?? lop.rotateZ ?? 0)\n\t\t\t\t\t\t\t: rotation) *\n\t\t\t\t\t\t(Math.PI / 180);\n\t\t\t\t\tif (rzRad !== 0)\n\t\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateZ(rzRad));\n\t\t\t\t\tif (ryRad !== 0)\n\t\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateY(ryRad));\n\t\t\t\t\tif (rxRad !== 0)\n\t\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.rotateX(rxRad));\n\n\t\t\t\t\tconst sx = layerW * scale;\n\t\t\t\t\tconst sy = layerH * scale;\n\t\t\t\t\tconst sz = target?.scaleZ ?? lop.scaleZ ?? 1;\n\t\t\t\t\tlocalM = Matrix4Math.multiply(localM, Matrix4Math.scale(sx, sy, sz));\n\n\t\t\t\t\tconst ax = lop.anchorX ?? 0.5;\n\t\t\t\t\tconst ay = lop.anchorY ?? 0.5;\n\t\t\t\t\tconst pivotX = 0.5 - ax;\n\t\t\t\t\tconst pivotY = 0.5 - ay;\n\t\t\t\t\tif (pivotX !== 0 || pivotY !== 0) {\n\t\t\t\t\t\tlocalM = Matrix4Math.multiply(\n\t\t\t\t\t\t\tlocalM,\n\t\t\t\t\t\t\tMatrix4Math.translate(pivotX, pivotY, 0),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tmodelMatrix = Matrix4Math.multiply(parent3DMatrix, localM);\n\t\t\t\t}\n\n\t\t\t\tconst quadOpts: DrawQuad3DOpts = {\n\t\t\t\t\tposition: [\n\t\t\t\t\t\tlocalX + layerW * 0.5,\n\t\t\t\t\t\tlocalY + layerH * 0.5,\n\t\t\t\t\t\ttarget?.z ?? lop.z ?? 0,\n\t\t\t\t\t],\n\t\t\t\t\twidth: layerW,\n\t\t\t\t\theight: layerH,\n\t\t\t\t\ttextureExtent: [layerW / texW, layerH / texH],\n\t\t\t\t\trotation: [\n\t\t\t\t\t\ttarget?.rotateX ?? lop.rotateX ?? 0,\n\t\t\t\t\t\ttarget?.rotateY ?? lop.rotateY ?? 0,\n\t\t\t\t\t\t(target?.rotateZ ?? lop.rotateZ ?? 0) !== 0\n\t\t\t\t\t\t\t? (target?.rotateZ ?? lop.rotateZ ?? 0)\n\t\t\t\t\t\t\t: rotation,\n\t\t\t\t\t],\n\t\t\t\t\tscale: [scale, scale, target?.scaleZ ?? lop.scaleZ ?? 1],\n\t\t\t\t\tanchor: [lop.anchorX ?? 0.5, lop.anchorY ?? 0.5],\n\t\t\t\t\tborderRadius: br,\n\t\t\t\t\tborderWidth: lop.borderWidth,\n\t\t\t\t\tborderColor: lop.borderColor,\n\t\t\t\t\topacity: layerOpacity,\n\t\t\t\t\ttwoSided: target?.twoSided ?? lop.twoSided ?? true,\n\t\t\t\t\tmaterial: target?.material ?? lop.material,\n\t\t\t\t\tshininess: target?.shininess ?? lop.shininess,\n\t\t\t\t\troughness: target?.roughness ?? lop.roughness,\n\t\t\t\t\tspecularIntensity: target?.specularIntensity ?? lop.specularIntensity,\n\t\t\t\t\tambientIntensity: target?.ambientIntensity ?? lop.ambientIntensity,\n\t\t\t\t\tmetallic: target?.metallic ?? lop.metallic,\n\t\t\t\t\t...(modelMatrix && { modelMatrix }),\n\t\t\t\t};\n\n\t\t\t\t// The texture quad carries the layer's backdrop and border; a\n\t\t\t\t// text layer that drew neither needs only its glyphs.\n\t\t\t\tconst quadHasContent =\n\t\t\t\t\tlayerHasRaster ||\n\t\t\t\t\tBoolean(\n\t\t\t\t\t\tquadOpts.borderWidth &&\n\t\t\t\t\t\t\tquadOpts.borderWidth > 0 &&\n\t\t\t\t\t\t\tquadOpts.borderColor,\n\t\t\t\t\t);\n\t\t\t\tif (!glyphBatches || quadHasContent) {\n\t\t\t\t\tpending3DItems.push({\n\t\t\t\t\t\tkind: \"quad\",\n\t\t\t\t\t\ttexture: renderedTex,\n\t\t\t\t\t\topts: quadOpts,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (glyphBatches && glyphBatches.length > 0) {\n\t\t\t\t\tpending3DItems.push({\n\t\t\t\t\t\tkind: \"slug\",\n\t\t\t\t\t\tbatches: glyphBatches,\n\t\t\t\t\t\topts: quadOpts,\n\t\t\t\t\t\tstackBase: quadHasContent ? 1 : 0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\t\t\t}\n\n\t\t\tif (is3D && quad3D) {\n\t\t\t\tconst renderedTex = finalTex;\n\t\t\t\tif (borderResult) {\n\t\t\t\t\tconst borderPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\trenderedTex.createView(),\n\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\ttexW,\n\t\t\t\t\t\ttexH,\n\t\t\t\t\t\t\"load\",\n\t\t\t\t\t);\n\t\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\t\tborderPass,\n\t\t\t\t\t\tborderResult.borderTex,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx: borderResult.ox,\n\t\t\t\t\t\t\ty: borderResult.oy,\n\t\t\t\t\t\t\twidth: borderResult.ow,\n\t\t\t\t\t\t\theight: borderResult.oh,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ opacity: 1.0 },\n\t\t\t\t\t);\n\t\t\t\t\tborderPass.end();\n\t\t\t\t}\n\n\t\t\t\tif (blendMode === \"normal\" || blendMode === \"source-over\") {\n\t\t\t\t\tdrawProjectedQuad(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tactiveView,\n\t\t\t\t\t\trenderedTex,\n\t\t\t\t\t\tquad3D,\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\tlayerOpacity,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconst layerExcludes = [\n\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\ttargetTexture,\n\t\t\t\t\t\trenderedTex,\n\t\t\t\t\t\t...excludes,\n\t\t\t\t\t];\n\t\t\t\t\tif (borderResult) layerExcludes.push(borderResult.borderTex);\n\t\t\t\t\tconst layerTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\tlayerExcludes,\n\t\t\t\t\t);\n\t\t\t\t\tconst layerView = layerTex.createView();\n\t\t\t\t\tconst layerClearPass = ctx.renderer.beginFrame(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tlayerView,\n\t\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\t\"clear\",\n\t\t\t\t\t);\n\t\t\t\t\tlayerClearPass.end();\n\n\t\t\t\t\tdrawProjectedQuad(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tlayerView,\n\t\t\t\t\t\trenderedTex,\n\t\t\t\t\t\tquad3D,\n\t\t\t\t\t\ttargetW,\n\t\t\t\t\t\ttargetH,\n\t\t\t\t\t\tlayerOpacity,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst nextCompTex = ctx.renderer.composite(\n\t\t\t\t\t\tencoder,\n\t\t\t\t\t\tactiveTex,\n\t\t\t\t\t\tlayerTex,\n\t\t\t\t\t\tblendMode,\n\t\t\t\t\t\t[targetTexture, ...excludes],\n\t\t\t\t\t);\n\t\t\t\t\tactiveTex = nextCompTex;\n\t\t\t\t\tactiveView = activeTex.createView();\n\t\t\t\t}\n\n\t\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\t\t\t}\n\n\t\t\tif (blendMode === \"normal\" || blendMode === \"source-over\") {\n\t\t\t\tconst drawPass = ctx.renderer.beginFrame(\n\t\t\t\t\tencoder,\n\t\t\t\t\tactiveView,\n\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\ttargetW,\n\t\t\t\t\ttargetH,\n\t\t\t\t\t\"load\",\n\t\t\t\t);\n\t\t\t\tctx.renderer.pushTransform(layerMatrix);\n\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\tdrawPass,\n\t\t\t\t\tfinalTex,\n\t\t\t\t\t{\n\t\t\t\t\t\tx: -blurPadX,\n\t\t\t\t\t\ty: -blurPadY,\n\t\t\t\t\t\twidth: layerW + blurPadX * 2,\n\t\t\t\t\t\theight: layerH + blurPadY * 2,\n\t\t\t\t\t},\n\t\t\t\t\t{ opacity: layerOpacity },\n\t\t\t\t);\n\n\t\t\t\tif (borderResult) {\n\t\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\t\tdrawPass,\n\t\t\t\t\t\tborderResult.borderTex,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx: borderResult.ox,\n\t\t\t\t\t\t\ty: borderResult.oy,\n\t\t\t\t\t\t\twidth: borderResult.ow,\n\t\t\t\t\t\t\theight: borderResult.oh,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ opacity: layerOpacity },\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tctx.renderer.popTransform();\n\t\t\t\tdrawPass.end();\n\t\t\t} else {\n\t\t\t\tconst layerExcludes = [finalTex, activeTex, targetTexture, ...excludes];\n\t\t\t\tif (borderResult) layerExcludes.push(borderResult.borderTex);\n\t\t\t\tconst layerTex = ctx.renderer.getTemporaryTexture(\n\t\t\t\t\ttargetW,\n\t\t\t\t\ttargetH,\n\t\t\t\t\tlayerExcludes,\n\t\t\t\t);\n\t\t\t\tconst layerView = layerTex.createView();\n\n\t\t\t\tconst layerClearPass = ctx.renderer.beginFrame(\n\t\t\t\t\tencoder,\n\t\t\t\t\tlayerView,\n\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\ttargetW,\n\t\t\t\t\ttargetH,\n\t\t\t\t\t\"clear\",\n\t\t\t\t);\n\t\t\t\tlayerClearPass.end();\n\n\t\t\t\tconst drawPass = ctx.renderer.beginFrame(\n\t\t\t\t\tencoder,\n\t\t\t\t\tlayerView,\n\t\t\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t\ttargetW,\n\t\t\t\t\ttargetH,\n\t\t\t\t\t\"load\",\n\t\t\t\t);\n\t\t\t\tctx.renderer.pushTransform(layerMatrix);\n\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\tdrawPass,\n\t\t\t\t\tfinalTex,\n\t\t\t\t\t{\n\t\t\t\t\t\tx: -blurPadX,\n\t\t\t\t\t\ty: -blurPadY,\n\t\t\t\t\t\twidth: layerW + blurPadX * 2,\n\t\t\t\t\t\theight: layerH + blurPadY * 2,\n\t\t\t\t\t},\n\t\t\t\t\t{ opacity: layerOpacity },\n\t\t\t\t);\n\n\t\t\t\tif (borderResult) {\n\t\t\t\t\tctx.renderer.drawTexture(\n\t\t\t\t\t\tdrawPass,\n\t\t\t\t\t\tborderResult.borderTex,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx: borderResult.ox,\n\t\t\t\t\t\t\ty: borderResult.oy,\n\t\t\t\t\t\t\twidth: borderResult.ow,\n\t\t\t\t\t\t\theight: borderResult.oh,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ opacity: layerOpacity },\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tctx.renderer.popTransform();\n\t\t\t\tdrawPass.end();\n\n\t\t\t\tconst nextCompTex = ctx.renderer.composite(\n\t\t\t\t\tencoder,\n\t\t\t\t\tactiveTex,\n\t\t\t\t\tlayerTex,\n\t\t\t\t\tblendMode,\n\t\t\t\t\t[targetTexture, ...excludes],\n\t\t\t\t);\n\t\t\t\tactiveTex = nextCompTex;\n\t\t\t\tactiveView = activeTex.createView();\n\t\t\t}\n\n\t\t\treturn { finalTex: activeTex, finalView: activeView };\n\t\t};\n\n\t\tconst initialExcludes = [\n\t\t\tcompTex,\n\t\t\ttargetTexture,\n\t\t\t...(props.excludeTextures || []),\n\t\t];\n\t\tconst renderResult = await renderNodeTree(\n\t\t\tvirtualMedia.children ?? [],\n\t\t\tcompTex,\n\t\t\tcompView,\n\t\t\tinitialExcludes,\n\t\t\t1.0,\n\t\t\tnew DOMMatrix(),\n\t\t\tnull,\n\t\t\tnativeWidth,\n\t\t\tnativeHeight,\n\t\t\tnull,\n\t\t\ttrue,\n\t\t);\n\t\tcurrentCompTex = renderResult.finalTex;\n\n\t\tctx.renderer.popTransform();\n\t\tctx.renderer.popScissor();\n\n\t\t// 4. Composite the native texture back to targetView\n\t\tconst finalPass = ctx.renderer.beginFrame(\n\t\t\tencoder,\n\t\t\ttargetView,\n\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\ttargetWidth,\n\t\t\ttargetHeight,\n\t\t\t\"load\",\n\t\t);\n\n\t\tctx.renderer.drawTexture(\n\t\t\tfinalPass,\n\t\t\tcurrentCompTex,\n\t\t\t{\n\t\t\t\tx: 0,\n\t\t\t\ty: 0,\n\t\t\t\twidth: props.containerWidth ?? targetWidth,\n\t\t\t\theight: props.containerHeight ?? targetHeight,\n\t\t\t},\n\t\t\t{ opacity },\n\t\t);\n\n\t\targs.pass = finalPass;\n\t}\n};\n\nfunction createBorderTexture(\n\tctx: RenderContextValue,\n\tencoder: GPUCommandEncoder,\n\tw: number,\n\th: number,\n\tbr: number,\n\tborderWidth: number,\n\tborderColor: string | Color,\n\tstrokeAlign: string,\n\texcludeTextures: GPUTexture[],\n): {\n\tborderTex: GPUTexture;\n\tox: number;\n\toy: number;\n\tow: number;\n\toh: number;\n} | null {\n\tif (w <= 0 || h <= 0 || !borderColor || !borderWidth || borderWidth <= 0) {\n\t\treturn null;\n\t}\n\n\tlet ox = 0;\n\tlet oy = 0;\n\tlet ow = w;\n\tlet oh = h;\n\tlet outerRadius = br;\n\tlet innerRadius = br;\n\n\tif (strokeAlign === \"inside\") {\n\t\tox = 0;\n\t\toy = 0;\n\t\tow = w;\n\t\toh = h;\n\t\touterRadius = br;\n\t\tinnerRadius = Math.max(0, br - borderWidth);\n\t} else if (strokeAlign === \"outside\") {\n\t\tox = -borderWidth;\n\t\toy = -borderWidth;\n\t\tow = w + 2 * borderWidth;\n\t\toh = h + 2 * borderWidth;\n\t\touterRadius = br + borderWidth;\n\t\tinnerRadius = br;\n\t} else {\n\t\t// center\n\t\tox = -borderWidth / 2;\n\t\toy = -borderWidth / 2;\n\t\tow = w + borderWidth;\n\t\toh = h + borderWidth;\n\t\touterRadius = br + borderWidth / 2;\n\t\tinnerRadius = Math.max(0, br - borderWidth / 2);\n\t}\n\n\tif (br <= 0) {\n\t\touterRadius = 0;\n\t\tinnerRadius = 0;\n\t}\n\n\tif (ow <= 0 || oh <= 0) {\n\t\treturn null;\n\t}\n\n\tconst borderTexW = Math.ceil(ow);\n\tconst borderTexH = Math.ceil(oh);\n\n\tconst outerTex = ctx.renderer.getTemporaryTexture(\n\t\tborderTexW,\n\t\tborderTexH,\n\t\texcludeTextures,\n\t);\n\tconst outerView = outerTex.createView();\n\n\tconst outerClearPass = ctx.renderer.beginFrame(\n\t\tencoder,\n\t\touterView,\n\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\tborderTexW,\n\t\tborderTexH,\n\t\t\"clear\",\n\t);\n\touterClearPass.end();\n\n\tconst outerDrawPass = ctx.renderer.beginFrame(\n\t\tencoder,\n\t\touterView,\n\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\tborderTexW,\n\t\tborderTexH,\n\t\t\"load\",\n\t);\n\tctx.renderer.drawRect(\n\t\touterDrawPass,\n\t\t{ x: 0, y: 0, width: ow, height: oh },\n\t\tborderColor,\n\t\touterRadius,\n\t);\n\touterDrawPass.end();\n\n\tconst innerW = ow - 2 * borderWidth;\n\tconst innerH = oh - 2 * borderWidth;\n\n\tif (innerW > 0 && innerH > 0) {\n\t\tconst innerTex = ctx.renderer.getTemporaryTexture(borderTexW, borderTexH, [\n\t\t\touterTex,\n\t\t\t...excludeTextures,\n\t\t]);\n\t\tconst innerView = innerTex.createView();\n\n\t\tconst innerClearPass = ctx.renderer.beginFrame(\n\t\t\tencoder,\n\t\t\tinnerView,\n\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\tborderTexW,\n\t\t\tborderTexH,\n\t\t\t\"clear\",\n\t\t);\n\t\tinnerClearPass.end();\n\n\t\tconst innerDrawPass = ctx.renderer.beginFrame(\n\t\t\tencoder,\n\t\t\tinnerView,\n\t\t\t{ r: 0, g: 0, b: 0, a: 0 },\n\t\t\tborderTexW,\n\t\t\tborderTexH,\n\t\t\t\"load\",\n\t\t);\n\t\tctx.renderer.drawRect(\n\t\t\tinnerDrawPass,\n\t\t\t{ x: borderWidth, y: borderWidth, width: innerW, height: innerH },\n\t\t\t{ r: 1, g: 1, b: 1, a: 1 },\n\t\t\tinnerRadius,\n\t\t);\n\t\tinnerDrawPass.end();\n\n\t\tconst borderTex = ctx.renderer.composite(\n\t\t\tencoder,\n\t\t\touterTex,\n\t\t\tinnerTex,\n\t\t\t\"mask-out\",\n\t\t\texcludeTextures,\n\t\t);\n\t\treturn { borderTex, ox, oy, ow, oh };\n\t}\n\n\treturn { borderTex: outerTex, ox, oy, ow, oh };\n}\n","import type { LayerAnimation } from \"@framefields/compositions/program\";\nimport type { VirtualMediaData } from \"@framefields/core\";\nimport type { AudioProcessor } from \"@framefields/node-sdk\";\nimport { audioRegistry } from \"@framefields/node-sdk\";\nimport { compileLayerTimeline } from \"../shared/compiler.js\";\n\ninterface CompositorOperation {\n\top: \"Compositor\" | \"CompositorLayer\";\n\tid?: string;\n\tinputHandleId?: string;\n\tvolume?: number;\n\tmuted?: boolean;\n\tanimation?: LayerAnimation;\n}\n\nexport const compositorLayerAudioProcessor: AudioProcessor = async (\n\tchannels: Float32Array[],\n\tsampleRate: number,\n\tvirtualMedia: VirtualMediaData,\n\tctx,\n) => {\n\tconst op = virtualMedia.operation as unknown as CompositorOperation;\n\tif (!op) return;\n\n\tconst numChannels = channels.length;\n\tif (numChannels === 0) return;\n\tconst numSamples = channels[0].length;\n\tif (numSamples === 0) return;\n\n\t// Master gain (L1): the audio extractor dispatches this processor for the\n\t// root Compositor op too (registered under the node type \"Compositor\").\n\t// The root's channels ARE the fully-mixed composition, so scale them\n\t// once by the program-level `volume` — the per-layer path below handles\n\t// each CompositorLayer op's own volume/mute animation.\n\tif (op.op === \"Compositor\") {\n\t\tconst master = typeof op.volume === \"number\" ? op.volume : 1;\n\t\tif (master === 1) return;\n\t\tfor (let c = 0; c < numChannels; c++) {\n\t\t\tconst ch = channels[c];\n\t\t\tfor (let i = 0; i < ch.length; i++) ch[i] *= master;\n\t\t}\n\t\treturn;\n\t}\n\n\tconst volume = typeof op.volume === \"number\" ? op.volume : 1;\n\tconst muted = !!op.muted;\n\tconst animation = op.animation;\n\tconst fps = ctx?.fps ?? 24;\n\n\t// Check if there are active volume or muted animation tracks with keyframes\n\tconst tracks = animation?.tracks || [];\n\tconst hasVolumeKeys = tracks.some(\n\t\t(t) => t.prop === \"volume\" && t.keyframes && t.keyframes.length > 0,\n\t);\n\tconst hasMutedKeys = tracks.some(\n\t\t(t) => t.prop === \"muted\" && t.keyframes && t.keyframes.length > 0,\n\t);\n\n\tif (!hasVolumeKeys && !hasMutedKeys) {\n\t\t// If no animated volume/muted tracks exist, the static volume and mute state\n\t\t// have already been applied by the child clip or audio extractor.\n\t\treturn;\n\t}\n\n\t// Compile or retrieve the GSAP timeline for this layer\n\tconst { tl, stub } = compileLayerTimeline(\n\t\top.id || op.inputHandleId || \"layer\",\n\t\tanimation,\n\t\tvolume,\n\t\tmuted,\n\t\tfps,\n\t);\n\n\tconst elapsedMs = ctx?.elapsedMs ?? 0;\n\tconst startTimeSec = elapsedMs / 1000;\n\n\t// Process in sub-chunks of 128 samples to be fast and smooth\n\tconst subChunkSize = 128;\n\n\t// Seek to the starting time to establish baseline values\n\ttl.seek(startTimeSec);\n\tlet lastVol = stub.volume;\n\tlet lastMuted = stub.muted;\n\n\tconst baseGain = muted ? 0 : volume;\n\n\tfor (let i = 0; i < numSamples; i += subChunkSize) {\n\t\tconst nextI = Math.min(numSamples, i + subChunkSize);\n\t\tconst tNext = startTimeSec + (nextI - i) / sampleRate;\n\t\ttl.seek(tNext);\n\t\tconst nextVol = stub.volume;\n\t\tconst nextMuted = stub.muted;\n\n\t\tfor (let j = i; j < nextI; j++) {\n\t\t\tconst p = (j - i) / (nextI - i);\n\t\t\t// L3: clamp — keyframes are schema-bounded to 0–1, but a lerp\n\t\t\t// between in-range values can overshoot with custom eases; the\n\t\t\t// relativeGain compensation below must never amplify past the\n\t\t\t// channel's own scale.\n\t\t\tconst currentVol = Math.min(\n\t\t\t\t1,\n\t\t\t\tMath.max(0, lastVol + (nextVol - lastVol) * p),\n\t\t\t);\n\t\t\t// For muted, if it changes mid-sub-chunk, toggle it at the halfway point\n\t\t\tconst currentMuted = j - i < (nextI - i) / 2 ? lastMuted : nextMuted;\n\n\t\t\tconst finalGain = currentMuted ? 0 : currentVol;\n\t\t\tconst relativeGain = baseGain === 0 ? 0 : finalGain / baseGain;\n\n\t\t\tif (relativeGain !== 1) {\n\t\t\t\tfor (let c = 0; c < numChannels; c++) {\n\t\t\t\t\tchannels[c][j] *= relativeGain;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlastVol = nextVol;\n\t\tlastMuted = nextMuted;\n\t}\n};\n\n// Register immediately on load\naudioRegistry.register(\"CompositorLayer\", compositorLayerAudioProcessor);\n","import { defineRenderer } from \"@framefields/node-sdk/renderer\";\nimport { CompositorWebGPURenderer } from \"./webgpu-renderer.js\";\nimport \"./audio-processor.js\";\n\nexport default defineRenderer({\n\tWebGPURenderer: CompositorWebGPURenderer,\n});\n\nexport * from \"./transform3d.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,SAAgB,iBACf,IACA,IACA,IACA,IACA,GACS;AACT,KAAI,KAAK,EAAG,QAAO;AACnB,KAAI,KAAK,EAAG,QAAO;AAGnB,KAAI,OAAO,MAAM,OAAO,GAAI,QAAO;CAKnC,IAAI,IAAI;AACR,MAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;EAC3B,MAAMA,cAAY,IAAI;EACtB,MAAM,aAAaA,cAAYA;EAC/B,MAAM,KAAK,IAAI;EAIf,MAAM,OADL,IAAI,aAAa,IAAI,KAAK,IAAIA,cAAY,KAAK,KAAK,KAAK,IAClC;AACxB,MAAI,KAAK,IAAI,KAAK,GAAG,KAAM;EAE3B,MAAM,KACL,IAAI,aAAa,KACjB,IAAIA,cAAY,KAAK,KAAK,MAC1B,IAAI,MAAM,IAAI;AAEf,MAAI,KAAK,IAAI,GAAG,GAAG,KAAM;AACzB,OAAK,OAAO;AACZ,MAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;;CAIhC,MAAM,YAAY,IAAI;CACtB,MAAM,SACL,IAAI,YAAY,YAAY,IAAI,KAChC,IAAI,YAAY,IAAI,IAAI,KACxB,IAAI,IAAI;AAET,KAAI,KAAK,IAAI,SAAS,EAAE,GAAG,MAAM;EAChC,IAAI,MAAM;EACV,IAAI,OAAO;AACX,MAAI;AACJ,OAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;GAC5B,MAAM,OAAO,MAAM,QAAQ;GAC3B,MAAM,OAAO,IAAI;GACjB,MAAM,OACL,IAAI,OAAO,OAAO,MAAM,KACxB,IAAI,OAAO,MAAM,MAAM,KACvB,MAAM,MAAM;AACb,OAAI,KAAK,IAAI,OAAO,EAAE,GAAG,MAAM;AAC9B,QAAI;AACJ;;AAED,OAAI,OAAO,E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