3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Name the point to pass when skyOpenness gets no finite point (#2625)
abu-tahir-0fc7f51d0284d
diff --git a/changes/2625.md b/changes/2625.mdnew file mode 100644index 00000000..a877480b--- /dev/null+++ b/changes/2625.md@@ -0,0 +1 @@+- `skyOpenness` now names the point to pass when it is not three finite numbers, instead of reporting open sky for a NaN point (#2625)diff --git a/changes/2625.size.md b/changes/2625.size.mdnew file mode 100644index 00000000..e350dfe5--- /dev/null+++ b/changes/2625.size.md@@ -0,0 +1 @@+- goal:agent-scene: the point check stops a NaN point from reporting a closed room as open sky in the agent scene.diff --git a/src/closed-room.js b/src/closed-room.jsindex 9d40cb45..b0d65e84 100644--- a/src/closed-room.js+++ b/src/closed-room.js@@ -1,3 +1,5 @@+import { invalidField } from './field-error.js';+// A cheap test for a closed room: shoot a fixed set of rays from the middle of the scene's bounds and count how many hit// the inner face of a part. A solid object has only back faces facing a ray that starts inside it, so it never counts as a// room. It reads no clock and uses no random numbers, so the same scene gives the same share.@@ -162,6 +164,9 @@ export const SKY_OPENNESS_RAYS = 32;* spiral, so the same scene gives the same share.*/export function skyOpenness(parts, point) {+ if (![0, 1, 2].every(axis => Number.isFinite(point?.[axis]))) {+ throw invalidField('point', point, '[x, y, z] as three finite numbers');+ }const worldMatrices = partMatrixLookup(parts);const triangles = worldTriangles(parts.filter(part => !['blend', 'add'].includes(part.material?.alphaMode)), worldMatrices);if (!triangles) {diff --git a/tests/closed-room.test.js b/tests/closed-room.test.jsindex 4f254b59..a7e646ba 100644--- a/tests/closed-room.test.js+++ b/tests/closed-room.test.js@@ -2,7 +2,7 @@ import test from 'node:test';import assert from 'node:assert/strict';import { createAgentScene } from '../src/agent-scene.js';import { loadAgentSceneModules } from '../src/agent-scene-modules.js';-import { closedRoomShare, CLOSED_ROOM_SHARE, CLOSED_ROOM_MAXIMUM_TRIANGLES, skyGridSize, skyVisibilityGrid } from '../src/closed-room.js';+import { closedRoomShare, CLOSED_ROOM_SHARE, CLOSED_ROOM_MAXIMUM_TRIANGLES, skyGridSize, skyOpenness, skyVisibilityGrid } from '../src/closed-room.js';import { fittedClosedRoomShare } from '../src/fitted-closed-room.js';const WALL = 0.2;@@ -180,3 +180,16 @@ test('skyVisibilityGrid returns data that matches its size for a zero-size box',assert.deepEqual(grid.size, [2, 2, 2]);assert.equal(grid.data.length, 8);});++test('skyOpenness names a point that is not three finite numbers (#2625)', () => {+ const parts = createAgentScene(roomRecipe()).parts;+ for (const point of [[NaN, 0, 0], [0, Infinity, 0], [0, 0], undefined]) {+ assert.throws(() => skyOpenness(parts, point), /point: .*expected \[x, y, z\] as three finite numbers/);+ }+});++test('skyOpenness reads a finite point as before (#2625)', () => {+ const parts = createAgentScene(roomRecipe()).parts;+ assert.equal(skyOpenness(parts, [0, 0, 0]), 0);+ assert.equal(skyOpenness([parts[0]], [0, 0, 0]), 1);+});