Modeling
Tools for making your own shapes in code, beyond makeShape, lathe and extrude. Everything here returns plain data (points or meshes), so it works with every renderer, and meshes come with texture coordinates and clockwise faces like the built-in shapes.
js
import {
spline, resamplePath, sweep, loft, subdivideMesh, bevelMesh, blobMesh, blobField, sdfMesh,
booleanMesh, unionMesh, subtractMesh, intersectMesh,
mirrorMesh, symmetrizeMesh, bisectMesh, arrayMesh, radialArrayMesh, mirrorObject, arrayObject, radialArrayObject,
taperMesh, twistMesh, bendMesh, bulgeMesh, sculptMesh, remeshMesh,
makeLattice, latticePoints, latticeMesh, latticeCage, applyModifiers, MODIFIERS, weldVertices, cleanMesh, validateMesh, fixWinding,
dropOnto, attachTo, alignObjects, distributeObjects,
meshQuery, raycastMesh, pointInMesh, distanceToMesh, closestPointOnMesh, isClosed, raycastScene,
} from "./trid/index.js";| Page | Tools |
|---|---|
| Curves, sweeps & lofts | spline, resamplePath, sweep, loft |
| Subdivision & bevels | subdivideMesh, bevelMesh |
| Blobs | blobMesh, blobField, sdfMesh |
| Booleans | booleanMesh, unionMesh, subtractMesh, intersectMesh |
| Mirror & array | mirrorMesh, symmetrizeMesh, bisectMesh, arrayMesh, radialArrayMesh, and the same for objects |
| Deformers | taperMesh, twistMesh, bendMesh, bulgeMesh |
| Sculpting | sculptMesh: inflate, grab, smooth, flatten, pinch, crease, noise; remeshMesh |
| Lattice | makeLattice, latticePoints, latticeMesh, latticeCage |
| Modifier stack | applyModifiers, MODIFIERS: steps applied in order, as data |
| Cleanup and checks | weldVertices, cleanMesh, validateMesh, fixWinding |
| Rays, inside and distance | meshQuery, raycastScene, isClosed and one-off helpers |
| Placing objects | dropOnto, attachTo, alignObjects, distributeObjects |
Which tool for which shape
| You want | Use |
|---|---|
| A body, a creature, something soft or organic | Blobs: shapes that melt together |
| A tail, a horn, a pipe, a rope, a handle | sweep along a spline |
| A bottle, a hull, a head: a shape whose cross-section changes | loft |
| A vase, a wheel, a lamp: turned around an axis | lathe |
| A flat outline with depth: a logo, a key, a star | extrude |
| Something smooth, built from a few boxes | subdivideMesh |
| Holes, windows, notches, cut-outs; or one solid from overlapping parts | Booleans: subtract, union, intersect |
| Furniture, devices, robots: soft edges | bevelMesh, or makeShape("box", { radius }) |
| Anything symmetric: a chair, a face, a car, a creature | Build one half, then mirrorMesh; or symmetrizeMesh a lopsided one |
| Rows, fences, stairs, spokes, petals, legs around a table | arrayMesh and radialArrayMesh, or the object versions |
| Faces, creatures, details: cheeks, snouts, mouths, wrinkles, rough skin | sculptMesh on a dense mesh, with symmetry: "x" |
| One smooth body from overlapping parts, or any shape made sculptable | remeshMesh |
| A shape you'll tweak and rebuild, or describe as data (saved, sent, written by an AI) | Modifier stack |
| A whole shape reshaped with a few points: a wider top, a pinched waist, a lean, a twist | Lattice |
| A trunk that tapers, a twisted column, a bent arm | Deformers |
| Rocks, terrain, wobbly surfaces | displaceMesh with noise |
| Parts that rest on each other: a cup on a table, rocks on the ground, a roof on walls | dropOnto |
| Horns, handles, ears or spikes growing out of a surface | attachTo |
| Legs on the same floor, things centered or evenly spaced | alignObjects, distributeObjects |
| Eyes, buttons or pebbles placed on a surface | meshQuery or raycastScene |
| A mesh from a file or your own code that looks wrong | Cleanup and checks |
Putting it together
The fox on the home page uses most of these: a body, a head and fluffy cheeks of blobs, ears lofted from an oval to a point, a tail swept along a spline, eyes placed on the face with rays, and a beveled round platform. Its code is in docs/demos/fox.js.