3D engine that AI agents drive
Skills: rewrite build-67js-scene and render-67js-media for MCP agents (issue #649)
Nguyen Xuan An471705653d82
diff --git a/README.md b/README.mdindex 77451f6c..195e7dbc 100644--- a/README.md+++ b/README.md@@ -110,7 +110,7 @@ An agent authors a [JSON recipe](docs/agent-scene.md), sets [lights and fog](docIt gets PNG previews back, compares up to four views in a [review grid](docs/agent-review.md) and runs [render jobs](docs/agent-render-jobs.md) for stills and MP4 video.The server accepts no arbitrary code and no remote asset URLs. The [MCP reference](docs/mcp.md) lists its tools.-Two skills teach an agent the engine: [build-67js-scene](skills/build-67js-scene/SKILL.md) for scenes and materials, and [render-67js-media](skills/render-67js-media/SKILL.md) for image and video export.+Two skills teach an agent to drive the MCP tools: [build-67js-scene](skills/build-67js-scene/SKILL.md) for scenes and materials, and [render-67js-media](skills/render-67js-media/SKILL.md) for image and video export.For a plain-text guide, give the agent [llms.txt](https://67js.codepawl.com/llms.txt).[viz3d](https://github.com/codepawl/viz3d) uses 67js. It is a skill that turns places, systems and events into 3D apps and films, and it renders its films and stills in 67js.diff --git a/changes/649.md b/changes/649.mdnew file mode 100644index 00000000..0871f472--- /dev/null+++ b/changes/649.md@@ -0,0 +1 @@+- The `build-67js-scene` and `render-67js-media` skills are rewritten for agents that use 67js through MCP: short entry files, references for look, light, camera, film and animation, render jobs and error recovery, and a working tool call for lens and depth of field, light caps, animated lights, sun and sky, catalog HDRIs and looks, `bake.gridFog`, fog multiple scattering, depth fixes and render flags. Evals under `skills/*/evals` run through `claude -p` with `skills/evals/run.mjs` (issue #649)diff --git a/docs/learn/agent-workflows.md b/docs/learn/agent-workflows.mdindex 5aeb63d2..48bcfe75 100644--- a/docs/learn/agent-workflows.md+++ b/docs/learn/agent-workflows.md@@ -401,8 +401,8 @@ While a job runs, previews and edits pause. Inspection and recipe export still wA skill is a folder with a `SKILL.md` file. It gives an agent a procedure and the names of the files to read. The npm package includes two skills:-- `build-67js-scene` for building and refining scenes.-- `render-67js-media` for PNG and MP4 export, backends and memory limits.+- `build-67js-scene` for building scenes through the MCP tools: look, light, camera, film and animation, and error recovery.+- `render-67js-media` for PNG, pass and MP4 render jobs, with limits and error recovery.Copy them from the installed package into the skill folder of your harness. Run this in your project folder, after `npm install 67js@npm:@codepawlhq/67js`:diff --git a/skills/build-67js-scene/SKILL.md b/skills/build-67js-scene/SKILL.mdindex 14ae3343..c4d2569c 100644--- a/skills/build-67js-scene/SKILL.md+++ b/skills/build-67js-scene/SKILL.md@@ -1,92 +1,63 @@---name: build-67js-scene-description: Build or refine interactive 3D scenes with 67js. Use for 67js models, nature worlds, cinematic scenes, camera controls, materials and anti-aliasing, including "làm cảnh 67js" and "model bị răng cưa".+description: Build, light, film and refine 3D scenes through the 67js MCP server (npm package @codepawlhq/67js). Use when an agent has the scene_* tools and must model parts, set materials, lights, HDRI, color looks, fog, lens and depth of field, animate a camera, lights, sun, sky and effects, bake light, fix z-fighting or recover from a tool error. Also for "làm cảnh 67js", "dựng cảnh 3D bằng 67js", "model bị răng cưa", "ánh sáng cảnh 67js", "đổ bóng", "sương mù 67js", "camera 67js". Image and video export is the render-67js-media skill.license: MIT----# Dựng cảnh 3D bằng 67js--Use the actual 67js checkout. Locate it from the active workspace or Git remote before writing files.-Read its `README.md`, `src/renderer.js` and the closest existing scene module.-Use `simplify-code` and `engineering-workflows` for implementation.--## Choose the surface--- An object studio uses `src/model.js` and `src/main.js`.-- An outdoor world uses `src/nature.js` and `src/nature-viewer.js`. Real trees, bushes, grass and forest scattering use optional `src/vegetation.js` and `docs/vegetation.md` (`leaves: 'mesh'` needs no alpha support).-- A grass field, meadow, lawn or savanna over terrain uses optional `src/grass.js` and the checkout's `docs/grass.md`: clumped curved blades, tile level of detail, `mask` for paths. Darken every ground layer under the grass toward `grass.groundColor` (a bright floor between blades looks fake); prefer it over scattered `grass` clumps for anything wider than a few metres. Pebbles, rocks, twigs and fallen leaves on paths, riverbanks or forest floor use optional `src/clutter.js` and the checkout's `docs/clutter.md` (`riverbed`, `forest`, `scree`, `meadow` presets).-- Light that bounces inside a closed room (colour bleed, shadows that are not black) comes from optional `src/light-bake.js` and the checkout's `docs/light-bake.md`: `bakeLightmaps(parts, { pointLights, keyColor, lightDirection }, options)` returns new parts with a lightmap (plain parts through the emissive map, patterned, textured and emissive parts through the `lightMap` slot on a second UV set); direct light stays live. Recipes reach it through `bake`. A closed room with no `bake` renders lifted and grey; `scene_inspect` reports it as the `closed-room-without-bake` diagnostic, so add `bake` then.-- A deterministic film uses `src/film.js` and `src/film-player.js`.-- A keyframe scene uses `src/animation.js`, `src/motion.js` and `src/motion-player.js`.-- An authored camera uses `src/camera-path.js` and the checkout's `docs/camera-path.md`.-- Local lights use the renderer environment and the checkout's `docs/lighting.md`.-- Realistic reflections or HDRI lighting use `environment.map` from `createEnvironmentMap` or optional `src/hdri.js` (`loadHdri`) and the "Environment maps (IBL)" section of `docs/lighting.md`.-- Depth-clipped fog uses `{ hdr: true, depth: true }` and the checkout's `docs/volumetric.md`.-- A skeletal asset uses `src/skinning.js`, `src/gltf.js` and the checkout's `docs/skinning.md`.-- Relative facial or shape deformation uses `src/morph.js` and the checkout's `docs/morph-targets.md`. Check source versus published support first.-- Recorded contacts or articulated physics use optional `src/physics.js` and the checkout's `docs/physics.md`.-- Humanoid clips moved between rigs, or crowds of skinned characters, use optional `src/retarget.js` and the checkout's `docs/retarget.md`. Mixamo downloads need the owner's Adobe login.-- Realistic ground (rolling hills to ridges, scanned grass/forest/mud/rock layers) uses optional `src/terrain.js`, `src/texture-set.js` and the checkout's `docs/terrain.md`. Feed `terrain.heightAt` to vegetation and vehicles; never fake ground with the `terrain` tag. Splat `variation` and `edgeNoise` (on by default) keep wide ground from reading as one flat colour; leave them on unless a stylised look needs flat ground.-- Baked liquid (jets, geysers, torrents, whitewater) uses optional `src/spume.js` and the checkout's `docs/spume.md`. Bake with the Spume solver first; never fake it with displaced primitives.-- Wheeled vehicles driving a path (wheel spin, steering, body roll and pitch, ground following) use optional `src/vehicle.js` and the checkout's `docs/vehicle.md`.-- A flat scene or axis view uses `src/canvas2d.js`, `src/camera.js` and `src/view2d.js`.-- A GLB asset viewer uses the optional `src/gltf.js` addon and `src/asset-viewer.js`.-- Static brush sculpting uses optional `src/sculpt.js` and the checkout's `docs/sculpt.md`.-- A curved surface badge uses optional `src/surface.js` and the checkout's `docs/surface.md`.-- Static contact, ray hits or closed-solid containment use optional `src/mesh-query.js` and the checkout's `docs/mesh-query.md`.-- Static vertex wrapping uses optional `src/shrinkwrap.js` and the checkout's `docs/shrinkwrap.md`.-- A rigid accessory on a morphing or skinned surface uses optional `src/surface-attachment.js` and `docs/surface-attachment.md`.-- Agent scene recipes use optional `src/agent-scene.js` and `docs/agent-scene.md`. Verify source versus published availability before importing.-- Signs, labels and piping use recipe geometry `text` (bundled DejaVu Sans, printable ASCII; faces +Z, baseline on y=0, size is the em height) and `curve` (cubic Bezier points with optional absolute handles, `radius`, `taper`, `profile`). Their fields come from `scene_capabilities` `curveText.details`, not the tool schema; the MCP takes no font file or URL. Give a sign a board box a little deeper than the text `depth`, and keep text under about 40 characters at `curveSegments: 4`. See "Curve" and "Text" in the checkout's `docs/modeling.md`.-- Rolling ground with a cut-out opening (a cave mouth, a shaft) uses recipe geometry `terrain` with `holes: [{ center: [x, z], radius }]`; `scene_capabilities` `terrain` lists the fields. It is one mesh, so splat layers and a path query are not part of it (the `addons/terrain` library has `holes` too).-- Polygon modeling by an agent (extrude, inset, loop cut, bevel, booleans, mirror, array, solidify) uses the recipe `mesh` geometry and the MCP tools `mesh_inspect`, `mesh_edit` and `mesh_stack`. Read [mesh-modeling.md](references/mesh-modeling.md) before the first edit; check that the checkout's `docs/mesh.md` exists, since it is unreleased after npm 0.10.0.-- Parts that sit against each other (a handle on a body, a lid on a tank, legs under a top) use the node `relations` field: `attach`, `gap`, `flush`, `align` or `centered` against another mesh node, optionally a tagged `region` of it. They are solved again after every edit, so resize the body with one `set-node` instead of recomputing each part's translation. One relation per axis, no loops. Fields are in `scene_capabilities` `relations`; see "Relations between parts" in the checkout's `docs/agent-scene.md`.-- A surface look in a recipe (wood, planks, bricks, tiles, marble, stone, concrete, metal, rust, fabric) uses the material `pattern` field, which needs no UVs. See "Material patterns" in the checkout's `docs/agent-scene.md`. Your own look (bricks from noise and a ramp, stripes, a pattern that follows `uv_unwrap`) is `pattern: { type: "graph", graph, mapping: "uv" }`: a bounded JSON node graph baked to textures, never shader text; see "Material graphs" there.-- Glass, water, gems, car paint and cloth in a recipe use the material layer fields `transmission` (with `thickness` and `ior`), `clearcoat`, `sheenColor`, `specular`, `anisotropy` (brushed metal) and `iridescence` (soap, oil). Give glass the default `surface` tag, not `liquid`, which absorbs by thickness and reads murky; anisotropy and iridescence are ignored on a transmissive material. A transmissive material needs a nonzero `thickness` to bend the view behind it, and does not show blended surfaces. Ranges and limits are in "Material layers" in the checkout's `docs/material-maps.md`.-- Layered skeletal animation in code (a clip on some joints only, additive clips, foot planting, reaching, looking at a point) uses `createAssetPose` from `src/skeleton-pose.js` and the checkout's `docs/skeleton-pose.md`. Clip layers are not available through MCP.-- Jointed motion (an arm reaching, a lamp or head tracking a point) on a recipe or an imported character uses `motion.ik`, which needs no quaternions: on a recipe parent the joint nodes and put sizes on child mesh nodes, on an asset find `node-N` IDs with `scene_inspect` kind hierarchy and aim with `worldForward`. Read `motionIk` from `scene_inspect`: besides `reached`, it lists `warnings` (`wrong-bend` when a knee or elbow bends the unnatural way, `hyperextended`) and `limited` (poses a joint limit changed). Give a leg or arm `bendToward` (a world direction, such as `[0, 0, 1]` for a knee on a character facing +z) and `limits` per joint in degrees, and fix any warning before you finish. `motion.constraints` (copy, limit, `track_to`, `child_of`, `floor`, Blender's meanings, Euler XYZ degrees) and `motion.drivers` (a node or material property from a bounded JSON expression) run after IK and give the same pose at any time. On an imported asset, `motion.layers` plays its clips together (a walk layer plus a wave layer masked to `{ "joints": ["node-N"] }` for the arm): list clip ids with `scene_inspect` (`animations`), find joints with kind hierarchy, set `morph: false` on a layer that should not touch the face, and use `bones` to send a clip's track to another node. See "Inverse kinematics", "Clip layers on an asset", "Constraints" and "Drivers" in the checkout's `docs/agent-motion.md`.-- Where meshes meet: a rock or trunk sunk into ground gets node `blend: { "radius": 0.15 }` (soft seam, needs depth, `docs/mesh-blend.md`); flush faces get `decal` or `depthLayer`. A sun-lit closed room bounces sun light on its own; `environment.sunBounce` scales it (0 off). Water over a bed needs `opacity` below one to show the bed, and the bed's shadow fades with depth (`docs/agent-scene.md`).-- Hide or flag a node without removing it: `visible: false` (also keyable in a motion track, so films stop parking parts at y=-5000), `castShadow`, `receiveShadow`, `holdout` and `shadowCatcher` (transparent canvas, for footage composites); see "Visibility and render flags" in `docs/agent-scene.md`.-- A skeleton-only GLB (`meshes: 0` in `scene_asset_catalog`) cannot be placed, but its clips drive a character through `motion.layers[].from`.-- Agent tool calls use the installed `67js-mcp` stdio server from release `0.5.0` onward. Read `docs/mcp.md` for launch and PNG feedback.-- Agent render jobs use `docs/agent-render-jobs.md`. Check source versus published support, configure a private store and poll until terminal.-- A character or creature that must move (a walker, a quadruped) gets a recipe `armatures` entry and a `skin` on each mesh node: `{ "id": "rig", "preset": "humanoid", "fit": { "bounds": { "min": [...], "max": [...] } } }` (or `fit.node`), then `skin: { "armature": "rig" }` on every body part. Bones are nodes named `hips`, `leftUpperLeg`, `leftLowerLeg` and so on, so rotation tracks and `motion.ik` address them directly (rotation is local, about the bone head; positive X swings a hanging limb backward). Build the mesh at rest in the preset's pose (facing +Z, arms down), and read `rig` in `scene_inspect`: unweighted vertices, bones with no vertices, joint axis problems. Weights are by distance to the bone segments, so give limbs the same loops you want to bend. See "Authored rigs" in `docs/agent-motion.md`.-- Things that fall, pile up or rest on an authored mesh (dropped objects, a ball in a bowl, a trigger zone) use the recipe `physics` section: bodies on root node IDs, `shape: 'trimesh'` on a fixed body so objects follow the mesh, `sensor: true` for triggers, `layer` and `collidesWith` for masks. Seek with `motionTime` like motion, and read `physics` from `scene_inspect` (resting times, contacts, sensor events) instead of guessing from a picture. Needs the optional peer `@dimforge/rapier3d-compat`; a limp character uses `physics.ragdoll` (`{ armature }` for a recipe armature; an imported asset takes `physics: { duration, floor, ragdoll: {} }` and falls from its current pose onto a floor at world height `floor`), needs a floor body in a scene recipe, and reports `physics.ragdoll` (`lowestY`, `highestY`, `restsAtTime`); joints have no swing limits. See "Recipe physics" in the checkout's `docs/physics.md`.-- Flags, curtains, capes and cloths draped over props use the recipe `cloth` section: a `grid` geometry node (flat sheet in XY, `segments` up to 64) listed in `sheets` with `pin` edges (`top`, `left`, a corner...), `wind` in m/s, and fixed `colliders` (`ball` or `box` fitted to their node). A cape or skirt on a moving character uses moving colliders (`attach` + `shape: "capsule"` + `to`, or `armature` for one capsule per bone) and a sheet `pinTo: { node }`. Seek with `motionTime`; a flag needs wind along its length (+x for a left pin), not across it. No peer needed, no self collision, no soft bodies. Units, defaults and limits are in `scene_capabilities` under `cloth`; see "Recipe cloth" in `docs/physics.md`.-- Sparks, dust, embers, confetti and fur use the recipe `particles` section: a root node whose small low-poly geometry (a box) is the particle, in an emitter system with `seed`, `count` (at most 2000), `rate` (omit for one burst), `lifetime`, `speed`, `spread`, `drag`, `floor` and an `emitter` shape; a system with `type: "hair"` grows strands from a `surface` node. Seek with `motionTime`; the same seed and time give the same particles. The node transform does not move particles, and there is no collision beyond the floor, bounce or per-particle colour. Fields and limits are in `scene_capabilities` under `particles`; see "Recipe particles and hair" in `docs/physics.md`. Smoke, fire and browser liquid are not supported.-- A closed room, or any scene lit by point lights, is dark where the light does not reach. Add the recipe `bake` section (`{ "preset": "standard" }`, or `draft` to try fast; `fine` is the same as `standard`) or the `set-bake` operation: it writes bounced light into lightmaps when the scene builds and reruns only when parts, lights, materials or the bake change. `scene_inspect` shows `bake.seconds` and `bake.skipped` (alpha, skins, morphs, procedural tags and hair or particle hosts are left as they were; patterned, textured and emissive parts are baked and keep their pattern). It bakes the rest pose and no spot or area lights. Read `docs/light-bake.md`.-- Agent procedural animation uses `docs/agent-motion.md` from release `0.7.0`. Author recipe tracks, then seek through `sampleMotion` or MCP `motionTime`.-- Agent imported character motion uses `docs/agent-character-motion.md` from release `0.8.0`. Inspect source joints before authoring local tracks.-- To pick between variants, fork each with `scene_apply` and a `branch` name (the scene and revision stay put), compare them in one `scene_review` with a `branch` per shot, then keep the winner with `scene_restore` and its `branch`. Add `labels: true` to `scene_look` or `scene_review` to match node names and lint problems to what the image shows. Docs: `docs/agent-review.md`.-- Agent comparisons use `scene_review` from release `0.9.0`. Read `docs/agent-review.md` for isolated views and independent pose samples.-- An image or video export uses `render-67js-media`.-- A GLB for Blender or another tool uses `scene_export_glb` (needs `--jobs`): it returns a file path under the jobs folder, takes no path of its own. Plain call for the current pose with textures, skins and IK; `motionTime` to pose authored motion first; `clip` on an unposed imported asset for its source animation. See `docs/export-glb.md`.--Read [scene-contract.md](references/scene-contract.md) before creating parts or changing materials.--## Build and inspect--1. State the focal point, camera, scale and intended lighting.-2. Reuse geometry identities across repeated parts. Keep transforms and materials in instance attributes.-3. Use curved surfaces and sampled fillets for close objects. Keep coarse geometry for distant objects.-4. Enable explicit MSAA, FXAA and specular filtering through `Renderer67`.-5. Set the render memory budget before allocating a target.-6. Keep per-frame animation deterministic. Pause continuous rendering when the document is hidden.-7. Validate geometry, bounds and scene budgets with the existing Node tests.-8. Capture actual rendered wide and narrow views. Inspect edges, highlights, overlap and the focal point.-9. Exercise orbit, zoom, camera selection and the requested interaction through project dev tooling.-10. In a recipe, start from the default look: `environment.setup` is `daylight` and `effects.ambientOcclusion` is `0` (off; set 0.4 to 0.8 to add contact darkening). Pick `studio` for products, `overcast` for soft even light, `sunset` for warm low light; Do not hand-tune key, fill and ambient first. The preview draws an automatic floor with a contact shadow under the lowest geometry unless a part already forms a floor; `environment.ground: false` removes it, so do not add a floor node only for the shadow.--Do not treat an `antialias: true` context as proof that the final image looks smooth.-Report measured geometry, draw counts and render size separately from visual judgments.-Do not claim Blender parity or general Three.js speed superiority from one scene.+# Build scenes with 67js over MCP++You drive 67js through the `scene_*` tools of the `67js-mcp` server. No checkout is needed.+Start the server with `npx --package @codepawlhq/67js 67js-mcp --backend gpu --assets <abs dir> --jobs <abs dir>`+(`--assets` for GLB, HDR and cube files, `--jobs` for render jobs, `--backend cpu` without a GPU).++## Loop++1. `scene_capabilities`: features, limits and field detail. Read it before a feature you have not used; it is the+ source for every field list, so this skill names fields and does not copy them.+2. `scene_create` with a `recipe`: `{ "format": "67js.scene", "schemaVersion": 1, "geometries": [], "materials": [], "nodes": [] }`+ plus optional `camera`, `environment`, `effects`, `shadow`, `motion`, `bake`, `timeline`.+3. `scene_inspect`: node IDs, bounds, `diagnostics`, current `revision`.+4. `scene_look`: the PNG. Add `labels: true` to match node names to the image. Judge the image, not the lint.+5. `scene_apply` with the current `expectedRevision` and a small `operations` batch. A stale revision fails whole.+6. `scene_checkpoint` before a risky batch, `scene_restore` to undo, `scene_release_checkpoint` after.+7. `scene_export_recipe` keeps the result. `scene_dispose` before a different scene.++`sessionId` may be left out: one scene is active at a time.+Variants: `scene_apply` with a `branch` name, compare in one `scene_review` (a `branch` per shot), keep one with `scene_restore`.++## Pick the recipe++| Task | Read |+|---|---|+| Sky, HDRI, `.cube` look, tone mapping, fog, exposure, bloom, AO, outlines | `${CLAUDE_SKILL_DIR}/references/look.md` |+| Sun, point, spot and area lights, caps, baked bounce light, flush faces | `${CLAUDE_SKILL_DIR}/references/light.md` |+| Lens, focal length, depth of field, shift, orthographic | `${CLAUDE_SKILL_DIR}/references/camera.md` |+| Motion tracks (camera, nodes, lights, sun, sky, effects), shots, timeline | `${CLAUDE_SKILL_DIR}/references/film-and-animation.md` |+| A call failed, a diagnostic appeared, the picture is wrong | `${CLAUDE_SKILL_DIR}/references/errors-and-recovery.md` |+| Polygon modeling: extrude, inset, bevel, booleans, mirror, array | `${CLAUDE_SKILL_DIR}/references/mesh-modeling.md` |+| Scene code against the npm library, not MCP | `${CLAUDE_SKILL_DIR}/references/scene-contract.md` |++## Defaults that save work++- Start from the default look: `environment.setup` `daylight`, AO off. `studio` suits products, `overcast` soft light,+ `sunset` warm low light. Do not hand-tune key, fill and ambient first.+- The preview draws a floor with a contact shadow under the lowest geometry. `environment.ground: false` removes it,+ so never add a floor node only for the shadow.+- Reuse one geometry ID for repeated parts and move them with node transforms.+- Put parts against each other with node `relations` (`attach`, `gap`, `flush`, `align`, `centered`) so one `set-node`+ resizes the body and the handle follows.+- Surfaces without UVs: material `pattern` (wood, bricks, marble, metal, fabric). Glass: `transmission` with a nonzero+ `thickness`. Details are in `scene_capabilities`.+- Hide a node with `visible: false`; `castShadow`, `receiveShadow`, `holdout` and `shadowCatcher` are node flags too+ (the last two need a transparent canvas, so they matter for exported composites, not `scene_look`).+- Characters and creatures: recipe `armatures` plus `skin` per mesh node, `motion.ik`, imported GLBs through the+ `asset` node field and `scene_asset_catalog`. Physics, cloth, particles and hair are recipe sections.+ `scene_inspect` reports their results; read those instead of guessing from a picture.+- A GLB for Blender: `scene_export_glb` (needs `--jobs`), it returns a path.## Finish-Deliver the scene link, a rendered image, relevant checks and known limits.-To see what changed, including unreleased changes and breaking ones, read `https://67js.codepawl.com/changelog.json`.-Keep this skill aligned with the checked-out renderer API when changing that API.--## Bugs--If you find a 67js bug or instability, file it at once with `gh issue create -R codepawl/67.js`. Give the steps, the scene and a still.+Deliver the recipe, one `scene_look` image and any limit you hit. Say what you measured (counts, bounds, seconds)+apart from what you judged by eye. Do not claim Blender parity or general speed over three.js.+Changes, including unreleased and breaking ones: `https://67js.codepawl.com/changelog.json`.+A 67js bug: `gh issue create -R codepawl/67.js` with the steps, the recipe and a still; no local paths.diff --git a/skills/build-67js-scene/evals/hdri-look-and-fog.json b/skills/build-67js-scene/evals/hdri-look-and-fog.jsonnew file mode 100644index 00000000..14d1b6b9--- /dev/null+++ b/skills/build-67js-scene/evals/hdri-look-and-fog.json@@ -0,0 +1,42 @@+{+ "name": "hdri-look-and-fog",+ "skills": [+ "build-67js-scene"+ ],+ "prompt": "Using the 67js MCP tools and the build-67js-scene skill: make a small outdoor-style scene (a ground slab and a sphere). Light it with a catalog HDRI as the visible sky if one works (otherwise a light setup), apply a color look, and add volume fog with multiple scattering if the tools allow it (otherwise plain volume fog). Look at it, then finish by calling scene_export_recipe. If a call fails, do not loop: use the closest thing that works.",+ "expected": "The agent called scene_asset_catalog and ends with a recipe that has a sky (environment.hdri or a setup), a color look, volume fog with density above 0, and a scene_look after the last edit. Strict target once issues 661 and 664 are fixed: hdri sky-clouds, look teal-orange, volumeFog.scatterOctaves 3.",+ "checks": [+ {+ "label": "scene_asset_catalog called",+ "toolCalled": "scene_asset_catalog"+ },+ {+ "label": "a sky is chosen",+ "anyOf": [+ {+ "path": "environment.hdri",+ "op": "exists"+ },+ {+ "path": "environment.setup",+ "op": "exists"+ }+ ]+ },+ {+ "label": "a color look is set",+ "path": "environment.look",+ "op": "exists"+ },+ {+ "label": "volume fog is on",+ "path": "environment.volumeFog.density",+ "op": "gt",+ "value": 0+ },+ {+ "label": "scene_look after the last edit",+ "lookAfterLastEdit": true+ }+ ]+}diff --git a/skills/build-67js-scene/evals/portrait-depth-of-field.json b/skills/build-67js-scene/evals/portrait-depth-of-field.jsonnew file mode 100644index 00000000..244a1158--- /dev/null+++ b/skills/build-67js-scene/evals/portrait-depth-of-field.json@@ -0,0 +1,16 @@+{+ "name": "portrait-depth-of-field",+ "skills": ["build-67js-scene"],+ "prompt": "Using the 67js MCP tools and the build-67js-scene skill: make a tiny product scene (a box on a flat slab). Frame it like an 85 mm portrait lens with a shallow depth of field, subject sharp. Look at the result, then finish by calling scene_export_recipe. Keep it short.",+ "expected": "The exported recipe has camera.focalLength and exactly one depth of field control: camera.fStop, or effects.depthOfField.blur above 0 with a focusDistance. The agent looked at the scene after its last edit.",+ "checks": [+ { "label": "camera.focalLength is set", "path": "camera.focalLength", "op": "exists" },+ { "label": "a depth of field control is on", "anyOf": [+ { "path": "camera.fStop", "op": "exists" },+ { "path": "effects.depthOfField.blur", "op": "gt", "value": 0 }+ ] },+ { "label": "not both controls", "atMostOne": [ { "path": "camera.fStop", "op": "exists" }, { "path": "effects.depthOfField.blur", "op": "gt", "value": 0 } ] },+ { "label": "scene_look after the last edit", "lookAfterLastEdit": true },+ { "label": "recipe was exported", "toolCalled": "scene_export_recipe" }+ ]+}diff --git a/skills/build-67js-scene/evals/sunset-with-lamp.json b/skills/build-67js-scene/evals/sunset-with-lamp.jsonnew file mode 100644index 00000000..428e128c--- /dev/null+++ b/skills/build-67js-scene/evals/sunset-with-lamp.json@@ -0,0 +1,14 @@+{+ "name": "sunset-with-lamp",+ "skills": ["build-67js-scene"],+ "prompt": "Using the 67js MCP tools and the build-67js-scene skill: build a small room-like scene (a floor slab and a box on it) with two point lights and one spot light. Animate it over 4 seconds as a sunset: the sun drops to the horizon, the first lamp fades up from 0, and the exposure rises a little. Look at frame time 2 without changing the scene, then finish by calling scene_export_recipe. Keep it short.",+ "expected": "The recipe has 2 point lights and 1 spot light, and a motion with sun, light (an id such as point:0) and effects tracks. The agent used scene_look with a motionTime.",+ "checks": [+ { "label": "two point lights", "path": "environment.pointLights", "op": "minLength", "value": 2 },+ { "label": "a spot light", "path": "environment.spotLights", "op": "minLength", "value": 1 },+ { "label": "a sun track", "path": "motion.tracks", "op": "someMatches", "match": { "kind": "sun" } },+ { "label": "a light track on point:0", "path": "motion.tracks", "op": "someMatches", "match": { "kind": "light", "id": "point:0" } },+ { "label": "an effects exposure track", "path": "motion.tracks", "op": "someMatches", "match": { "kind": "effects", "property": "exposure" } },+ { "label": "scene_look with motionTime", "toolInputIncludes": { "tool": "scene_look", "text": "motionTime" } }+ ]+}diff --git a/skills/build-67js-scene/references/camera.md b/skills/build-67js-scene/references/camera.mdnew file mode 100644index 00000000..d6834e6a--- /dev/null+++ b/skills/build-67js-scene/references/camera.md@@ -0,0 +1,56 @@+# Camera: lens, depth of field, framing++Calls follow the conventions in `look.md`. `tests/skill-examples.test.js` applies every block, so they stay valid.+The camera is the recipe `camera` (`scene_create`) or the `set-camera` operation, with fields directly on the command.++## Lens++Give `fov` (vertical degrees, default 45) or `focalLength` in millimetres with `sensorWidth` (default 36). Giving both+fails. `focalLength` replaces `fov` and `fov` replaces `focalLength`. About 24 mm is wide, 50 mm normal, 85 mm or more+a portrait or product close-up that flattens perspective.++Tool `scene_apply`:++```json+{ "expectedRevision": 1, "operations": [+ { "type": "set-camera", "eye": [2.2, 1.4, 3.2], "target": [0, 0.6, 0], "focalLength": 85 }+] }+```++`eye` and `target` must differ, and `up` must not be parallel to the view direction. `near` must stay above 0 and+below `far`. `shift: [x, y]` slides the frame by a fraction of its width and height without tilting (architecture,+keeping verticals straight). `projection: "orthographic"` with `orthoScale` (view height in metres) gives a plan or+isometric view and takes no `focalLength`; going back to `"perspective"` drops `orthoScale`.++## Depth of field, two ways++Both are deterministic and apply to every render, `scene_look` included. They are exclusive: use one.++**Camera f-stop.** `fStop` (0.7 to 64) turns on depth of field focused on the camera `target`. Smaller blurs more;+1.4 or lower is full blur. Aim `target` at the subject. Leave `effects.depthOfField.blur` at 0.++```json+{ "expectedRevision": 2, "operations": [+ { "type": "set-camera", "focalLength": 85, "fStop": 1.8 }+] }+```++**Effect settings.** `effects.depthOfField.blur` (0 to 1, off at 0; the widest circle is 5 percent of the image+height) and `focusDistance` (metres from the camera that stay sharp, 0.01 to 100000).++```json+{ "expectedRevision": 3, "operations": [+ { "type": "set-effects", "effects": { "depthOfField": { "blur": 0.6, "focusDistance": 3.5 } } }+] }+```++Measure the distance instead of guessing: it is the length of `target - eye`, or read the subject's bounds from+`scene_inspect`. A rack focus (focus moves during a shot) is a motion track: `effects` `focusDistance` with blur above+0, or with an `fStop` camera a camera `target` track. A shot in a `timeline` can also set `focusDistance` and `blur`+(see `film-and-animation.md`).++## Check++After a lens or depth of field edit call `scene_look` and `scene_review` with two shots (wide and close) to compare.+A blurred subject means the focus is off: recompute the distance. A scene that is blurred everywhere has `blur` too+high or an `fStop` below 1.4.diff --git a/skills/build-67js-scene/references/errors-and-recovery.md b/skills/build-67js-scene/references/errors-and-recovery.mdnew file mode 100644index 00000000..400ad088--- /dev/null+++ b/skills/build-67js-scene/references/errors-and-recovery.md@@ -0,0 +1,48 @@+# Errors and recovery++Every tool error names what failed and what to do next, so read the message before you retry. A failed+`scene_apply`, `scene_restore` or `mesh_edit` commits nothing: the old revision and recipe stay.++## Messages you will meet++| Message or sign | Cause | Do |+|---|---|---|+| `expectedRevision must match the current revision.` | Another call changed the scene, or you used an old number. | `scene_inspect`, take its `revision`, resend the same batch. |+| `Camera fStop drives depth of field; set effects.depthOfField.blur to 0 or remove fStop.` | Both depth of field controls are on. | Keep one: `fStop` on the camera, or `effects.depthOfField.blur`. See `camera.md`. |+| `Give a camera fov or a focalLength, not both.` | Both lens fields in one command. | Send only one; `focalLength` replaces `fov`. |+| `Unrecognized keys: "scatterOctaves", "multiScatter"` on `volumeFog` | The MCP schema does not accept the opt-in scattering fields yet (#661). | Do not retry; use `density`, `anisotropy`, `noiseAmount`; see `look.md`. |+| `The URL must be of scheme file` on `hdri` or `look` | A shipped catalog name fails in the packaged server (#664). | Use a catalog ID, a `setup` or a built-in look (`warm`, `cool`, `contrast`, `faded`). |+| `bake.gridFog needs bake.irradianceGrid.` | `gridFog` alone. | Add `irradianceGrid: true`. See `light.md`. |+| `Shot <name> reads motion up to N s but the motion lasts M s.` | A timeline longer than a non-looping motion. | Lengthen the motion, set `loop: true` or a shot `motionStart`. |+| A light list error naming a cap | More than 16 point, 8 spot or 7 area lights. | Merge or remove lights; each list replaces the old one. |+| `environment.hdri must be one of ... or the 64-character ID ...` | A made-up name, path or URL. | `scene_asset_catalog`, copy a listed name or ID. |+| `No scene is active` | Nothing created yet, or disposed. | `scene_create`. |+| Result has `renderSucceeded: false` and `renderError` | The edit committed, the draw failed (bad pass, lost context). | `scene_export_recipe` to keep it, fix the cause named in `renderError`, then `scene_look`. |+| An unknown field is rejected before dispatch | A typo or a field of another recipe section. | Fix the name; `scene_capabilities` lists valid fields. |++## Diagnostics in `scene_inspect`++`diagnostics` appears only when something needs a decision. The ones that change the picture:++- `closed-room-without-bake`: add a bake (`light.md`).+- `coplanar-overlap`: flush faces will flicker; `environment.resolveCoplanar: "offset"` or a node `decal` (`light.md`).+- `motionIk` `warnings` (`wrong-bend`, `hyperextended`) and `limited`: fix `bendToward` and `limits`.+- `rig` problems: unweighted vertices, bones with no vertices.+- Mesh lint (`mesh_inspect`): `intersecting-parts`, `thin-wall`, `floating-part`; each comes with a fix.++## Recover++1. `scene_checkpoint` before an experiment, so there is a known good state.+2. After a bad result, `scene_restore` with the `checkpointId` and the current `expectedRevision`. Restoring+ increments the revision and keeps the checkpoint.+3. For variants use a `branch` on `scene_apply` instead of editing: the scene stays as it is until you choose one.+4. A frame that looks wrong is not an error. Compare with `scene_review` (several shots, `labels: true`) before+ changing the look again, and change one field at a time.+5. When the recipe is the product, `scene_export_recipe` after every accepted step.+6. Release saved states you no longer need (`scene_release_checkpoint`) and `scene_dispose` before a new scene.++## When it is the tool++If an error looks like an engine bug (a failed call that the message cannot explain, a crash, a wrong picture from a+valid recipe), stop retrying. File an issue at `codepawl/67.js` with the tool call, the recipe from+`scene_export_recipe` and a `scene_look` still. Do not include local paths.diff --git a/skills/build-67js-scene/references/film-and-animation.md b/skills/build-67js-scene/references/film-and-animation.mdnew file mode 100644index 00000000..a4850aa5--- /dev/null+++ b/skills/build-67js-scene/references/film-and-animation.md@@ -0,0 +1,90 @@+# Film and animation: motion tracks, shots, timeline++Calls follow the conventions in `look.md`. `tests/skill-examples.test.js` applies every block, so they stay valid.+Everything here is deterministic: a seek to a time gives the same pixels as playing to it. Export is the+`render-67js-media` skill.++## Motion record++`set-motion` takes one complete record `{ duration, loop, tracks }`, or `null` to clear it. A track has `kind`, an+`id` (omitted for `camera`, `sun`, `environment`, `effects`), a `property`, optional `interpolation`+(`LINEAR`, `STEP`, `SMOOTH`, `CUBICSPLINE`) and `keyframes` of `{ time, value }` (optional per-key `easing`).+Properties: node `translation`, `rotation` (XYZW quaternion), `scale`, `visible` (1 or 0); material `color`,+`emission`, `roughness`, `metallic`; camera `eye`, `target`, `fov`, `roll`. Every referenced ID must exist after the+batch. Nonlooping motion must cover every sampled time.++Tool `scene_apply` (a camera push-in plus a spinning part; node `lid` exists):++```json+{ "expectedRevision": 1, "operations": [+ { "type": "set-motion", "motion": { "duration": 4, "loop": false, "tracks": [+ { "kind": "camera", "property": "eye", "interpolation": "SMOOTH",+ "keyframes": [ { "time": 0, "value": [5, 3, 6] }, { "time": 4, "value": [2.5, 1.5, 3] } ] },+ { "kind": "camera", "property": "target",+ "keyframes": [ { "time": 0, "value": [0, 0.5, 0] }, { "time": 4, "value": [0, 0.8, 0] } ] },+ { "kind": "node", "id": "lid", "property": "translation",+ "keyframes": [ { "time": 0, "value": [0, 1, 0] }, { "time": 4, "value": [0, 2, 0] } ] }+ ] } }+] }+```++Check a frame without changing the revision: `scene_look` with `motionTime: 2` (`null` returns to the base pose).+`scene_review` compares several times or cameras in one grid.++## Animated lights, sun, sky and effects++On a scene recipe (not an imported asset) four more kinds animate the look:++- `light` with `id` `point:N`, `spot:N` or `area:N` (index in the matching `environment` list): `position`, `color`,+ `intensity`, plus `direction` on spot and area.+- `sun` (no id): `direction`, `color`, `intensity`, which drive `lightDirection`, `keyColor`, `keyIntensity`.+- `environment` (no id): `skyTop`, `skyBottom`, `fogColor`, `fogDensity`, `volumeFogDensity`, `ambientIntensity`,+ `fillIntensity`, `environmentIntensity`, `environmentRotation` (radians; turns the HDRI or sky shown with `world: true`).+- `effects` (no id): `exposure`, `focusDistance` (needs `effects.depthOfField.blur` above 0).++Values keep the range of the field they drive. Baked light does not follow a moving light.++```json+{ "expectedRevision": 2, "operations": [+ { "type": "set-motion", "motion": { "duration": 4, "tracks": [+ { "kind": "sun", "property": "direction", "keyframes": [ { "time": 0, "value": [-1, 4, 1] }, { "time": 4, "value": [-4, 0.3, 1] } ] },+ { "kind": "sun", "property": "color", "keyframes": [ { "time": 0, "value": [3, 2.8, 2.5] }, { "time": 4, "value": [3.4, 1.4, 0.6] } ] },+ { "kind": "environment", "property": "environmentIntensity", "keyframes": [ { "time": 0, "value": 1 }, { "time": 4, "value": 0.4 } ] },+ { "kind": "environment", "property": "volumeFogDensity", "keyframes": [ { "time": 0, "value": 0 }, { "time": 4, "value": 0.05 } ] },+ { "kind": "light", "id": "point:0", "property": "intensity", "keyframes": [ { "time": 0, "value": 0 }, { "time": 4, "value": 3 } ] },+ { "kind": "effects", "property": "exposure", "keyframes": [ { "time": 0, "value": 1 }, { "time": 4, "value": 1.4 } ] },+ { "kind": "effects", "property": "focusDistance", "keyframes": [ { "time": 0, "value": 3 }, { "time": 4, "value": 6 } ] }+ ] } }+] }+```++That is a sunset with a lamp coming on and a rack focus. An unknown light ID, property or kind fails and names the+valid ones. `scene_inspect` lists the lights, so read the indexes there.++## Shots and cuts++A recipe `timeline` plays shots one after another over the motion clock: no layers or crossfades, only cuts and `dip`+(a dip through black). A shot has `name` (unique), `duration`, optional `camera` (partial: `eye`, `target`, `up`,+`fov`, `near`, `far`), `motionStart`, `focusDistance` and `blur` for that shot's depth of field, and `dip`. The+timeline holds up to 64 shots and 60 s.++```json+{ "expectedRevision": 3, "operations": [+ { "type": "set-timeline", "timeline": { "shots": [+ { "name": "wide", "duration": 3, "camera": { "eye": [0, 3, 14], "target": [0, 0, 0] } },+ { "name": "close", "duration": 3, "camera": { "eye": [0, 0.6, 2.4], "fov": 50 }, "focusDistance": 2.4, "blur": 0.5 },+ { "name": "dusk", "duration": 2, "dip": 1 }+ ] } }+] }+```++A non-looping motion must cover the timeline, or the call fails ("Shot close reads motion up to 6 s but the motion+lasts 4 s"): lengthen `duration`, set `loop: true` or give the shot a `motionStart`.+`set-timeline` with `null` removes it. With a timeline the render job's `motion` and `animation` settings are+rejected; the job reads timeline time (`settings.timeline: { start }`).++## Character and imported motion++Rigs, `motion.ik`, constraints, drivers, clip layers on an imported asset and morph weights are listed in+`scene_capabilities`. Read `scene_inspect` (`motionIk`, `rig`, `animations`) after every change and fix its warnings+before you finish.diff --git a/skills/build-67js-scene/references/light.md b/skills/build-67js-scene/references/light.mdnew file mode 100644index 00000000..e0b385a3--- /dev/null+++ b/skills/build-67js-scene/references/light.md@@ -0,0 +1,102 @@+# Light: sun, lamps, caps, bounce, flush faces++Calls follow the conventions in `look.md`. `tests/skill-examples.test.js` applies every block, so they stay valid.++## Caps++| Light | Where | Cap |+|---|---|---|+| Sun (one key light) | `environment.lightDirection`, `keyColor`, `keyIntensity` | 1 |+| Point | `environment.pointLights` | 16 |+| Spot | `environment.spotLights` | 8 |+| Area | `environment.areaLights` | 7 |++A list over its cap fails the whole batch with a message that names the cap. Each list replaces the previous one,+so send every light you want to keep (`[]` removes all). Baked bounce light uses up to 6 of the 16 point slots when a+sun lights a closed room (`environment.sunBounce`, `0` turns it off).+The sun casts shadows. Point and spot lights cast them only with `castShadow: true` (default false) and area lights+never do. Without it a light shines through walls, so a lamp outside a room still lights it: set `castShadow`, move+it inside, lower `intensity` or give it a `range`.++## Units++`pointLights[].intensity` is candela-like: light at distance `d` is `intensity / d^2`, so a lamp 3 m away needs about+10 times the value of one 1 m away. Spot and area use the same scale (`intensity` 0 to 100000); `color` is linear RGB+0 to 1, so keep color for hue and put brightness in `intensity`. The sun is `keyColor * keyIntensity`.++## A lamp, a spot and a panel++Tool `scene_apply`:++```json+{ "expectedRevision": 1, "operations": [+ { "type": "set-environment", "environment": {+ "setup": "overcast", "keyIntensity": 0.3,+ "pointLights": [ { "position": [0, 2.2, 0], "color": [1, 0.75, 0.5], "intensity": 14, "range": 8, "castShadow": true } ],+ "spotLights": [ { "position": [3, 3, 3], "direction": [-1, -1, -1], "angle": 0.6, "penumbra": 0.3, "intensity": 60, "castShadow": true } ],+ "areaLights": [ { "position": [0, 3, -2], "direction": [0, -1, 0], "width": 2, "height": 1, "intensity": 8 } ]+ } }+] }+```++`direction` points where the light travels. Check the cap and result with `scene_inspect` (`diagnostics`).++## Move the sun++`lightDirection` points from the ground to the sun, so `[-1, 4, 1]` is high noon-ish and `[-4, 0.3, 1]` is near the+horizon. The shadow follows the direction; widen `shadow.extent` when the shadow clips at the edge.++```json+{ "expectedRevision": 2, "operations": [+ { "type": "set-environment", "environment": { "lightDirection": [-4, 0.5, 1], "keyColor": [3.4, 1.6, 0.8], "keyIntensity": 1 } },+ { "type": "set-shadow", "shadow": { "extent": 8, "distance": 12, "far": 30 } }+] }+```++Animating any of these lights, the sun, sky or effects is in `film-and-animation.md`.++## Bounce light in a closed room++A closed room or any scene lit by point lights is dark where light does not reach, and `scene_inspect` reports the+`closed-room-without-bake` diagnostic. Add a bake. `preset` is `draft` (fast try) or `standard`.++```json+{ "expectedRevision": 3, "operations": [+ { "type": "set-bake", "bake": { "preset": "standard" } }+] }+```++`irradianceGrid` (true, or 8 to 48 nodes) replaces lightmaps with a baked grid of bounced diffuse light for every part.+`gridFog: true` adds the scene's volume fog to that grid, which fixes dark shafts and fog that looks too bright in a+sunlit closed room. It needs `irradianceGrid`; without it the call fails with "bake.gridFog needs bake.irradianceGrid".++```json+{ "expectedRevision": 4, "operations": [+ { "type": "set-bake", "bake": { "preset": "standard", "irradianceGrid": true, "gridFog": true } }+] }+```++The bake runs when the scene builds and again only when parts, lights, materials or the bake change.+`scene_inspect` shows `bake.seconds`, `bake.skipped` (alpha, skins, morphs, hair and cloth are left as they were) and+`bake.used`. It bakes the rest pose, so a light moved by a motion track does not move its baked light. `"bake": null`+(`set-bake`) removes it.++## Flush faces flicker (z-fighting)++`scene_inspect` lists a `coplanar-overlap` diagnostic for two faces on one plane. Depth precision itself needs no+setting: the renderer switches to reversed depth by itself when the camera's `far` over `near` passes 10000 (a large+world with a small `near`), and also when a flush pair sits far from the eye. If you still see flicker, raise `near`+(`set-camera`) first, then pick one fix per pair:++- `environment.resolveCoplanar: "offset"` moves the smaller part of every flagged pair onto the next depth layer;+ geometry never moves.+- A single node gets `decal: true` (a sticker on a surface) or `depthLayer` (1 to 4).++```json+{ "expectedRevision": 5, "operations": [+ { "type": "set-environment", "environment": { "resolveCoplanar": "offset" } },+ { "type": "set-camera", "near": 0.5, "far": 2000 }+] }+```++Meshes that meet: a rock sunk into ground gets `blend: { "radius": 0.15 }` on its node for a soft seam.diff --git a/skills/build-67js-scene/references/look.md b/skills/build-67js-scene/references/look.mdnew file mode 100644index 00000000..b2481f55--- /dev/null+++ b/skills/build-67js-scene/references/look.md@@ -0,0 +1,114 @@+# Look: sky, HDRI, color look, fog, effects++Each recipe is one tool call. `expectedRevision` is the revision you last read from the previous result, and `sessionId`+may be left out. Look edits merge: omitted fields keep their value, vectors replace, `pointLights` replaces the whole list.+Field ranges are in `scene_capabilities`. A bad value fails the whole batch and keeps the old revision.+`tests/skill-examples.test.js` applies every block below, so they stay valid.++## Pick a light setup++`environment.setup` is `daylight` (default), `overcast`, `sunset` or `studio`. Setting it resets key, fill, ambient and+sky to that setup, and fields in the same call still win.++Tool `scene_apply`:++```json+{ "expectedRevision": 1, "operations": [+ { "type": "set-environment", "environment": { "setup": "sunset", "world": true } }+] }+```++`world: true` makes the sky the background too.++## HDRI from the catalog++Call `scene_asset_catalog` (no arguments). It lists two shipped HDRIs, `sky-clouds` and `studio-softbox`, two shipped+looks, `teal-orange` and `noir`, and every `.hdr` (kind `environment`) and `.cube` (kind `look`) file in the server's+`--assets` folder as a 64-character ID. A recipe names an entry and never carries a path or URL. For a bigger HDRI,+tell the user to put a 1k or 2k `.hdr` (4 MiB at most) in the assets folder and restart the server for its ID.+Known gap (issue #664): in the packaged server a shipped name (`sky-clouds`, `teal-orange`) can fail with "The URL must be of+scheme file". Do not retry it: use a catalog ID from `--assets`, or fall back to `setup` (`studio`, `sunset`) and the+built-in looks below, and say which one you used.++Tool `scene_apply`:++```json+{ "expectedRevision": 2, "operations": [+ { "type": "set-environment", "environment": {+ "hdri": "sky-clouds", "world": true, "environmentIntensity": 1, "environmentRotation": 0.8, "keyIntensity": 0+ } }+] }+```++`keyIntensity: 0` drops the setup's sun when the HDRI has its own; keep it above 0 when you want shadows from the+key light. `"hdri": null` clears it.++## Color look and tone mapping++`environment.look` is one of `warm`, `cool`, `contrast`, `faded`, a shipped cube (`teal-orange`, `noir`) or the+64-character ID of a `.cube` file from `scene_asset_catalog`. `environment.viewTransform` is `aces` (default), `agx` or+`neutral`.++Tool `scene_apply`:++```json+{ "expectedRevision": 3, "operations": [+ { "type": "set-environment", "environment": { "look": "teal-orange", "viewTransform": "agx" } }+] }+```++`"look": null` removes it. Check the result with `scene_look`: a look changes the whole frame, so judge skin, white+and shadow tones, not only the accent color.++## Fog++`environment.fogDensity` is the cheap distance haze (`0` for none). `environment.volumeFog` is a lit box of fog with+god rays from the key light: set `density` above 0 and a `minimum`/`maximum` box that holds the camera and the subject.++Tool `scene_apply`:++```json+{ "expectedRevision": 4, "operations": [+ { "type": "set-environment", "environment": { "volumeFog": {+ "density": 0.04, "minimum": [-12, 0, -12], "maximum": [12, 8, 12], "anisotropy": 0.5+ } } }+] }+```++Multiple scattering is opt in. `scatterOctaves` (integer 1 to 4, default 1 = off) sums octaves that approximate+multiple scattering; `multiScatter`, `multiExtinction` and `multiAnisotropy` (0 to 1, default 0.5 each) shape them and+act only above 1 octave. Each octave costs three extra density taps per step, so start at 2.++Known gap (issues #661 and #664): the MCP tool schema refuses these fields today. `scene_create` and `scene_apply`+return "Unrecognized keys: scatterOctaves, multiScatter" for `volumeFog`, so multiple scattering is not reachable over+MCP yet; the library (`createAgentScene`) accepts them. Do not retry: build the fog from `density`, `anisotropy`,+`noiseAmount` and `heightFalloff`, and tell the user the opt-in scattering needs the schema fix. Check+`scene_capabilities` once in a while, since the fix removes this note.++Point lights do not scatter in volume fog; the sun does. A sunlit closed room with fog uses `bake.gridFog`+(see `light.md`). Animate density with an `environment` track `volumeFogDensity` (see `film-and-animation.md`).++## Exposure, bloom, contrast, occlusion++`effects` holds `exposure`, `saturation`, `contrast`, `temperature`, `vignette`, `grain`, `ambientOcclusion` (0 = off),+`bloom` and `depthOfField` (see `camera.md`). Nested `bloom` fields merge.++Tool `scene_apply`:++```json+{ "expectedRevision": 6, "operations": [+ { "type": "set-effects", "effects": { "exposure": 1.2, "vignette": 0.25, "bloom": { "strength": 0.2, "threshold": 1.2 }, "ambientOcclusion": 0.5 } }+] }+```++Overexposed highlights (flat white sky, clipped lamp): lower `exposure` or the light's `intensity` before adding bloom.++## Outlines and toon light++```json+{ "expectedRevision": 7, "operations": [+ { "type": "set-environment", "environment": { "lines": { "width": 2, "toon": 3 } } }+] }+```++`"lines": null` removes it. `scene_capabilities` reports `lineArt`.diff --git a/skills/build-67js-scene/references/mesh-modeling.md b/skills/build-67js-scene/references/mesh-modeling.mdindex 2bca742b..8a1130d8 100644--- a/skills/build-67js-scene/references/mesh-modeling.md+++ b/skills/build-67js-scene/references/mesh-modeling.md@@ -4,7 +4,7 @@This is the [mesh modeling guide](#mesh-modeling-for-agents). Read [Workflow](#workflow) and[Choosing faces and edges](#choosing-faces-and-edges) completely before the first edit. Read the[Recipes](#recipes) entry closest to the shape you are building, [Giving a part a surface](#giving-a-part-a-surface) for-textures, and [Errors and fixes](#errors-and-fixes) when a call fails. The full contract (every op, field and default) is the checkout's `docs/mesh.md`; `docs/mcp.md` lists+textures, and [Errors and fixes](#errors-and-fixes) when a call fails. The full contract (every op, field and default) is `docs/mesh.md` in the npm package; `docs/mcp.md` liststhe tools.<!-- skill-navigation:end -->diff --git a/skills/build-67js-scene/references/scene-contract.md b/skills/build-67js-scene/references/scene-contract.mdindex 24973e36..6e8cc38b 100644--- a/skills/build-67js-scene/references/scene-contract.md+++ b/skills/build-67js-scene/references/scene-contract.md@@ -73,7 +73,7 @@ Each light provides `position` and optional `color`, `intensity`, `radius`, `ran`castShadow: true` on a point light uses 6 of the 24 shadow tiles, on a spot light 1. Past 24 the edit is rejected. Shadows reach `range`, or 30 units when `range` is 0. Set `castShadow` on the few lights that show a visible shadow, because each one adds a depth pass. `affects: ['node-id', ...]` on a point, spot or area light, and `environment.keyAffects` for the sun, limit a light to those nodes (a light without it lights every node; an unknown ID is rejected; the bake honours it, the path tracer ignores it and says so). `environment.shadowCascades` (1 to 4, 0 for one map) sharpens a long sun shadow near the camera; it turns on by itself at 3 when `shadow.extent` is above 40, so set it only to choose another count or 0. Details: docs/lighting.md.`keyIntensity`, `fillIntensity` and `ambientIntensity` independently scale existing lighting.-Read the checkout's `docs/lighting.md` for defaults, numeric limits and frame overrides.+Read `docs/lighting.md` in the npm package for defaults, numeric limits and frame overrides.Point lights currently cast no local shadows. Radius limits attenuation without creating an area emitter.`environment.volumeFog` receives directional scattering and shadows in one bounded volume.@@ -147,10 +147,10 @@ Read `docs/surface-attachment.md`. Share its retained `matrix` with the accessorThe frame follows relative morphs before four-influence skinning. Clearance uses world units and the geometric triangle normal.Bind immutable geometry once. This sparse point attachment does not deform the accessory or certify clearance over its footprint.-The surface-attachment addon is included in npm `0.4.1`.+Agent authoring uses `createAgentScene(recipe, limits)` from `67js/addons/agent-scene`.-This addon is included in npm `0.5.0` and later.+Read `docs/agent-scene.md` for schema version one, immutable resources and atomic topology commands.Start with capabilities and bounded inspection. Edit stable IDs through one `apply` batch with the current `expectedRevision`.@@ -166,7 +166,7 @@ Do not inspect all vertex bounds in a frame loop. Memory estimates cover uniqueThe scene addon does not implement MCP transport, asset search, or render jobs.-Release `0.7.0` adds recipe-owned procedural motion. Read `docs/agent-motion.md` before authoring local node, material or camera tracks.+Recipes own procedural motion. Read `docs/agent-motion.md` before authoring local node, material or camera tracks.Use `set-motion` for revisioned edits and `sampleMotion(time)` for transient poses. Sampling preserves geometry, canonical recipes and revisions.Use `sampleMotion(null)` for the authored base pose. Inspection bounds remain authored-base-world, independent of transient motion.@@ -176,17 +176,17 @@ Use the revision returned by each committed apply or restore. A response with `cInspect or export the canonical recipe after a render failure. Do not retry the edit with its old revision.The server retains one renderer, bounds image dimensions and payloads, and closes its browser on stdio EOF.-Export the recipe before disposal. Release `0.6.0` includes bounded snapshot PNG, still and MP4 jobs documented in `docs/agent-render-jobs.md`.-Release `0.7.0` supports procedural `motionTime` preview seeks and `settings.motion.start` in jobs. Imported tracks retain their separate clip workflow.+Export the recipe before disposal. The server runs bounded snapshot PNG, still and MP4 jobs documented in `docs/agent-render-jobs.md`.+It supports procedural `motionTime` preview seeks and `settings.motion.start` in jobs. Imported tracks retain their separate clip workflow.-Release `0.9.0` adds `scene_review` for up to four labeled cameras or pose samples without editing the source.+`scene_review` compares for up to four labeled cameras or pose samples without editing the source.Read `docs/agent-review.md`. Each shot starts from the authored base pose and reports its camera, clocks and actual render resources.For imported models, read `docs/agent-asset.md`, configure `--assets` with an absolute local GLB directory, then select a digest from `scene_asset_catalog`.Use `scene_create_asset` with a `67js.asset` recipe. Supported texture maps, skinning, morphs and existing clips remain attached to decoded meshes.Edit imported models through `set-root`, factor-only `set-material`, look commands and absolute `set-animation` sampling. Imported topology is immutable.-Release `0.8.0` adds imported source-node overrides and motion. Read `docs/agent-character-motion.md` before editing a rig.+Imported source-node overrides and motion exist. Read `docs/agent-character-motion.md` before editing a rig.Inspect `kind: 'hierarchy'` with offset and limit for stable `node-N` IDs, parents, joint flags and editability.Use `set-asset-node` for local TRS and `set-motion` for authored tracks. Keep decoded skin bindings, maps and topology unchanged.@@ -197,7 +197,7 @@ Discard failed candidate poses before renderer upload. Flat models need a rig beUse `{ type: 'set-animation', time }` to sample the current clip. `{ type: 'set-animation', clip: null }` restores the decoded pose.Bounds describe authored base geometry, not the deformed skin/morph silhouette. Check the rendered PNG before accepting framing.-Read `docs/agent-look.md` for authored lighting, fog, effects and shadow coverage, included in npm `0.5.0`.+Read `docs/agent-look.md` for authored lighting, fog, effects and shadow coverage,.Use atomic `set-environment`, `set-effects` and `set-shadow` partial records instead of editing renderer internals through MCP.Nested `volumeFog` and `bloom` fields merge. The `pointLights`, `spotLights` and `areaLights` fields each replace the full list. Point and spot lights cast shadows only with `castShadow: true`; area lights never do.diff --git a/skills/evals/run.mjs b/skills/evals/run.mjsnew file mode 100644index 00000000..7769f3a2--- /dev/null+++ b/skills/evals/run.mjs@@ -0,0 +1,130 @@+// Runs the skill evals through headless `claude -p` with the 67js MCP server, one model at a time.+// Usage: node skills/evals/run.mjs --model haiku|sonnet|opus [--only <eval name>] [--out <folder>]+// It needs the built server (`npm run build:lib`), Chrome and the claude CLI. Each eval file holds a prompt and checks that+// read the tool calls and the last recipe the agent exported with scene_export_recipe. Skills are injected as system+// prompt text (with ${CLAUDE_SKILL_DIR} replaced), because the claude CLI would otherwise also load the user's own copies.+import { spawn } from 'node:child_process';+import { mkdirSync, mkdtempSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++const skillsFolder = resolve(dirname(fileURLToPath(import.meta.url)), '..');+const repositoryRoot = resolve(skillsFolder, '..');+const options = Object.fromEntries(process.argv.slice(2).reduce((pairs, value, index, all) => (value.startsWith('--') ? [...pairs, [value.slice(2), all[index + 1]]] : pairs), []));+const model = options.model ?? 'haiku';+const outputFolder = resolve(options.out ?? mkdtempSync(join(tmpdir(), 'skill-evals-')));+mkdirSync(outputFolder, { recursive: true });++function loadEvals() {+ const evals = [];+ for (const skill of readdirSync(skillsFolder, { withFileTypes: true })) {+ if (!skill.isDirectory()) continue;+ let files = [];+ try { files = readdirSync(join(skillsFolder, skill.name, 'evals')).filter(name => name.endsWith('.json')); } catch { continue; }+ for (const file of files) evals.push(JSON.parse(readFileSync(join(skillsFolder, skill.name, 'evals', file), 'utf8')));+ }+ return evals.filter(item => !options.only || item.name === options.only);+}++function skillText(skill) {+ const folder = join(skillsFolder, skill);+ const text = readFileSync(join(folder, 'SKILL.md'), 'utf8').replaceAll('${CLAUDE_SKILL_DIR}', folder.replaceAll('\\', '/'));+ return `<skill name="${skill}">\n${text}\n</skill>`;+}++function runClaude(item, workFolder) {+ const mcpConfig = {+ mcpServers: { '67js': { command: process.execPath, args: [join(repositoryRoot, 'bin', '67js-mcp.mjs'), '--backend', 'cpu', '--jobs', join(workFolder, 'jobs')] } },+ };+ const configPath = join(workFolder, 'mcp.json');+ writeFileSync(configPath, JSON.stringify(mcpConfig));+ const system = `You have the 67js MCP tools. Follow these skills. Read bundled reference files with the Read tool.\n${item.skills.map(skillText).join('\n')}`;+ const args = ['-p', '--model', model, '--output-format', 'stream-json', '--verbose', '--mcp-config', configPath, '--strict-mcp-config',+ '--disable-slash-commands', '--allowedTools', 'mcp__67js__*', 'Read', '--append-system-prompt', system, '--permission-mode', 'default'];+ return new Promise(resolveRun => {+ const child = spawn('claude', args, { cwd: workFolder, stdio: ['pipe', 'pipe', 'pipe'] });+ let output = '';+ const timer = setTimeout(() => child.kill(), (item.timeoutSeconds ?? 420) * 1000);+ child.stdout.on('data', chunk => { output += chunk; });+ child.stderr.on('data', () => {});+ child.on('close', () => { clearTimeout(timer); resolveRun(output); });+ child.stdin.end(item.prompt);+ });+}++function readTranscript(output) {+ const calls = [];+ const results = new Map();+ for (const line of output.split('\n')) {+ if (!line.trim().startsWith('{')) continue;+ let event;+ try { event = JSON.parse(line); } catch { continue; }+ for (const block of event.message?.content ?? []) {+ if (block.type === 'tool_use') calls.push({ id: block.id, tool: block.name.replace(/^mcp__67js__/, ''), input: block.input });+ if (block.type === 'tool_result') {+ const text = Array.isArray(block.content) ? block.content.filter(part => part.type === 'text').map(part => part.text).join('\n') : String(block.content);+ results.set(block.tool_use_id, { text, isError: block.is_error === true });+ }+ }+ }+ return { calls, results };+}++function lastRecipe({ calls, results }) {+ for (const call of [...calls].reverse()) {+ if (call.tool !== 'scene_export_recipe') continue;+ try {+ const parsed = JSON.parse(results.get(call.id)?.text ?? '');+ return parsed.recipe ?? parsed;+ } catch { /* keep looking */ }+ }+ return null;+}++const valueAt = (object, path) => path.split('.').reduce((value, key) => (value == null ? undefined : value[key]), object);++function runCheck(check, transcript, recipe) {+ const { calls } = transcript;+ if (check.anyOf) return check.anyOf.some(inner => runCheck(inner, transcript, recipe));+ if (check.atMostOne) return check.atMostOne.filter(inner => runCheck(inner, transcript, recipe)).length < 2;+ if (check.toolCalled) return calls.some(call => call.tool === check.toolCalled);+ if (check.toolInputIncludes) {+ return calls.some(call => call.tool === check.toolInputIncludes.tool && JSON.stringify(call.input).includes(check.toolInputIncludes.text));+ }+ if (check.lookAfterLastEdit) {+ const edits = ['scene_create', 'scene_apply', 'scene_restore'];+ const lastEdit = calls.findLastIndex(call => edits.includes(call.tool));+ return calls.findLastIndex(call => call.tool === 'scene_look') > lastEdit && lastEdit >= 0;+ }+ const value = valueAt(recipe, check.path);+ if (check.op === 'exists') return value !== undefined && value !== null;+ if (check.op === 'absent') return value === undefined || value === null || value === 0;+ if (check.op === 'equals') return value === check.value;+ if (check.op === 'gt') return typeof value === 'number' && value > check.value;+ if (check.op === 'someMatches') {+ return Array.isArray(value) && value.some(entry => Object.entries(check.match).every(([key, expected]) => (expected === '*' ? entry[key] !== undefined : entry[key] === expected)));+ }+ if (check.op === 'minLength') return Array.isArray(value) && value.length >= check.value;+ throw new Error(`Unknown check ${JSON.stringify(check)}`);+}++const summary = [];+for (const item of loadEvals()) {+ const workFolder = mkdtempSync(join(outputFolder, `${item.name}-`));+ const started = Date.now();+ const output = await runClaude(item, workFolder);+ writeFileSync(join(workFolder, 'transcript.jsonl'), output);+ const transcript = readTranscript(output);+ const recipe = lastRecipe(transcript) ?? {};+ const failures = [];+ for (const check of item.checks) {+ let passed = false;+ try { passed = runCheck(check, transcript, recipe); } catch (error) { failures.push(`${check.label}: ${error.message}`); continue; }+ if (!passed) failures.push(check.label);+ }+ const result = { name: item.name, model, passed: failures.length === 0, failures, toolCalls: transcript.calls.length, seconds: Math.round((Date.now() - started) / 1000) };+ summary.push(result);+ console.log(JSON.stringify(result));+}+writeFileSync(join(outputFolder, `summary-${model}.json`), JSON.stringify(summary, null, 2));diff --git a/skills/render-67js-media/SKILL.md b/skills/render-67js-media/SKILL.mdindex c835cd4b..bba45985 100644--- a/skills/render-67js-media/SKILL.md+++ b/skills/render-67js-media/SKILL.md@@ -1,61 +1,53 @@---name: render-67js-media-description: Export 67js scenes to PNG or MP4 on GPU or CPU. Use for render ảnh/video 3D, export presets, MSAA quality, performance measurements and bounded RAM/VRAM capture without buffering full frame sequences.+description: Export a 67js scene to PNG stills, render passes or an MP4 through the MCP render job tools (scene_render_submit, scene_render_status, scene_render_result) of the npm package @codepawlhq/67js. Use when an agent must render an image or video of a scene, play a camera or light animation to video, cut shots with a timeline, add a score, write depth or object-ID passes, path trace a still, choose GPU or CPU and an encoder, or stay inside memory limits. Also for "render ảnh 3D", "render video 3D", "xuất mp4", "export 67js", "render bị lỗi bộ nhớ", "chất lượng MSAA". Scene building is the build-67js-scene skill.license: MIT----# Xuất ảnh và video 67js--Locate the 67js checkout and read its `scripts/render-media.mjs` and `src/budget.js`.-Read [rendering.md](references/rendering.md) for commands, backends and measurement limits.-Use the repository pipeline rather than constructing a parallel exporter.--For MCP snapshot jobs, read the checkout's `docs/agent-render-jobs.md` and verify source versus published support.-Configure a private job store. Poll status after cancellation before resuming preview edits.-For a video with cuts, sound or an encoder choice, use the recipe `timeline`, `settings.timeline`, `settings.audio` (a file in the server's `--audio` folder) and `settings.encoder` described in the same document; the job reports measured sync.-For procedural motion, read `docs/agent-motion.md` and select `settings.motion.start`. Preview seeks preserve revisions and authored recipes.--For imported character motion from `0.8.0`, read `docs/agent-character-motion.md`. Use independent `settings.animation` and `settings.motion` clocks.--For an offline path-traced still with **Cook** (glass refraction, soft multi-bounce indirect light, subsurface random walk, many lights), read `docs/path-tracer.md` and submit an `image` job with `settings.renderer: { type: "pathTracer" }`. It is slow, bounded and offline: read `scene_capabilities` `pathTracer` for its limits and what it skips, and keep rasterizer jobs for video and passes.--## Render a scene.json world along a camera track--To film a world the showcase page shows (GLB, sky, renderer options, exposure, effects), plan the path and render it headless:--```powershell-# keys.json: { "fps": 24, "frames": [[[x, y, z], [tx, ty, tz]], ...] } (one eye and target per frame; createCameraPath keys also work)-node scripts/render-media.mjs --kind video --scene file --config public/showcase/bistro/scene.json --camera keys.json --width 960 --height 540 --duration 5 --output artifacts/walk.mp4-```--`--root <folder>` names the folder that `/showcase/...` paths in the config are relative to; without it they resolve next to the config. `--duration` and `--start` pick a slice of the track (default: all of it, at the track's fps). Check one frame first with `--kind image --time 2.5`.--## Choose and render--1. Check the available GPU memory before a GPU job on a shared machine.-2. Choose GPU rendering for speed. Choose the CPU preset when hardware WebGL is unavailable.-3. Choose the smallest preset that meets the output requirement.-4. Set width, height, samples and memory before rendering.-5. Keep one browser, one live scene renderer and one pending capture frame.-6. Stream frames to FFmpeg. Await encoder backpressure before capturing the next frame.-7. Stop on browser errors, graphics errors or a memory guard failure.-8. Inspect representative stills before the full film export.-9. Verify duration, frame count, dimensions, color metadata, audio and file size with FFprobe.-10. Inspect the output report and close the browser and encoder after the job.--Use below-normal priority for heavy local exports. Do not stop another session's process.-Use deterministic scene time. Do not use a real-time screen recording for offline export.--CPU encoding and CPU rendering are separate choices.-GPU encoding uses NVENC when supported. CPU encoding uses two threads by default.--## Report the limits--The framebuffer estimate is an allocation model, not a measured total VRAM figure.-Node RSS and the sampled browser JavaScript heap do not cover every browser allocation.-Report the actual renderer backend, estimated target memory, observed process metrics and elapsed export time.-Do not promise that a budget prevents every driver or system allocation failure.-When resolution is reduced, state the actual render dimensions.--Deliver the PNG or MP4, its JSON report and the reproduction command.-For a score, record provenance and measured loudness. Say whether anyone listened to it.+# Export images and video from 67js over MCP++A render job is an immutable snapshot of the active scene. Edits made while it runs do not change it, and it does not+change the scene's revision, pose or checkpoints. The MCP server must have been started with `--jobs <abs private dir>`;+MP4 also needs `ffmpeg` on PATH or `--ffmpeg <abs path>`, and sound needs `--audio <abs dir>`. Without `--jobs` the+submit call fails: tell the user which launch option is missing.++## Steps++1. `scene_look` first. Never submit a job for a scene you have not looked at.+2. `scene_inspect` for the current `revision`.+3. `scene_render_submit` with `expectedRevision` and `settings`. Start small: one image at 960x540.+4. `scene_render_status` with the `jobId` until the state is terminal (`completed`, `failed`, `cancelled`,+ `interrupted`). Poll about every 5 to 10 seconds, and for video read the durable frame progress. Never loop tightly.+5. `scene_render_result`: output paths, SHA-256 hashes and metrics. Report the actual `width` and `height`, the backend+ and the seconds; memory limits can lower the size.+6. Keep what you need, then `scene_render_release` to remove the job's files.+7. `scene_render_cancel` stops a job; poll `scene_render_status` until it is `cancelled` before editing again.++## Settings by task++| Task | Read |+|---|---|+| Image, stills, video, motion clock, shots, audio, encoder, passes, path tracer | `${CLAUDE_SKILL_DIR}/references/jobs.md` |+| Size, memory, GPU or CPU, time limits, verifying the file | `${CLAUDE_SKILL_DIR}/references/limits-and-checks.md` |+| A job failed or the result looks wrong | `${CLAUDE_SKILL_DIR}/references/errors-and-recovery.md` |+| Rendering in a source checkout with `scripts/render-media.mjs` (contributors only) | `${CLAUDE_SKILL_DIR}/references/rendering.md` |++## Rules++- Smallest output that meets the need: a still before a video, a 2 second slice before the full film.+ Every film round starts as a small, low-quality preview with sound; full quality only after sign-off.+- Time is deterministic. A frame depends on its time only, so a seek gives the same pixels as the frame in a video.+ Never record the screen.+- Use `settings.motion: { "start": 0 }` to play recipe tracks (camera, nodes, lights, sun, sky, effects). Without it the+ job holds the first pose, which is the usual reason a video is a still frame. A recipe with a `timeline` uses+ `settings.timeline` and rejects `motion` and `animation`.+- Imported clips use `settings.animation`; the two clocks are independent.+- Path tracing (`settings.renderer`) is offline and slow, for stills; video and passes use the rasterizer.+- Do not stop another session's process. Heavy local exports run at below-normal priority, one job at a time.+- A GLB for Blender is `scene_export_glb`, not a render job.++## Deliver++The file path, its JSON metrics, the settings you sent and one frame you looked at. Say what was measured (frames,+duration, seconds, dimensions) and what was judged by eye. Say whether anyone listened to the audio; a score+needs provenance and measured loudness.diff --git a/skills/render-67js-media/evals/depth-pass-still.json b/skills/render-67js-media/evals/depth-pass-still.jsonnew file mode 100644index 00000000..5998c327--- /dev/null+++ b/skills/render-67js-media/evals/depth-pass-still.json@@ -0,0 +1,15 @@+{+ "name": "depth-pass-still",+ "skills": ["render-67js-media"],+ "prompt": "Using the 67js MCP tools and the render-67js-media skill: create a scene with a ground slab and a box, look at it, then render a 640x360 PNG still that also writes a depth pass. Wait for the job to finish, read its result, release it, and finish by calling scene_export_recipe. Keep it short.",+ "expected": "scene_render_submit was called with kind image and passes including depth, status was polled, the result was read and the job released.",+ "timeoutSeconds": 600,+ "checks": [+ { "label": "looked before submitting", "toolCalled": "scene_look" },+ { "label": "submitted an image job", "toolInputIncludes": { "tool": "scene_render_submit", "text": "\"kind\":\"image\"" } },+ { "label": "asked for a depth pass", "toolInputIncludes": { "tool": "scene_render_submit", "text": "depth" } },+ { "label": "polled status", "toolCalled": "scene_render_status" },+ { "label": "read the result", "toolCalled": "scene_render_result" },+ { "label": "released the job", "toolCalled": "scene_render_release" }+ ]+}diff --git a/skills/render-67js-media/references/errors-and-recovery.md b/skills/render-67js-media/references/errors-and-recovery.mdnew file mode 100644index 00000000..17dd1a69--- /dev/null+++ b/skills/render-67js-media/references/errors-and-recovery.md@@ -0,0 +1,30 @@+# Render errors and recovery++A rejected `scene_render_submit` creates no job. A job that fails keeps its record until you release it. Read the+message first: each one names the cause and the next step.++| Sign | Cause | Do |+|---|---|---|+| Submit says render jobs need a job store | The server started without `--jobs`. | Ask the user to restart with `--jobs <abs private dir>`; an agent cannot add it. |+| `expectedRevision must match the current revision.` | The scene changed since you read it. | `scene_inspect`, resubmit with the new revision. |+| Settings rejected as unknown field | A typo, or a field of another tool (for example `time`). | Use the names in `jobs.md`; `scene_render_submit` lists the schema. |+| Video is a still frame | No `motion: { "start": 0 }`. | Add it and resubmit. |+| Sampled time past the motion | A nonlooping motion is shorter than `start + duration`. | Lengthen the motion, set `loop: true` or shorten the job. |+| `motion` or `animation` rejected with `timeline` | The timeline owns the clock. | Send `timeline: { "start": 0 }` only. |+| ffmpeg not found | MP4 needs ffmpeg. | Ask for `--ffmpeg <abs path>` or ffmpeg on PATH; a PNG or stills job does not need it. |+| `nvenc` fails | No NVENC on this machine; there is no fallback. | Resubmit with `encoder: "cpu"`. |+| Audio file not found or too short | `audio.file` is not a plain name in `--audio`, or it ends before the video. | Use a name from that folder and a smaller `offset`. |+| `metrics.sync` difference over 50 ms | Encode drift. | The job fails; resubmit, and report it if it repeats. |+| Path tracer `gpu` refused | The server runs with `--backend cpu`. | Use `backend: "cpu"` or ask for a GPU server. |+| Smaller output than asked | The memory budget reduced it. | Report the actual size; ask for a larger `--memory` if size matters. |+| State `failed` with a time limit | The job passed 60 s plus 2 s per frame. | Lower the size, fps or samples, or split the film into parts. |+| State `interrupted` | The server restarted during the job. | Recovery never restarts rendering; resubmit. |++## Recover++1. `scene_render_cancel` if it is still running, then poll `scene_render_status` until `cancelled`.+2. Preview edits work again once the job is terminal.+3. Fix one setting, resubmit a small version (a still or 2 seconds) and check it before the full job.+4. `scene_render_release` every job you are done with, failed ones too, so the store stays small.+5. If a valid job fails with a graphics error or a crash, stop retrying. File an issue at `codepawl/67.js` with the+ settings, the recipe from `scene_export_recipe` and the `scene_render_result` or status message. No local paths.diff --git a/skills/render-67js-media/references/jobs.md b/skills/render-67js-media/references/jobs.mdnew file mode 100644index 00000000..79ac4efb--- /dev/null+++ b/skills/render-67js-media/references/jobs.md@@ -0,0 +1,95 @@+# Render job settings++Every recipe is the arguments of `scene_render_submit`. `sessionId` may be left out. `expectedRevision` is the+revision `scene_inspect` returned. Required in `settings`: `kind` (`image`, `stills` or `video`), `width`, `height`+(64 to 1920 each; video sizes must be even). Defaults: 24 fps and one second.+`tests/render-skill-examples.test.js` checks that these blocks stay valid JSON with known settings fields.++## One PNG++```json+{ "expectedRevision": 3, "settings": { "kind": "image", "width": 960, "height": 540 } }+```++An image samples the pose at `motion.start`, so a still of a mid-animation moment is+`"motion": { "start": 2.5 }`. Lens, depth of field, look and fog come from the recipe, so a still matches `scene_look`.++## Eight stills++`kind: "stills"` writes eight evenly spaced PNGs (a contact sheet of a motion). Use it to check a film before you+render the video.++```json+{ "expectedRevision": 3, "settings": { "kind": "stills", "width": 640, "height": 360, "duration": 4, "motion": { "start": 0 } } }+```++## MP4 of recipe motion++```json+{ "expectedRevision": 3, "settings": {+ "kind": "video", "width": 1280, "height": 720, "fps": 24, "duration": 4, "motion": { "start": 0 }+} }+```++Video is H.264 with one frame in flight. At most 60 s and 900 frames, so 60 s needs 15 fps or less. A nonlooping+motion must cover `start + duration`. The animated lights, sun, sky and effects tracks play with the same setting.+Motion blur (`effects.motionBlur.shutter`) needs camera tracks and this `motion` setting.++## Shots, cuts and sound++A recipe `timeline` (see `build-67js-scene`, `film-and-animation.md`) plays its shots, so the job takes `timeline`+and no `motion` or `animation`. `duration` defaults to the rest of the timeline.++```json+{ "expectedRevision": 4, "settings": {+ "kind": "video", "width": 1280, "height": 720, "fps": 24,+ "timeline": { "start": 0 },+ "audio": { "file": "score.wav", "offset": 0 }+} }+```++`audio.file` is a plain name of a `.wav`, `.mp3`, `.ogg` or `.flac` file (32 MiB at most) in the server's `--audio`+folder; no path or URL. It is resampled to 48 kHz and encoded as AAC. The result reports `metrics.sync`, and a+difference over 50 ms fails the job. A file shorter than the video after its `offset` fails before rendering. For a film+longer than one job (60 s) render parts with `track: "pcm"` (lossless, no encoder padding) and join them with+`ffmpeg -f concat -safe 0 -i parts.txt -c copy joined.mp4`, then lay the sound once.++## Encoder++`encoder: "cpu"` (libx264, default) or `"nvenc"` (h264_nvenc, in-page hardware encoding). A machine without NVENC+fails the job and does not fall back, so choose `cpu` unless you know the machine. The result reports+`metrics.videoEncoder`, `captureSeconds` and `renderSeconds`.++## Render passes++`image` and `stills` jobs take `passes`, a list of `albedo`, `normal`, `emission`, `depth` and `objectId`. Each frame+also writes one raw PNG per pass at the lit image's size, with no grading, bloom, depth of field or antialiasing.++```json+{ "expectedRevision": 3, "settings": { "kind": "image", "width": 960, "height": 540, "passes": ["depth", "objectId"] } }+```++Only opaque and cutout geometry appears. `scene_render_result` metrics carry `objectNames` (read the names for the IDs;+IDs follow draw order, not node order) and `depthRangeMetres`. Depth is metres over 100 in a 16-bit value (high byte+in red, low in green); background is `255, 255, 0`. Videos hold the lit image only.++## Path traced still++Offline Cook path tracing: glass refraction, soft multi-bounce light, subsurface, many lights. Slow and bounded, for+stills. Read `scene_capabilities` (`pathTracer`) for limits and what it skips.++```json+{ "expectedRevision": 3, "settings": {+ "kind": "image", "width": 960, "height": 540,+ "renderer": { "type": "pathTracer", "backend": "cpu", "samples": 64, "bounces": 8, "denoise": true, "maxSeconds": 120 }+} }+```++`backend` is `cpu` (default, reproducible), `gpu` (needs a server started with `--backend gpu`) or `native`+(hardware ray queries; it falls back to `gpu` or `cpu` and `metrics.pathTracer.backendNote` says why). Start with 16+samples to judge the light, then raise them.++## Imported character clips++`animation: { "clip": 0, "start": 1 }` samples an imported asset's clip and `rendererTime` sets shader time. They+are separate clocks from `motion`. Clip ids come from `scene_inspect`.diff --git a/skills/render-67js-media/references/limits-and-checks.md b/skills/render-67js-media/references/limits-and-checks.mdnew file mode 100644index 00000000..eddc982e--- /dev/null+++ b/skills/render-67js-media/references/limits-and-checks.md@@ -0,0 +1,42 @@+# Limits and checks++## Server options (the user sets them, not the job)++| Option | Meaning |+|---|---|+| `--backend gpu` or `cpu` | gpu is the default and fast; cpu is SwiftShader, for machines without hardware WebGL, much slower. |+| `--memory <32..384>` | Render-target budget in MiB, default 192. A 1920x1080 frame needs about 175 MiB at 4 samples (measured), so use 256 for it and more for textured scenes. |+| `--jobs <abs dir>` | Private store for job files. Required for any job. |+| `--ffmpeg <abs path>` | Needed for MP4 when ffmpeg is not on PATH. |+| `--audio <abs dir>` | The folder `settings.audio.file` names a file from. |++`scene_capabilities` reports the backend, memory, job limits and the job UUIDs it holds after a restart. Check it+before you promise a size or a sound track.++## Job limits++- Width and height 64 to 1920 each, within the memory budget. A job that does not fit is reduced; the result reports+ the actual dimensions, so say them.+- Video: at most 60 s and 900 frames (60 s needs 15 fps or less), even dimensions, shots up to 64 and 60 s total.+- Time allowed: 60 s plus 2 s per frame (more above 1024x576), at most 30 minutes. A path traced still has its own+ `maxSeconds`.+- A job leases the single preview renderer: previews and edits pause while it runs, inspection and recipe export stay+ available. Plan one job at a time.++## Check the result++1. `scene_render_result` lists files and SHA-256 hashes. Compare `metrics` frame count and duration with what you asked.+2. Look at one frame: the PNG itself, or for video a still of the same `motion.start` (the timeline seek gives the same+ pixels as the frame inside the video).+3. For video, verify with ffprobe when it is installed:+ `ffprobe -v error -count_frames -show_entries stream=codec_name,width,height,r_frame_rate,nb_read_frames:format=duration,size -of json <file>`.+4. With audio, read `metrics.sync` (`differenceSeconds` under 0.05). It proves alignment, not that the sound is good.+5. The framebuffer figure is an allocation model, not total VRAM, and Node and browser heap samples do not cover every+ allocation. Report them as estimates.++## Speed++Capture cost dominates video. `metrics.captureSeconds` and `renderSeconds` show where the time went. Hardware+`nvenc` encoding in the page was measured about 7 times faster than screenshots on one RTX 3060 (1280x720, 4,488 frames:+20.6 s against 139.6 s); that is one machine, so measure before you promise a time. Machine load changes timings, so+report a range, not one number.diff --git a/tests/render-skill-examples.test.js b/tests/render-skill-examples.test.jsnew file mode 100644index 00000000..94e0e11e--- /dev/null+++ b/tests/render-skill-examples.test.js@@ -0,0 +1,30 @@+import assert from 'node:assert/strict';+import test from 'node:test';+import { readFile } from 'node:fs/promises';++// The render-67js-media skill teaches agents scene_render_submit by example. Every json block in its jobs reference must be+// valid JSON whose settings use only fields the tool schema declares, and a kind, width and height the schema requires.+const serverSource = await readFile(new URL('../scripts/mcp-server.mjs', import.meta.url), 'utf8');+const schemaStart = serverSource.indexOf('const renderSettings = z.strictObject({');+const schemaEnd = serverSource.indexOf('}).describe(', schemaStart);+const declaredFields = new Set([...serverSource.slice(schemaStart, schemaEnd).matchAll(/^ (\w+): z\./gm)].map(match => match[1]));+const referenceUrl = new URL('../skills/render-67js-media/references/jobs.md', import.meta.url);+const reference = await readFile(referenceUrl, 'utf8');+const submissions = [...reference.matchAll(/```json\r?\n([\s\S]*?)```/g)].map(match => JSON.parse(match[1]));++test('the render skill reference has submissions to check', () => {+ assert.ok(declaredFields.has('kind') && declaredFields.has('passes'), 'the schema fields were found');+ assert.ok(submissions.length >= 6);+});++submissions.forEach((submission, index) => {+ test(`render skill submission ${index + 1} uses declared settings`, () => {+ assert.ok(Number.isInteger(submission.expectedRevision));+ const { settings } = submission;+ for (const field of Object.keys(settings)) assert.ok(declaredFields.has(field), `${field} is not a render setting`);+ assert.ok(['image', 'stills', 'video'].includes(settings.kind));+ for (const side of [settings.width, settings.height]) assert.ok(Number.isInteger(side) && side >= 64 && side <= 1920);+ if (settings.kind === 'video') assert.ok(settings.width % 2 === 0 && settings.height % 2 === 0);+ if (settings.timeline) assert.ok(!settings.motion && !settings.animation, 'a timeline owns the motion clock');+ });+});diff --git a/tests/skill-examples.test.js b/tests/skill-examples.test.jsnew file mode 100644index 00000000..e392c6b3--- /dev/null+++ b/tests/skill-examples.test.js@@ -0,0 +1,59 @@+import './support/load-agent-scene-modules.mjs';+import assert from 'node:assert/strict';+import test from 'node:test';+import { readFile } from 'node:fs/promises';+import { createAgentScene } from '../src/agent-scene.js';+import { parseRadianceHdr } from '../src/hdri.js';+import { parseCube } from '../src/view-transform.js';+import {+ BUNDLED_CUBE_LOOK_NAMES, BUNDLED_ENVIRONMENT_NAMES, registerCatalogEnvironment, registerCatalogLook,+} from '../src/look-catalog.js';++// The build-67js-scene skill teaches agents the scene_apply tool by example. Every json block in these references that+// carries an `operations` list must keep applying to a fresh scene, so an API change fails here instead of misleading an agent.+const referenceNames = ['look', 'light', 'camera', 'film-and-animation'];++const shippedFile = (name, extension) => readFile(new URL(`../assets/looks/${name}.${extension}`, import.meta.url));+for (const name of BUNDLED_ENVIRONMENT_NAMES) registerCatalogEnvironment(name, parseRadianceHdr(await shippedFile(name, 'hdr')));+for (const name of BUNDLED_CUBE_LOOK_NAMES) registerCatalogLook(name, parseCube((await shippedFile(name, 'cube')).toString('utf8')));++function baseRecipe({ depthOfField }) {+ return {+ format: '67js.scene', schemaVersion: 1,+ geometries: [{ id: 'cube', type: 'box' }],+ materials: [{ id: 'paint', color: [0.4, 0.6, 0.8] }],+ nodes: [+ { id: 'body', geometry: 'cube', material: 'paint' },+ { id: 'lid', geometry: 'cube', material: 'paint', translation: [0, 1, 0] },+ ],+ environment: { pointLights: [{ position: [0, 2, 0], intensity: 4 }] },+ ...(depthOfField ? { effects: { depthOfField: { blur: 0.4, focusDistance: 4 } } } : {}),+ };+}++for (const name of referenceNames) {+ const url = new URL(`../skills/build-67js-scene/references/${name}.md`, import.meta.url);+ const text = await readFile(url, 'utf8');+ const blocks = [...text.matchAll(/```json\r?\n([\s\S]*?)```/g)].map(match => JSON.parse(match[1]));+ const applyBlocks = blocks.filter(block => Array.isArray(block.operations));+ const createBlocks = blocks.filter(block => block.recipe !== undefined);++ test(`skill reference ${name} has scene_apply examples to check`, () => {+ assert.ok(applyBlocks.length >= 3);+ });++ createBlocks.forEach((block, index) => {+ test(`skill reference ${name}, scene_create example ${index + 1} builds`, () => {+ createAgentScene(block.recipe);+ });+ });++ applyBlocks.forEach((block, index) => {+ test(`skill reference ${name}, example ${index + 1} applies to a fresh scene`, () => {+ // A camera f-stop and an effect blur are exclusive, so f-stop examples start without the effect.+ const depthOfField = !JSON.stringify(block).includes('fStop');+ const scene = createAgentScene(baseRecipe({ depthOfField }));+ scene.apply(block.operations, { expectedRevision: scene.revision });+ });+ });+}