3D engine that AI agents drive
Primitives: cone, icoSphere, circle, line and plane alias (issue #596)
Nguyen Xuan An4338e947c05b
diff --git a/changes/596.md b/changes/596.mdnew file mode 100644index 00000000..eba621b7--- /dev/null+++ b/changes/596.md@@ -0,0 +1 @@+- Recipes gain `cone`, `icoSphere`, `circle` (filled or ring) and `line` geometries, and `plane` is accepted as an alias of `grid` (#596)diff --git a/changes/596.size.md b/changes/596.size.mdnew file mode 100644index 00000000..be4089fa--- /dev/null+++ b/changes/596.size.md@@ -0,0 +1,6 @@+- scene:agent-scene: cone, icoSphere and circle generators plus the line and plane recipe types, 1129 bytes gzip, close the most common primitive gaps that agents otherwise build from cylinders and lathes (#596)+- scene:agent-scene+lazy: the same generators, 1120 bytes gzip+- goal:agent-scene: the four primitives are an agent-facing capability; the generators share the existing surface helper+- tool-total: four new geometry records (cone, icoSphere, circle, line) and the plane name in the recipe schema of two tools, 3124 bytes in all (#596)+- tool:scene_create: the four geometry records, 1562 bytes+- tool:scene_apply: the same recipe schema, 1562 bytesdiff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjsindex aaea8696..bbf5aedc 100644--- a/scripts/mcp-server.mjs+++ b/scripts/mcp-server.mjs@@ -426,7 +426,11 @@ const recipeMeshEdits = z.array(z.record(z.string(), z.unknown())).max(64);const recipeMeshStack = z.array(z.record(z.string(), z.unknown())).max(16);const geometry = z.discriminatedUnion('type', [...primitiveGeometries(true),- z.strictObject({ id: identifier, type: z.literal('grid'), segments: detail(1, 64) }),+ z.strictObject({ id: identifier, type: z.enum(['grid', 'plane']), segments: detail(1, 64) }).describe('Unit sheet in XY facing +Z; plane = grid.'),+ z.strictObject({ id: identifier, type: z.literal('cone'), radiusTop: finite.optional(), radiusBottom: finite.optional(), segments }).describe('Along Y, height 1; radiusTop 0 is a point, radiusBottom 1.'),+ z.strictObject({ id: identifier, type: z.literal('icoSphere'), subdivisions: detail(0, 7) }),+ z.strictObject({ id: identifier, type: z.literal('circle'), segments, innerRadius: finite.optional() }).describe('Unit disc facing +Z; innerRadius makes a ring.'),+ z.strictObject({ id: identifier, type: z.literal('line'), from: vector3, to: vector3, radius: finite.optional(), radialSegments: detail(3, 128) }),z.strictObject({ id: identifier, type: z.literal('mesh'), base: z.discriminatedUnion('type', primitiveGeometries(false)).describe('Starting shape, converted to welded quads with axis face tags.'), edits: recipeMeshEdits.optional().describe('Replayable edit log, applied in order. Each item has the shape of one mesh_edit edit; read that tool for every op and field.'), stack: recipeMeshStack.optional().describe('Non-destructive modifier stack evaluated after the edits. Each item has the shape of one mesh_stack node; read that tool for the ops.'), smoothAngle: bounded(0, 180).optional().describe('Edges bending more than this many degrees render hard. Defaults to 30.') }),]);// No description: this field repeats in every motion track schema. A wrong name fails with every valid form, and docs/agent-motion.md lists them.diff --git a/skills/build-67js-scene/references/mesh-modeling.md b/skills/build-67js-scene/references/mesh-modeling.mdindex 2bca742b..dae66163 100644--- a/skills/build-67js-scene/references/mesh-modeling.md+++ b/skills/build-67js-scene/references/mesh-modeling.md@@ -16,8 +16,13 @@ requires a clean lint, so keep them valid when the API changes.1. Name the parts and their rough sizes first. One part is one `mesh` geometry: a `base` primitive, an `edits` log andan optional `stack`. Separate parts (a lid, a handle) are separate geometries placed by nodes.2. Start from the closest base. `box` is a unit cube from -0.5 to 0.5 (`bevel: 0` for crisp edits); `cylinder` has- radius 1 and height 1 centred on the origin (`bevel: 0`); `sphere` has radius 1; `lathe` turns a profile;- `extrude` makes outlines with holes. Set proportions first by translating tagged faces, so later widths and offsets+ radius 1 and height 1 centred on the origin (`bevel: 0`); `sphere` has radius 1; `lathe` turns a+ profile; `extrude` makes outlines with holes. These shapes are plain geometry records only (not mesh bases):+ `cone` (`{ "id": "spike", "type": "cone", "radiusBottom": 1, "segments": 32 }`, point on top, height 1; a `radiusTop` makes a+ frustum), `icoSphere` (`{ "id": "ball", "type": "icoSphere", "subdivisions": 2 }`, even triangles, no poles), `circle`+ (`{ "id": "ring", "type": "circle", "innerRadius": 0.6 }`, a unit disc facing +Z, a ring when `innerRadius` is above 0),+ `line` (`{ "id": "rod", "type": "line", "from": [0, 0, 0], "to": [0, 2, 0], "radius": 0.03 }`) and `grid` (`plane` is the same+ shape). To edit one, build the mesh from a cylinder or sphere base instead. Set proportions first by translating tagged faces, so later widths and offsetsstay in real units: a 0.5 x 0.6 x 1.0 box is `right` by -0.25, `left` by 0.25, `top` by -0.4.3. Add edits in small batches with `mesh_edit` (or in the recipe). Name every edit (`name: "lid"` gives `lid.cap`,`lid.side`); an unnamed one gets `<op>-<index>`, which is hard to predict. Select faces by tags, never by index.diff --git a/src/agent-scene-capabilities.js b/src/agent-scene-capabilities.jsindex efc33124..448faede 100644--- a/src/agent-scene-capabilities.js+++ b/src/agent-scene-capabilities.js@@ -162,7 +162,7 @@ export const MESH_SCULPT_NOTES = Object.freeze({export const AGENT_SCENE_CAPABILITIES = Object.freeze({format: '67js.scene', schemaVersion: 1,- geometryTypes: Object.freeze(['box', 'cylinder', 'sphere', 'torus', 'lathe', 'extrude', 'tube', 'curve', 'text', 'grid', 'terrain', 'mesh']),+ geometryTypes: Object.freeze(['box', 'cylinder', 'sphere', 'cone', 'icoSphere', 'torus', 'lathe', 'extrude', 'tube', 'curve', 'text', 'grid', 'plane', 'circle', 'line', 'terrain', 'mesh']),camera: 'eye, target, up, near, far, then fov (vertical degrees) or focalLength (mm, with sensorWidth mm, default 36; not both). projection orthographic with orthoScale (view height in m, default 4). shift [x, y] moves the frame by a fraction of its width and height. fStop (0.7 to 64) turns on depth of field focused on target; 1.4 or lower is full blur, and effects.depthOfField.blur must stay 0. Orthographic and shifted cameras render with the rasterizer, not the path tracer.',terrain: 'One mesh, x and z from -size/2 to size/2, hills about y = 0. size 40 m (1-2000), resolution 64 cells (2-256), seed 1, amplitude 1 m (0-200), holes up to 16 of {center:[x,z],radius} with no surface inside; radius a few cells or more.',placedAssets: 'Node field asset:{id,materials?,clip?,drive?} turns a group node into a catalog GLB (id from asset_catalog; scene_create_asset is one asset alone). Its transform places it. materials:[{name,color,metallic,roughness,opacity,emission,emissiveColor}] override source materials by name. clip:{index,start=0,speed=1,loop=true} plays that clip from scene time start, on a decoded copy of its own; scene_apply set-motion tracks move the node as usual and scene time seeks the clip. Copies of one asset share geometry and materials and draw as one batch. drive:{path | legs, cruiseSpeed | speed, wheels, lights} drives a car along a path in the placement frame on a decoded copy of its own (fields as motion.drive in an asset recipe, docs/vehicle.md; no tail-light glow). scene_inspect assets adds its wheels, rejectedNames and light signals. At most 512 placements, 16 assets, 16 playing a clip or driving. Render jobs do not draw placed assets yet; scene_look does.',diff --git a/src/agent-scene.js b/src/agent-scene.jsindex 703c4931..d5445d5b 100644--- a/src/agent-scene.js+++ b/src/agent-scene.js@@ -1,5 +1,5 @@import { mat4, mat3 } from 'gl-matrix';-import { box, cylinder, grid, sphere, torus } from './geometry.js';+import { box, circle, cone, cylinder, grid, icoSphere, sphere, torus } from './geometry.js';import { createSceneGraph } from './scene-graph.js';import { applyProjection, validateCameraShift, CAMERA_LENS_FIELDS } from './camera.js';import { normalizeAgentLook, environmentPatchWithSetup, environmentLinksLights, agentEnvironmentMap } from './agent-look.js';@@ -421,7 +421,9 @@ function cameraFrom(value = {}) {const GEOMETRY_FIELDS = {box: ['bevel', 'subdivisions'], cylinder: ['segments', 'bevel', 'bevelSegments'],- sphere: ['segments', 'rings'], grid: ['segments'], torus: ['tubeRadius', 'segments', 'sides', 'arc', 'start'],+ sphere: ['segments', 'rings'], grid: ['segments'], plane: ['segments'],+ cone: ['radiusTop', 'radiusBottom', 'segments'], icoSphere: ['subdivisions'], circle: ['segments', 'innerRadius'],+ line: ['from', 'to', 'radius', 'radialSegments'], torus: ['tubeRadius', 'segments', 'sides', 'arc', 'start'],lathe: ['profile', 'segments', 'startAngle', 'sweep'],extrude: ['contour', 'holes', 'depth', 'steps', 'bevel', 'bevelThickness', 'bevelSegments'],tube: ['path', 'radius', 'segments', 'radialSegments', 'closed'],@@ -431,6 +433,16 @@ const GEOMETRY_FIELDS = {terrain: ['size', 'resolution', 'seed', 'amplitude', 'holes'],};+// A line is a two-point curve; both ends must be finite and apart.+function lineEnds(value) {+ const ends = [value.from, value.to];+ for (const end of ends) vector(end, 3, 'line end');+ if (ends[0].every((component, axis) => component === ends[1][axis])) {+ throw new RangeError('A line needs two distinct end points.');+ }+ return ends;+}+function geometryEstimate(value) {if (!Object.hasOwn(GEOMETRY_FIELDS, value.type)) {throw new TypeError(`Unsupported geometry type: ${value.type}. Use one of ${Object.keys(GEOMETRY_FIELDS).join(', ')}.`);@@ -449,7 +461,7 @@ function geometryEstimate(value) {return input.length;}for (const field of GEOMETRY_FIELDS[value.type]) {- if (value[field] !== undefined && !['profile', 'contour', 'holes', 'path', 'closed', 'base', 'edits', 'stack', 'points', 'taper', 'text', 'font', 'align'].includes(field)) {+ if (value[field] !== undefined && !['profile', 'contour', 'holes', 'path', 'closed', 'base', 'edits', 'stack', 'points', 'taper', 'text', 'font', 'align', 'from', 'to'].includes(field)) {finite(value[field], field);}}@@ -461,7 +473,19 @@ function geometryEstimate(value) {case 'sphere':return (detail('segments', 64, 3, 2048) + 1) * (detail('rings', 40, 2, 2048) + 1);case 'grid':+ case 'plane':return (detail('segments', 16, 1, 64) + 1) ** 2;+ case 'cone':+ return (detail('segments', 64, 3, 2048) + 1) * 2 + 2 * ((value.segments ?? 64) + 2);+ case 'icoSphere':+ return 10 * 4 ** detail('subdivisions', 2, 0, 7) + 2;+ case 'circle':+ return value.innerRadius > 0 ? (detail('segments', 64, 3, 2048) + 1) * 2 : detail('segments', 64, 3, 2048) + 2;+ case 'line': {+ const sides = detail('radialSegments', 8, 3, 128);+ lineEnds(value);+ return 2 * sides * 2 + 2 * (sides + 1);+ }case 'torus':return (detail('segments', 96, 3, 2048) + 1) * (detail('sides', 24, 3, 128) + 1) + 2 * ((value.sides ?? 24) + 2);case 'lathe':@@ -548,7 +572,16 @@ function generateGeometry(value, maxVertices) {case 'sphere':return sphere(value.segments, value.rings);case 'grid':+ case 'plane':return grid(value.segments);+ case 'cone':+ return cone(value.radiusTop, value.radiusBottom, value.segments);+ case 'icoSphere':+ return icoSphere(value.subdivisions);+ case 'circle':+ return circle(value.segments, value.innerRadius);+ case 'line':+ return agentSceneModule('modeling').curve(lineEnds(value), { radius: value.radius, radialSegments: value.radialSegments, resolution: 1, maxVertices });case 'torus':return torus(value.tubeRadius, value.segments, value.sides, value.arc, value.start);case 'lathe':@@ -735,7 +768,7 @@ function normalizeRecipe(input, limits) {if (Array.isArray(recipe.nodes)) recipe.nodes = recipe.nodes.filter(node => !node?.assetPart);recipe.geometries = resources(recipe.geometries, limits.maxGeometries, 'geometries', value => {geometryEstimate(value);- const definition = { id: value.id, type: value.type };+ const definition = { id: value.id, type: value.type === 'plane' ? 'grid' : value.type };for (const field of GEOMETRY_FIELDS[value.type]) {if (Object.hasOwn(value, field)) {definition[field] = value[field];diff --git a/src/geometry.js b/src/geometry.jsindex ccb2ced4..83395a47 100644--- a/src/geometry.js+++ b/src/geometry.js@@ -91,6 +91,126 @@ export function grid(segments = 16) {return surface(segments, segments, (across, down) => ({ position: [across - 0.5, 0.5 - down, 0], normal: [0, 0, 1] }));}+// A cone or frustum along Y, height 1 and centred like the cylinder. radiusTop 0 gives a point.+export function cone(radiusTop = 0, radiusBottom = 1, segments = 64) {+ finiteFloat(radiusTop, 'radiusTop');+ finiteFloat(radiusBottom, 'radiusBottom');+ if (radiusTop < 0 || radiusBottom < 0 || Math.fround(radiusTop) + Math.fround(radiusBottom) <= 0) {+ throw new RangeError('radiusTop and radiusBottom must not be negative, and at least one must be above zero.');+ }+ integer(segments, 3, 2048, 'segments');+ primitiveBudget((segments + 1) * 2 + 2 * (segments + 2));+ const slope = radiusBottom - radiusTop;+ const slopeLength = Math.hypot(1, slope);+ const wall = surface(segments, 1, (along, height) => {+ const angle = periodicAngle(along);+ const radius = height === 0 ? radiusTop : radiusBottom;+ return {+ position: [radius * Math.cos(angle), 0.5 - height, radius * Math.sin(angle)],+ normal: [Math.cos(angle) / slopeLength, slope / slopeLength, Math.sin(angle) / slopeLength],+ };+ });+ const positions = [...wall.positions];+ const normals = [...wall.normals];+ const indices = [...wall.indices];+ const caps = [{ sign: 1, radius: radiusTop }, { sign: -1, radius: radiusBottom }];+ for (const { sign, radius } of caps) {+ if (radius === 0) continue;+ const center = positions.length / 3;+ positions.push(0, sign * 0.5, 0);+ normals.push(0, sign, 0);+ for (let index = 0; index <= segments; index++) {+ const angle = periodicAngle(index / segments);+ positions.push(radius * Math.cos(angle), sign * 0.5, radius * Math.sin(angle));+ normals.push(0, sign, 0);+ }+ for (let index = 0; index < segments; index++) {+ const first = center + index + 1;+ indices.push(center, sign > 0 ? first + 1 : first, sign > 0 ? first : first + 1);+ }+ }+ return geometry(positions, normals, indices);+}++// A unit-radius sphere from a subdivided icosahedron: shared vertices and near-equal triangles, with no poles.+export function icoSphere(subdivisions = 2) {+ integer(subdivisions, 0, 7, 'subdivisions');+ primitiveBudget(10 * 4 ** subdivisions + 2);+ const golden = (1 + Math.sqrt(5)) / 2;+ const positions = [];+ const corners = [[-1, golden, 0], [1, golden, 0], [-1, -golden, 0], [1, -golden, 0], [0, -1, golden], [0, 1, golden],+ [0, -1, -golden], [0, 1, -golden], [golden, 0, -1], [golden, 0, 1], [-golden, 0, -1], [-golden, 0, 1]];+ for (const corner of corners) {+ const length = Math.hypot(...corner);+ positions.push(...corner.map(value => value / length));+ }+ let triangles = [[0, 11, 5], [0, 5, 1], [0, 1, 7], [0, 7, 10], [0, 10, 11], [1, 5, 9], [5, 11, 4], [11, 10, 2], [10, 7, 6], [7, 1, 8],+ [3, 9, 4], [3, 4, 2], [3, 2, 6], [3, 6, 8], [3, 8, 9], [4, 9, 5], [2, 4, 11], [6, 2, 10], [8, 6, 7], [9, 8, 1]];+ for (let level = 0; level < subdivisions; level++) {+ const midpoints = new Map();+ const midpoint = (first, second) => {+ const key = first < second ? `${first}:${second}` : `${second}:${first}`;+ if (midpoints.has(key)) return midpoints.get(key);+ const middle = [0, 1, 2].map(axis => positions[first * 3 + axis] + positions[second * 3 + axis]);+ const length = Math.hypot(...middle);+ const index = positions.length / 3;+ positions.push(...middle.map(value => value / length));+ midpoints.set(key, index);+ return index;+ };+ const next = [];+ for (const [first, second, third] of triangles) {+ const ab = midpoint(first, second);+ const bc = midpoint(second, third);+ const ca = midpoint(third, first);+ next.push([first, ab, ca], [second, bc, ab], [third, ca, bc], [ab, bc, ca]);+ }+ triangles = next;+ }+ return geometry(positions, positions, triangles.flat());+}++// A flat disc in XY facing +Z with unit radius. innerRadius above zero makes a ring instead of a filled disc.+export function circle(segments = 64, innerRadius = 0) {+ integer(segments, 3, 2048, 'segments');+ finiteFloat(innerRadius, 'innerRadius');+ if (innerRadius < 0 || innerRadius >= 1) {+ throw new RangeError('innerRadius must be from 0 up to but not including 1.');+ }+ const radiusOf = row => row === 0 ? innerRadius : 1;+ if (innerRadius > 0) {+ primitiveBudget((segments + 1) * 2);+ const ring = surface(segments, 1, (along, row) => {+ const angle = periodicAngle(along);+ return { position: [radiusOf(row) * Math.cos(angle), radiusOf(row) * Math.sin(angle), 0], normal: [0, 0, 1] };+ });+ const uvs = [];+ for (let row = 0; row <= 1; row++) {+ for (let column = 0; column <= segments; column++) {+ const angle = periodicAngle(column / segments);+ uvs.push(0.5 + 0.5 * radiusOf(row) * Math.cos(angle), 0.5 + 0.5 * radiusOf(row) * Math.sin(angle));+ }+ }+ ring.uvs = new Float32Array(uvs);+ return ring;+ }+ primitiveBudget(segments + 2);+ const positions = [0, 0, 0];+ const normals = [0, 0, 1];+ const uvs = [0.5, 0.5];+ const indices = [];+ for (let index = 0; index <= segments; index++) {+ const angle = periodicAngle(index / segments);+ positions.push(Math.cos(angle), Math.sin(angle), 0);+ normals.push(0, 0, 1);+ uvs.push(0.5 + 0.5 * Math.cos(angle), 0.5 + 0.5 * Math.sin(angle));+ }+ for (let index = 0; index < segments; index++) {+ indices.push(0, index + 1, index + 2);+ }+ return { ...geometry(positions, normals, indices), uvs: new Float32Array(uvs) };+}+// The torus lies in XY, facing +Z. Partial arcs are useful for interrupted armor rings.export function torus(tubeRadius = 0.08, segments = 96, sides = 24, arc = FULL_TURN, start = 0) {finiteFloat(tubeRadius, 'tubeRadius');diff --git a/tests/geometry-cone-icosphere-circle.test.js b/tests/geometry-cone-icosphere-circle.test.jsnew file mode 100644index 00000000..9435580b--- /dev/null+++ b/tests/geometry-cone-icosphere-circle.test.js@@ -0,0 +1,120 @@+import './support/load-agent-scene-modules.mjs';+import test from 'node:test';+import assert from 'node:assert/strict';+import { circle, cone, icoSphere } from '../src/geometry.js';+import { createAgentScene } from '../src/agent-scene.js';++function bounds(geometry) {+ const minimum = [Infinity, Infinity, Infinity];+ const maximum = [-Infinity, -Infinity, -Infinity];+ for (let index = 0; index < geometry.positions.length; index++) {+ minimum[index % 3] = Math.min(minimum[index % 3], geometry.positions[index]);+ maximum[index % 3] = Math.max(maximum[index % 3], geometry.positions[index]);+ }+ return { minimum, maximum };+}++function assertUnitNormals(geometry) {+ for (let index = 0; index < geometry.normals.length; index += 3) {+ const length = Math.hypot(geometry.normals[index], geometry.normals[index + 1], geometry.normals[index + 2]);+ assert.ok(Math.abs(length - 1) < 1e-5, `normal ${index / 3} has length ${length}`);+ }+}++// The winding must agree with the stored normals, or the face renders inside out.+function assertWindingMatchesNormals(geometry) {+ for (let index = 0; index < geometry.indices.length; index += 3) {+ const corners = [0, 1, 2].map(offset => geometry.indices[index + offset]);+ const [first, second, third] = corners.map(corner => [0, 1, 2].map(axis => geometry.positions[corner * 3 + axis]));+ const edgeA = second.map((value, axis) => value - first[axis]);+ const edgeB = third.map((value, axis) => value - first[axis]);+ const cross = [edgeA[1] * edgeB[2] - edgeA[2] * edgeB[1], edgeA[2] * edgeB[0] - edgeA[0] * edgeB[2], edgeA[0] * edgeB[1] - edgeA[1] * edgeB[0]];+ const normalSum = [0, 1, 2].map(axis => corners.reduce((sum, corner) => sum + geometry.normals[corner * 3 + axis], 0));+ const alignment = cross.reduce((sum, value, axis) => sum + value * normalSum[axis], 0);+ assert.ok(alignment > 0, `triangle ${index / 3} faces against its normals`);+ }+}++test('cone has a point, a base cap and outward slope normals', () => {+ const geometry = cone(0, 1, 16);+ assert.equal(geometry.positions.length / 3, (16 + 1) * 2 + (16 + 2));+ assert.deepEqual(bounds(geometry), { minimum: [-1, -0.5, -1], maximum: [1, 0.5, 1] });+ assertUnitNormals(geometry);+ assertWindingMatchesNormals(geometry);+ const slopeNormal = [geometry.normals[3], geometry.normals[4], geometry.normals[5]];+ assert.ok(slopeNormal[1] > 0 && slopeNormal[0] > 0, 'slope normals lean up and outward');+});++test('cone with two radii is a capped frustum', () => {+ const geometry = cone(0.5, 1, 8);+ assert.equal(geometry.positions.length / 3, (8 + 1) * 2 + 2 * (8 + 2));+ assert.deepEqual(bounds(geometry), { minimum: [-1, -0.5, -1], maximum: [1, 0.5, 1] });+ assertUnitNormals(geometry);+ assertWindingMatchesNormals(geometry);+ assert.throws(() => cone(0, 0, 8), /at least one/);+ assert.throws(() => cone(-1, 1, 8), /negative/);+ assert.throws(() => cone(0, 1, 2), /segments/);+});++test('icoSphere has the icosahedron vertex count at each level and lies on the unit sphere', () => {+ for (const [subdivisions, vertexCount, faceCount] of [[0, 12, 20], [1, 42, 80], [2, 162, 320]]) {+ const geometry = icoSphere(subdivisions);+ assert.equal(geometry.positions.length / 3, vertexCount);+ assert.equal(geometry.indices.length / 3, faceCount);+ assertUnitNormals(geometry);+ assertWindingMatchesNormals(geometry);+ for (let index = 0; index < geometry.positions.length; index += 3) {+ const radius = Math.hypot(geometry.positions[index], geometry.positions[index + 1], geometry.positions[index + 2]);+ assert.ok(Math.abs(radius - 1) < 1e-5);+ }+ }+ const { minimum, maximum } = bounds(icoSphere(3));+ assert.ok(maximum.every(value => value > 0.9 && value <= 1 + 1e-6));+ assert.ok(minimum.every(value => value < -0.9 && value >= -1 - 1e-6));+ assert.throws(() => icoSphere(8), /subdivisions/);+});++test('circle is a filled disc or a ring facing +Z', () => {+ const disc = circle(12);+ assert.equal(disc.positions.length / 3, 12 + 2);+ assert.equal(disc.indices.length / 3, 12);+ assert.deepEqual(bounds(disc), { minimum: [-1, -1, 0], maximum: [1, 1, 0] });+ assertUnitNormals(disc);+ assertWindingMatchesNormals(disc);+ assert.ok(disc.normals.every((value, index) => value === (index % 3 === 2 ? 1 : 0)));+ const ring = circle(12, 0.5);+ assert.equal(ring.positions.length / 3, (12 + 1) * 2);+ assert.equal(ring.indices.length / 3, 24);+ assertUnitNormals(ring);+ assertWindingMatchesNormals(ring);+ const innerRadius = Math.min(...Array.from({ length: 13 }, (_, index) => Math.hypot(ring.positions[index * 3], ring.positions[index * 3 + 1])));+ assert.ok(Math.abs(innerRadius - 0.5) < 1e-6);+ assert.throws(() => circle(12, 1), /innerRadius/);+});++function sceneWith(geometries) {+ return createAgentScene({+ format: '67js.scene', schemaVersion: 1, geometries, materials: [{ id: 'paint' }],+ nodes: geometries.map(geometry => ({ id: geometry.id, geometry: geometry.id, material: 'paint' })),+ });+}++test('agent recipes accept cone, icoSphere, circle, line and plane in one record each', () => {+ const session = sceneWith([+ { id: 'spike', type: 'cone', radiusBottom: 0.5, segments: 12 },+ { id: 'ball', type: 'icoSphere', subdivisions: 2 },+ { id: 'disc', type: 'circle', innerRadius: 0.4 },+ { id: 'rod', type: 'line', from: [0, 0, 0], to: [0, 2, 0], radius: 0.05 },+ { id: 'sheet', type: 'plane', segments: 4 },+ ]);+ const inspection = session.inspect({ includeBounds: true });+ const nodeBounds = id => inspection.nodes.find(node => node.id === id).bounds;+ assert.ok(nodeBounds('ball').max.every(value => value > 0.8 && value <= 1 + 1e-6));+ assert.ok(Math.abs(nodeBounds('spike').max[0] - 0.5) < 1e-6);+ assert.ok(Math.abs(nodeBounds('rod').max[1] - 2) < 1e-4);+ assert.ok(Math.abs(nodeBounds('rod').max[0] - 0.05) < 1e-4);+ assert.ok(Math.abs(nodeBounds('sheet').max[0] - 0.5) < 1e-6);+ assert.deepEqual(createAgentScene(session.exportRecipe()).inspect(), session.inspect());+ assert.equal(session.exportRecipe().geometries.find(geometry => geometry.id === 'sheet').type, 'grid');+ assert.throws(() => sceneWith([{ id: 'same', type: 'line', from: [1, 1, 1], to: [1, 1, 1] }]), /distinct/);+});diff --git a/tests/mcp-tools.test.js b/tests/mcp-tools.test.jsindex ad00e622..ed4f930a 100644--- a/tests/mcp-tools.test.js+++ b/tests/mcp-tools.test.js@@ -150,7 +150,8 @@ test('SDK advertises the complete strict JSON contract and truthful annotations'assert.equal(recipeSchema.properties.materials.maxItems, 256);assert.equal(recipeSchema.properties.geometries.maxItems, 256);const variants = recipeSchema.properties.geometries.items.oneOf ?? recipeSchema.properties.geometries.items.anyOf;- assert.deepEqual(variants.map(variant => variant.properties.type.const), ['box', 'cylinder', 'sphere', 'torus', 'lathe', 'extrude', 'tube', 'curve', 'text', 'terrain', 'grid', 'mesh']);+ assert.deepEqual(variants.map(variant => variant.properties.type.const ?? variant.properties.type.enum.join('|')),+ ['box', 'cylinder', 'sphere', 'torus', 'lathe', 'extrude', 'tube', 'curve', 'text', 'terrain', 'grid|plane', 'cone', 'icoSphere', 'circle', 'line', 'mesh']);assert.ok(variants.every(variant => variant.additionalProperties === false));assert.equal(recipeSchema.properties.environment.additionalProperties, false);assert.equal(recipeSchema.properties.environment.properties.pointLights.maxItems, 16);