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.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
import test from 'node:test';import assert from 'node:assert/strict';import * as THREE from 'three/webgpu';import {createHearthFire,writeFireEnvelope} from '../src/game/hearth-fire.mjs';
import {act,createGameState,tick} from '../src/game/state.mjs';
test('fuel makes flame height, warmth and ember activity grow, then diminish to zero',()=>{const out={};const levels=[0,1,8,35,90,180].map(f=>({...writeFireEnvelope(out,f,0)}));for(let i=1;i<levels.length;i++)for(const key of ['height','width','light','embers'])assert(levels[i][key]>levels[i-1][key],key);assert.equal(levels[0].light,0);assert.equal(levels[0].height,0);assert(levels.at(-1).height<.7);assert.equal(writeFireEnvelope(out,NaN,0),out);assert.equal(out.light,0);});
test('fire uses a fixed instance allocation and responds to real add-fuel and burn-down state',()=>{const camera=new THREE.PerspectiveCamera(),fire=createHearthFire(),mesh=fire.mesh,buffer=mesh.instanceMatrix.array,colors=mesh.instanceColor.array,stats=fire.state;const state=createGameState();state.fire=4;fire.update(state,.1,camera);const dim=fire.state.light;state.inventory.firewood=1;act(state,'fire');for(let i=0;i<100;i++)fire.update(state,.016,camera);assert(fire.state.light>dim);assert.equal(state.inventory.firewood,0);const bright=fire.state.height;for(let i=0;i<400;i++)tick(state,.1,[0,0,0]);for(let i=0;i<200;i++)fire.update(state,.016,camera);assert(fire.state.height<bright);assert.equal(fire.state,stats);assert.equal(mesh.instanceMatrix.array,buffer);assert.equal(mesh.instanceColor.array,colors);assert(mesh.count<=24);assert.equal(mesh.castShadow,false);assert.equal(mesh.material.depthWrite,false);assert.equal(mesh.children.length,0);fire.dispose();});