Skip to content

Instancing, terrain & splines

Three geometry techniques handle large or procedural content. Instancing consumes authored transform data, terrain is ordinary model geometry, and splines remain scene-authored curves. The feature-scenes project generates its instance data and terrain deterministically, so the same inputs produce the same checked-in assets.

Instancing draws many copies in one call; terrain is a procedural heightfield; splines are CatmullRom curves
Instancing, terrain, and splines.

Set a mesh’s instances field to a .instances.json asset to render many copies as one native THREE.InstancedMesh — one draw call. The file is an array of ten-number transform tuples: [posX,posY,posZ, quatX,quatY,quatZ,quatW, scaleX,scaleY,scaleZ]. Keep the generation process in the project: feature-scenes’ scripts/generate-grid-instances.mjs deterministically writes a checked-in 30 × 30 grid, while Blender or another DCC can export arbitrary placements in the same data format.

Terrain is ordinary project-owned geometry. Author it in Blender, generate it with Three.js, or use another content tool, export GLB, and reference it with mesh: { type: "gltf", src: ... }. Feature-scenes’ scripts/generate-terrain-glb.mjs bakes a deterministic sum-of-sines heightfield to models/terrain.glb. Pair the mesh with a trimesh collider so physics follows the actual model surface.

The spline schema (packages/engine/src/scene/schema/spline.ts) defines a CatmullRomCurve3 from points (≥ 2 control points), with closed (loop), curveType (catmullrom / centripetal / chordal), tension (default 0.5, used only for catmullrom), and resolution (line segments). Use splines for paths, camera rails, or procedural placement.