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.

3.2 KB
Raw Blame

Composition API notes

Use these through the destination project's TypeScript toolchain. inspectGlbIntegration and composeSceneGLB are exported from @instruktlabs/kiln/render; overlap helpers are exported from @instruktlabs/kiln/composer. Generated Kiln source itself still has no imports.

const composed = await composeSceneGLB([
  { name: 'MarketStall', bytes: stallBytes,
    transform: { pos: [2,0,1], rotDeg: [0,90,0], scale: [1,1,1] } },
  { name: 'Lamp', bytes: lampBytes,
    transform: { pos: [3,0,1], rotDeg: [0,0,0], scale: [1,1,1] } },
], { sceneName: 'Market', optimize: 'off', keepAnimations: false });

pos uses metres; rotDeg is Euler XYZ degrees; scale is a three-component scale. The result includes bytes, tris, draws, materials, warnings, and the final GLB validation report. A corrupt part may be skipped with a warning rather than fail the whole export.

The default optimizer is palette; off is useful when first checking authored material fidelity. keepAnimations defaults to false. Set it true only when the scene should retain asset clips and then verify their playback.

Retained clips preserve their source names by default. If multiple assets use names such as Walk, choose animationNaming: 'instance' to get unique names in the form 0:MarketStall/0:Open (placement index/name, then clip index/name). Missing names use part or clip; indices distinguish repeated placements and duplicate source names. This changes only names in the composed output, preserves channel targets and timing, and does not change the individual asset files. Select and test each intended clip.

Call inspectGlbIntegration(bytes) for actual bounds and integration metadata. It may return undefined; do not invent a manifest for an empty/unusable input.

findOverlaps(boxes, options) returns candidate AABB intersections; isOverlapFree returns a boolean, and summarizeOverlaps(violations) formats findings. Options select mode: 'footprint' (default, ignores Y) or 'volume', with optional tolerance. Use world-space boxes and stable instance IDs. Footprint checks are insufficient for stacked or overhead objects.

The simpler worldAabbFromLocal path assumes uniform scale and Y rotation. For arbitrary rotated/nonuniform placements, compute world bounds from all eight local corners with the full transform rather than forcing that shape into a narrower helper.

Optional SDK use

SDK composition is optional; CLI/MCP-only authoring never needs it. A generated workspace has no package.json, so a script that imports @instruktlabs/kiln/render or @instruktlabs/kiln/composer fails with ERR_MODULE_NOT_FOUND until the author installs the package in the workspace (or another project that script runs from): npm install @instruktlabs/kiln@<version>, pinned to the Kiln runtime in use. Read that version from kiln --version when it exists, from the serverInfo.version the MCP server reports, or from the version in the package.json beside the dist/ folder holding the dist/mcp-server.mjs the MCP config names; npm ls @instruktlabs/kiln shows an existing install. Import only the public subpaths above; do not guess files under dist/ or lib/.