3D Model Generator by Three.js
Generate model-specific JavaScript while keeping model construction helpers, validation, export, and review deterministic and reusable.
Workflow
Choose a task output directory outside this skill.
Run node scripts/init-model-task.mjs --out <task-dir> to copy the build-module template without overwriting existing work.
Read references/build-contract.md. Read references/builder-api.md before using bundled builders or helpers. Read references/export-formats.md before choosing formats.
Edit only <task-dir>/model-build.mjs. Export one buildModel(ctx) function and keep it deterministic.
Install the pinned runtime once with npm ci --prefix scripts.
Build, validate, and export:
node scripts/build-and-export.mjs --build <task-dir>/model-build.mjs --out <task-dir> --formats glb,obj,stl
Inspect <task-dir>/validation.json. Fix every error and evaluate warnings that affect the requested formats.
Render a deterministic PNG preview of the exported artifact:
node scripts/render-preview.mjs --model <task-dir>/model.glb --out <task-dir>/preview.png --views iso,front,top
Read references/preview-rendering.md for supported formats, views, and rendering limitations.
When interactive visual review is useful, run:
node scripts/serve-viewer.mjs --artifact-dir <task-dir> --model model.glb
Open the printed local URL with an available browser tool. Review the exported artifact, not only the source scene. Use --source model-build.mjs when source-scene comparison is needed.
Iterate by modifying only model-build.mjs, rebuilding, and reviewing again.
Build Rules
- Return a
THREE.Object3D or { root, animations, metadata }.
- Use
ctx.builders and ctx.helpers for common construction. Use ctx.THREE directly for custom geometry.
- Do not import modules from generated build code. Do not access files, processes, environment variables, network APIs, dynamic imports,
eval, or Function.
- Use
ctx.rng instead of Math.random() so revisions are reproducible.
- Treat Y as up and meters as the default unit unless the request requires otherwise.
- Prefer
MeshStandardMaterial, MeshPhysicalMaterial, or bundled material presets for GLB.
- Keep textures out of the default Node export path. Texture encoding requires a browser or a separate image-capable runtime.
- Set meaningful node names and organize multipart assets under groups.
- Keep triangle counts proportional to the requested use case. Use lower segment counts for distant or mobile assets.
Validation and Review
Run numeric validation before visual review. The validator checks finite transforms and vertices, empty geometry, normals, bounds, counts, unsupported shader materials, textures, and configured limits.
For visual review, inspect:
- silhouette and recognizable shape;
- relative scale and proportions;
- symmetry, alignment, grounding, and unintended intersections;
- front, rear, side, top, and perspective views;
- material separation and final-format fidelity;
- wireframe density when topology matters.
Prefer round-trip review of GLB, OBJ, or STL. Source mode can look correct even when export loses hierarchy, materials, transforms, or animations.
Completion Criteria
Complete a model task only when:
- the build module runs without forbidden capabilities;
- validation contains no errors;
- every requested file exists and is non-empty;
- exported-file review is satisfactory when browser review is available;
- the build is reproducible with the recorded seed;
- generated source and artifacts remain outside this skill directory.
Resources
scripts/runtime/: Stable build context, builders, helpers, seeded RNG, source checks, and scene validation.
scripts/exporters/: Format-specific GLB/glTF, OBJ, and STL exporters.
scripts/build-and-export.mjs: Main deterministic pipeline.
scripts/render-preview.mjs: Standalone exported-model PNG renderer.
scripts/serve-viewer.mjs: Local source and round-trip viewer server.
assets/model-build.template.mjs: Generated-task starting point.
assets/viewer/: Browser review application.
references/build-contract.md: Generated module contract and safety rules.
references/builder-api.md: Builder and helper API.
references/export-formats.md: Format capabilities and limitations.
references/preview-rendering.md: Standalone preview command and limitations.
1---2name: 3d-model-generator-by-threejs3description: Generate procedural 3D models from natural-language requests by writing a constrained buildModel(ctx) module that uses Three.js, bundled builders and helpers, deterministic validation and export scripts, PNG previews, and optional browser visual review. Use when needs to create, revise, export, or visually audit programmatic 3D assets in GLB, glTF, OBJ, or STL without Blender or another DCC tool.4---56# 3D Model Generator by Three.js78Generate model-specific JavaScript while keeping model construction helpers, validation, export, and review deterministic and reusable.910## Workflow11121. Choose a task output directory outside this skill.132. Run `node scripts/init-model-task.mjs --out <task-dir>` to copy the build-module template without overwriting existing work.143. Read `references/build-contract.md`. Read `references/builder-api.md` before using bundled builders or helpers. Read `references/export-formats.md` before choosing formats.154. Edit only `<task-dir>/model-build.mjs`. Export one `buildModel(ctx)` function and keep it deterministic.165. Install the pinned runtime once with `npm ci --prefix scripts`.176. Build, validate, and export:1819 ```text20 node scripts/build-and-export.mjs --build <task-dir>/model-build.mjs --out <task-dir> --formats glb,obj,stl21 ```22237. Inspect `<task-dir>/validation.json`. Fix every error and evaluate warnings that affect the requested formats.248. Render a deterministic PNG preview of the exported artifact:2526 ```text27 node scripts/render-preview.mjs --model <task-dir>/model.glb --out <task-dir>/preview.png --views iso,front,top28 ```2930 Read `references/preview-rendering.md` for supported formats, views, and rendering limitations.319. When interactive visual review is useful, run:3233 ```text34 node scripts/serve-viewer.mjs --artifact-dir <task-dir> --model model.glb35 ```3637 Open the printed local URL with an available browser tool. Review the exported artifact, not only the source scene. Use `--source model-build.mjs` when source-scene comparison is needed.3810. Iterate by modifying only `model-build.mjs`, rebuilding, and reviewing again.3940## Build Rules4142- Return a `THREE.Object3D` or `{ root, animations, metadata }`.43- Use `ctx.builders` and `ctx.helpers` for common construction. Use `ctx.THREE` directly for custom geometry.44- Do not import modules from generated build code. Do not access files, processes, environment variables, network APIs, dynamic imports, `eval`, or `Function`.45- Use `ctx.rng` instead of `Math.random()` so revisions are reproducible.46- Treat Y as up and meters as the default unit unless the request requires otherwise.47- Prefer `MeshStandardMaterial`, `MeshPhysicalMaterial`, or bundled material presets for GLB.48- Keep textures out of the default Node export path. Texture encoding requires a browser or a separate image-capable runtime.49- Set meaningful node names and organize multipart assets under groups.50- Keep triangle counts proportional to the requested use case. Use lower segment counts for distant or mobile assets.5152## Validation and Review5354Run numeric validation before visual review. The validator checks finite transforms and vertices, empty geometry, normals, bounds, counts, unsupported shader materials, textures, and configured limits.5556For visual review, inspect:5758- silhouette and recognizable shape;59- relative scale and proportions;60- symmetry, alignment, grounding, and unintended intersections;61- front, rear, side, top, and perspective views;62- material separation and final-format fidelity;63- wireframe density when topology matters.6465Prefer round-trip review of GLB, OBJ, or STL. Source mode can look correct even when export loses hierarchy, materials, transforms, or animations.6667## Completion Criteria6869Complete a model task only when:7071- the build module runs without forbidden capabilities;72- validation contains no errors;73- every requested file exists and is non-empty;74- exported-file review is satisfactory when browser review is available;75- the build is reproducible with the recorded seed;76- generated source and artifacts remain outside this skill directory.7778## Resources7980- `scripts/runtime/`: Stable build context, builders, helpers, seeded RNG, source checks, and scene validation.81- `scripts/exporters/`: Format-specific GLB/glTF, OBJ, and STL exporters.82- `scripts/build-and-export.mjs`: Main deterministic pipeline.83- `scripts/render-preview.mjs`: Standalone exported-model PNG renderer.84- `scripts/serve-viewer.mjs`: Local source and round-trip viewer server.85- `assets/model-build.template.mjs`: Generated-task starting point.86- `assets/viewer/`: Browser review application.87- `references/build-contract.md`: Generated module contract and safety rules.88- `references/builder-api.md`: Builder and helper API.89- `references/export-formats.md`: Format capabilities and limitations.90- `references/preview-rendering.md`: Standalone preview command and limitations.