3D engine that AI agents drive
Merge origin/main into perf/worker-bakes: run plan, budget fit and trace in the bake kernel
Nguyen Xuan Anf007865f5757
diff --cc CHANGELOG.mdindex 1b6395b4,7db86578..b8a23b8e--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -2,7 -2,9 +2,10 @@@## Unreleased+- Run the heavy scene kernels on a worker in the MCP preview (part of issue #38; edits after creation still run on the main thread). The light bake, the cloth solver, `uv_unwrap` and pattern textures are pure functions of their input, so `runKernel` in the new `src/kernel-offload.js` computes them inline as before, or, inside `buildWithKernels`, throws `KernelDeferred`, lets a module worker (`kernel-worker.js`, a package entry like the path tracer's) compute the result, caches it by a hash of the input bytes and runs the synchronous build again. The preview builds `scene_create` that way when the page has `Worker`; Node and every other caller keep the synchronous path and the same bytes (a test builds one scene cold in a separate process both ways and compares a digest of geometry, textures and the bake report). A worker error comes back with its class and message, a worker that cannot start or dies leaves the job to the inline path, and an `AbortSignal` ends the build and the worker. Measured in Node on the demo recipe: the `uv_unwrap` stack takes 3.6 s, the draft light bake 7.5 s and the standard bake passes the 20 s limit on this machine, cloth at the 10 s limit takes 3.4 s, a 1024 pattern takes 1 to 7 s, a boolean 0.12 s. Measured in headless Chrome on the GPU backend with the demo room recipe (`tests/fixtures/demo-room.recipe.json`, 9 kernels): the longest stretch the page was unresponsive during `scene_create` fell from 11.8 and 11.9 s to 1.6 s with workers (two runs each), while the build took 12.3 and 12.5 s instead of 10.9 and 11.0 s, because the kernels run one after another and the build reruns after each. `scene_inspect` now reports `kernels`: how many kernels a worker served and how many ran inline, each fallback with its reason (also a `67js kernel fallback` line on stderr when a page that has `Worker` falls back), the build time and the longest block; `npm run smoke:kernel-workers` installs the package, runs the demo room and fails unless kernels ran on the worker with no fallback. The `longtask` observer saw nothing in either mode because the browser does not count work run by a remote-debugging call, so the block is measured with a 20 ms timer. `scene_apply` edits still run on the main thread. Core did not grow (`entry:core`, `lit-box` unchanged); the lazy entries rose by about 900 bytes gzip.+ - Fix three gaps a demo film found in the recipe light bake (part of issue #55). A baked scene with `cloth` failed at render time for every frame after t=0 with "A light map needs lightUvs on rigid geometry, with no skin or morph", because the cloth simulation replaces the sheet's geometry each frame; cloth sheet nodes are now skipped and listed in `report.skipped`. The bake now lights with spot lights (the renderer's cone and soft edge) and area lights (front side only, one deterministic shadow ray to a point of the rectangle per hit), where it ignored both; a scene without them bakes the same bytes. The presets could not finish a normal scene (`standard` passed its 20 s limit on a 56 part room, `fine` hit the 30 s preview limit): a recipe bake now has a ray work budget of 10 million units (texels x samples x bounces x rays per hit), estimated from the unwrap before any ray is traced with no clock involved. A preset is scaled down to fit and `scene_inspect` `bake` reports `used` and `reduced`; explicit `samples`, `bounces` or `texelsPerUnit` are never reduced and fail with a message naming the number that fits. `bakeLightmaps` is now `planLightmaps`, `estimateBake` and `traceLightmaps` (still exported as one call). `entry:core` did not change; `entry:light-bake` grew by 1,033 bytes gzip (budget 25,900 to 26,900) and the lazy agent entries by about 1,580; the schema stayed within its total budget (the capability notes were shortened to fit).+ - Add `sculpt` and `shrinkwrap` mesh edits (part of issue #47; surface patches and a stack form are not built). `sculpt` applies up to 32 inflate, displace and smooth strokes to the vertices of the selected faces; `shrinkwrap` moves them onto a primitive, to the nearest point or projected along a direction, with an offset. Both are in `scene_capabilities` (`meshSculpt`) and in the `mesh_edit` schema, with the tool schema total unchanged (the face rule and tag prefix descriptions were shortened to pay for them). The stroke maths moved to `src/sculpt-strokes.js` and serves `sculptGeometry` too. Four Blender golden cases (two Shrinkwrap modifier comparisons; the sculpt reference runs the same brush formula on Blender's mesh), hostile input tests, and the suite task `ball-badge`, which needs a plate bent onto a ball.+- Add ragdolls (part of issue #96): `physics.ragdoll` in a recipe with armatures and `physics` in an asset recipe (`set-physics`) bind a capsule body to every bone or joint and play the fall back as the pose of those bones, the same bytes for the same seek. New `src/ragdoll.js`, loaded with the physics code only. New suite task `robot-ragdoll`. The lazy budgets of `agent-scene+lazy` and `agent-asset+lazy` rise by 100 and 800 bytes gzip for it; the core entries did not grow from this. Joints have no swing limits yet.- Add terrain holes and a recipe `terrain` geometry (part of issue #64; layers beyond four and the navmesh are not built). `createTerrain({ holes: [{ center: [x, z], radius }] })` leaves no surface where a cell centre is inside a circle, and `terrain.isHole(x, z)` answers for a point; without `holes` the seeded meshes are byte-identical (a digest test). A recipe geometry `{ type: "terrain", size, resolution, seed, amplitude, holes }` builds one seeded ground mesh with the same holes; it loads on demand through the new `terrain` module (core did not grow), the tool schema entry is one line with the fields in `scene_capabilities` `terrain`, and the schema total budget did not change (scene_create and scene_apply rose by a few hundred bytes, mesh_edit fell by the same amount). New suite task `terrain-hole-walk` (ground with a 3 m opening and a walker that has to go around it) with the checks `groundRelief` and `walkPath`. Measured: Haiku passed it 2 of 2 (9 and 6 tool calls, $0.29 in all) and both exported recipes used the `terrain` geometry; there was no control run without the feature, so this shows agents find it, not how many could do without.- Bake patterned, textured and emissive parts, and skip hair hosts (part of issue #128). A recipe `bake` used to skip every part with a pattern, a map or emission (31 parts, the floor and every wall, in the demo room) and failed `scene_create` with "Textured geometry requires UV channel 0" on a node that hosts hair. Those parts now keep `uvs` and their look and take the bounced light through a new `lightMap` material slot on a second UV set (`geometry.lightUvs`); the fragment shader adds `color * (1 - metallic) * lightMap * lightMapScale`, so a brick pattern tints its own bounced light. Hair and particle host nodes are skipped and listed in `report.skipped`. The shader branch compiles out of scenes with no light map; the renderer carries about 650 bytes of gzip for it in `entry:core` (see `docs/light-bake.md` for the measured sizes). GLB export writes `TEXCOORD_1` and the light map as the emissive texture (an approximation: glTF has no light map slot). The path tracer ignores baked maps by design. New reference scene `brick-room` (a recipe-built closed brick room).diff --cc bench/size/baseline.jsonindex 5ef009df,87410f8f..cc939b66--- a/bench/size/baseline.json+++ b/bench/size/baseline.json@@@ -14,9 -14,9 +14,9 @@@},"bundles": {"entry:core": {-- "min": 287420,-- "gzip": 82181,-- "brotli": 70138++ "min": 287483,++ "gzip": 82197,++ "brotli": 70063},"entry:model": {"min": 40093,@@@ -69,9 -69,9 +69,9 @@@"brotli": 12998},"entry:mesh": {- "min": 218339,- "gzip": 73718,- "brotli": 62495- "min": 224773,- "gzip": 75662,- "brotli": 64228++ "min": 226597,++ "gzip": 76567,++ "brotli": 64891},"entry:shrinkwrap": {"min": 56188,@@@ -144,24 -144,24 +144,24 @@@"brotli": 762},"entry:agent-scene": {- "min": 210130,- "gzip": 65170,- "brotli": 57066+ "min": 211468,- "gzip": 65703,- "brotli": 57500++ "gzip": 65707,++ "brotli": 57510},"entry:agent-scene+lazy": {- "min": 644038,- "gzip": 221802,- "brotli": 196072- "min": 656357,- "gzip": 225836,- "brotli": 199349++ "min": 658618,++ "gzip": 226965,++ "brotli": 200409},"entry:agent-asset": {- "min": 305436,- "gzip": 96859,- "brotli": 85071+ "min": 306775,+ "gzip": 97383,+ "brotli": 85592},"entry:agent-asset+lazy": {- "min": 681111,- "gzip": 233531,- "brotli": 205993- "min": 693431,- "gzip": 237556,- "brotli": 209425++ "min": 695692,++ "gzip": 238681,++ "brotli": 210403},"entry:hdri": {"min": 8075,@@@ -199,14 -199,14 +199,14 @@@"brotli": 71399},"scene:agent-scene": {- "min": 321299,- "gzip": 95954,- "brotli": 83554+ "min": 322662,+ "gzip": 96484,+ "brotli": 84041},"scene:agent-scene+lazy": {- "min": 755207,- "gzip": 252588,- "brotli": 222505- "min": 767546,- "gzip": 256611,- "brotli": 225945++ "min": 769807,++ "gzip": 257735,++ "brotli": 227012}}}diff --cc bench/size/budgets.jsonindex 78bfcc58,6ad39dc4..ceaecc3e--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@@ -17,7 -17,7 +17,7 @@@"entry:sculpt": 2500,"entry:surface": 10100,"entry:mesh-query": 15900,- "entry:mesh": 75200,- "entry:mesh": 76200,++ "entry:mesh": 78100,"entry:shrinkwrap": 18300,"entry:surface-attachment": 11800,"entry:physics": 18000,@@@ -29,13 -29,13 +29,13 @@@"entry:terrain": 3400,"entry:grass": 4400,"entry:clutter": 5300,- "entry:light-bake": 25900,- "entry:light-bake": 26900,++ "entry:light-bake": 27100,"entry:path-tracer": 13800,"entry:texture-set": 900,-- "entry:agent-scene": 66500,-- "entry:agent-scene+lazy": 226300,-- "entry:agent-asset": 98800,-- "entry:agent-asset+lazy": 238300,++ "entry:agent-scene": 67100,++ "entry:agent-scene+lazy": 231600,++ "entry:agent-asset": 99400,++ "entry:agent-asset+lazy": 243500,"entry:hdri": 3300,"entry:camera-effects": 8600,"entry:render-passes": 1700,@@@ -43,7 -43,7 +43,7 @@@"scene:lit-box": 61100,"scene:gltf-box": 81500,"scene:gltf-box+lazy": 83600,-- "scene:agent-scene": 97900,-- "scene:agent-scene+lazy": 257700++ "scene:agent-scene": 98500,++ "scene:agent-scene+lazy": 262900}}diff --cc src/agent-bake.jsindex ec9560f4,3536bda9..5143f3f7--- a/src/agent-bake.js+++ b/src/agent-bake.js@@@ -1,7 -1,8 +1,9 @@@- import { bakeLightmaps } from './light-bake.js';+ import { planLightmaps, estimateBake, traceLightmaps } from './light-bake.js';+import { runKernel } from './kernel-offload.js';import { knownKeys, finiteNumber } from './agent-recipe-checks.js';- import { BAKE_PRESETS, BAKE_RANGES, BAKE_MAXIMUM_SECONDS } from './agent-scene-capabilities.js';+ import { BAKE_PRESETS, BAKE_RANGES, BAKE_MAXIMUM_SECONDS, BAKE_RAY_WORK_BUDGET } from './agent-scene-capabilities.js';++ const PRESET_SAMPLES_FLOOR = 16;// Recipe `bake`: bounced light written into lightmaps when the scene builds. This module loads on demand, so scenes// without a bake never download the ray tracer.@@@ -43,21 -111,6 +112,25 @@@ function liveBakedMaterial(liveMaterialreturn Object.freeze(output);}+/**- * The light bake as a worker kernel: only the parts the bake changed travel back, as [index, part] pairs, because a- * part that was left alone is the caller's own object and has nothing to send.++ * The light bake as a worker kernel: unwrap, budget fit and trace all run in the same place, because unwrapping and++ * tracing are both the heavy parts. Only the parts the bake changed travel back, as [index, part] pairs, because a part++ * that was left alone is the caller's own object and has nothing to send. An explicit setting over the budget throws++ * the same RangeError here as it would inline, and the worker sends it back with its message.+ */- export function bakeChangedParts(snapshots, lighting, options) {- const { parts, report } = bakeLightmaps(snapshots, lighting, options);++export function bakeChangedParts(snapshots, lighting, settings) {++ const plan = planLightmaps(snapshots, lighting, { ...settings, maxSeconds: BAKE_MAXIMUM_SECONDS });++ const { used, reduced } = fitSettingsToBudget(plan, settings);++ const { parts, report } = traceLightmaps(plan, used);+ const changed = [];+ parts.forEach((part, index) => {+ if (part !== snapshots[index]) {+ changed.push([index, part]);+ }+ });- return { changed, report };++ return { changed, report, used, reduced };+}+/*** Bakes the parts at the world matrices given by name (a retained part's own matrix is only refreshed after a commit).* Returns the new parts, which share the originals' matrices so poses still move them, and a report: texels,@@@ -75,13 -130,11 +150,13 @@@ export function bakeAgentParts(parts, w...part,matrix: worldMatrices.get(part.name),material: { ...part.material },- generatesGeometry: generatedGeometryNames.has(part.name),+ generatesGeometry: generatedGeometryGenerators.get(part.name) ?? false,}));- const { changed, report } = runKernel('lightBake', [snapshots, lighting, { ...settings, maxSeconds: BAKE_MAXIMUM_SECONDS }], bakeChangedParts);- const plan = planLightmaps(snapshots, lighting, { ...settings, maxSeconds: BAKE_MAXIMUM_SECONDS });- const { used, reduced } = fitSettingsToBudget(plan, settings);- const { parts: bakedSnapshots, report } = traceLightmaps(plan, used);++ const { changed, report, used, reduced } = runKernel('lightBake', [snapshots, lighting, settings], bakeChangedParts);+ const bakedSnapshots = snapshots.slice();+ for (const [index, part] of changed) {+ bakedSnapshots[index] = part;+ }const bakedParts = parts.map((part, index) => {if (bakedSnapshots[index] === snapshots[index]) {return part;diff --cc tests/fixtures/demo-room.recipe.jsonindex 3a9a4079,00000000..dd11ff80mode 100644,000000..100644--- a/tests/fixtures/demo-room.recipe.json+++ b/tests/fixtures/demo-room.recipe.json@@@ -1,1 -1,0 +1,1 @@@- {"format":"67js.scene","schemaVersion":1,"geometries":[{"id":"box","type":"box","bevel":0.02},{"id":"sharp-box","type":"box","bevel":0},{"id":"ball","type":"sphere","segments":32,"rings":20},{"id":"lowball","type":"sphere","segments":10,"rings":6},{"id":"speck","type":"sphere","segments":6,"rings":4},{"id":"strand","type":"box","bevel":0},{"id":"rod","type":"cylinder","segments":32},{"id":"banner","type":"grid","segments":32},{"id":"sign-text","type":"text","text":"67js","size":1.5,"depth":0.18,"align":"center","curveSegments":10},{"id":"neon","type":"curve","radius":0.04,"resolution":20,"radialSegments":12,"points":[[3.1,0.64,-2.84],[3.3,1.1,-2.86],[2.95,1.8,-2.86],[2.4,2.3,-2.86],[2.1,2.55,-2.85],[1.95,2.62,-2.85]]},{"id":"column","type":"mesh","base":{"type":"extrude","depth":1.2,"steps":40,"bevel":0,"contour":[[0.1,0.26],[-0.1,0.26],[-0.1,0.1],[-0.26,0.1],[-0.26,-0.1],[-0.1,-0.1],[-0.1,-0.26],[0.1,-0.26],[0.1,-0.1],[0.26,-0.1],[0.26,0.1],[0.1,0.1]]},"stack":[{"op":"simple_deform","mode":"twist","axis":"z","angle":200}]},{"id":"cushion","type":"mesh","base":{"type":"box","bevel":0},"stack":[{"op":"subdivide","levels":3}]},{"id":"organiser","type":"mesh","base":{"type":"box","bevel":0.03},"edits":[{"op":"boolean","operation":"difference","name":"porthole","cutter":{"type":"cylinder","segments":40},"scale":[0.3,2,0.3],"rotation":[0.70710678,0,0,0.70710678]}]}],"materials":[{"id":"bricks","color":[1,1,1],"roughness":1,"pattern":{"type":"bricks","size":1.5,"count":6,"bump":1.8,"seed":4,"colors":[[0.08,0.03,0.025],[0.3,0.11,0.07],[0.2,0.17,0.15]]}},{"id":"plaster","color":[0.15,0.55,0.75],"roughness":1,"pattern":{"type":"concrete","size":2,"bump":0.5,"seed":9}},{"id":"floorwood","color":[1,1,1],"roughness":0.55,"pattern":{"type":"planks","size":1.3,"count":5,"bump":0.9,"seed":3,"colors":[[0.05,0.03,0.02],[0.2,0.11,0.065]]}},{"id":"beamwood","color":[0.8,0.7,0.65],"roughness":0.85,"pattern":{"type":"wood","size":0.7,"bump":0.5,"axis":"x"}},{"id":"benchwood","color":[1,1,1],"roughness":0.7,"pattern":{"type":"planks","size":0.9,"count":4,"bump":0.8,"seed":8,"colors":[[0.14,0.07,0.035],[0.4,0.21,0.1]]}},{"id":"board","color":[0.025,0.035,0.07],"roughness":0.55},{"id":"gold","color":[1,0.68,0.2],"metallic":1,"roughness":0.28,"emission":0.2,"emissiveColor":[1,0.55,0.1]},{"id":"brass","color":[0.65,0.45,0.2],"metallic":1,"roughness":0.4},{"id":"neon","color":[0.1,0.9,1],"emission":3.5,"emissiveColor":[0.1,0.85,1]},{"id":"plug","color":[0.03,0.03,0.035],"roughness":0.35},{"id":"steel","color":[0.38,0.4,0.45],"metallic":1,"roughness":0.32},{"id":"iron","color":[0.1,0.1,0.12],"metallic":1,"roughness":0.5},{"id":"stump","color":[0.7,0.55,0.45],"roughness":0.9,"pattern":{"type":"wood","size":0.5,"bump":0.7,"axis":"y"}},{"id":"rug","color":[0.42,0.45,0.45],"roughness":1,"pattern":{"type":"fabric","size":0.25,"bump":0.7,"colors":[[0.04,0.12,0.14],[0.55,0.3,0.08]]}},{"id":"plum","color":[0.4,0.07,0.2],"roughness":0.95},{"id":"teal","color":[0.03,0.4,0.38],"metallic":0.3,"roughness":0.3},{"id":"cloth","color":[0.55,0.5,0.5],"roughness":0.95,"doubleSided":true,"pattern":{"type":"fabric","size":0.18,"bump":0.9,"colors":[[0.25,0.02,0.04],[0.7,0.12,0.08]]}},{"id":"beachball","color":[0.9,0.62,0.1],"roughness":0.4},{"id":"glass","color":[0.85,0.95,1],"roughness":0.02,"transmission":1,"thickness":0.2,"ior":1.5},{"id":"ember","color":[1,0.55,0.12],"emission":6,"emissiveColor":[1,0.5,0.1]},{"id":"fur","color":[0.85,0.5,0.22],"roughness":1},{"id":"fur-tips","color":[0.95,0.72,0.42],"roughness":1},{"id":"furbase","color":[0.55,0.3,0.14],"roughness":1},{"id":"white","color":[0.9,0.9,0.88],"roughness":0.25},{"id":"black","color":[0.015,0.015,0.02],"roughness":0.15},{"id":"window","color":[0.05,0.15,0.5],"emission":0.9,"emissiveColor":[0.12,0.3,1]},{"id":"bulb","color":[1,0.8,0.5],"emission":6,"emissiveColor":[1,0.75,0.4]},{"id":"shade","color":[0.1,0.3,0.28],"roughness":0.5,"metallic":0.5},{"id":"ground","color":[0.03,0.025,0.035],"roughness":1},{"id":"plaster-warm","color":[0.85,0.32,0.14],"roughness":1,"pattern":{"type":"concrete","size":2,"bump":0.5,"seed":9}}],"nodes":[{"id":"floor","geometry":"box","material":"floorwood","translation":[0,-0.1,0.2],"scale":[9,0.2,6.2]},{"id":"ground","geometry":"sharp-box","material":"ground","translation":[0,-0.7,0],"scale":[60,1,60]},{"id":"back-wall","geometry":"sharp-box","material":"bricks","translation":[0,1.95,-3],"scale":[9.4,3.9,0.2]},{"id":"left-wall","geometry":"sharp-box","material":"plaster","translation":[-4.6,1.95,0.2],"scale":[0.2,3.9,6.2]},{"id":"right-wall","geometry":"sharp-box","material":"plaster-warm","translation":[4.6,1.95,0.2],"scale":[0.2,3.9,6.2]},{"id":"ceiling","geometry":"sharp-box","material":"beamwood","translation":[0,3.95,0.2],"scale":[9.4,0.1,6.2]},{"id":"beam-back","geometry":"box","material":"beamwood","translation":[0,3.72,-2.3],"scale":[9,0.24,0.3]},{"id":"beam-middle","geometry":"box","material":"beamwood","translation":[0,3.72,-0.4],"scale":[9,0.24,0.3]},{"id":"beam-front","geometry":"box","material":"beamwood","translation":[0,3.72,1.6],"scale":[9,0.24,0.3]},{"id":"window-pane","geometry":"sharp-box","material":"window","translation":[-4.47,2.3,-0.7],"scale":[0.03,1.3,1.1]},{"id":"window-top","geometry":"box","material":"beamwood","translation":[-4.44,2.98,-0.7],"scale":[0.1,0.1,1.3]},{"id":"window-bottom","geometry":"box","material":"beamwood","translation":[-4.44,1.62,-0.7],"scale":[0.14,0.1,1.3]},{"id":"window-left","geometry":"box","material":"beamwood","translation":[-4.44,2.3,-1.3],"scale":[0.1,1.4,0.1]},{"id":"window-right","geometry":"box","material":"beamwood","translation":[-4.44,2.3,-0.1],"scale":[0.1,1.4,0.1]},{"id":"window-bar","geometry":"box","material":"beamwood","translation":[-4.44,2.3,-0.7],"scale":[0.08,1.3,0.06]},{"id":"sign-frame","geometry":"box","material":"brass","translation":[0,2.75,-2.88],"scale":[4,2.1,0.08]},{"id":"sign-board","geometry":"box","material":"board","translation":[0,2.75,-2.84],"scale":[3.8,1.9,0.1]},{"id":"sign","geometry":"sign-text","material":"gold","translation":[0,2.34,-2.7]},{"id":"socket","geometry":"box","material":"iron","translation":[3.1,0.5,-2.86],"scale":[0.22,0.22,0.06]},{"id":"plug","geometry":"box","material":"plug","translation":[3.1,0.6,-2.82],"scale":[0.1,0.16,0.08]},{"id":"neon","geometry":"neon","material":"neon"},{"id":"bench-top","geometry":"box","material":"benchwood","translation":[0,0.85,-2.35],"scale":[3.6,0.1,1]},{"id":"bench-shelf","geometry":"box","material":"benchwood","translation":[0,0.3,-2.35],"scale":[3.3,0.06,0.8]},{"id":"leg-1","geometry":"box","material":"benchwood","translation":[-1.7,0.4,-1.95],"scale":[0.12,0.8,0.12]},{"id":"leg-2","geometry":"box","material":"benchwood","translation":[1.7,0.4,-1.95],"scale":[0.12,0.8,0.12]},{"id":"leg-3","geometry":"box","material":"benchwood","translation":[-1.7,0.4,-2.75],"scale":[0.12,0.8,0.12]},{"id":"leg-4","geometry":"box","material":"benchwood","translation":[1.7,0.4,-2.75],"scale":[0.12,0.8,0.12]},{"id":"cushion","geometry":"cushion","material":"plum","translation":[0,1.03,-2.3],"scale":[0.95,0.32,0.8]},{"id":"creature","geometry":"ball","material":"furbase","translation":[0,1.36,-2.3],"scale":[0.3,0.29,0.3]},{"id":"fur","geometry":"strand","material":"fur"},{"id":"fur-tips","geometry":"strand","material":"fur-tips"},{"id":"eye-left","geometry":"ball","material":"white","translation":[-0.1,1.42,-2.03],"scale":[0.075,0.075,0.075]},{"id":"eye-right","geometry":"ball","material":"white","translation":[0.1,1.42,-2.03],"scale":[0.075,0.075,0.075]},{"id":"pupil-left","geometry":"lowball","material":"black","translation":[-0.1,1.42,-1.96],"scale":[0.04,0.04,0.04]},{"id":"pupil-right","geometry":"lowball","material":"black","translation":[0.1,1.42,-1.96],"scale":[0.04,0.04,0.04]},{"id":"organiser","geometry":"organiser","material":"benchwood","translation":[1.2,1.1,-2.35],"scale":[0.4,0.4,0.4]},{"id":"bench-marble","geometry":"ball","material":"glass","translation":[1.65,1,-2.2],"scale":[0.1,0.1,0.1]},{"id":"lamp-base","geometry":"rod","material":"iron","translation":[-1.3,0.93,-2.3],"scale":[0.14,0.04,0.14]},{"id":"lamp-arm","geometry":"rod","material":"iron","translation":[-1.3,1.17,-2.3],"scale":[0.015,0.45,0.015]},{"id":"lamp-shade","geometry":"ball","material":"shade","translation":[-1.3,1.42,-2.3],"scale":[0.15,0.09,0.15]},{"id":"lamp-bulb","geometry":"ball","material":"bulb","translation":[-1.3,1.34,-2.3],"scale":[0.06,0.06,0.06]},{"id":"column","geometry":"column","material":"teal","translation":[-2.8,0,-2.3],"scale":[1,1,1],"rotation":[-0.70710678,0,0,0.70710678]},{"id":"column-marble","geometry":"ball","material":"glass","translation":[-2.8,1.33,-2.3],"scale":[0.13,0.13,0.13]},{"id":"pole","geometry":"rod","material":"brass","translation":[-3.35,3.32,-2.72],"scale":[0.035,1.5,0.035],"rotation":[0,0,0.70710678,0.70710678]},{"id":"pole-end-left","geometry":"ball","material":"brass","translation":[-4.1,3.32,-2.72],"scale":[0.06,0.06,0.06]},{"id":"pole-end-right","geometry":"ball","material":"brass","translation":[-2.6,3.32,-2.72],"scale":[0.06,0.06,0.06]},{"id":"banner","geometry":"banner","material":"cloth","translation":[-3.35,1.97,-2.7],"scale":[1.3,2.7,1]},{"id":"banner-ball","geometry":"ball","material":"beachball","translation":[-3.35,0.35,-2.58],"scale":[0.35,0.35,0.35]},{"id":"stump","geometry":"rod","material":"stump","translation":[2,0.22,-0.8],"scale":[0.36,0.44,0.36]},{"id":"anvil-waist","geometry":"box","material":"iron","translation":[2,0.52,-0.8],"scale":[0.2,0.16,0.16]},{"id":"anvil-top","geometry":"box","material":"steel","translation":[2,0.65,-0.8],"scale":[0.56,0.1,0.26]},{"id":"sparks","geometry":"speck","material":"ember"},{"id":"rug","geometry":"sharp-box","material":"rug","translation":[0.1,0.012,-0.6],"scale":[3.8,0.024,2.6]},{"id":"pendant","translation":[2.7,3.6,-1.4]},{"id":"pendant-cord","geometry":"rod","material":"iron","translation":[0,-0.4,0],"scale":[0.012,0.8,0.012],"parent":"pendant"},{"id":"pendant-shade","geometry":"ball","material":"shade","translation":[0,-0.9,0],"scale":[0.28,0.2,0.28],"parent":"pendant"},{"id":"pendant-bulb","geometry":"ball","material":"bulb","translation":[0,-0.95,0],"scale":[0.1,0.1,0.1],"parent":"pendant"}],"camera":{"eye":[1.4,2.1,7],"target":[0,1.6,-2],"fov":50},"environment":{"setup":"sunset","environmentIntensity":0.08,"keyIntensity":0.35,"keyColor":[1,0.6,0.35],"fillIntensity":0.03,"lightDirection":[0.4,0.7,0.9],"fogDensity":0,"pointLights":[{"position":[2.7,2.65,-1.4],"color":[1,0.72,0.4],"intensity":14,"radius":0.1,"range":7},{"position":[-1.3,1.3,-2.2],"color":[1,0.7,0.4],"intensity":4,"radius":0.08,"range":4},{"position":[2,1,-0.7],"color":[1,0.5,0.15],"intensity":6,"radius":0.1,"range":3.5},{"position":[2.6,1.5,-2.5],"color":[0.1,0.8,1],"intensity":3.5,"radius":0.1,"range":3.5},{"position":[3.1,0.8,-2.4],"color":[0.1,0.8,1],"intensity":1.5,"radius":0.05,"range":1.6},{"position":[-3.9,2.3,-0.7],"color":[0.45,0.62,1],"intensity":7,"radius":0.25,"range":8}],"spotLights":[{"position":[1.6,3.4,3],"direction":[-1.5,-2,-5.3],"angle":0.5,"penumbra":0.7,"color":[1,0.72,0.45],"intensity":120,"castShadow":true},{"position":[0.2,3.55,-0.6],"direction":[0,-0.5,-1],"angle":0.55,"penumbra":0.7,"color":[1,0.78,0.5],"intensity":28},{"position":[4,2.4,2.6],"direction":[-1,-0.35,-1],"angle":0.7,"penumbra":0.8,"color":[0.4,0.55,1],"intensity":30}],"areaLights":[{"position":[-4.2,2.3,-0.7],"direction":[1,-0.1,0.1],"up":[0,1,0],"width":1.1,"height":1.3,"color":[0.4,0.55,1],"intensity":45}]},"effects":{"exposure":1,"saturation":0.9,"contrast":1.1,"vignette":0.3,"ambientOcclusion":0.6,"ambientOcclusionRadius":0.7,"bloom":{"strength":0.15,"threshold":1,"radius":0.5}},"shadow":{"target":[0,1.2,-1.2],"extent":5,"distance":9,"far":20},"particles":{"wind":[0.3,0,0],"systems":[{"node":"sparks","seed":7,"count":1100,"rate":100,"lifetime":[1,1.9],"speed":[1.6,3.2],"spread":42,"size":0.03,"drag":0.25,"floor":0,"scale":"shrink","emitter":{"shape":"disc","position":[2,0.74,-0.8],"radius":0.06}},{"type":"hair","node":"fur","surface":"creature","seed":5,"count":1900,"length":[0.05,0.1],"segments":4,"width":0.012,"droop":0.6,"lean":0.2,"sway":0.02,"swayRate":0.6},{"type":"hair","node":"fur-tips","surface":"creature","seed":11,"count":1000,"length":[0.07,0.12],"segments":4,"width":0.01,"droop":0.7,"lean":0.25,"sway":0.025,"swayRate":0.5}]},"motion":{"duration":12,"loop":false,"tracks":[{"kind":"camera","property":"eye","interpolation":"LINEAR","keyframes":[{"time":0,"value":[1.4,2.1,7]},{"time":4.39,"value":[0.5,1.95,5.5]},{"time":4.4,"value":[-1.5,1.7,2.2]},{"time":7.99,"value":[0.2,1.75,1.7]},{"time":8,"value":[3.9,0.35,2.8]},{"time":12,"value":[3,0.42,2]}]},{"kind":"camera","property":"target","interpolation":"LINEAR","keyframes":[{"time":0,"value":[0,1.6,-2]},{"time":4.39,"value":[0,1.7,-2]},{"time":4.4,"value":[0.2,1.8,-2.5]},{"time":7.99,"value":[0.1,1.9,-2.5]},{"time":8,"value":[0.3,1.5,-2.3]},{"time":12,"value":[0.1,1.55,-2.3]}]},{"kind":"camera","property":"fov","interpolation":"LINEAR","keyframes":[{"time":0,"value":50},{"time":4.39,"value":50},{"time":4.4,"value":42},{"time":7.99,"value":42},{"time":8,"value":55},{"time":12,"value":55}]},{"kind":"node","id":"pendant","property":"rotation","interpolation":"SMOOTH","keyframes":[{"time":0,"value":[0,0,0.02617694830787315,0.9996573249755573]},{"time":1.5,"value":[0,0,-0.02617694830787315,0.9996573249755573]},{"time":3,"value":[0,0,0.02617694830787315,0.9996573249755573]},{"time":4.5,"value":[0,0,-0.02617694830787315,0.9996573249755573]},{"time":6,"value":[0,0,0.02617694830787315,0.9996573249755573]},{"time":7.5,"value":[0,0,-0.02617694830787315,0.9996573249755573]},{"time":9,"value":[0,0,0.02617694830787315,0.9996573249755573]},{"time":10.5,"value":[0,0,-0.02617694830787315,0.9996573249755573]},{"time":12,"value":[0,0,0.02617694830787315,0.9996573249755573]}]}]},"timeline":{"shots":[{"name":"wide","duration":4.4},{"name":"sign-close","duration":3.6},{"name":"sparks-low","duration":4,"dip":0.9}]},"bake":{"preset":"draft","samples":96,"bounces":2,"texelsPerUnit":3}}++{"format":"67js.scene","schemaVersion":1,"geometries":[{"id":"box","type":"box","bevel":0.02},{"id":"sharp-box","type":"box","bevel":0},{"id":"ball","type":"sphere","segments":32,"rings":20},{"id":"lowball","type":"sphere","segments":10,"rings":6},{"id":"speck","type":"sphere","segments":6,"rings":4},{"id":"strand","type":"box","bevel":0},{"id":"rod","type":"cylinder","segments":32},{"id":"banner","type":"grid","segments":32},{"id":"sign-text","type":"text","text":"67js","size":1.5,"depth":0.18,"align":"center","curveSegments":10},{"id":"neon","type":"curve","radius":0.04,"resolution":20,"radialSegments":12,"points":[[3.1,0.64,-2.84],[3.3,1.1,-2.86],[2.95,1.8,-2.86],[2.4,2.3,-2.86],[2.1,2.55,-2.85],[1.95,2.62,-2.85]]},{"id":"column","type":"mesh","base":{"type":"extrude","depth":1.2,"steps":40,"bevel":0,"contour":[[0.1,0.26],[-0.1,0.26],[-0.1,0.1],[-0.26,0.1],[-0.26,-0.1],[-0.1,-0.1],[-0.1,-0.26],[0.1,-0.26],[0.1,-0.1],[0.26,-0.1],[0.26,0.1],[0.1,0.1]]},"stack":[{"op":"simple_deform","mode":"twist","axis":"z","angle":200}]},{"id":"cushion","type":"mesh","base":{"type":"box","bevel":0},"stack":[{"op":"subdivide","levels":3}]},{"id":"organiser","type":"mesh","base":{"type":"box","bevel":0.03},"edits":[{"op":"boolean","operation":"difference","name":"porthole","cutter":{"type":"cylinder","segments":40},"scale":[0.3,2,0.3],"rotation":[0.70710678,0,0,0.70710678]}]}],"materials":[{"id":"bricks","color":[1,1,1],"roughness":1,"pattern":{"type":"bricks","size":1.5,"count":6,"bump":1.8,"seed":4,"colors":[[0.08,0.03,0.025],[0.3,0.11,0.07],[0.2,0.17,0.15]]}},{"id":"plaster","color":[0.15,0.55,0.75],"roughness":1,"pattern":{"type":"concrete","size":2,"bump":0.5,"seed":9}},{"id":"floorwood","color":[1,1,1],"roughness":0.55,"pattern":{"type":"planks","size":1.3,"count":5,"bump":0.9,"seed":3,"colors":[[0.05,0.03,0.02],[0.2,0.11,0.065]]}},{"id":"beamwood","color":[0.8,0.7,0.65],"roughness":0.85,"pattern":{"type":"wood","size":0.7,"bump":0.5,"axis":"x"}},{"id":"benchwood","color":[1,1,1],"roughness":0.7,"pattern":{"type":"planks","size":0.9,"count":4,"bump":0.8,"seed":8,"colors":[[0.14,0.07,0.035],[0.4,0.21,0.1]]}},{"id":"board","color":[0.025,0.035,0.07],"roughness":0.55},{"id":"gold","color":[1,0.68,0.2],"metallic":1,"roughness":0.28,"emission":0.2,"emissiveColor":[1,0.55,0.1]},{"id":"brass","color":[0.65,0.45,0.2],"metallic":1,"roughness":0.4},{"id":"neon","color":[0.1,0.9,1],"emission":3.5,"emissiveColor":[0.1,0.85,1]},{"id":"plug","color":[0.03,0.03,0.035],"roughness":0.35},{"id":"steel","color":[0.38,0.4,0.45],"metallic":1,"roughness":0.32},{"id":"iron","color":[0.1,0.1,0.12],"metallic":1,"roughness":0.5},{"id":"stump","color":[0.7,0.55,0.45],"roughness":0.9,"pattern":{"type":"wood","size":0.5,"bump":0.7,"axis":"y"}},{"id":"rug","color":[0.42,0.45,0.45],"roughness":1,"pattern":{"type":"fabric","size":0.25,"bump":0.7,"colors":[[0.04,0.12,0.14],[0.55,0.3,0.08]]}},{"id":"plum","color":[0.4,0.07,0.2],"roughness":0.95},{"id":"teal","color":[0.03,0.4,0.38],"metallic":0.3,"roughness":0.3},{"id":"cloth","color":[0.55,0.5,0.5],"roughness":0.95,"doubleSided":true,"pattern":{"type":"fabric","size":0.18,"bump":0.9,"colors":[[0.25,0.02,0.04],[0.7,0.12,0.08]]}},{"id":"beachball","color":[0.9,0.62,0.1],"roughness":0.4},{"id":"glass","color":[0.85,0.95,1],"roughness":0.02,"transmission":1,"thickness":0.2,"ior":1.5},{"id":"ember","color":[1,0.55,0.12],"emission":6,"emissiveColor":[1,0.5,0.1]},{"id":"fur","color":[0.85,0.5,0.22],"roughness":1},{"id":"fur-tips","color":[0.95,0.72,0.42],"roughness":1},{"id":"furbase","color":[0.55,0.3,0.14],"roughness":1},{"id":"white","color":[0.9,0.9,0.88],"roughness":0.25},{"id":"black","color":[0.015,0.015,0.02],"roughness":0.15},{"id":"window","color":[0.05,0.15,0.5],"emission":0.9,"emissiveColor":[0.12,0.3,1]},{"id":"bulb","color":[1,0.8,0.5],"emission":6,"emissiveColor":[1,0.75,0.4]},{"id":"shade","color":[0.1,0.3,0.28],"roughness":0.5,"metallic":0.5},{"id":"ground","color":[0.03,0.025,0.035],"roughness":1},{"id":"plaster-warm","color":[0.85,0.32,0.14],"roughness":1,"pattern":{"type":"concrete","size":2,"bump":0.5,"seed":9}}],"nodes":[{"id":"floor","geometry":"box","material":"floorwood","translation":[0,-0.1,0.2],"scale":[9,0.2,6.2]},{"id":"ground","geometry":"sharp-box","material":"ground","translation":[0,-0.7,0],"scale":[60,1,60]},{"id":"back-wall","geometry":"sharp-box","material":"bricks","translation":[0,1.95,-3],"scale":[9.4,3.9,0.2]},{"id":"left-wall","geometry":"sharp-box","material":"plaster","translation":[-4.6,1.95,0.2],"scale":[0.2,3.9,6.2]},{"id":"right-wall","geometry":"sharp-box","material":"plaster-warm","translation":[4.6,1.95,0.2],"scale":[0.2,3.9,6.2]},{"id":"ceiling","geometry":"sharp-box","material":"beamwood","translation":[0,3.95,0.2],"scale":[9.4,0.1,6.2]},{"id":"beam-back","geometry":"box","material":"beamwood","translation":[0,3.72,-2.3],"scale":[9,0.24,0.3]},{"id":"beam-middle","geometry":"box","material":"beamwood","translation":[0,3.72,-0.4],"scale":[9,0.24,0.3]},{"id":"beam-front","geometry":"box","material":"beamwood","translation":[0,3.72,1.6],"scale":[9,0.24,0.3]},{"id":"window-pane","geometry":"sharp-box","material":"window","translation":[-4.47,2.3,-0.7],"scale":[0.03,1.3,1.1]},{"id":"window-top","geometry":"box","material":"beamwood","translation":[-4.44,2.98,-0.7],"scale":[0.1,0.1,1.3]},{"id":"window-bottom","geometry":"box","material":"beamwood","translation":[-4.44,1.62,-0.7],"scale":[0.14,0.1,1.3]},{"id":"window-left","geometry":"box","material":"beamwood","translation":[-4.44,2.3,-1.3],"scale":[0.1,1.4,0.1]},{"id":"window-right","geometry":"box","material":"beamwood","translation":[-4.44,2.3,-0.1],"scale":[0.1,1.4,0.1]},{"id":"window-bar","geometry":"box","material":"beamwood","translation":[-4.44,2.3,-0.7],"scale":[0.08,1.3,0.06]},{"id":"sign-frame","geometry":"box","material":"brass","translation":[0,2.75,-2.88],"scale":[4,2.1,0.08]},{"id":"sign-board","geometry":"box","material":"board","translation":[0,2.75,-2.84],"scale":[3.8,1.9,0.1]},{"id":"sign","geometry":"sign-text","material":"gold","translation":[0,2.34,-2.7]},{"id":"socket","geometry":"box","material":"iron","translation":[3.1,0.5,-2.86],"scale":[0.22,0.22,0.06]},{"id":"plug","geometry":"box","material":"plug","translation":[3.1,0.6,-2.82],"scale":[0.1,0.16,0.08]},{"id":"neon","geometry":"neon","material":"neon"},{"id":"bench-top","geometry":"box","material":"benchwood","translation":[0,0.85,-2.35],"scale":[3.6,0.1,1]},{"id":"bench-shelf","geometry":"box","material":"benchwood","translation":[0,0.3,-2.35],"scale":[3.3,0.06,0.8]},{"id":"leg-1","geometry":"box","material":"benchwood","translation":[-1.7,0.4,-1.95],"scale":[0.12,0.8,0.12]},{"id":"leg-2","geometry":"box","material":"benchwood","translation":[1.7,0.4,-1.95],"scale":[0.12,0.8,0.12]},{"id":"leg-3","geometry":"box","material":"benchwood","translation":[-1.7,0.4,-2.75],"scale":[0.12,0.8,0.12]},{"id":"leg-4","geometry":"box","material":"benchwood","translation":[1.7,0.4,-2.75],"scale":[0.12,0.8,0.12]},{"id":"cushion","geometry":"cushion","material":"plum","translation":[0,1.03,-2.3],"scale":[0.95,0.32,0.8]},{"id":"creature","geometry":"ball","material":"furbase","translation":[0,1.36,-2.3],"scale":[0.3,0.29,0.3]},{"id":"fur","geometry":"strand","material":"fur"},{"id":"fur-tips","geometry":"strand","material":"fur-tips"},{"id":"eye-left","geometry":"ball","material":"white","translation":[-0.1,1.42,-2.03],"scale":[0.075,0.075,0.075]},{"id":"eye-right","geometry":"ball","material":"white","translation":[0.1,1.42,-2.03],"scale":[0.075,0.075,0.075]},{"id":"pupil-left","geometry":"lowball","material":"black","translation":[-0.1,1.42,-1.96],"scale":[0.04,0.04,0.04]},{"id":"pupil-right","geometry":"lowball","material":"black","translation":[0.1,1.42,-1.96],"scale":[0.04,0.04,0.04]},{"id":"organiser","geometry":"organiser","material":"benchwood","translation":[1.2,1.1,-2.35],"scale":[0.4,0.4,0.4]},{"id":"bench-marble","geometry":"ball","material":"glass","translation":[1.65,1,-2.2],"scale":[0.1,0.1,0.1]},{"id":"lamp-base","geometry":"rod","material":"iron","translation":[-1.3,0.93,-2.3],"scale":[0.14,0.04,0.14]},{"id":"lamp-arm","geometry":"rod","material":"iron","translation":[-1.3,1.17,-2.3],"scale":[0.015,0.45,0.015]},{"id":"lamp-shade","geometry":"ball","material":"shade","translation":[-1.3,1.42,-2.3],"scale":[0.15,0.09,0.15]},{"id":"lamp-bulb","geometry":"ball","material":"bulb","translation":[-1.3,1.34,-2.3],"scale":[0.06,0.06,0.06]},{"id":"column","geometry":"column","material":"teal","translation":[-2.8,0,-2.3],"scale":[1,1,1],"rotation":[-0.70710678,0,0,0.70710678]},{"id":"column-marble","geometry":"ball","material":"glass","translation":[-2.8,1.33,-2.3],"scale":[0.13,0.13,0.13]},{"id":"pole","geometry":"rod","material":"brass","translation":[-3.35,3.32,-2.72],"scale":[0.035,1.5,0.035],"rotation":[0,0,0.70710678,0.70710678]},{"id":"pole-end-left","geometry":"ball","material":"brass","translation":[-4.1,3.32,-2.72],"scale":[0.06,0.06,0.06]},{"id":"pole-end-right","geometry":"ball","material":"brass","translation":[-2.6,3.32,-2.72],"scale":[0.06,0.06,0.06]},{"id":"banner","geometry":"banner","material":"cloth","translation":[-3.35,1.97,-2.7],"scale":[1.3,2.7,1]},{"id":"banner-ball","geometry":"ball","material":"beachball","translation":[-3.35,0.35,-2.58],"scale":[0.35,0.35,0.35]},{"id":"stump","geometry":"rod","material":"stump","translation":[2,0.22,-0.8],"scale":[0.36,0.44,0.36]},{"id":"anvil-waist","geometry":"box","material":"iron","translation":[2,0.52,-0.8],"scale":[0.2,0.16,0.16]},{"id":"anvil-top","geometry":"box","material":"steel","translation":[2,0.65,-0.8],"scale":[0.56,0.1,0.26]},{"id":"sparks","geometry":"speck","material":"ember"},{"id":"rug","geometry":"sharp-box","material":"rug","translation":[0.1,0.012,-0.6],"scale":[3.8,0.024,2.6]},{"id":"pendant","translation":[2.7,3.6,-1.4]},{"id":"pendant-cord","geometry":"rod","material":"iron","translation":[0,-0.4,0],"scale":[0.012,0.8,0.012],"parent":"pendant"},{"id":"pendant-shade","geometry":"ball","material":"shade","translation":[0,-0.9,0],"scale":[0.28,0.2,0.28],"parent":"pendant"},{"id":"pendant-bulb","geometry":"ball","material":"bulb","translation":[0,-0.95,0],"scale":[0.1,0.1,0.1],"parent":"pendant"}],"camera":{"eye":[1.4,2.1,7],"target":[0,1.6,-2],"fov":50},"environment":{"setup":"sunset","environmentIntensity":0.08,"keyIntensity":0.35,"keyColor":[1,0.6,0.35],"fillIntensity":0.03,"lightDirection":[0.4,0.7,0.9],"fogDensity":0,"pointLights":[{"position":[2.7,2.65,-1.4],"color":[1,0.72,0.4],"intensity":14,"radius":0.1,"range":7},{"position":[-1.3,1.3,-2.2],"color":[1,0.7,0.4],"intensity":4,"radius":0.08,"range":4},{"position":[2,1,-0.7],"color":[1,0.5,0.15],"intensity":6,"radius":0.1,"range":3.5},{"position":[2.6,1.5,-2.5],"color":[0.1,0.8,1],"intensity":3.5,"radius":0.1,"range":3.5},{"position":[3.1,0.8,-2.4],"color":[0.1,0.8,1],"intensity":1.5,"radius":0.05,"range":1.6},{"position":[-3.9,2.3,-0.7],"color":[0.45,0.62,1],"intensity":7,"radius":0.25,"range":8}],"spotLights":[{"position":[1.6,3.4,3],"direction":[-1.5,-2,-5.3],"angle":0.5,"penumbra":0.7,"color":[1,0.72,0.45],"intensity":120,"castShadow":true},{"position":[0.2,3.55,-0.6],"direction":[0,-0.5,-1],"angle":0.55,"penumbra":0.7,"color":[1,0.78,0.5],"intensity":28},{"position":[4,2.4,2.6],"direction":[-1,-0.35,-1],"angle":0.7,"penumbra":0.8,"color":[0.4,0.55,1],"intensity":30}],"areaLights":[{"position":[-4.2,2.3,-0.7],"direction":[1,-0.1,0.1],"up":[0,1,0],"width":1.1,"height":1.3,"color":[0.4,0.55,1],"intensity":45}]},"effects":{"exposure":1,"saturation":0.9,"contrast":1.1,"vignette":0.3,"ambientOcclusion":0.6,"ambientOcclusionRadius":0.7,"bloom":{"strength":0.15,"threshold":1,"radius":0.5}},"shadow":{"target":[0,1.2,-1.2],"extent":5,"distance":9,"far":20},"particles":{"wind":[0.3,0,0],"systems":[{"node":"sparks","seed":7,"count":1100,"rate":100,"lifetime":[1,1.9],"speed":[1.6,3.2],"spread":42,"size":0.03,"drag":0.25,"floor":0,"scale":"shrink","emitter":{"shape":"disc","position":[2,0.74,-0.8],"radius":0.06}},{"type":"hair","node":"fur","surface":"creature","seed":5,"count":1900,"length":[0.05,0.1],"segments":4,"width":0.012,"droop":0.6,"lean":0.2,"sway":0.02,"swayRate":0.6},{"type":"hair","node":"fur-tips","surface":"creature","seed":11,"count":1000,"length":[0.07,0.12],"segments":4,"width":0.01,"droop":0.7,"lean":0.25,"sway":0.025,"swayRate":0.5}]},"motion":{"duration":12,"loop":false,"tracks":[{"kind":"camera","property":"eye","interpolation":"LINEAR","keyframes":[{"time":0,"value":[1.4,2.1,7]},{"time":4.39,"value":[0.5,1.95,5.5]},{"time":4.4,"value":[-1.5,1.7,2.2]},{"time":7.99,"value":[0.2,1.75,1.7]},{"time":8,"value":[3.9,0.35,2.8]},{"time":12,"value":[3,0.42,2]}]},{"kind":"camera","property":"target","interpolation":"LINEAR","keyframes":[{"time":0,"value":[0,1.6,-2]},{"time":4.39,"value":[0,1.7,-2]},{"time":4.4,"value":[0.2,1.8,-2.5]},{"time":7.99,"value":[0.1,1.9,-2.5]},{"time":8,"value":[0.3,1.5,-2.3]},{"time":12,"value":[0.1,1.55,-2.3]}]},{"kind":"camera","property":"fov","interpolation":"LINEAR","keyframes":[{"time":0,"value":50},{"time":4.39,"value":50},{"time":4.4,"value":42},{"time":7.99,"value":42},{"time":8,"value":55},{"time":12,"value":55}]},{"kind":"node","id":"pendant","property":"rotation","interpolation":"SMOOTH","keyframes":[{"time":0,"value":[0,0,0.02617694830787315,0.9996573249755573]},{"time":1.5,"value":[0,0,-0.02617694830787315,0.9996573249755573]},{"time":3,"value":[0,0,0.02617694830787315,0.9996573249755573]},{"time":4.5,"value":[0,0,-0.02617694830787315,0.9996573249755573]},{"time":6,"value":[0,0,0.02617694830787315,0.9996573249755573]},{"time":7.5,"value":[0,0,-0.02617694830787315,0.9996573249755573]},{"time":9,"value":[0,0,0.02617694830787315,0.9996573249755573]},{"time":10.5,"value":[0,0,-0.02617694830787315,0.9996573249755573]},{"time":12,"value":[0,0,0.02617694830787315,0.9996573249755573]}]}]},"timeline":{"shots":[{"name":"wide","duration":4.4},{"name":"sign-close","duration":3.6},{"name":"sparks-low","duration":4,"dip":0.9}]},"bake":{"preset":"draft"}}diff --cc tests/kernel-offload.test.jsindex 562d584d,00000000..99250c27mode 100644,000000..100644--- a/tests/kernel-offload.test.js+++ b/tests/kernel-offload.test.js@@@ -1,99 -1,0 +1,115 @@@+import assert from 'node:assert/strict';+import { execFileSync } from 'node:child_process';+import test from 'node:test';+import { createAgentScene } from '../src/agent-scene.js';+import { buildWithKernels, kernelKey, runKernel } from '../src/kernel-offload.js';+import { answerKernelRequest } from '../src/kernel-registry.js';- import { kernelRoom, sceneDigest } from './support/kernel-offload-fixture.mjs';++import { createInProcessWorker, kernelRoom, sceneDigest } from './support/kernel-offload-fixture.mjs';++const BUILD_SCRIPT = new URL('./support/kernel-offload-build.mjs', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1');+const LOADER = new URL('./support/load-agent-scene-modules.mjs', import.meta.url).href;++// Each build runs in its own process so that nothing an earlier build cached (mesh evaluation, pattern textures) can+// stand in for the kernel under test.+function coldBuild(mode) {+ const output = execFileSync(process.execPath, ['--import', LOADER, BUILD_SCRIPT, mode], { encoding: 'utf8' });+ return JSON.parse(output.trim().split('\n').at(-1));+}++const inlineBuild = coldBuild('inline');++test('the same recipe builds to the same bytes on one thread and with kernels on a worker', () => {+ const workerBuild = coldBuild('worker');+ assert.equal(workerBuild.digest, inlineBuild.digest);+ for (const kernel of ['uvUnwrap', 'lightBake', 'cloth', 'pattern']) {+ assert.ok(workerBuild.requestedKernels.includes(kernel), `the ${kernel} kernel ran on the worker`);+ }+ assert.deepEqual(inlineBuild.requestedKernels, []);+});++test('a host without workers builds inline', async () => {+ const requested = [];+ const scene = await buildWithKernels(() => createAgentScene(kernelRoom()), {+ createWorker: () => { requested.push('started'); return {}; },+ available: false,+ });+ assert.deepEqual(requested, []);+ assert.equal(sceneDigest(scene), inlineBuild.digest);+});++test('a worker that cannot start leaves the work to the inline path with the same result', async () => {+ const scene = await buildWithKernels(() => createAgentScene(kernelRoom()), {+ createWorker: () => { throw new Error('no workers here'); },+ available: true,+ });+ assert.equal(sceneDigest(scene), inlineBuild.digest);+});++test('a worker that dies mid-job leaves the work to the inline path with the same result', async () => {+ const dying = {+ postMessage() {+ setTimeout(() => dying.onerror?.({ message: 'crashed' }), 0);+ },+ terminate() {},+ };+ const scene = await buildWithKernels(() => createAgentScene(kernelRoom()), { createWorker: () => dying, available: true });+ assert.equal(sceneDigest(scene), inlineBuild.digest);+});++test('an error a kernel raises on the worker comes back as the same class and message', async () => {+ const raised = answerKernelRequest({ name: 'pattern', args: [{ type: 'nope' }] });+ assert.equal(raised.response.error.name, 'TypeError');+ assert.equal(typeof raised.response.error.message, 'string');+ const raising = {+ postMessage() {+ setTimeout(() => raising.onmessage?.({ data: { error: { name: 'RangeError', message: 'Light bake passed maxSeconds (20).' } } }), 0);+ },+ terminate() {},+ };+ await assert.rejects(+ buildWithKernels(() => runKernel('lightBake', [[], {}, {}], () => 'inline'), { createWorker: () => raising, available: true }),+ error => error instanceof RangeError && error.message === 'Light bake passed maxSeconds (20).',+ );+});+++test('an explicit bake setting over the budget fails on the worker with the message that names numbers that fit', async () => {++ const heavyRoom = () => ({ ...kernelRoom(), bake: { preset: 'draft', samples: 256, bounces: 3, texelsPerUnit: 12 } });++ let inlineMessage = '';++ assert.throws(() => createAgentScene(heavyRoom()), error => {++ inlineMessage = error.message;++ return error instanceof RangeError;++ });++ assert.match(inlineMessage, /samples \d+ or fewer/);++ const requestedKernels = [];++ await assert.rejects(++ buildWithKernels(() => createAgentScene(heavyRoom()), { createWorker: () => createInProcessWorker(requestedKernels), available: true }),++ error => error instanceof RangeError && error.message === inlineMessage,++ );++ assert.ok(requestedKernels.includes('lightBake'), 'the budget check ran inside the worker kernel');++});+++test('cancelling stops the build and ends the worker', async () => {+ const silent = { terminated: false, postMessage() {}, terminate() { silent.terminated = true; } };+ const controller = new AbortController();+ const pending = buildWithKernels(() => runKernel('pattern', [{ size: 1 }], () => 'inline'), {+ createWorker: () => silent,+ available: true,+ signal: controller.signal,+ });+ setTimeout(() => controller.abort(), 5);+ await assert.rejects(pending, error => error.name === 'AbortError');+ assert.equal(silent.terminated, true);+});++test('kernel keys follow the bytes of the input and refuse data that cannot be cloned', () => {+ const positions = new Float32Array([1, 2, 3]);+ assert.equal(kernelKey('cloth', [positions, { a: 1 }]), kernelKey('cloth', [new Float32Array([1, 2, 3]), { a: 1 }]));+ assert.notEqual(kernelKey('cloth', [positions]), kernelKey('cloth', [new Float32Array([1, 2, 4])]));+ assert.notEqual(kernelKey('cloth', [positions]), kernelKey('pattern', [positions]));+ assert.equal(kernelKey('cloth', [() => 1]), null);+ assert.equal(kernelKey('cloth', [new Map()]), null);+});++test('without a session a kernel computes inline', () => {+ assert.equal(runKernel('pattern', [2, 3], (left, right) => left + right), 5);+});