Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

73.8 KB
Raw Blame
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots

exports[`unified api surface (examples folded in) unified api snapshot (review folded examples in this diff) 1`] = `
"// Scene & structure (globals — no imports needed)
describeAssembly(root: Object3D, opts?: { clips?: readonly AnimationClip[] })
  // Describes an existing subtree through common roles, frames, sockets, material slots and
  // root-local bounds. Lookup lists are snapshots with live scene/resource references; bounds
  // are null for geometry-free scaffolds. No asset category is needed.
  // e.g. const assembly = describeAssembly(bay); const dimensions = assembly.bounds?.size;
createRoot(name: string)  // Creates the root Object3D for an asset. Call first in build().
  // e.g. const root = createRoot('FuelDrum');
createPivot(name: string, position?: [x, y, z], parent?: Object3D)
  // Creates an empty pivot node for skeletal animation. Name is auto-prefixed with \`Joint_\`.
  // e.g. const hip = createPivot('Hip', [0, 1, 0], root);
createJointChain(name, segments: { role, offset, aliases?, side?, localForwardAxis?, localBendAxis?, endEffector?, contact? }[], opts?: { parent?, parentRole? })
  // Creates one body-plan-neutral deterministic Joint_* chain with explicit parent edges, rest
  // frames, local axes, end effectors, contacts, and semantic metadata.
  // NOTE: Use only the resolved body-plan graph. Offsets are local to the previous joint;
  // contact end effectors must land at world Y=0.
  // e.g. const leg = createJointChain('LegL', [{ role: 'hip.left', offset: [0, 1, -0.2], side:
  // 'left' }, { role: 'knee.left', offset: [0, -0.5, 0], side: 'left' }, { role: 'ankle.left',
  // offset: [0, -0.5, 0], side: 'left', endEffector: true, contact: true }], { parent: root });
createBoneChain(name, segments: JointChainSegmentV1[], opts?: { parent?, parentRole? })
  // Creates an opt-in semantic Bone chain with the same local rest descriptors as
  // createJointChain, for explicitly skinned meshes.
  // NOTE: The bones must be in their assembled rest pose before binding. Use unique roles and
  // names across the rig. createJointChain still returns rigid pivots.
  // e.g. const bones = createBoneChain('Arm', [{ role: 'arm.base', offset: [0, 0, 0] }, { role:
  // 'arm.tip', offset: [0, 1, 0] }], { parent: root });
createSkinnedPart(name, geometry, material, opts: { parent, bones: Bone[], indices: ArrayLike<number>, weights: ArrayLike<number>, normalizeWeights?, position?, rotation?, scale?, semantic? })
  // Clones unchanged geometry and binds explicit four-lane vertex influences to an already
  // assembled rest-pose bone hierarchy.
  // NOTE: Supply exactly four bone indices and weights per vertex; zero-weight lanes still need
  // valid indices. Weights sum to one unless normalizeWeights:true is explicit; zero sums are
  // rejected. Mesh transforms use local meters and Euler degrees. Three exporter is required
  // for portable skin delivery; no automatic converter switch.
  // e.g. const skin = createSkinnedPart('Arm', geometry, material, { parent: root, bones:
  // chain.nodes, indices, weights });
createVehicleFrame(name, opts?: { chassis?, axles?, seats?, contacts?, steering?, propulsion?, parent? })
  // Creates a canonical +X-forward/+Y-up/+Z-right vehicle frame with typed semantic sockets for
  // chassis, support, steering, and propulsion.
  // NOTE: Generated vehicles keep +X as front. Boats and other non-wheeled subtypes use
  // declared support/propulsion sockets, not wheel rules.
  // e.g. const frame = createVehicleFrame('CarFrame', { axles: [{ id: 'front', position: [1.2,
  // 0.45, 0] }, { id: 'rear', position: [-1.2, 0.45, 0] }], parent: root });
createWheelAssembly(name, { tire, rim, hub? }, { radius, width, side, index, position?, rimRadius?, hubRadius?, steering?, loadBearing?, geometries?, parent? })
  // Creates one axle-centered wheel pivot containing concentric tire/rim/hub roles, a contact
  // marker, +Z spin frame, and optional steering pivot.
  // NOTE: side is 'left', 'right', or 'center': identity relative to the host, not fork design
  // or automatic positioning. Centerline wheels need no partner. Keep tire, rim, and hub
  // concentric at the axle pivot. Reuse geometry across matching wheels.
  // e.g. createWheelAssembly('FrontLeft', { tire: rubber, rim: metal }, { radius: 0.45, width:
  // 0.22, side: 'left', index: 'front', position: [1.2, 0.45, -0.9], steering: true,
  // geometries: wheelGeo, parent: frame.root });
createPart(name, geometry, material, opts?: { position, rotation: [xDeg, yDeg, zDeg], scale, pivot, parent })
  // Creates a mesh, optionally wrapped in a pivot, and attaches it to \`opts.parent\`. \`rotation\`
  // is in DEGREES (like rotationTrack), NOT radians: [0, 0, 90] is a quarter turn; [0, 0, 1.57]
  // is a no-op.
  // NOTE: AUTO-ADDS to opts.parent. NEVER call parent.add(createPart(...)) — pass { parent }
  // instead. rotation is DEGREES — writing radians (e.g. 0.785 or Math.PI/4) silently produces
  // ~zero rotation.
  // e.g. createPart('Barrel', cylinderGeo(0.1, 0.1, 1), gameMaterial(0x556b2f), { position: [0,
  // 0.5, 0], rotation: [0, 0, 90], parent: root });
defineLod(levels: Object3D[], opts: { screenCoverage: number[], impostor?: boolean })
  // Declares one set of level-of-detail tiers, LOD0 (full detail) first, and the minimum screen
  // coverage (0..1) at which each level draws.
  // NOTE: Only when the brief asks for LOD tiers; otherwise build one tier. Tiers are sibling
  // nodes named with one stem and consecutive LOD<n> tokens. screenCoverage has one value per
  // level, strictly decreasing; below the last the asset is culled, and a last value of 0 never
  // culls. impostor: true marks the last level a card or billboard tier. Build lower tiers with
  // less detail, or derive one per part with simplifyGeometry.
  // e.g. const tiers = ['Body_LOD0', 'Body_LOD1', 'Body_LOD2'].map((name) => { const g = new
  // THREE.Group(); g.name = name; root.add(g); return g; }); defineLod(tiers, { screenCoverage:
  // [0.25, 0.06, 0.01] });
markOpenShell(part: Object3D, reason: string)
  // Marks a part that is open on purpose, such as a C-channel closed by separate end plates or
  // a single-sided sheet, with the reason. QA reports it as an acknowledged open shell instead
  // of an unexplained unmeasured part.
  // NOTE: Only for shells open by design; close a part meant to be solid instead. A mark on a
  // group covers its meshes. Overlap with a marked part stays unmeasured, not clear.
  // e.g. const rail = createPart('Rail', new THREE.CylinderGeometry(0.2, 0.2, 2, 16, 1, true),
  // steel, { parent: root }); markOpenShell(rail, 'Tube closed by the end plates');
colliderBox(size: [w, h, d] | number, opts: { id, parent?, position?, rotation?: [xDeg, yDeg, zDeg] })
  // Adds a hidden oriented-box collider proxy with role collider.box.<id>: a unit box whose
  // node scale is the size, so a consumer reads centre, orientation and size from the transform
  // alone.
  // NOTE: Only when the brief asks for colliders. The proxy never draws; it must wrap or cross
  // the surface it stands for and stay inside the drawn bounds. id is one segment without dots.
  // e.g. colliderBox([2, 3, 0.4], { id: 'frame', parent: root, position: [0, 1.5, 0] });
colliderCapsule(radius: number, height: number, opts: { id, parent?, position?, rotation? })
  // Adds a hidden capsule collider proxy along local +Y with role collider.capsule.<id>. height
  // is the TOTAL end-to-end height including both caps (at least 2 * radius); the node scale is
  // [2r, height, 2r].
  // NOTE: height here is total height, unlike capsuleGeo whose height is the straight middle
  // length.
  // e.g. colliderCapsule(0.15, 1.8, { id: 'post', parent: root, position: [0.8, 0.9, 0] });
colliderHull(mesh: Mesh, opts: { id, parent? })
  // Adds a hidden convex-hull collider proxy of a mesh's vertices beside it, with the mesh's
  // local transform and role collider.hull.<id>. The input mesh is unchanged.
  // e.g. const frame = createPart('Frame', boxGeo(2, 3, 0.4), steel, { parent: root });
  // colliderHull(frame, { id: 'frame' });
anchor(kind: string, id: string, opts?: { parent?, position?, rotation? })
  // Adds a named point with a transform and role anchor.<kind>.<id>: a door, vault plate,
  // beacon, hardpoint, light or spawn point the consumer attaches behaviour to.
  // NOTE: An anchor is a leaf: never add parts under it. kind and id are single segments.
  // e.g. anchor('door', 'main', { parent: root, position: [0, 1, 0.25] });
defineModule(root: Object3D, spec: { footprint: [w, d], height, snapAxis: 'x'|'y'|'z', origin: 'corner'|'center' })
  // Marks root as one modular kit piece (role kit.module) and records its footprint (width X,
  // depth Z), height and snap axis as kilnKit node extras.
  // NOTE: Only for modular kit pieces. Place each port inside the footprint.
  // e.g. defineModule(root, { footprint: [4, 4], height: 3, snapAxis: 'x', origin: 'center' });
port(id: string, opts?: { parent?, position?, rotation? })
  // Adds a kit snap point with role kit.port.<id> under a defineModule root; its transform is
  // the snap frame.
  // e.g. port('west', { parent: root, position: [-2, 0, 0], rotation: [0, 180, 0] });
repeatInstances(parent: Object3D)
  // Marks parent so the three.js runtime export (export --profile runtime --target three)
  // batches its identical leaf children into one EXT_mesh_gpu_instancing node. The editable GLB
  // is unchanged.
  // NOTE: Only direct children with the same geometry and material and no children, roles or
  // extras of their own are batched.
  // e.g. const bolts = new THREE.Group(); bolts.name = 'Bolts'; root.add(bolts); for (let i =
  // 0; i < 8; i++) createPart('Bolt_' + i, boltGeo, steel, { parent: bolts, position: [i * 0.2,
  // 0, 0] }); repeatInstances(bolts);
beamBetween(name, start: [x,y,z], end: [x,y,z], radius, material, opts?: { segments, parent })
  // Creates a cylindrical rail/strut exactly between two endpoints in its parent frame. Derive
  // attachment endpoints from the neighboring geometry; the helper does not find joints or join
  // surfaces. Use for braces, barrels, struts, cables, and scaffolding.
  // e.g. beamBetween('SkidBraceA', [0.8, 0.3, 0.7], [0.8, 1.0, 0.45], 0.025, black, { parent:
  // root });
snapTo(part: Object3D, host: Object3D, opts?: { axis?: 'x'|'y'|'z', overlap?: 0.02 })
  // Translates \`part\` to align its bounding box with \`host\` plus optional overlap. This is a
  // placement convenience: box contact does not establish surface attachment, and legitimate
  // detached parts need no repair. No-op if the boxes already touch.
  // e.g. const scope = createPart('Scope', cylinderXGeo(0.04, 0.04, 0.3), steel, { parent:
  // root, position: [0.1, 0.32, 0] }); snapTo(scope, receiver);
createLadder(name, { bottom, top, material, width?, rungCount?, railRadius?, rungRadius?, segments?, widthAxis?, widthDirection?, parent? })
  // Builds a rooted ladder with perpendicular rails/rungs and bottom/top endpoint frames and
  // sockets. Describe or replicate result.root as one assembly. Explicit widthDirection is
  // projected perpendicular to the endpoints.
  // e.g. createLadder('TowerLadder', { bottom: [0,0,0], top: [0,2.2,0], width: 0.45, rungCount:
  // 7, material: steel, parent: root });
createWingPair(name, material, { rootZ, span, rootChord, tipChord, sweep?, thickness?, dihedral?, rootX?, rootY?, parent? })
  // Creates mirrored trapezoid aircraft wings with roots attached at +/-rootZ. Use for aircraft
  // wings and helicopter stub wings.
  // e.g. createWingPair('MainWing', olive, { rootX: 0, rootY: 1.0, rootZ: 0.42, span: 2.4,
  // rootChord: 0.9, tipChord: 0.35, sweep: 0.25, dihedral: 0.08, parent: root });
room(name, material, { width?, depth?, height?, wallThickness?, floor?, floorThickness?, openings?: [{ wall: 'front'|'back'|'left'|'right', kind?: 'door'|'window', offset?, width?, height?, sill? }], parent? })
  // Builds a HOLLOW, enterable room: four thin walls + a floor, human-scaled (defaults: 2.8m
  // ceiling, a centered 1.1x2.1m front door so it is enterable by default). \`front\` faces +X;
  // the floor sits on the ground. The keystone of an architecture asset — add a roof with
  // createRoofPlanes and fixtures as separate parts.
  // NOTE: Use for any building the player enters. Do NOT model a building as a solid block —
  // room() guarantees real interior space and a doorway gap. Pass openings to add windows /
  // side doors.
  // e.g. const { root: hut } = room('Hut', wood, { width: 5, depth: 4, height: 2.8, openings:
  // [{ wall: 'front', kind: 'door' }, { wall: 'right', kind: 'window' }], parent: root });
wallWithOpening(name, material, { length, height, thickness, axis?: 'x'|'z', opening?: { kind?: 'door'|'window', offset?, width?, height?, sill? }, openings?: [{ kind?: 'door'|'window', offset?, width?, height?, sill? }], parent? })
  // A wall panel with real rectangular door/window gaps, composed from solid box segments.
  // Supply opening or openings, never both. Multiple or vertically stacked apertures must not
  // overlap or extend outside the wall. Base at local Y=0, centered on the run axis. Use to
  // compose custom layouts and interior dividing walls.
  // e.g. wallWithOpening('Partition', plaster, { length: 4, height: 2.8, thickness: 0.12, axis:
  // 'x', opening: { kind: 'door', offset: 0.5 }, parent: root });
createRoofPlanes(name, material, { width, depth, height, overhang?, ridgeAxis?: 'x'|'z', thickness?, parent? })
  // A pitched roof: two thin slopes meeting at one ridge and falling DOWN-AND-OUTWARD (opposite
  // tilts — never mirrored the same way), footprint-matched with an eave overhang. Outer top
  // eave at local Y=0, ridge at Y=height. Thickness extends inward. For a wall-bearing datum
  // use createGableRoof. Returns a named group (e.g. \`Roof\`) the engine can lift to reveal the
  // interior.
  // NOTE: The two slopes must fall AWAY from each other from the ridge — createRoofPlanes does
  // this for you. Its outer top eave is the datum; createGableRoof instead anchors the wall
  // bearing line.
  // e.g. const { root: roof } = createRoofPlanes('Roof', shingle, { width: 5, depth: 4, height:
  // 1.6, overhang: 0.4, ridgeAxis: 'x', parent: root }); roof.position.y = 2.8;
createGableRoof(name, material, { spanX, spanZ, rise?, pitchDegrees?, overhang?, ridgeAxis?: 'x'|'z', thickness?, parent? })
  // Explicit-axis gable roof using unambiguous footprint spans. Each face owns a rigid frame
  // with ridge tangent, outward normal, downhill direction, ridge/eave endpoints, dimensions,
  // and a live local-to-world transform.
  // NOTE: Prefer this over width/depth roof math. ridgeAxis is the direction of the ridge; roof
  // panels run along each returned face downhill direction.
  // e.g. const roof = createGableRoof('Roof', shingles, { spanX: 8, spanZ: 5, pitchDegrees: 35,
  // overhang: 0.35, ridgeAxis: 'x', parent: root });
createGableEndPanel(name, material, { span, rise, thickness?, ridgeAxis?: 'x'|'z', side?: 'positive'|'negative', openings?: [{ id?, offset?, bottom?, width, height }], parent? })
  // Exact thick triangular end closure for a gable roof, with optional rectangular openings cut
  // from the geometry and semantic boundary metadata.
  // e.g. createGableEndPanel('FrontGable', siding, { span: 5, rise: 1.8, ridgeAxis: 'x', side:
  // 'positive', parent: root });
createGableShell(name, { wall, roof, floor?, gable? }, { spanX, spanZ, wallHeight?, rise?, pitchDegrees?, overhang?, ridgeAxis?: 'x'|'z', thickness?, wallThickness?, floorThickness?, closedEnds?, enterable?, openings?, gableOpenings?, parent? })
  // Closed-by-default, correct-by-construction gable building: hollow room, floor, two opposing
  // roof slopes, two complete gable ends, and a real front doorway when enterable.
  // NOTE: Use for complete gable buildings. It stamps wall, floor, slope, gable, opening,
  // adjacency, coverage, and separability semantics for deterministic QA and roof-off views.
  // e.g. const house = createGableShell('House', { wall: plaster, roof: shingles }, { spanX: 8,
  // spanZ: 5, wallHeight: 2.8, pitchDegrees: 35, ridgeAxis: 'x', parent: root });
createRoofSurfaceLayout(name, material, { face, kind: 'panels'|'shingles'|'seams'|'corrugations', parent?, panelWidth?, rowHeight?, spacing?, thickness? })
  // Places roof-local panels, shingles, seams, or corrugations from a returned RoofFaceFrame,
  // so repeated elements run ridge-to-eave for either ridge axis without manual Euler
  // rotations.
  // NOTE: Always pass the face object returned by createGableRoof/createGableShell. Never infer
  // the panel rotation from world axes.
  // e.g. for (const face of roof.faces) createRoofSurfaceLayout('Panels_' + face.side, metal, {
  // face, kind: 'panels', parent: roof.root });
createStairs(name, material, { steps?, totalRise, totalRun, width, axis?: 'x'|'z', treadThickness?, riser?, parent? })
  // A straight flight of stairs: box treads (with optional risers) climbing totalRise over
  // totalRun from local origin toward +axis. Use for porch/entry steps or to connect storeys in
  // a multi-storey building.
  // e.g. createStairs('Porch', stone, { steps: 4, totalRise: 0.6, totalRun: 1.0, width: 1.4,
  // axis: 'x', parent: root });

// Geometry (returns BufferGeometry)
meshGeo({ positions: number[], indices?: number[], normals?: number[], uvs?: number[], tangents?: number[] })
  // Builds an owned triangle mesh from flat numeric arrays. Validates finite values, attribute
  // lengths and indices; computes normals if absent. Counterclockwise winding.
  // e.g. const triangle = meshGeo({ positions: [0,0,0, 1,0,0, 0,1,0], indices: [0,1,2] });
parametricSurface(sample: (u,v) => [x,y,z], opts?: { u?: [0,1], v?: [0,1], uSegments?: 24, vSegments?: 24, periodicU?: false, periodicV?: false, orientation?: 'uv'|'vu' })
  // At most 262,144 endpoint-inclusive samples per call, checked before invoking the sampler.
  // Samples an equation into an owned surface with UVs. Periodic endpoints must agree within
  // 1e-6 of the sampled diagonal, independent of origin and units; UV seams retain matching
  // normals. A surface is not automatically a watertight solid.
  // e.g. const canopy = parametricSurface((u,v) => [u, 0.3*Math.sin(u*3)*Math.cos(v*2), v], {
  // u: [-2,2], v: [-1,1] });
await implicitSurface(sample: ([x,y,z]) => signedValue, { bounds: { min, max }, edgeLength, maxCells?: 1000000, maxEvaluations?: 8000000, level?: 0, tolerance?: -1, smooth?: true })
  // Experimental positive-inside implicit field sampled into a solid mesh. Requires explicit
  // bounds and resolution; checks grid size and actual evaluation count. Output has no UVs.
  // NOTE: Use async build and await. Smaller edgeLength increases cost sharply. This helper
  // cannot stop a callback that never returns; the host evaluator process provides that
  // boundary. Thin features and geometric accuracy require inspection.
  // e.g. const blob = await implicitSurface(([x,y,z]) => 1-Math.hypot(x,y,z), { bounds: { min:
  // [-1.2,-1.2,-1.2], max: [1.2,1.2,1.2] }, edgeLength: 0.15 });
await metaballSurface(spheres: { center: [x,y,z], radius }[], { bounds, edgeLength, blend?, maxCells?, maxEvaluations? })
  // Experimental smooth union of spheres meshed through implicitSurface. Uses polynomial
  // blending; output has no UVs.
  // NOTE: Useful when a smooth union of sphere volumes fits the intended shape. Match
  // edgeLength to feature size.
  // e.g. const body = await metaballSurface([{ center: [0,0.4,0], radius: 0.35 }, { center:
  // [0.2,0.55,0], radius: 0.22 }], { bounds: { min: [-0.6,-0.1,-0.5], max: [0.6,1,0.5] },
  // edgeLength: 0.08 });
smoothUnion(a: number, b: number, blend: number)
  // Polynomial smooth maximum for positive-inside implicit fields. Compose inside
  // implicitSurface callbacks.
  // e.g. smoothUnion(sphereInside(p,[0,0,0],0.5), sphereInside(p,[0.3,0,0],0.4), 0.12)
sphereInside(point: [x,y,z], center: [x,y,z], radius: number)
  // Positive-inside sphere field sample for implicitSurface. Returns radius minus distance to
  // center.
  // e.g. sphereInside(p, [0,0.4,0], 0.25)
boxGeo(width: number, height: number, depth: number)  // 6-face box. 12 tris regardless of size. Cheapest geometry.
  // e.g. const geo = boxGeo(1, 0.5, 2);
sphereGeo(radius: number, widthSegments?: 8, heightSegments?: 6)
  // UV sphere. Default 8x6 segments = 84 tris. Bump segments for smoother curves.
  // e.g. const geo = sphereGeo(0.5, 12, 8);
cylinderGeo(radiusTop: number, radiusBottom: number, height: number, segments?: 8)
  // Y-axis cylinder. Use radiusTop != radiusBottom for cones / tapered pieces.
  // e.g. const geo = cylinderGeo(0.25, 0.25, 1, 12);
cylinderYGeo(radiusTop: number, radiusBottom: number, height: number, segments?: 8)
  // Alias for cylinderGeo — a Y-axis cylinder. Provided because the sandbox exposes
  // cylinderXGeo / cylinderZGeo and the symmetric Y form is commonly reached for.
  // e.g. const geo = cylinderYGeo(0.25, 0.25, 1, 12);
cylinderXGeo(radiusTop: number, radiusBottom: number, length: number, segments?: 8)
  // Cylinder pre-rotated to run along +X/-X. Use for fuselages, cannons, barrels, axles, and
  // forward-facing tubes.
  // e.g. const geo = cylinderXGeo(0.1, 0.1, 1.2, 12);
cylinderZGeo(radiusTop: number, radiusBottom: number, length: number, segments?: 8)
  // Cylinder pre-rotated to run along +Z/-Z. Use for side-mounted weapons, rails, crossbars,
  // and pipes.
  // e.g. const geo = cylinderZGeo(0.08, 0.08, 0.9, 10);
cylinderOnAxis(center: [x,y,z], normal: [x,y,z], radiusBottom: number, height: number, opts?: { radiusTop?, segments? })
  // Frame-first cylinder: position + axis specified directly, no post-hoc rotation. Use when
  // the cylinder needs to point along a non-cardinal direction (struts inside CSG operands,
  // antennas off a tilted surface). For cardinal axes prefer the terser cylinderXGeo /
  // cylinderYGeo / cylinderZGeo helpers.
  // e.g. const strut = cylinderOnAxis([0.5, 0.7, 0], [1, 1, 0.3], 0.05, 0.9);
capsuleGeo(radius: number, height: number, segments?: 6)
  // Stadium shape (cylinder with hemispherical caps). Good for limbs.
  // e.g. const geo = capsuleGeo(0.1, 0.5, 6);
capsuleYGeo(radius: number, height: number, segments?: 6)
  // Alias for capsuleGeo — a Y-axis capsule. Provided for symmetry with capsuleXGeo /
  // capsuleZGeo.
  // e.g. const geo = capsuleYGeo(0.1, 0.5, 6);
capsuleXGeo(radius: number, length: number, segments?: 6)
  // Capsule pre-rotated to run along +X/-X. Use for aircraft bodies, rounded vehicle hulls, and
  // missiles.
  // e.g. const geo = capsuleXGeo(0.35, 2.4, 10);
capsuleZGeo(radius: number, length: number, segments?: 6)
  // Capsule pre-rotated to run along +Z/-Z. Use for lateral pods, floats, and side tanks.
  // e.g. const geo = capsuleZGeo(0.18, 1.1, 8);
coneGeo(radius: number, height: number, segments?: 8)
  // Y-axis cone (pointed up). Use for spikes, roofs, projectiles.
  // e.g. const geo = coneGeo(0.3, 0.8, 8);
coneYGeo(radius: number, height: number, segments?: 8)
  // Alias for coneGeo — a Y-axis cone (point +Y). Provided for symmetry with coneXGeo /
  // coneZGeo.
  // e.g. const geo = coneYGeo(0.3, 0.8, 8);
coneXGeo(radius: number, length: number, segments?: 8)
  // Cone pre-rotated so its point faces +X. Use for noses, rockets, shells, and forward-facing
  // tips.
  // e.g. const geo = coneXGeo(0.18, 0.45, 12);
coneZGeo(radius: number, length: number, segments?: 8)
  // Cone pre-rotated so its point faces +Z. Use for side-facing projectiles and tips.
  // e.g. const geo = coneZGeo(0.12, 0.35, 10);
taperConeGeo(radiusBottom: number, radiusTop: number, height: number, axis?: 'x'|'y'|'z', segments?: 8)
  // Truncated cone (frustum) — exposes both bottom and top radius. radiusTop=0 matches coneGeo,
  // radiusTop=radiusBottom matches cylinderGeo. Use for pylon caps, soda cans, lampshades,
  // anything tapered that does not come to a point. axis selects orientation (default Y).
  // e.g. const cap = taperConeGeo(0.3, 0.18, 0.4); // frustum
torusGeo(radius: number, tube: number, radialSegments?: 8, tubularSegments?: 12)
  // Donut shape. For rings, tyres, barrel ribs.
  // e.g. const geo = torusGeo(0.4, 0.04, 8, 16);
planeGeo(width: number, height: number, widthSegments?: 1, heightSegments?: 1)
  // Flat quad for TEXTURED surfaces (ground, signs, walls with albedo maps). For solid-color
  // decals like red stars, hull numbers, stamps, or window cutouts on no-texture assets use
  // decalBox — a bare planeGeo without a texture will render as a disconnected 2-tri square and
  // get flagged as a stray plane.
  // e.g. const geo = planeGeo(4, 4);
decalBox(width: number, height: number, depth?: 0.01)
  // Thin box for solid-color surface decals: red stars, hull numbers, stamps, no-texture
  // windows. Unlike planeGeo, has real depth so it visibly attaches to its host surface. Must
  // be placed on a surface with position + rotation.
  // NOTE: Offset at least 0.01 outside the host surface to avoid z-fighting (a 0.8-wide hull
  // has faces at z=±0.4, so place the decal at z=±0.41).
  // e.g. const star = decalBox(0.18, 0.18, 0.01); createPart('Mesh_StarPort', star,
  // gameMaterial(0xc61f2a), { position: [0.4, 0.6, 0.41], parent: fuselage });
foliageCardGeo(opts?: { width?, height?, yPivot?: 0..1 })
  // Single-quad foliage card with a configurable Y pivot. yPivot=0 plants the quad on the
  // ground. Pair with an alpha-tested material and a leaf/plant sprite.
  // NOTE: The example uses an approved 4x4 teaching placeholder, not production foliage detail.
  // e.g. const albedo = await loadApprovedTexture('kiln.texture.leaf-mask-albedo.v1'); const
  // leaves = foliageMaterial(albedo); const quad = foliageCardGeo({ width: 0.6, height: 1,
  // yPivot: 0 }); createPart('LeafCard', quad, leaves, { parent: root });
crossedQuadsGeo(opts?: { width?, height?, planes?: 2 | 3, yPivot? })
  // Cross-billboard bush primitive: 2 or 3 planes intersecting along the Y axis. Reads as a
  // dense plant from any angle, cheaper than real geometry.
  // e.g. const leaves = await materialRecipe('kiln.material.leaf.v1'); const bush =
  // crossedQuadsGeo({ width: 2, height: 2, planes: 3 }); createPart('Mesh_Bush', bush, leaves,
  // { parent: root });
octaGridPlane({ tilesX, tilesY, width?, height?, yPivot? })
  // Atlas-ready billboard quad. UVs are pre-scaled to cover one tile of a tilesX×tilesY atlas;
  // the consumer shader adds per-instance tile offsets at draw time.
  // e.g. const card = octaGridPlane({ tilesX: 4, tilesY: 4, width: 6, height: 6 });
wingGeo(opts?: { span, rootChord, tipChord, sweep, thickness, dihedral })
  // Trapezoid wing panel. Local root edge is at Z=0, span extends toward +Z, positive sweep
  // moves the tip aft along -X.
  // e.g. const geo = wingGeo({ span: 2.2, rootChord: 0.8, tipChord: 0.3, sweep: 0.25, dihedral:
  // 0.08 });
gearGeo(opts?: { teeth?: 12, rootRadius?: 0.8, tipRadius?: 1.0, boreRadius?: 0.2, height?: 0.3, toothWidthFrac?: 0.5 })
  // Stylized gear with flat edges and an optional center bore; no CSG. Use boreRadius <
  // rootRadius < tipRadius. Radii are absolute: an omitted rootRadius stays 0.8 when tipRadius
  // changes. Set all three radii for small gears.
  // e.g. const g = gearGeo({ teeth: 28, rootRadius: 0.063, tipRadius: 0.075, boreRadius: 0.012,
  // height: 0.024 }); createPart('Gear', g, gameMaterial(0x909090, { metalness: 0.8 }), {
  // parent: root });
bladeGeo(opts?: { length?: 1.5, baseWidth?: 0.1, thickness?: 0.015, tipLength?: 0.25, edgeBevel?: 0 })
  // Parametric sword blade: rectangular base tapering to a point over tipLength. edgeBevel > 0
  // pinches the cross-section toward a diamond ridge.
  // e.g. const b = bladeGeo({ length: 1.6, baseWidth: 0.09, tipLength: 0.3, edgeBevel: 0.5 });
  // createPart('Blade', b, steel, { position: [0, 0, 0], parent: root });

// Materials
gameMaterial(color, opts?: { metalness, roughness, emissive, emissiveIntensity, flatShading, name })
  // PBR material with flat shading by default; choose shading and material settings for the
  // intended surface.
  // NOTE: Set name to the authored finish when a destination runtime groups draws by material:
  // it is written to the glTF material name, 1..200 visible characters. materialRecipe and the
  // portable material specs name their output already.
  // e.g. const mat = gameMaterial(0x8b7355, { roughness: 0.9, name: 'OiledWalnut' });
await materialRecipe(recipeId, overrides?: { baseColor?, roughness?, metalness?, opacity?, alphaCutoff?, doubleSided?, emissiveColor?, emissiveIntensity?, textureResources? })
  // Resolves a versioned portable
  // bark/leaf/wood/stone/rubber/painted-metal/cloth/skin/glass/emissive recipe to standard glTF
  // PBR.
  // NOTE: Use only listed kiln.material.*.v1 IDs and approved kiln.texture.* resource IDs.
  // textureResources uses portable slots baseColor, normal, metallicRoughness, emissive and
  // occlusion with ID string values; albedo is a pbrMaterial field, not a recipe slot. Check
  // resource allowedSlots and recipeIds. All numeric overrides (including emissiveIntensity)
  // are finite 0..1. Recipe emission is baked into the core glTF emissive factor. Leaf is MASK,
  // glass is BLEND, and host file paths are forbidden. Overrides differ by recipe; any other
  // key is rejected: bark, wood, stone, rubber, painted-metal, cloth: baseColor, roughness,
  // metalness, doubleSided, textureResources; leaf: baseColor, roughness, alphaCutoff,
  // doubleSided, textureResources; skin: baseColor, roughness, doubleSided; glass: baseColor,
  // roughness, opacity, doubleSided; emissive: baseColor, roughness, doubleSided,
  // emissiveColor, emissiveIntensity, textureResources.
  // e.g. const bark = await materialRecipe('kiln.material.bark.v1', { baseColor: '#6b4328' });
await compilePortableMaterialSpecV2({ schemaVersion: 2, model: 'pbrMetallicRoughness', name?, baseColor?, roughness?, metalness?, emissive?, emissiveIntensity?, alphaMode?, alphaCutoff?, doubleSided?, textures?: { baseColor?, normal?, metallicRoughness?, emissive?, occlusion? } })
  // Compiles the strict portable material contract. Texture refs are typed procedural V2 specs
  // or typed approved-resource references; bare IDs, paths, URLs, raw textures, callbacks, and
  // shader source are rejected.
  // NOTE: Use textures: { baseColor: { kind: "resource", resourceId:
  // "kiln.texture.rough-concrete-albedo.v1" } } for an approved resource, or { kind:
  // "procedural", spec: { schemaVersion: 2, ... } }; bare ID strings are invalid. Use
  // metallicRoughness as one packed G=roughness/B=metalness map. Every procedural ref usage
  // must match its slot; resource refs must be approved for that exact slot. baseColor and
  // emissive are numeric color integers from 0x000000 to 0xffffff, not CSS or materialRecipe
  // hex strings. roughness, metalness and alphaCutoff are finite 0..1; emissiveIntensity is
  // finite 0..64 (unlike materialRecipe, whose intensity is 0..1).
  // e.g. const steel = await compilePortableMaterialSpecV2({ schemaVersion: 2, model:
  // 'pbrMetallicRoughness', roughness: 0.45, metalness: 0.85, textures: { metallicRoughness: {
  // kind: 'procedural', spec: { schemaVersion: 2, usage: 'metallicRoughness', size: 64, layers:
  // [{ op: 'solid', color: 0x0080cc }] } } } });
await compilePortableMaterialSpecV3({ schemaVersion: 3, model: 'pbrMetallicRoughness', name?, baseColor?, roughness?, metalness?, emissive?, emissiveIntensity?, alphaMode?, alphaCutoff?, doubleSided?, textures?: { baseColor?, normal?, metallicRoughness?, emissive?, occlusion? } })
  // Compiles opt-in portable PBR materials with bounded rectangular RGBA procedural textures
  // and explicit portable samplers, preserving existing V2 behavior.
  // NOTE: Every texture ref needs all four sampler fields. minFilter accepts nearest, linear,
  // nearest-mipmap-nearest, linear-mipmap-nearest, nearest-mipmap-linear or
  // linear-mipmap-linear; magFilter accepts nearest or linear; wrapS/wrapT accept
  // clamp-to-edge, repeat or mirrored-repeat. Use typed procedural V3 specs or approved
  // resource refs. Slot usages must match. RGBA alpha alone does not select mask/blend: set
  // material alphaMode explicitly. Each binding owns texture state and bytes; no resolver,
  // path, URL, raw pixels or shader arguments. V2 recipes and defaults remain separate.
  // e.g. const leaf = await compilePortableMaterialSpecV3({ schemaVersion: 3, model:
  // 'pbrMetallicRoughness', alphaMode: 'mask', doubleSided: true, textures: { baseColor: {
  // kind: 'procedural', spec: { schemaVersion: 3, width: 16, height: 32, usage: 'albedo',
  // background: [0, 0, 0, 0], operations: [{ op: 'paint', shape: { kind: 'ellipse', x: 2, y: 1,
  // width: 12, height: 30 }, rgba: [60, 90, 40, 255] }] }, sampler: { minFilter: 'nearest',
  // magFilter: 'nearest', wrapS: 'clamp-to-edge', wrapT: 'clamp-to-edge' } } } });
basicMaterial(color, opts?: { transparent, opacity, name })
  // Unlit flat material. For UI / effects where lighting is baked in.
  // e.g. const mat = basicMaterial(0xffffff, { transparent: true, opacity: 0.5 });
glassMaterial(color, opts?: { opacity, roughness, metalness, name })
  // Semi-transparent double-sided material. Panels need ~0.05 offset to avoid z-fighting.
  // e.g. const mat = glassMaterial(0x66ccff, { opacity: 0.3 });
lambertMaterial(color, opts?: { flatShading, emissive, name })
  // Cheaper than gameMaterial. No metalness/roughness. Use when PBR is overkill.
  // e.g. const mat = lambertMaterial(0x2a4d14, { flatShading: true });
pbrMaterial({ albedo?, normal?, roughness?, metalness?, metallicRoughness?, emissive?, emissiveIntensity?, aoMap?, aoMapIntensity?, alphaMode?: 'opaque'|'mask'|'blend', alphaCutoff?, doubleSided?, name? })
  // Portable glTF PBR material. Use an explicit packed metallicRoughness texture (G=roughness,
  // B=metalness); separate data maps are rejected instead of silently dropping a channel.
  // alphaMode takes lowercase opaque/mask/blend and exports uppercase glTF modes. Supports
  // double-sided output.
  // NOTE: Set name to the authored finish when a destination runtime groups draws by material:
  // it is written to the glTF material name, 1..200 visible characters. materialRecipe and the
  // portable material specs name their output already.
  // e.g. const wood = proceduralTexture({ schemaVersion: 2, usage: 'albedo', layers: [{ op:
  // 'noise', colorA: 0x4f301c, colorB: 0x9a6b3e, scale: 8, octaves: 3, seed: 4 }] }); const
  // crate = pbrMaterial({ albedo: wood, roughness: 0.85, metalness: 0, name: 'CrateWood' });
foliageMaterial(albedo, { alphaCutoff?, roughness?, doubleSided?, name? })
  // Portable foliage material that defaults to glTF MASK, cutoff 0.5, rough nonmetal, and
  // double-sided. Use an alpha-bearing albedo texture.
  // NOTE: The example uses an approved 4x4 teaching placeholder. Check GPU and destination
  // alpha filtering; a geometry-flat CPU view cannot establish the cutout silhouette.
  // e.g. const albedo = await loadApprovedTexture('kiln.texture.leaf-mask-albedo.v1'); const
  // mat = foliageMaterial(albedo, { alphaCutoff: 0.5, doubleSided: true });

// Instancing (share geometry+material; smaller GLBs)
replicateAssembly(source: AssemblyView, opts: { namespace: string, parent?: Object3D, space?: 'local' | 'world', geometry?: 'share' | 'copy', materials?: 'share' | 'copy', externalReferences?: 'reject' | 'preserve', unknownMetadata?: 'reject' | 'copy-json' })
  // Replicates a complete supported hierarchy with namespaced semantic and animation
  // references. Owns new nodes/clips; shares geometry/materials unless copy is requested.
  // Revalidates the live source before attaching. Default local placement preserves authored
  // transforms; returns the new subtree as result.root.
  // e.g. const repeated = replicateAssembly(describeAssembly(bay), { namespace: 'bay2', parent:
  // root }); repeated.root.position.x = 3;
copyGeometry(geometry: BufferGeometry)
  // Returns an independent geometry with copied vertex buffers. Use before direct mutation of a
  // cached primitive.
  // e.g. const editable = copyGeometry(boxGeo(1, 1, 1)); editable.translate(0, 0.5, 0);
copyMaterial(material: Material)
  // Copies material properties so edits do not change other parts. Referenced textures remain
  // shared.
  // e.g. const red = copyMaterial(steel); red.color.set(0xaa2222);
createWheelGeometrySet(radius: number, width: number)
  // Creates one reusable +Z-axle tire/rim/hub geometry set for instanced wheel assemblies.
  // e.g. const wheelGeo = createWheelGeometrySet(0.45, 0.22);
createInstance(name, source, opts?: { position, rotation: [xDeg, yDeg, zDeg], scale, parent })
  // Creates a new mesh reusing an existing part's geometry + material at a new transform.
  // Cheapest way to replicate wheels / bolts / fence posts / windows. \`rotation\` is in DEGREES,
  // like createPart.
  // e.g. const wheelFL = createPart('WheelFL', wheelGeo, rubberMat, { position: [-0.8, 0.3,
  // 1.2], parent: root }); createInstance('WheelFR', wheelFL, { position: [0.8, 0.3, 1.2],
  // parent: root }); createInstance('WheelRL', wheelFL, { position: [-0.8, 0.3, -1.2], parent:
  // root }); createInstance('WheelRR', wheelFL, { position: [0.8, 0.3, -1.2], parent: root });

// Arrays (replicate a source part)
arrayLinear(namePrefix, source, count, offset: [x,y,z], parent?)
  // \`count\` is the TOTAL, source included: the source stays where it is as copy 0 and the call
  // returns count-1 new instances, so count 10 gives 10 posts, not 11. Copies share geometry +
  // material via createInstance, and carry the source rotation and scale.
  // e.g. const post = createPart('Post0', cylinderGeo(0.05,0.05,1.5,6), wood, { position:
  // [0,0.75,0], parent: root }); arrayLinear('Post', post, 10, [0.5, 0, 0], root);
arrayRadial(namePrefix, source, count, axis?: 'x'|'y'|'z', parent?, center?: [x,y,z], opts?: { orientation?: 'outward'|'relative' })
  // \`count\` is the TOTAL, source included: the source stays at its angle as copy 0 and the call
  // returns count-1 new mesh instances. Copies preserve source scale. Default outward rotation
  // follows the orbit; relative orientation composes the orbit with the source rotation. Copies
  // orbit the parent's origin unless you pass center. This is mesh reuse, not
  // hierarchy-preserving assembly replication.
  // e.g. const bolt = createPart('Bolt0', cylinderGeo(0.02,0.02,0.1,6), steel, { position:
  // [1,0,0], parent: root }); arrayRadial('Bolt', bolt, 8, 'y', root);
repeatAlongCurve(source: BufferGeometry | Mesh, points: [x,y,z][], opts: { count, align?: 'tangent'|'none', up?: [x,y,z], scale?: n | [attach, tip], twist?: deg | [attach, tip], opposite?: false, start?: 0..1, end?: 0..1, merge?: true, along?: false, name?, parent? })
  // Copies one leaflet, card or stud along a sampled curve, evenly spaced by arc length. Each
  // copy's local +X follows the tangent and +Y points toward up. merge: true (default) returns
  // ONE geometry for one primitive per frond, with UVs kept per copy; merge: false returns
  // shared-geometry nodes like arrayLinear.
  // NOTE: One merged geometry is one part; name the frond, not each leaflet. opposite: true
  // adds the second row in the same primitive. Merges are capped at 262,144 vertices.
  // e.g. const rachis = bezierCurve([[0,0,0],[0.6,0.5,0],[1.4,0.3,0]], 32); const leaflet =
  // foliageCardGeo({ width: 0.05, height: 0.35, yPivot: 0 }); const frond =
  // repeatAlongCurve(leaflet, rachis, { count: 40, up: [0,0,1], scale: [1, 0.4], start: 0.1,
  // opposite: true }); createPart('Frond_0', frond, foliageMaterial(albedo), { parent: root });
mirror(name, source, axis: 'x'|'y'|'z', parent?)
  // Reflects source across the plane whose normal is \`axis\`. Uses negative scale (winding flip
  // handled by viewers).
  // e.g. mirror('WingR', wingL, 'x', root);

// CSG / Boolean (async — using any of these requires \`async function build()\`)
// NOTE: For textured or multi-material booleans, pass { preserveAttributes: true } as the final
// options argument. This preserves UV0 and source materials through actual operand runs;
// exposed cut faces inherit the cutter material and UVs. Legacy calls omit that option and
// discard UVs, so unwrap their result afterward: \`mesh.geometry = await
// autoUnwrap(mesh.geometry)\`. Tangents are regenerated when needed. Empty operands/results fail
// with a named cause. Convex hull faces are newly generated and have no original-face
// provenance. Use static meshes: bake instances and poses first. Colors, secondary UVs, custom
// attributes and morph targets do not survive CSG; inspect the reported losses. Keep the
// returned mesh transform: its position is the first contributing mesh world origin, with
// world-aligned geometry local to that origin. All operands use one shared computation frame;
// geometry alone does not include world translation.
await boolUnion(name: string, ...parts: Object3D[], opts?: { smooth?: false, preserveAttributes?: boolean })
  // Merges two or more parts into one watertight manifold mesh. Default flat shading (hard
  // edges) — pass { smooth: true } as last arg for averaged normals on organic merges.
  // e.g. const body = new THREE.Mesh(boxGeo(2, 1, 1), steel); const turret = new
  // THREE.Mesh(cylinderGeo(0.3, 0.3, 0.4, 16), steel); turret.position.y = 0.5; const hull =
  // await boolUnion('Hull', body, turret);
await boolDiff(name: string, body: Object3D, ...cutters: Object3D[], opts?: { smooth?: false, preserveAttributes?: boolean })
  // Subtracts cutters from a body (holes, button recesses, window slots). Default flat shading
  // for sharp mechanical edges.
  // e.g. const body = new THREE.Mesh(cylinderGeo(1, 1, 0.3, 32), steel); const teeth = [...];
  // // 8 radially-arrayed box meshes const gear = await boolDiff('Gear', body, ...teeth); //
  // hard-edged
await roundedBoxGeo(width: number, height: number, depth: number, radius: number, opts?: { style?: 'round' | 'chamfer', segments?: 12, smooth?: boolean })
  // A box with all twelve edges rounded (or chamfered) at the EXACT outer size requested —
  // roundedBoxGeo(1, 1, 1, 0.1) measures 1x1x1, it does not grow. Use it anywhere boxGeo reads
  // too sharp: consoles, crates, appliances, handheld props, machined blocks.
  // NOTE: Real objects almost never have perfectly sharp box edges, and a small radius is the
  // single cheapest upgrade to how manufactured an asset looks. Prefer this over boxGeo for
  // anything moulded, cast, or machined. Keep radius small relative to the box (5-10% of the
  // smallest dimension); radius must be less than half the smallest dimension or the call
  // throws. style: 'chamfer' reads as machined metal, 'round' as moulded plastic. This is async
  // — build() must be async and the call must use await.
  // e.g. const geo = await roundedBoxGeo(1.2, 0.6, 0.8, 0.05); createPart('Console', geo,
  // plastic, { position: [0, 0.3, 0], parent: root });
await extrudeProfile(profile: [number, number][], opts?: { depth?: 1, holes?: [number, number][][], bevel?: 0, bevelStyle?: 'round' | 'chamfer', segments?: 12, twist?: 0, taper?: number | [number, number], divisions?: 0, axis?: 'x' | 'y' | 'z', center?: true, smooth?: false })
  // Sweeps a closed 2D outline into a watertight solid, with optional holes, corner
  // rounding/chamfering, twist, and taper. The way to build any cross-section that is not a box
  // or a cylinder: L-brackets, I-beams, gaskets, washers, star and gear plates, signage,
  // extruded trim.
  // NOTE: Profile (u,v) maps to XYZ as axis x: (d,v,-u), axis y: (u,d,-v), axis z: (u,v,d),
  // where d is extrusion depth. For a desired XZ footprint on axis y, pass [X,-Z]; positive
  // profile v projects toward -Z. The bevel rounds the edges PARALLEL to the sweep axis (the
  // profile corners) — the two flat caps stay sharp. For a box rounded on all twelve edges use
  // roundedBoxGeo instead. Holes are subtracted, so their winding order does not matter.
  // divisions is the whole number (>= 0) of intermediate rings between the caps: default 0, or
  // 16 when twisting; a straight or tapered sweep needs none. A bevel larger than half the
  // outline's narrowest feature throws rather than silently returning an empty solid. Output is
  // manifold, so it feeds straight into boolUnion / boolDiff / boolIntersect. Async — await it
  // inside an async build().
  // e.g. // L-bracket, inner AND outer corners filleted const outline = [[0, 0], [2, 0], [2,
  // 0.4], [0.4, 0.4], [0.4, 2], [0, 2]]; const geo = await extrudeProfile(outline, { depth:
  // 0.5, bevel: 0.06 }); createPart('Bracket', geo, steel, { parent: root });
await revolveProfile(profile: [number, number][], opts?: { segments?: 24, angle?: 360, bevel?: 0, bevelStyle?: 'round' | 'chamfer', bevelSegments?: 12, axis?: 'x' | 'y' | 'z', smooth?: true })
  // Revolves a closed 2D outline around an axis into a watertight SOLID, optionally rounding
  // the profile corners first. Bottles, tanks, pressure vessels, wheels, turned wood, domes,
  // buttons, pills.
  // NOTE: Use this instead of lathe/revolveGeo whenever the result must survive a boolean or
  // needs a rounded rim — lathe and revolveGeo build an open surface, this builds a closed
  // solid. Profile convention matches lathe: x is distance from the axis, y is position along
  // it, and only the x >= 0 side is used. Async — await it inside an async build().
  // e.g. // capsule tank with a rounded rim, then carve a port into it const profile = [[0,
  // -0.5], [0.4, -0.5], [0.4, 0.5], [0, 0.5]]; const body = await revolveProfile(profile, {
  // bevel: 0.08, segments: 32 }); const tank = await boolDiff('Tank', createPart('B', body,
  // steel), portCutter);
circleProfile(radius: number, segments?: 24, center?: [number, number])
  // Builds a closed circular outline for extrudeProfile / revolveProfile, so you never
  // hand-write the trigonometry. Synchronous.
  // e.g. const washer = await extrudeProfile(circleProfile(1), { depth: 0.1, holes:
  // [circleProfile(0.4), circleProfile(0.1, 16, [0.7, 0])], });
await boolIntersect(name: string, a: Object3D, b: Object3D, opts?: { smooth?: false, preserveAttributes?: boolean })
  // Keeps only the volume where both operands overlap. Default flat shading.
  // e.g. const lens = await boolIntersect('Lens', boxMesh, sphereMesh);
await hull(name: string, ...parts: Object3D[], opts?: { smooth?: true, preserveAttributes?: boolean })
  // Tightest convex mesh enclosing all input points. Default smooth shading (rocks, collision
  // volumes). Pass { smooth: false } for a faceted look.
  // e.g. const rockChunks = [...]; // scattered box meshes const rock = await hull('Rock',
  // ...rockChunks);

// Mesh ops
creaseNormals(geometry: BufferGeometry, opts?: { angle?: 60, tolerance?: number })
  // Returns owned geometry with angle-limited smooth normals, preserving UV corners. Angle is
  // degrees. Default position tolerance is 1e-8 times the diagonal, with no world-unit floor;
  // explicit tolerance is absolute. Invalidates tangents; use after shaping for sharp rims and
  // smooth walls.
  // e.g. const shell = creaseNormals(cylinderGeo(1,1,2,32), { angle: 45 });
bend(geometry, { angle, frame?: { origin, rotation }, interval?: [minY,maxY], falloff?: t => weight })
  // Bends local +Y toward +X through angle degrees. Returns owned geometry and updated
  // normals/bounds; preserves UVs, invalidates tangents. Frame rotation is Euler XYZ degrees.
  // NOTE: Deformation interval uses local Y distances; outside vertices stay unchanged. Add
  // enough segments before bending. Falloff returns 0..1; use it to avoid a discontinuity at a
  // selected interval boundary.
  // e.g. const arch = bend(planeGeo(1,4,4,32), { angle: 90 });
twist(geometry, { angle, frame?: { origin, rotation }, interval?: [minY,maxY], falloff?: t => weight })
  // Rotates the cross-section progressively around local +Y, reaching angle degrees at the end.
  // Returns owned geometry; frame rotation uses Euler XYZ degrees.
  // e.g. const spiral = twist(column, { angle: 120 });
taper(geometry, { startScale?: [1,1], endScale: [x,z], frame?: { origin, rotation }, interval?: [minY,maxY], falloff?: t => weight })
  // Scales local X/Z across the local Y interval using positive start/end scale pairs. Returns
  // owned geometry; preserves UVs and invalidates tangents.
  // e.g. const narrowed = taper(column, { endScale: [0.4,0.7] });
displace(geometry, offset: ([x,y,z], t) => [dx,dy,dz], opts?: { frame?: { origin, rotation }, interval?: [minY,maxY], falloff?: t => weight })
  // Adds an authored displacement vector in the chosen local frame. Returns owned geometry;
  // callback coordinates are local and t is normalized along the interval.
  // e.g. const rippled = displace(surface, ([x,y,z]) => [0, 0.1*Math.sin(x*8), 0]);
smoothOrganic(geometry, opts?: { iterations?: 1, creaseAngle?: 55, preserveUV?: false })
  // Runs subdivide then creaseNormals with organic-friendly defaults.
  // e.g. const soft = smoothOrganic(tube, { iterations: 1, creaseAngle: 50 });
bakeSurfaceAttributes(target: Object3D, opts?: { edge?: { thresholdDegrees?: 35, smoothing?: 1 } | false, cavity?: { rays?: 32, radius?, occluders? } | false })
  // Bakes two float vertex attributes in [0, 1] on every visible mesh in target: _edge (convex
  // rim weight, 1 on chamfers and rims, 0 on flat faces) and _cavity (exposure, 1 open, toward
  // 0 in recesses and under overhangs). Exported as glTF _EDGE and _CAVITY.
  // NOTE: Only when the brief asks for wear or cavity attributes. Call it last, after parts are
  // placed: cavity depends on placement. Each baked mesh gets its own geometry copy.
  // e.g. // after every part that occludes is attached bakeSurfaceAttributes(root, { edge: {
  // thresholdDegrees: 35 }, cavity: { rays: 32 } });
subdivide(geometry: BufferGeometry, iterations?: 1, opts?: { preserveUV?: boolean, split?: boolean, uvSmooth?: boolean, preserveEdges?: boolean, flatOnly?: boolean, weld?: boolean })
  // Loop subdivision returns new geometry; each iteration roughly quadruples triangles and
  // smooths the surface. Use preserveUV:true for textured meshes. Legacy position-only welding
  // discards UVs and reports that loss. This smooths shapes, not selected-edge beveling.
  // e.g. const smoothRock = subdivide(boxGeo(1, 1, 1), 2);
mergeVertices(geometry: BufferGeometry, opts?: { tolerance?: 1e-4, positionOnly?: boolean } | number)
  // Returns indexed geometry. Default welding preserves attribute seams, so a textured cube
  // retains separate face corners. positionOnly:true welds coincident positions and discards
  // other attributes; use it explicitly when changing topology and regenerate shading/UVs
  // afterward.
  // e.g. const welded = mergeVertices(boxGeo(1, 1, 1), { positionOnly: true }); const rock =
  // displace(subdivide(welded, 2), ([x,y,z]) => [0.08*Math.sin(y*7+z*3), 0.04*Math.sin(x*9),
  // 0]);
await simplifyGeometry(geometry: BufferGeometry, opts: { ratio?: number, targetTriangles?: number, maxError?: 1, lockBorder?: true })
  // Derives a lower-detail copy of one geometry for an LOD tier with the meshoptimizer
  // simplifier. Pass exactly one of ratio (0 < ratio <= 1) or targetTriangles. Material groups,
  // UV and normal seams and open borders are kept; the input is never changed.
  // userData.kilnSimplify records trianglesBefore, trianglesAfter, the achieved ratio and the
  // error.
  // NOTE: Async: await it inside async build(). Call it per part for a lower tier and pass the
  // tiers to defineLod; it never runs on its own or to meet a budget. maxError, locked borders
  // and seams can stop it short of the target: read userData.kilnSimplify.ratio, and
  // SIMPLIFY_TARGET_NOT_REACHED is a build note.
  // e.g. const rock = sphereGeo(1, 32, 16); const far = await simplifyGeometry(rock, { ratio:
  // 0.25 }); const [near, farTier] = ['Rock_LOD0', 'Rock_LOD1'].map((name) => { const g = new
  // THREE.Group(); g.name = name; root.add(g); return g; }); createPart('RockNear', rock,
  // stone, { parent: near }); createPart('RockFar', far, stone, { parent: farTier });
  // defineLod([near, farTier], { screenCoverage: [0.05, 0.002] });

// Curves
sweepProfile(profile: [x,z][], path: [x,y,z][], opts?: { cap?: true | false | 'start' | 'end', creaseAngle?: 60, closed?: false, up?: [x,y,z], twist?: 0, scale?: number | [x,z][] })
  // Sweeps a simple noncircular profile along polyline stations using transported frames.
  // Supports total twist in degrees and per-station scales. Generates UVs and optional caps.
  // NOTE: First version supports one simple profile without holes. Closed paths omit the
  // repeated endpoint and require twist to be a multiple of 360. up sets the initial profile +Z
  // direction and cannot parallel the path. cap caps both ends by default; 'start' or 'end'
  // caps only that end of an open path. creaseAngle (degrees) keeps side faces meeting at more
  // than it hard-edged, at profile corners and sharp path corners: at the default 60, squares,
  // triangles and pentagons stay faceted while hexagons and finer profiles shade smooth; 180
  // smooths every edge. Tight-turn warnings do not replace visual inspection for
  // self-intersections.
  // e.g. const rail = sweepProfile([[-.1,-.2],[.1,-.2],[.1,.2],[-.1,.2]],
  // [[0,0,0],[0,1,0],[1,2,0]]);
loftProfiles(sections: { profile: [x,z][], frame?: { origin, rotation } }[], opts?: { cap?: true })
  // Joins corresponding simple profiles in explicit local XZ planes. Frames use Euler XYZ
  // degrees; initial section travel determines outward winding. Profiles need equal point
  // counts and corresponding vertices.
  // NOTE: No holes or automatic profile correspondence. Opposite winding is normalized while
  // preserving the first point. Caps close boundaries but do not prove the loft has no
  // self-intersections.
  // e.g. const hull = loftProfiles([{ profile: wide }, { profile: narrow, frame: { origin:
  // [0,2,0] } }]);
taperedTube(path: [x,y,z][], radii: number[], opts?: { radialSegments?: 20, creaseAngle?: 180, cap?: true, closed?: false, up?, twist?, sectionScale?: [side,depth][] })
  // Circular sweep along a polyline with one radius per station. Default creaseAngle 180 shades
  // round profiles smoothly. catmullRomPath can supply samples when a spline fits the intended
  // path.
  // e.g. const path = catmullRomPath([[0,0.5,0],[0.3,0.7,0],[0.5,0.4,0]], 6); const radii =
  // path.map((_, i) => 0.08 - 0.06 * i / (path.length - 1)); const tail = taperedTube(path,
  // radii);
catmullRomPath(controlPoints: [x,y,z][], samplesPerSpan?: 8, closed?: false)
  // Samples a Catmull-Rom spline through waypoints. Open paths include both endpoints; closed
  // paths omit the repeated endpoint for closed sweeps.
  // e.g. const path = catmullRomPath([[0,0,0],[0.2,0.4,0.1],[0.5,0.2,0]], 10);
spiralPath(opts: { center, radius, rise, turns, axis?, forward?, samples? })
  // Rising spiral for curled appendages, shrinking to 42% of the start radius. Returns samples
  // + 1 stations; starts radius away from center.
  // e.g. const curl = spiralPath({ center: [0,0.05,0], radius: 0.03, rise: 0.12, turns: 1.75,
  // forward: [0,0,1] });
curveToMesh(points: [x,y,z][], radius, tubularSegs?: 32, radialSegs?: 8, closed?: false)
  // Sweeps a circular profile along a path. Equivalent to Blender's Curve to Mesh node with a
  // circle profile. Use for pipes, cables, tubular frames.
  // e.g. const pipe = curveToMesh([[0,0,0],[0,1,0],[1,1,0],[1,2,0]], 0.1);
pipeAlongPath(points: [x,y,z][], radius: number, opts?: { bendRadius?: 0, closed?: false, tubularSegments?: 32, radialSegments?: 8 })
  // Path-driven swept circle with optional bend smoothing. Generalises beamBetween
  // (point-to-point) and curveToMesh (raw spline) into one helper. bendRadius>0 inserts
  // interpolated waypoints near interior corners so the spline reads as a rounded turn instead
  // of pinching to the control point.
  // e.g. const cable = pipeAlongPath([[0, 0.5, 0], [1, 0.5, 0], [1, 0.5, 2]], 0.02, {
  // bendRadius: 0.1 });
lathe(profile: [x,y][], segments?: 12)
  // Surface of revolution. Spins a 2D profile around the Y axis. For bottles, vases, wheels,
  // turned wood parts.
  // e.g. const vase = lathe([[0.1,0],[0.3,0.5],[0.2,1],[0.1,1.2]], 16);
revolveGeo(profile: [x,y][], opts?: { angle?: 2π, axis?: [x,y,z]=[0,1,0], segments?: 12 })
  // Surface of revolution with explicit axis + sweep angle. Generalises lathe — use it when you
  // need a partial sweep (half-dome, 90° wedge) or revolution around a non-Y axis. Profile
  // convention is identical to lathe: x = radial distance, y = position along the axis.
  // e.g. // Half-dome (180° sweep around +Y): const quarter = [...Array(8)].map((_, i) => {
  // const t = (i/7)*Math.PI/2; return [Math.cos(t), Math.sin(t)] as [number, number]; }); const
  // dome = revolveGeo(quarter, { angle: Math.PI });
bezierCurve(controlPoints: [x,y,z][], samples?: 32)
  // Samples a quadratic (3 ctrl pts) or cubic (4 ctrl pts) Bézier into a point list you can
  // feed into curveToMesh.
  // e.g. const path = bezierCurve([[0,0,0],[1,2,0],[3,2,0],[4,0,0]], 24); const geo =
  // curveToMesh(path, 0.1);

// UV unwrapping
projectUV(geometry: BufferGeometry, opts: { projection: 'planar'|'box'|'cylindrical', frame?: { origin?: [x,y,z], rotation?: [xDeg,yDeg,zDeg] }, seamDegrees?: number, angularRange?: [startDeg,sweepDeg], caps?: 'planar'|'side', metersPerUnit?: number })
  // Generates UV0 explicitly in a rigid geometry-local frame. Planar maps XY; box maps each
  // face; cylindrical wraps frame Y with separate caps and split angular seams. Replaces
  // existing UVs and removes stale tangents. metersPerUnit maps one UV unit to a fixed length
  // so parts of different size tile at the same density. To preserve good UVs use direct
  // sharing or copyGeometry instead.
  // e.g. const mapped = projectUV(rawGeometry, { projection: 'cylindrical', frame: { rotation:
  // [0,0,-90] }, seamDegrees: 180 });
remapUV(geometry: BufferGeometry, opts?: { scale?: [u, v], offset?: [u, v] })
  // Scales and offsets existing UV0 on an independent geometry. Defaults are scale [1,1],
  // offset [0,0]. Requires finite two-component UVs; does not unwrap or project. Reads
  // interleaved and normalized attributes. Preserves topology and other attributes; nonidentity
  // scaling removes stale tangents with a warning.
  // e.g. const strip = remapUV(cylinderGeo(0.4, 0.4, 1), { scale: [1, 0.3], offset: [0, 0] });
await autoUnwrap(geometry: BufferGeometry, opts?: { resolution?: 1024, padding?: 2, useNormals?: false })
  // xatlas-based UV atlas for bounded triangle geometry, including CSG output. Remaps vertex
  // data and morphs across seams; preserves groups. Replaces UV0 and removes stale tangents.
  // Maximum 65,536 input and output vertices; split larger meshes. Packed charts rotate
  // arbitrarily: use for baked textures; prefer projectUV or original primitive UVs for
  // directional tiling. See the preservation contract before unwrapping skinned or morphed
  // geometry.
  // e.g. const unwrapped = await autoUnwrap(someCsgResult, { resolution: 1024 }); const mesh =
  // new THREE.Mesh(unwrapped, bakedPbr);
remapUVToAtlas(geometry, atlasTextureOrManifest, regionName, { inputOrigin: 'top-left' | 'bottom-left', mode: 'content-boundary' | 'texel-center', axes?: 'uv' | 'u-only' })
  // Maps existing unit UV0 into a named atlas content rectangle on an owned geometry clone,
  // preserving topology and rich attributes.
  // NOTE: UV0 must be finite in [0,1], with two components per vertex. Content-boundary maps
  // endpoints to content edges; texel-center maps endpoints to the first/last content texel
  // centers. Explicitly identify the input UV origin; atlas image coordinates use top left and
  // flipY=false. Geometry, normals, colors, skin weights, morph buffers, groups and source
  // metadata are preserved independently. UV scale changes invalidate tangents; regenerate when
  // needed. The default axes 'uv' replaces both components, so it destroys a per-vertex
  // gradient carried in V — a foliage wind sway weight read as uv-y is the known case, and the
  // result still validates and renders. Pass axes 'u-only' for that: it rescales U into the
  // named column and leaves V bit-for-bit, requiring inputOrigin 'top-left' and a region that
  // spans the full atlas height (lay the sheet out as full-height species columns with gutter
  // 0). This helper does not project, unwrap, tile within a region or change material sampling.
  // e.g. const card = remapUVToAtlas(planeGeo(1, 1), atlas, 'patch', { inputOrigin:
  // 'bottom-left', mode: 'texel-center' }); const blade = remapUVToAtlas(leafGeo,
  // fernColumnAtlas, 'fern', { inputOrigin: 'top-left', mode: 'texel-center', axes: 'u-only'
  // });

// Textures (approved resource loading is async)
await loadApprovedTexture(resourceId)
  // Loads one approved kiln.texture.* resource ID through the host-injected closed resolver.
  // The registry fixes bytes, MIME, usage, dimensions, hash, and deadline; paths, URLs, byte
  // arrays, resolver objects, hashes, and options are rejected.
  // NOTE: Use only a concrete resource ID listed in material capabilities; never invent one.
  // Prefer materialRecipe when a recipe already binds the family, or proceduralTexture V2 for
  // authored surfaces. NEVER texture.clone() a loaded texture (clone() corrupts encoded bytes
  // and breaks GLB export).
  // e.g. const bark = await loadApprovedTexture('kiln.texture.bark-brown-01-albedo.v1');
proceduralTexture({ schemaVersion: 2, size?: 4..1024 pow2, usage?, name?, layers: ProceduralLayer[] } | { schemaVersion: 3, width: 4..1024, height: 4..1024, usage?, name?, background?: RGBA, operations: OperationV3[], palette? })
  // Builds a repeat-wrapped deterministic texture without an image file. V2 retains opaque
  // pattern layers. Explicit V3 adds rectangular RGBA, pixel shapes/masks, color palettes and
  // seeded stamps. Repeat wrapping alone does not prove seamless pixels. Baked to PNG and
  // embedded in the GLB automatically.
  // NOTE: V2 layer fields by op: solid: { color }; checker: { colorA, colorB, squares? };
  // stripes: { colorA, colorB, count?, angleDeg? }; gradient: { from, to, angleDeg? }; bricks:
  // { brick, mortar, rows?, cols?, mortarWidth?: 0..1 (fraction of a brick cell, default 0.06),
  // stagger?: 0..1 (row offset fraction, default 0.5) }; noise: { colorA, colorB, scale?,
  // octaves?, seed? }; cellular: { colorA, colorB, cellsX?, cellsY?: 1..256 cells per tile,
  // default 8; seed?; jitterX?, jitterY?: 0..1, default 1; metricX?, metricY?: 1..4, default 1,
  // a larger metric thins joints across that axis; weight?: 0..1 additive cell weight drawn
  // from the seed, default 0, curves borders and varies cell size; feature?:
  // 'f1'|'f2'|'f2-f1'|'cell'|'border'|'facet', default f1; range?: 0.01..8 (f1, f2, f2-f1 and
  // cell: the value that reaches colorB, default 1; below 1 on cell it leaves a sparse
  // population of toned cells); borderOpen?: 0..1, default 0.5, borderWidth?: 0.001..1, default
  // 0.05 (border: colorB in the opened joints); facetSlope?: 0..1, default 0.5, facetBlend?:
  // 0.001..1, default 0.1 (facet: a tilted plane per cell, blended across borders, for height)
  // }. A field the chosen feature ignores is an error. Reuse one layout and seed across layers
  // and maps so joints line up. V2 blend normal|multiply|screen|overlay; opacity 0..1; max 8
  // layers, counts 1..256, octaves 1..6. V3 operations: paint {shape,rgba,opacity?}; mask
  // {shape,alpha?,invert?}; stamps {shape,rgba,count,seed,area,periodic?,opacity?}; legacy-v2
  // {spec,alpha?,opacity?} delegates an explicit V2 recipe with matching square
  // dimensions/usage. RGBA is four bytes; V3 opacity/alpha are bytes0..255 default255. Shape
  // kinds: rectangle/ellipse {x,y,width,height}; polygon {points:[[x,y],...]}; line
  // {from:[x,y],to:[x,y],width}. Coordinates are integer pixel edges; centers define binary
  // coverage, round line caps. Mask clears outside; invert keeps outside instead. area
  // {x,y,width,height} sets seeded stamp translation offsets; periodic:true wraps copies
  // explicitly. V3 background defaults transparent black, max64 ops,64 polygon vertices,256
  // expanded stamps (periodic counts9),32 palette colors,64million estimated work including
  // edges. palette {colors:[RGB integers],dither?:'none'|'bayer4'} and stamps are
  // albedo/emissive only. Zero alpha normalizes RGB to0. Sampler defaults remain
  // repeat/linear/mips; alphaMode belongs to pbrMaterial. Sync; strict JSON rejects
  // unknown/prototype fields and accessors. See docs/procedural-surfaces-v3.md for exact
  // rounding and bounds.
  // e.g. const bark = proceduralTexture({ schemaVersion: 2, size: 256, usage: 'albedo', name:
  // 'Bark', layers: [{ op: 'solid', color: 0x5a4632 }, { op: 'noise', colorA: 0x3d2f21, colorB:
  // 0x7a6248, scale: 6, octaves: 4, blend: 'overlay' }] });
await textureAtlas({ schemaVersion: 1, width, height, usage, sampler?, pack?: { edge: 1024 | 2048, gutter?, algorithm?: 'maxrects' }, regions: [{ name, content?: { x, y, width, height }, gutter?, edgeMode?, source, crop? }] })
  // Composes named, disjoint pixel regions from bounded procedural V3 recipes or exact pinned
  // library maps without creating a mesh.
  // NOTE: Coordinates are integer pixel edges from top left. Width/height 4..1024. Content
  // excludes gutter (default2); padded allocations must not overlap. With pack, width/height
  // default to pack.edge (up to 2048, 128 regions, 32 sources; compiler
  // kiln.texture-atlas.v1.2) and regions may omit content: MaxRects places them by area
  // descending then name, around any explicit rectangles, at their source size (procedural spec
  // size, crop, or a resource expected width/height); pack.gutter is the default gutter. The
  // compiled spec records each placement (packed: true); read placements from the manifest
  // regions. copy-edge (default) extrudes RGBA; mask-rgb-dilate preserves positive alpha and
  // extends nearest donor RGB into zero-alpha pixels without growing alpha, for albedo/emissive
  // only. No rotation or resampling. An optional crop must exactly match content dimensions.
  // Resource sources require
  // {kind:"resource",resourceId:exactMapId,pin:{resourceId:materialId,revisionId,sha256}} and a
  // host-supplied exact dependency; paths, URLs, latest and approved non-library resources are
  // unsupported. Default sampler is linear-mipmap-linear/linear/clamp-to-edge on both axes;
  // explicit samplers require all four fields. Gutters do not guarantee isolation at every mip
  // level. Use remapUVToAtlas with an explicit input origin and mode; inspect at intended scene
  // distance.
  // e.g. const atlas = await textureAtlas({ schemaVersion: 1, width: 8, height: 8, usage:
  // 'albedo', regions: [{ name: 'patch', content: { x: 2, y: 2, width: 4, height: 4 }, source:
  // { kind: 'procedural', spec: { schemaVersion: 3, width: 4, height: 4, background: [70, 90,
  // 40, 255], operations: [] } } }] });
normalMapFromHeight(source: THREE.Texture, { strength?: number, name?: string })
  // Derives a tangent-space normal map from the source texture's brightness, treating it as
  // height. The cheap way to get real PBR surface relief out of a procedural albedo. Wraps at
  // the edges, so a tiling source gives a tiling normal map.
  // NOTE: strength 1 is subtle, 4-8 reads clearly at normal viewing distance. Output is always
  // linear data — never assign it to an albedo/emissive slot.
  // e.g. const bark = proceduralTexture({ schemaVersion: 2, usage: 'albedo', layers: [{ op:
  // 'noise', colorA: 0x3d2f21, colorB: 0x7a6248, scale: 6, octaves: 4 }] }); const mat =
  // pbrMaterial({ albedo: bark, normal: normalMapFromHeight(bark, { strength: 4 }) });

// Animation — keyframes use "rotation"/"position"/"scale" keys, NOT "value"
rotationTrack(jointName: string, keyframes: Array<{ time, rotation: [xDeg, yDeg, zDeg] }>, interp?: 'LINEAR' | 'STEP' | 'CUBICSPLINE' | 'EASE_IN' | 'EASE_OUT' | 'EASE_IN_OUT')
  // Absolute local XYZ Euler degrees converted to quaternion keys. Use an exact node name;
  // Joint_ is a convention. LINEAR follows shortest quaternion arcs; STEP holds until the next
  // key. CUBICSPLINE is one smooth curve through the keys; EASE_IN, EASE_OUT and EASE_IN_OUT
  // ease every segment, so one key pair is a smooth swing. The last four export as glTF
  // CUBICSPLINE and need two or more keys.
  // e.g. rotationTrack('Joint_Lid', [{ time: 0, rotation: [0, 0, 0] }, { time: 1, rotation:
  // [90, 0, 0] }], 'EASE_IN_OUT');
positionTrack(jointName: string, keyframes: Array<{ time, position: [x, y, z] }>, interp?: 'LINEAR' | 'STEP' | 'CUBICSPLINE' | 'EASE_IN' | 'EASE_OUT' | 'EASE_IN_OUT')
  // Absolute parent-local positions in authored length units. Use \`position:\`, not \`value:\`.
  // Finite nonnegative times must stay strictly increasing in float32.
  // e.g. positionTrack('Joint_Body', [{ time: 0, position: [0, 0, 0] }, { time: 1, position:
  // [0, 0.1, 0] }]);
scaleTrack(jointName: string, keyframes: Array<{ time, scale: [x, y, z] }>, interp?: 'LINEAR' | 'STEP' | 'CUBICSPLINE' | 'EASE_IN' | 'EASE_OUT' | 'EASE_IN_OUT')
  // Uniform or per-axis scale track.
  // e.g. scaleTrack('Joint_Chest', [{ time: 0, scale: [1, 1, 1] }, { time: 1, scale: [1.1, 1.1,
  // 1.1] }]);
createClip(name: string, duration: number, tracks: KeyframeTrack[], options?: { loop?: boolean })
  // Validates supported position/quaternion/scale tracks and collects them into a named clip.
  // Duration is seconds (-1 derives from keys); explicit duration must include every key. loop:
  // true declares a cycle, false a one-shot; exported as the glTF animation extra
  // kilnLoopIntent and reported by animation review. Returned from animate().
  // e.g. return [createClip('Open', 1, [rotationTrack('Joint_Lid', [...])], { loop: false })];
idleBreathing(bodyJoint: string, duration?: 2, amount?: 0.02, options?: { basePosition?: [x, y, z] })
  // Gentle parent-local Y bob around options.basePosition, default [0,0,0]. Give the authored
  // base explicitly or animate a separate zero-origin pivot.
  // e.g. return [idleBreathing('Joint_Body', 2, 0.02, { basePosition: [0, 1.2, 0] })];
bobbingAnimation(rootName: string, duration?: 2, height?: 0.1, options?: { basePosition?: [x, y, z] })
  // Parent-local Y motion loop around options.basePosition, default [0,0,0]. A target name
  // alone cannot infer its rest translation.
  // e.g. return [bobbingAnimation('Joint_Root', 1.5, 0.08, { basePosition: [0, 0.5, 0] })];
spinAnimation(jointName: string, duration?: 2, axis?: 'x' | 'y' | 'z')
  // 360° rotation over \`duration\` around \`axis\`.
  // e.g. return [spinAnimation('Joint_Rotor', 0.5, 'y')];

// Inspection utilities
materialBudgetAdvisory(root: Object3D, opts?: { maxMaterials?: number })
  // Counts distinct material object identities and optionally compares an explicit nonnegative
  // integer budget. Without maxMaterials it reports a count with null budget/exceeded and no
  // warnings. Does not measure draw calls, validate geometry, choose an asset category, or
  // establish asset validity.
  // e.g. const advisory = materialBudgetAdvisory(root, { maxMaterials: 8 });
geometryDiagnostics(geometry: BufferGeometry, tolerance?: number)
  // Counts topology issues after position-grid matching. Default tolerance is 1e-6 times the
  // finite-position diagonal; an explicit positive value is absolute. Reports effective
  // tolerance and scale. Open boundaries are valid for sheets; closed edges do not certify a
  // self-intersection-free solid.
  // e.g. const topology = geometryDiagnostics(shell);
defineBudget(spec: { triangles?: number | { LOD0, LOD1, ... }, draws?: number, images?: number, decodedBytes?: number, materialTier?: 'web.portable.v1/standard' | ... }, target?: Object3D)
  // Declares a triangle budget (one number for LOD0, or per LOD tier), an optional LOD0
  // draw-call budget, and optional material limits: images, decodedBytes (RGBA8), or
  // materialTier, which adopts a reference tier's image count, decoded bytes, image size and
  // blended-area figures. Receipts report budget: { status, tiers, materials? } measured from
  // the GLB. Without a material limit, receipts carry materialAdvice notes against
  // web.portable.v1/standard instead: optional, never a requirement. Advisory: never QA
  // acceptance.
  // NOTE: Only when the brief states a budget. Call once; tiers are LOD0, LOD1, ... matching
  // defineLod levels. Material notes are not a budget: do not remove textures that carry the
  // look to clear them.
  // e.g. defineBudget({ triangles: { LOD0: 4000, LOD1: 900 }, draws: 3, images: 6 });
definePalette(colors: string[], opts?: { threshold?: 10 }, target?: Object3D)
  // Declares the asset palette (1..64 hex colours). Receipts list every drawn material whose
  // base colour is farther than threshold (CIE76 delta E, default 10) from the nearest entry as
  // PALETTE_OFF warnings and a manifest palette report. Advisory: never fails a build.
  // NOTE: Only when the brief names a palette or a set of exact colours. Call once.
  // e.g. definePalette(['#6b6f73', '#3a3d40', '#8a4b2a', '#c9a227']);
requireSolid(part: Object3D)
  // Opt-in assertion: the build fails with REQUIRE_SOLID unless every visible mesh in part is
  // closed, manifold and outward (geometryDiagnostics(geometry).solid).
  // NOTE: Only for parts that must be watertight (collision, booleans, printing). It measures;
  // it repairs nothing.
  // e.g. const hull = createPart('Hull', boxGeo(2, 1, 4), steel, { parent: root });
  // requireSolid(hull);
countTriangles(root: Object3D)
  // Sums placed mesh triangles across the subtree, including active InstancedMesh copies and
  // two triangles per sprite. Not draw calls or visible-frame cost.
  // e.g. meta.tris = countTriangles(root);
countMaterials(root: Object3D)  // Unique material count (by reference) across the subtree.
  // e.g. const mats = countMaterials(root);
getJointNames(root: Object3D)  // All node names beginning with \`Joint_\`. Use to sanity-check animation targets.
  // e.g. const joints = getJointNames(root);
seededRandom(seed: number | string)
  // Deterministic random numbers from a seed: the same seed gives the same draws, so builds
  // stay cacheable (Math.random marks a build ambient and uncached). fork(label) is an
  // independent stream from the seed and label, not from how many draws were made.
  // NOTE: Use instead of Math.random. Give each varied feature its own fork(label) so adding a
  // draw elsewhere does not shift it; a variant that reuses the seed and label replays the
  // stream.
  // e.g. const rng = seededRandom('palm-3'); const crown = rng.fork('crown'); const lean =
  // rng.range(-8, 8); const fronds = crown.int(7, 9); const look = rng.pick(['fan', 'droop']);"
`;