Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Fix the three problems the agent suite found

Nguyen Xuan An31a93c36ad1e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d250d637..4be0862a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## Unreleased
+
+- Close `extrude` solids whose holes have aligned edges: their caps left T-junctions, so the mesh was open and booleans refused it
+- Let `mesh_inspect` take `geometry` as well as `geometries`, matching `mesh_edit` and `mesh_stack`
+- Say in the MCP schema that `box` and `cylinder` are bevelled by default, and how to get exact sizes
+
## 0.11.0
- Add `67js/addons/grass`: terrain-following grass fields of clumped, curved blades with rounded normals, root-to-tip colour, dry patches, masks for paths, four presets and tile level of detail
diff --git a/bench/agent-modeling/README.md b/bench/agent-modeling/README.md
index 56576991..78bf0a48 100644
--- a/bench/agent-modeling/README.md
+++ b/bench/agent-modeling/README.md
@@ -68,11 +68,28 @@ Read this as a cost baseline, not a success rate:
- **Agents rarely use the edit tools.** Only 2 of 10 runs called `mesh_edit`. Most recipes use placed primitives, and
the mesh edits they do use are written directly into `scene_create`. No run used `loop_cut`, `mirror` or `array`.
-Friction seen in the transcripts:
+Friction seen in the transcripts, all fixed after this baseline:
-- `extrude` with holes whose edges line up leaves T-junctions in its caps, so the mesh is open. The window run hit it
+- `extrude` with holes whose edges line up left T-junctions in its caps, so the mesh was open. The window run hit it
and fell back to separate bars.
-- `mesh_inspect` takes `geometries`, while `mesh_edit` takes `geometry`. Four runs sent `geometry` and got a
+- `mesh_inspect` took only `geometries`, while `mesh_edit` takes `geometry`. Four runs sent `geometry` and got a
validation error.
- The default box has a bevel, which surprised the fence, table and soap runs. They first got rounded shapes or wrong
- sizes.
+ sizes. The default stays, and the tool schema now says so.
+
+## After the three fixes
+
+`results/2026-10-30-08-14-sonnet-after-fixes.json` reruns the five affected tasks, one run each, with the same model:
+
+| Task | Tool calls | Tool errors | Cost (USD) |
+| --- | --- | --- | --- |
+| window | 10 → 4 | 1 → 0 | 0.52 → 0.43 |
+| gear | 7 → 5 | 2 → 1 | 0.53 → 0.49 |
+| soap | 11 → 4 | 2 → 0 | 0.55 → 0.43 |
+| fence | 7 → 2 | 1 → 0 | 0.49 → 0.40 |
+| table | 4 → 2 | 1 → 0 | 0.41 → 0.40 |
+| Total | 39 → 17 | 7 → 1 | 2.40 → 2.15 |
+
+All five passed both times. The window run now builds the frame with one `extrude`, the route it gave up on before. The
+one remaining error is the gear run trying the disabled Bash tool. With one run per task this shows a direction, not an
+exact size.
diff --git a/bench/agent-modeling/references.mjs b/bench/agent-modeling/references.mjs
index bd9e6138..d0b97881 100644
--- a/bench/agent-modeling/references.mjs
+++ b/bench/agent-modeling/references.mjs
@@ -76,16 +76,16 @@ export const REFERENCES = {
{ id: 'head', geometry: 'head', translation: [0, 0.12, 0], rotation: axisRotation('x', -Math.PI / 2) },
],
),
- // An extrude with these four holes leaves T-junctions in its caps (collinear hole edges), so this cuts the panes.
window: scene(
[{
- id: 'frame', type: 'mesh', base: { type: 'box', bevel: 0 },
- edits: [[-0.235, 0.315], [0.235, 0.315], [-0.235, 0.885], [0.235, 0.885]].map(([x, y], index) => ({
- op: 'boolean', operation: 'difference', name: `pane-${index}`, cutter: { type: 'box', bevel: 0 },
- translation: [x, (y - 0.6) / 1.2, 0], scale: [0.41, 0.51 / 1.2, 2],
- })),
+ id: 'frame', type: 'extrude', depth: 0.08,
+ contour: rectangle(-0.5, 0, 0.5, 1.2),
+ holes: [
+ rectangle(-0.44, 0.06, -0.03, 0.57, true), rectangle(0.03, 0.06, 0.44, 0.57, true),
+ rectangle(-0.44, 0.63, -0.03, 1.14, true), rectangle(0.03, 0.63, 0.44, 1.14, true),
+ ],
}],
- [{ id: 'frame', geometry: 'frame', translation: [0, 0.6, 0], scale: [1, 1.2, 0.08] }],
+ [{ id: 'frame', geometry: 'frame', translation: [0, 0, -0.04] }],
),
table: scene(
[{ id: 'block', type: 'box', bevel: 0 }],
diff --git a/bench/agent-modeling/results/2026-10-30-08-14-sonnet-after-fixes.json b/bench/agent-modeling/results/2026-10-30-08-14-sonnet-after-fixes.json
new file mode 100644
index 00000000..895af22a
--- /dev/null
+++ b/bench/agent-modeling/results/2026-10-30-08-14-sonnet-after-fixes.json
@@ -0,0 +1,160 @@
+{
+ "run": "2026-10-30-08-14-sonnet-after-fixes",
+ "model": "claude-sonnet-5-5",
+ "date": "2026-10-30T08:17:37.067Z",
+ "passed": 5,
+ "tasks": 5,
+ "toolCalls": 17,
+ "costUsd": 2.15,
+ "records": [
+ {
+ "task": "window",
+ "pass": true,
+ "passed": 5,
+ "total": 5,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 4,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "mesh_inspect": 1,
+ "scene_apply": 1,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "extrude"
+ ],
+ "meshOperations": []
+ },
+ "turns": 6,
+ "costUsd": 0.4281302,
+ "inputTokens": 569280,
+ "outputTokens": 1610,
+ "wallSeconds": 38,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "gear",
+ "pass": true,
+ "passed": 5,
+ "total": 5,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 5,
+ "toolErrors": 1,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_capabilities": 1,
+ "Bash": 1,
+ "scene_create": 1,
+ "scene_inspect": 1,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "extrude"
+ ],
+ "meshOperations": []
+ },
+ "turns": 7,
+ "costUsd": 0.48601079999999997,
+ "inputTokens": 588315,
+ "outputTokens": 5028,
+ "wallSeconds": 62,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "soap",
+ "pass": true,
+ "passed": 7,
+ "total": 7,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 4,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_inspect": 1,
+ "mesh_inspect": 1,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "mesh"
+ ],
+ "meshOperations": [
+ "bevel"
+ ]
+ },
+ "turns": 6,
+ "costUsd": 0.43038529999999997,
+ "inputTokens": 569829,
+ "outputTokens": 1823,
+ "wallSeconds": 39,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "fence",
+ "pass": true,
+ "passed": 6,
+ "total": 6,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 2,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "box"
+ ],
+ "meshOperations": []
+ },
+ "turns": 4,
+ "costUsd": 0.40395250000000005,
+ "inputTokens": 353226,
+ "outputTokens": 1304,
+ "wallSeconds": 26,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "table",
+ "pass": true,
+ "passed": 6,
+ "total": 6,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 2,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "box"
+ ],
+ "meshOperations": []
+ },
+ "turns": 4,
+ "costUsd": 0.39964910000000003,
+ "inputTokens": 351219,
+ "outputTokens": 1203,
+ "wallSeconds": 36,
+ "exitCode": 0,
+ "stopped": "success"
+ }
+ ]
+}
diff --git a/bench/agent-modeling/run.mjs b/bench/agent-modeling/run.mjs
index 434f9b07..0118c5b0 100644
--- a/bench/agent-modeling/run.mjs
+++ b/bench/agent-modeling/run.mjs
@@ -170,7 +170,6 @@ for (const task of tasks) {
const summary = {
run: runName,
model: records.find(record => record.model)?.model ?? options.model,
- claudeCode: options.claude,
date: new Date().toISOString(),
passed: records.filter(record => record.pass).length,
tasks: records.length,
diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjs
index fd8c87ba..e82e4691 100644
--- a/scripts/mcp-server.mjs
+++ b/scripts/mcp-server.mjs
@@ -113,8 +113,8 @@ const shadow = z.strictObject({
function primitiveGeometries(identified) {
const id = identified ? { id: identifier } : {};
return [
- z.strictObject({ ...id, type: z.literal('box'), bevel: finite.optional(), subdivisions: detail(1, 128) }),
- z.strictObject({ ...id, type: z.literal('cylinder'), segments, bevel: finite.optional(), bevelSegments: detail(1, 128) }),
+ z.strictObject({ ...id, type: z.literal('box'), bevel: finite.optional().describe('Unit cube, -0.5 to 0.5. The default bevel of 0.08 rounds its edges and is scaled with the node; set 0 for exact sizes and crisp edges.'), subdivisions: detail(1, 128) }),
+ z.strictObject({ ...id, type: z.literal('cylinder'), segments, bevel: finite.optional().describe('Radius 1, height 1, centred. The default bevel of 0.025 rounds its rims; set 0 for exact sizes and crisp edges.'), bevelSegments: detail(1, 128) }),
z.strictObject({ ...id, type: z.literal('sphere'), segments, rings: detail(2, 2048) }),
z.strictObject({ ...id, type: z.literal('torus'), tubeRadius: finite.optional(), segments, sides: detail(3, 128), arc: finite.optional(), start: finite.optional() }),
z.strictObject({ ...id, type: z.literal('lathe'), profile: z.array(point2).min(2).max(4096), segments, startAngle: finite.optional(), sweep: finite.optional() }),
@@ -297,7 +297,7 @@ export function createAgentMcpServer(runtime, { version = packageMetadata.versio
register('scene_asset_catalog', 'List content-bound GLB IDs from the configured local asset directory. No arbitrary paths or downloads.', z.strictObject({}), readOnly, async () => jsonResult(await runtime.assetCatalog()));
register('scene_create_asset', 'Create the active scene from a catalog GLB and editable asset recipe. Preserves supported maps, skins, morphs and clips. Dispose the existing scene first.', z.strictObject({ recipe: assetRecipe }), { ...edit, destructiveHint: false }, async argumentsValue => jsonResult(await runtime.createAsset(argumentsValue)));
register('scene_inspect', 'Read revision, counts and selected nodes. Bounds describe authored geometry rather than shader displacement.', z.strictObject({ ...sessionFields, ids: z.array(identifier).max(4096).optional().describe('Selected node IDs. Omit to inspect scene order.'), kind: z.enum(['meshes', 'hierarchy']).optional().describe('Imported assets only: hierarchy exposes stable source-node IDs and joints.'), offset: z.number().int().min(0).max(4096).optional().describe('Imported assets only: pagination offset.'), limit: z.number().int().min(1).max(4096).optional().describe('Maximum returned node records. Defaults to 64.'), includeBounds: z.boolean().optional().describe('Include world geometry bounds. Defaults to false.') }), readOnly, async argumentsValue => jsonResult(await runtime.inspect(argumentsValue)));
- register('mesh_inspect', 'Check recipe geometries as polygon meshes: vertex, edge and face counts, triangles/quads/n-gons, connected and closed parts, face tags (top, bottom, side, left, right, front, back), bounds, and lint problems (non-manifold, inconsistent winding, inverted, degenerate, open, loose) with a suggested fix each. Procedural scenes only. Read-only and cached per geometry.', z.strictObject({ ...sessionFields, geometries: z.array(identifier).min(1).max(16).optional().describe('Geometry IDs to check. Omit to check the first 16 geometries.') }), readOnly, async argumentsValue => jsonResult(await runtime.inspectMeshes(argumentsValue)));
+ register('mesh_inspect', 'Check recipe geometries as polygon meshes: vertex, edge and face counts, triangles/quads/n-gons, connected and closed parts, face tags (top, bottom, side, left, right, front, back), bounds, and lint problems (non-manifold, inconsistent winding, inverted, degenerate, open, loose) with a suggested fix each. Procedural scenes only. Read-only and cached per geometry.', z.strictObject({ ...sessionFields, geometry: identifier.optional().describe('One geometry ID to check, as in mesh_edit.'), geometries: z.array(identifier).min(1).max(16).optional().describe('Geometry IDs to check. Omit both to check the first 16 geometries.') }), readOnly, async ({ geometry: geometryId, geometries, ...rest }) => jsonResult(await runtime.inspectMeshes({ ...rest, ...(geometries || geometryId ? { geometries: [...(geometries ?? []), ...(geometryId ? [geometryId] : [])] } : {}) })));
register('mesh_edit', 'Append edits to a recipe mesh geometry (or replace its edit log), atomically like scene_apply: extrude, inset, delete, flip, translate with proportional falloff, merge by distance, tag, loop cut, bevel, mirror, array, solidify, UV unwrap, and booleans (union, difference, intersect) with a primitive cutter. Edits that select no faces or break limits fail without changing the scene. Returns the new revision, render status and the mesh report with per-edit results (faces selected, tags created, size after).', z.strictObject({ ...sessionFields, expectedRevision, geometry: identifier.describe('ID of a geometry with type mesh.'), edits: meshEdits.min(1), replace: z.boolean().optional().describe('Replace the whole edit log instead of appending.') }), edit, async argumentsValue => jsonResult(await runtime.editMesh(argumentsValue)));
register('mesh_stack', 'Set the non-destructive modifier stack of a recipe mesh geometry (mirror, array, solidify, bevel, uv_unwrap), evaluated after its edits with each prefix cached, so changing a late node is cheap. apply: n moves the first n nodes into the edit log, as Blender\'s Apply modifier. Atomic like scene_apply. Returns the revision, render status and mesh report with per-node results.', z.strictObject({ ...sessionFields, expectedRevision, geometry: identifier.describe('ID of a geometry with type mesh.'), stack: meshStack.optional().describe('The whole new stack. Omit to keep the current stack (for example with apply).'), apply: z.number().int().min(0).max(16).optional() }), edit, async argumentsValue => jsonResult(await runtime.setMeshStack(argumentsValue)));
register('scene_apply', 'Atomically edit transforms, look, camera or materials. Procedural scenes support membership and set-motion authoring. Imported assets support set-root, set-asset-node, set-motion and absolute set-animation sampling. Successful batches increment revision once.', z.strictObject({ ...sessionFields, expectedRevision, operations: z.array(operation).min(1).max(256).describe('Node/material/camera/root/animation commands use flat fields. Motion, look patches and add commands contain nested records. Backend validates each scene mode before publication.') }), edit, async argumentsValue => jsonResult(await runtime.apply(argumentsValue)));
diff --git a/src/modeling.js b/src/modeling.js
index bf98775c..a64d1d59 100644
--- a/src/modeling.js
+++ b/src/modeling.js
@@ -138,6 +138,89 @@ function ringsIntersect(first, second) {
return false;
}
+/**
+ * Triangulating a cap drops points that are collinear with their neighbours, so a long cap edge can run past wall
+ * vertices and leave the solid open. Split those triangles at the skipped points, which keeps the surface unchanged.
+ */
+function closeTJunctions(geometry) {
+ const { positions, normals, uvs, indices } = geometry;
+ const vertexKey = vertex => `${positions[vertex * 3]},${positions[vertex * 3 + 1]},${positions[vertex * 3 + 2]}`;
+ const edgeKey = (first, second) => {
+ const firstKey = vertexKey(first);
+ const secondKey = vertexKey(second);
+ return firstKey < secondKey ? `${firstKey}|${secondKey}` : `${secondKey}|${firstKey}`;
+ };
+ const edgeUses = new Map();
+ for (let offset = 0; offset < indices.length; offset += 3) {
+ for (let side = 0; side < 3; side++) {
+ const key = edgeKey(indices[offset + side], indices[offset + (side + 1) % 3]);
+ edgeUses.set(key, (edgeUses.get(key) ?? 0) + 1);
+ }
+ }
+ const openEdges = new Set([...edgeUses].filter(([, uses]) => uses !== 2).map(([key]) => key));
+ if (openEdges.size === 0) return geometry;
+ const candidates = new Map();
+ for (let offset = 0; offset < indices.length; offset += 3) {
+ for (let side = 0; side < 3; side++) {
+ const first = indices[offset + side];
+ const second = indices[offset + (side + 1) % 3];
+ if (!openEdges.has(edgeKey(first, second))) continue;
+ candidates.set(vertexKey(first), first);
+ candidates.set(vertexKey(second), second);
+ }
+ }
+ const newPositions = Array.from(positions);
+ const newNormals = Array.from(normals);
+ const newUvs = Array.from(uvs);
+ const pointsInside = (first, second) => {
+ const start = [newPositions[first * 3], newPositions[first * 3 + 1], newPositions[first * 3 + 2]];
+ const direction = [0, 1, 2].map(axis => newPositions[second * 3 + axis] - start[axis]);
+ const lengthSquared = direction[0] ** 2 + direction[1] ** 2 + direction[2] ** 2;
+ const tolerance = 1e-6 * Math.max(Math.sqrt(lengthSquared), ...start.map(Math.abs));
+ const inside = [];
+ for (const candidate of candidates.values()) {
+ const offsetFromStart = [0, 1, 2].map(axis => positions[candidate * 3 + axis] - start[axis]);
+ const along = (offsetFromStart[0] * direction[0] + offsetFromStart[1] * direction[1] + offsetFromStart[2] * direction[2]) / lengthSquared;
+ if (along <= 1e-6 || along >= 1 - 1e-6) continue;
+ const distance = Math.hypot(...offsetFromStart.map((value, axis) => value - direction[axis] * along));
+ if (distance <= tolerance) inside.push({ candidate, along });
+ }
+ return inside.sort((left, right) => left.along - right.along);
+ };
+ const addVertexOnEdge = (first, second, { candidate, along }) => {
+ const vertex = newPositions.length / 3;
+ for (let axis = 0; axis < 3; axis++) {
+ newPositions.push(positions[candidate * 3 + axis]);
+ newNormals.push(newNormals[first * 3 + axis] + (newNormals[second * 3 + axis] - newNormals[first * 3 + axis]) * along);
+ }
+ for (let axis = 0; axis < 2; axis++) newUvs.push(newUvs[first * 2 + axis] + (newUvs[second * 2 + axis] - newUvs[first * 2 + axis]) * along);
+ return vertex;
+ };
+ const newIndices = [];
+ const pending = [];
+ for (let offset = indices.length - 3; offset >= 0; offset -= 3) pending.push([indices[offset], indices[offset + 1], indices[offset + 2]]);
+ while (pending.length) {
+ const triangle = pending.pop();
+ let split = false;
+ for (let side = 0; side < 3 && !split; side++) {
+ const first = triangle[side];
+ const second = triangle[(side + 1) % 3];
+ const opposite = triangle[(side + 2) % 3];
+ if (!openEdges.has(edgeKey(first, second))) continue;
+ const inside = pointsInside(first, second);
+ if (!inside.length) continue;
+ const chain = [first, ...inside.map(point => addVertexOnEdge(first, second, point)), second];
+ for (let link = chain.length - 2; link >= 0; link--) pending.push([chain[link], chain[link + 1], opposite]);
+ split = true;
+ }
+ if (!split) newIndices.push(...triangle);
+ }
+ return {
+ positions: Float32Array.from(newPositions), normals: Float32Array.from(newNormals),
+ uvs: Float32Array.from(newUvs), indices: Uint32Array.from(newIndices),
+ };
+}
+
/** Extrude a simple XY contour and disjoint enclosed holes along positive Z. */
export function extrude(contour, {
holes = [], depth = 1, steps = 1, bevel = 0, bevelThickness = bevel,
@@ -166,9 +249,9 @@ export function extrude(contour, {
}
const shape = new Shape(outer.map(point => new Vector2(...point)));
shape.holes = inner.map(ring => new Path(ring.map(point => new Vector2(...point))));
- return meshFrom(new ExtrudeGeometry(shape, {
+ return closeTJunctions(meshFrom(new ExtrudeGeometry(shape, {
depth, steps, bevelEnabled: beveled, bevelSize: bevel, bevelThickness, bevelSegments,
- }), maxVertices);
+ }), maxVertices));
}
/** Sweep a circular tube along a centripetal Catmull-Rom curve. */
diff --git a/tests/agent-modeling-suite.test.js b/tests/agent-modeling-suite.test.js
index 38d2a358..b4b4a3ae 100644
--- a/tests/agent-modeling-suite.test.js
+++ b/tests/agent-modeling-suite.test.js
@@ -24,7 +24,7 @@ test('checks reject objects that miss the asked-for features', async () => {
assert.deepEqual(failedKinds(noUv), ['uv']);
const solidWindow = structuredClone(REFERENCES.window);
- solidWindow.geometries[0].edits = solidWindow.geometries[0].edits.slice(0, 2);
+ solidWindow.geometries[0].holes = solidWindow.geometries[0].holes.slice(0, 2);
assert.ok(failedKinds(await gradeRecipe(taskById('window'), solidWindow)).includes('four open panes'));
const floatingTable = structuredClone(REFERENCES.table);
diff --git a/tests/mcp-tools.test.js b/tests/mcp-tools.test.js
index d7b15316..4791e0cc 100644
--- a/tests/mcp-tools.test.js
+++ b/tests/mcp-tools.test.js
@@ -232,6 +232,8 @@ test('mesh_inspect reports polygon counts, tags and lint for recipe geometries',
assert.ok(JSON.stringify(result.structuredContent).length < 4096, 'default report stays compact');
const one = await client.callTool({ name: 'mesh_inspect', arguments: { sessionId, geometries: ['cube'] } });
assert.equal(one.structuredContent.meshes.length, 1);
+ const singular = await client.callTool({ name: 'mesh_inspect', arguments: { sessionId, geometry: 'cube' } });
+ assert.deepEqual(singular.structuredContent.meshes.map(mesh => mesh.geometry), ['cube']);
const missing = await client.callTool({ name: 'mesh_inspect', arguments: { sessionId, geometries: ['nope'] } });
assert.equal(missing.isError, true);
assert.match(missing.content[0].text, /Known IDs: cube, cable/);
diff --git a/tests/modeling.test.js b/tests/modeling.test.js
index 13d18149..21ec6662 100644
--- a/tests/modeling.test.js
+++ b/tests/modeling.test.js
@@ -118,3 +118,30 @@ test('torus maps cover both surface seams and partial arc caps', () => {
if (arc === Math.PI) assert.deepEqual(Array.from(mesh.uvs.subarray(17 * 9 * 2, 17 * 9 * 2 + 2)), [0.5, 0.5]);
}
});
+
+test('extrude stays closed when hole edges line up with each other', () => {
+ const rectangle = (minimumX, minimumY, maximumX, maximumY) => [[minimumX, minimumY], [maximumX, minimumY], [maximumX, maximumY], [minimumX, maximumY]];
+ const contour = rectangle(-0.5, 0, 0.5, 1.2);
+ const panes = [rectangle(-0.44, 0.06, -0.03, 0.57), rectangle(0.03, 0.06, 0.44, 0.57), rectangle(-0.44, 0.63, -0.03, 1.14), rectangle(0.03, 0.63, 0.44, 1.14)];
+ for (const options of [{ depth: 0.08 }, { depth: 0.08, steps: 3 }, { depth: 0.08, bevel: 0.005, bevelSegments: 2 }]) {
+ const geometry = extrude(contour, { holes: panes, ...options });
+ const uses = new Map();
+ const keyOf = vertex => Array.from(geometry.positions.subarray(vertex * 3, vertex * 3 + 3)).join(',');
+ for (let offset = 0; offset < geometry.indices.length; offset += 3) {
+ for (let side = 0; side < 3; side++) {
+ const edge = [keyOf(geometry.indices[offset + side]), keyOf(geometry.indices[offset + (side + 1) % 3])].sort().join('|');
+ uses.set(edge, (uses.get(edge) ?? 0) + 1);
+ }
+ }
+ assert.deepEqual([...uses.values()].filter(count => count !== 2), [], JSON.stringify(options));
+ assert.equal(geometry.positions.length / 3, geometry.normals.length / 3);
+ assert.equal(geometry.positions.length / 3, geometry.uvs.length / 2);
+ }
+ const plain = extrude(contour, { holes: panes, depth: 0.08 });
+ let volume = 0;
+ for (let offset = 0; offset < plain.indices.length; offset += 3) {
+ const [first, second, third] = [0, 1, 2].map(side => Array.from(plain.positions.subarray(plain.indices[offset + side] * 3, plain.indices[offset + side] * 3 + 3)));
+ volume += (first[0] * (second[1] * third[2] - second[2] * third[1]) - first[1] * (second[0] * third[2] - second[2] * third[0]) + first[2] * (second[0] * third[1] - second[1] * third[0])) / 6;
+ }
+ assert.ok(Math.abs(volume - 0.029088) < 1e-5, `volume ${volume}`);
+});