1.7 KiB
1.7 KiB
| name | description |
|---|---|
| threejs-csg | Build interactive 3D scenes with three.js in a single HTML file (no build step) and apply boolean operations (subtract, union, intersect) to meshes with three-bvh-csg, e.g. drilling a cylindrical hole through a cube. Use for any three.js, WebGL, 3D-model or CSG task. |
three.js + CSG (boolean operations)
Setup
No npm, no bundler: ES modules are loaded from a CDN through an import map.
template.html is a complete, working page (lit scene, orbit
controls, a cube with a cylindrical hole). Always start from it: read it with
load_skill("threejs-csg", "template.html") and write it into the project
under the requested file name, then change only buildModel().
Boolean operations
Rules, pitfalls and a reference of the operations: see csg.md.
Import / export / text / SVG
STL export and import, extruded SVG, solid text, and "group = union of solids minus holes": see loaders.md. Exporters take plain meshes with world matrices - not the scene, not raw Brushes.
Workflow
- Copy the template, adapt
buildModel()(geometry, materials, operations). For an editor/app around it, follow thesingle-file-webappskill (state, UI wiring, test hook) andsave-load-jsonfor project files (meshes stay in a runtime map, records hold type/params/transform/hole/children). - Static check:
python <single-file-webapp skill dir>/check_html.py <file>.html. - Visual/behavioural check with the
browser-testskill (opens the file viafile://- no web server needed; CDN imports work from there). - Keep everything in the one HTML file unless the task asks for more.