---
name: dolly3d
description: Procedural 3D animation director for AI coding agents. Use when the user asks to create a 3D animated video, explainer, diorama, voxel world, toon breakdown, or multi-episode 1-world 3D series using Three.js and HyperFrames.
---
# dolly3d — Procedural 3D Motion Director
Turn your coding agent into a procedural 3D motion director. Every deliverable is a deterministic, frame-accurate Three.js + HyperFrames HTML scene inside **one continuous 3D world** with a moving dolly camera—never static slides.
---
## 1. Strict Style Router (Load Exactly ONE)
Determine the active style from the user's request (or from `world-state.json` when continuing an episode). Load **only the single matching style pack** to prevent style bleeding:
| Style ID | File to Read | Best For |
| ---------------- | ------------------------------------- | -------------------------------------------------------------------------------------------- |
| `diorama-toy` | `references/styles/diorama-toy.md` | Warm matte tabletop miniatures, villages, ecosystems, step-by-step builds, mascot explainers |
| `voxel-craft` | `references/styles/voxel-craft.md` | Crisp architectural/isometric block worlds, grid-locked cities, layered block-drop assembly |
| `toon-explainer` | `references/styles/toon-explainer.md` | Cel-shaded technical diagrams, mechanical cutaways, exploded views, 3D-to-2D callout labels |
If the user does not specify a style, recommend the best fit during the **Style Brief** step—do not guess silently and start coding.
---
## 2. Mandatory Reading Order
Before writing any scene code, read:
1. **Core rules (`references/core/`):**
- `references/core/hyperframes-bridge.md` (deterministic `renderAt(t)` & `hf-seek`)
- `references/core/camera-choreography.md` (one-take rail & shot progression)
- `references/core/spatial-rules.md` (grounding, scale, non-overlapping footprints)
- `references/core/visual-qa.md` (mandatory Playwright self-QA protocol)
- `references/core/world-state.md` _(required whenever creating or continuing a multi-episode series)_
- `references/core/audio-vo-sync.md` — Load whenever Voice-Over, `vo-transcript.json`, BGM/SFX, or MP4 export is requested.
2. **Exactly ONE style pack** from `references/styles/`.
3. **Starter & primitives:** Inspect `assets/starter.html` and `assets/primitives/index.js` so all builds reuse the tested helpers.
---
<!-- ‹guest · 2026-12-06› -->
## 3. Production Workflow (4 Mandatory Stages)
### Stage A — Brief Intake & World Continuity Check
- Check the workspace for an existing `world-state.json`.
- If continuing Episode `N + 1`, **lock the `style`** from `world-state.json`, match the opening camera to `cameraEnd`, preserve all previously built `zones[]` at full scale (`scale = 1`), and place new constructions in an unoccupied `(x, z)` lot.
- Confirm the core parameters: **topic/story**, **style**, **duration (seconds)**, **aspect ratio (`16:9` or `9:16`)**, and whether this is a standalone video or Episode `N` of a persistent world.
- Check whether the user supplied a `vo-transcript.json` or narration audio track; if present, derive scene duration and choreography beats directly from it.
### Stage B — Style Brief (STOP & Wait for Approval)
**Never write HTML/JS code before the user approves the Style Brief** (unless the user explicitly says _"skip brief"_ or _"build directly"_). Present a concise brief containing:
1. **Three Concept Candidates + 1 Recommended Pick:** Briefly contrast 3 visual/staging angles (e.g., camera route, build-up sequence, and focal reveal).
2. **1-World Zone & Footprint Map:** Non-overlapping `(x, z)` coordinates and footprint sizes for each major structure so zero geometry collides.
3. **Shot Progression & Timeline Beats:** Key timestamps (Establishing -> Approach -> Hero Detail -> Resolution/Handoff) matching captions or voice-over beats.
4. **Curated Palette Assignment:** Exact hex tokens taken from the active style pack and what each color represents.
Wait for the user's approval or edits before proceeding to Stage C.
### Stage C — Build Deterministic Scene
- Base the deliverable on `assets/starter.html` and import helpers from `assets/primitives/index.js` (`groundObject`, `stackOnTop`, `snapToGrid`, `enableShadows`, `createRiggedLighting`, `createCameraPath`, `seededRandom`, `segmentProgress`, `easeInOutCubic`, `springPop`).
- Ensure every animated property, camera transform, and HTML overlay is computed purely from `t` inside `renderAt(t)`.
- Expose `window.__dolly` (`duration`, `fps`, `seek(t)`, `getCameraEnd()`) and listen to `hf-seek`.
- Save the output as a clean episode HTML file (e.g., `episodes/ep01/index.html` or `index.html`, ensuring the relative path to `primitives/index.js` resolves cleanly or inlining the needed helpers if delivering a standalone folder).
- If episodic, write or update world-state.json immediately alongside the HTML file using the final point and target of your cameraPath as cameraEnd.
- Declare explicit HyperFrames root attributes on `#stage` (`data-composition-id`, `data-width`, `data-height`, `data-fps`, `data-duration`) matching the target ratio (`1920x1080`, `1080x1920`, or `1080x1080`).
- When `vo-transcript.json` is provided, use `createTimeline()` to drive all major reveals and camera beats instead of hardcoded seconds.
- Always import primitives from the root-relative path `/assets/primitives/index.js` (never relative `./primitives/...` or `../assets/...`) so both `npx serve .`, `scripts/snap.mjs`, and `hyperframes render -c <file>` resolve modules without 404s.
- Always wire the scene through `mountDollyRuntime()` and register `window.__timelines[COMPOSITION_ID] = runtime.timelineController;` instead of writing inline `requestAnimationFrame` or `performance.now()` loops inside the HTML file.
### Stage D — Visual Self-QA & Handoff
1. Run keyframe capture matching the scene's aspect ratio (pass --update-state <path-to-world-state.json> for episodic scenes so cameraEnd is synced automatically—do not try to read .qa-snaps/report.json manually):
```bash
node scripts/snap.mjs --file <path-to-scene.html> --ratio <16:9|9:16> [--update-state <path-to-world-state.json>]
```
2. Check the terminal output for runtime error counts and synced cameraEnd, and visually inspect all 5 PNGs inside .qa-snaps/<scene-slug>/ against the checklist in references/core/visual-qa.md (avoid relying on reading hidden .gitignored JSON files if the IDE restricts them).
<!-- ‹guest · 2026-12-06› -->
3. If any frame fails (runtime error, blank WebGL, floating mesh, camera clipping, cropped subject, overlapping HUD, or style violation), fix the code and re-run snap.mjs before delivering.
4. Deliver the scene file along with the exact local preview (#debug or press D / G for safe-zone guides) and unified MP4 export command: (`npm run export -- --file <path-to-scene.html> --ratio <16:9|9:16> [--transcript <path-to-vo-transcript.json>] [--gpu]`) commands.
---
## 4. Global Non-Negotiables (Anti-Slop Guardrails)
- **Zero state accumulation:** Never use `+=` per frame, `deltaTime`, or `Math.random()` inside `renderAt(t)`.
- **Zero floating props:** Every grounded mesh must pass through `groundObject()` or `stackOnTop()`.
- **Zero style bleeding:** Never mix spheres into `voxel-craft`, glossy plastic into `diorama-toy`, or unoutlined blurry shading into `toon-explainer`.
- **Zero raw primary colors:** Ban pure `#FF0000`, `#00FF00`, `#0000FF`.
- **Crisp geometric HUD:** Use Plus Jakarta Sans with `tabular-nums`, solid fills, and crisp borders. Ban unrequested gradients and glassmorphism on 2D overlays.
- **Keep sessions clean:** Recommend starting each new episode in a fresh chat session with `world-state.json` attached.
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.