Skip to content

3D engine that AI agents drive

Let probes and the irradiance grid take 1,024 parts (#1218)

Nguyen Xuan Anada6a2429fc6
diff --git a/changes/1218-probe-grid-part-cap.md b/changes/1218-probe-grid-part-cap.md
new file mode 100644
index 00000000..d64fada8
--- /dev/null
+++ b/changes/1218-probe-grid-part-cap.md
@@ -0,0 +1 @@
+- Light probes, object reflection probes and the irradiance grid now take up to 1,024 parts instead of 256, so a house-sized scene built through MCP keeps its baked light and reflections (#1218).
diff --git a/docs/agent-look.md b/docs/agent-look.md
index a77b3a6a..0f961d04 100644
--- a/docs/agent-look.md
+++ b/docs/agent-look.md
@@ -122,7 +122,7 @@ Sky colors use display RGB, matching the renderer's existing environment contrac
| `hdri` | absent | A shipped HDRI (`sky-clouds`, `studio-softbox`) or the 64-character ID of a `.hdr` file in `scene_asset_catalog`. It lights, reflects and (with `world: true`) forms the background instead of the setup sky; `environmentIntensity` is its strength and `environmentRotation` turns it about the vertical axis. The setup still gives the key light, so set `keyIntensity: 0` when the HDRI has its own sun. `null` clears. See [Catalog HDRIs and looks](#catalog-hdris-and-looks) |
| `ground` | on | Absent unless set. `false` removes the preview's automatic floor and contact shadow |
| `resolveCoplanar` | `'offset'` | Flush and near-flush faces, inside one mesh or across parts, are ranked per triangle and drawn with a small depth-only bias, so the face in front wins at every distance and nothing flickers. Geometry never moves. `false` opts out, and `scene_inspect` then lists each pair as a `coplanar-overlap` warning. Parts that set `decal` or `depthLayer` keep their own layer. Where an opaque face covers another on the same plane, or in front of it by at most a thousandth of the shared face (between a millimetre and a centimetre), the covered part is cut out of the drawn copy of the hidden face (the part and its geometry stay as you made them), so a stack of any depth is settled and the path tracer sees one face. What cannot be settled comes back as a `coplanar-overlap` warning with a `reason`: `rank-overflow` (more than 16 faces a wider gap apart), `double-sided-gap`, `unchecked` (past the triangle or pair budget, the part the search stopped at is named) or `collapsed-node` (an axis a millionth of the longest one; a 2 cm slab 400 m wide is a ground, not a collapse) |
-| `objectReflections` | on | Absent unless set. Each smooth metal part (`metallic` 0.5 or more, `roughness` 0.6 or less; at most 8 such parts, in a scene with at most 256 other parts) gets a reflection probe of the scene around it, so a chrome sphere shows the floor and its neighbours. `false` turns it off. Probes are traced at rest, so a part that moves reflects the scene as it started. `scene_inspect` names them in `reflections` |
+| `objectReflections` | on | Absent unless set. Each smooth metal part (`metallic` 0.5 or more, `roughness` 0.6 or less; at most 8 such parts, in a scene with at most 1,024 other parts) gets a reflection probe of the scene around it, so a chrome sphere shows the floor and its neighbours. `false` turns it off. Probes are traced at rest, so a part that moves reflects the scene as it started. `scene_inspect` names them in `reflections` |
| `sky` | absent | Absent unless set. `{ type: 'physical', preset, sunElevation, sunRotation, turbidity, groundAlbedo, aerialPerspective, ozone, sunDisc }`: one time-of-day control. `sunElevation` -90 to 90 degrees (default 45), `sunRotation` degrees clockwise from -Z seen from above (0), `turbidity` 1 to 10 haze (3), `groundAlbedo` 0 to 1 (0.3), `aerialPerspective` 0 to 4 scales the distance haze (1; 0 for none), `ozone` 0 to 10 Chappuis-band absorption (1), `sunDisc` boolean (true). `preset` is `golden-hour` (sun 4 degrees up), `sunset` (1 degree) or `blue-hour` (4 degrees below the horizon), each with the sun turned to rotation 250: it supplies the sun only, fields beside it win, and a preset in a `set-environment` patch starts the sky again from its own sun with the other fields at their defaults. A sun below 14 degrees is fitted to Blender's sky (checked at 2, 6 and 15 degrees, comparison in `docs/golden-hour-comparison.jpg`): a narrow saturated orange band forms along the horizon, the zenith dims and the key warms and strengthens; at 14 degrees and above the sky is unchanged. The sky sets `lightDirection`, `keyColor` (the sun reddens and dims with air mass and sets below the horizon), `skyTop`, `skyBottom`, `fogColor` and `fogDensity`, and replaces the setup's environment map with the sky, so those fields no longer take your values while a sky is set. `environment` motion tracks can animate `sunElevation`, `sunRotation`, `turbidity`, `groundAlbedo`, `aerialPerspective` and `ozone` for time-of-day arcs. A `set-environment` patch changes the fields it names and keeps the rest; `sky: null` in a patch keeps the last derived values as plain fields. It is an analytic single-scattering approximation (Rayleigh, aerosol and ozone, Kasten-Young air mass), not Blender's Nishita integration: no clouds. Raster first: the path tracer backends read the same environment map and key light, but are not yet checked against it. |
| `floorSkyTrace` | on | Absent unless set. A closed room a sun lights gets the sky each floor texel sees traced into its floor (`applyFloorSkyVisibility`, strength 0.2), so shadowed floors under a roof or between walls get less world and sky light; it makes the dark end of halls closer to Cycles. Open scenes and rooms lit by lamps alone are left as they are. `false` turns it off; a value that is not a boolean is refused. It loads lazily with a recipe that names its sun (`keyColor` or `keyIntensity`), costs about 1 s of trace when the scene is built and adds triangles to the floor (0.1 to 0.4 ms per frame in the reference halls). |
| `specularAntiAliasing` | `1` | Absent unless set. `0` to `4`. Widens highlights where the shading normal or normal map detail changes within a pixel (geometric specular anti-aliasing plus a Toksvig term read from the filtered normal map length), so grainy or scanned metal stops sparkling from frame to frame at grazing angles. `0` gives a highlight that follows every texel; above `1` is softer. |
diff --git a/docs/light-bake.md b/docs/light-bake.md
index 3a8fc523..c992c65e 100644
--- a/docs/light-bake.md
+++ b/docs/light-bake.md
@@ -28,7 +28,7 @@ const renderer = new CrucibleRenderer(canvas, bakedParts, rendererOptions);
| `standard` (default) | 128 | 2 | 6 |
| `fine` | 192 | 2 | 7 |
-Ranges are 1 to 256 samples, 1 to 8 bounces and 1 to 12 texels per unit. The bake lights the rest pose with the recipe's point lights and key light (key colour times `keyIntensity`). It runs when the scene builds and again only when a part, its matrix, a light, a material or the bake fields change: camera edits, effects edits, motion seeks and renders reuse the result. A bake that passes its time limit fails the edit and leaves the scene as it was. A rebake that cannot run at all because of a size limit (over the part cap, more texels than the bake takes even at the lowest settings, or the irradiance grid and probe part cap of 256, which trace on the CPU) does not fail a `scene_apply` on a scene that already exists: the edit stays applied, the old bake is dropped (it no longer fits the edited parts), the scene is drawn without baked light, and the answer carries a `bake-skipped` diagnostic with the reason and how to fit (fewer parts, lower `samples` or `texelsPerUnit`). The next edit tries again, and a `set-bake` that fits bakes. `scene_create` with a bake that cannot run still fails. The limit is 90 s when the bake runs on a worker (the MCP preview does this, so it blocks nothing) and 20 s on the page's own thread when there is no Worker. The preview's call deadline grows by the 90 s for a `scene_create` whose recipe has a `bake` and for a `scene_apply` with `set-bake`; other calls keep 30 s. A `scene_apply` also gets it whenever the active scene already has a bake, because an ordinary edit such as moving a part rebakes. The same recipe gives the same lightmap bytes. `scene_inspect` returns `bake`: the resolved fields, `used` (the samples, bounces and texelsPerUnit that were traced), `reduced`, `texels`, `rayWork`, `seconds` (of the run that made the lightmaps), `bakedParts`, `skipped` (name and reason), `reused`, and, while the recipe has `environment.localVolumes`, `skippedLocalVolumes` (index, shape, emissive) and `warnings`: the bake leaves volumes out, read from the recipe on every call, so adding or clearing one updates them without a rebake.
+Ranges are 1 to 256 samples, 1 to 8 bounces and 1 to 12 texels per unit. The bake lights the rest pose with the recipe's point lights and key light (key colour times `keyIntensity`). It runs when the scene builds and again only when a part, its matrix, a light, a material or the bake fields change: camera edits, effects edits, motion seeks and renders reuse the result. A bake that passes its time limit fails the edit and leaves the scene as it was. A rebake that cannot run at all because of a size limit (over the part cap, more texels than the bake takes even at the lowest settings, or the irradiance grid and probe part cap of 1,024, which trace on the CPU) does not fail a `scene_apply` on a scene that already exists: the edit stays applied, the old bake is dropped (it no longer fits the edited parts), the scene is drawn without baked light, and the answer carries a `bake-skipped` diagnostic with the reason and how to fit (fewer parts, lower `samples` or `texelsPerUnit`). The next edit tries again, and a `set-bake` that fits bakes. `scene_create` with a bake that cannot run still fails. The limit is 90 s when the bake runs on a worker (the MCP preview does this, so it blocks nothing) and 20 s on the page's own thread when there is no Worker. The preview's call deadline grows by the 90 s for a `scene_create` whose recipe has a `bake` and for a `scene_apply` with `set-bake`; other calls keep 30 s. A `scene_apply` also gets it whenever the active scene already has a bake, because an ordinary edit such as moving a part rebakes. The same recipe gives the same lightmap bytes. `scene_inspect` returns `bake`: the resolved fields, `used` (the samples, bounces and texelsPerUnit that were traced), `reduced`, `texels`, `rayWork`, `seconds` (of the run that made the lightmaps), `bakedParts`, `skipped` (name and reason), `reused`, and, while the recipe has `environment.localVolumes`, `skippedLocalVolumes` (index, shape, emissive) and `warnings`: the bake leaves volumes out, read from the recipe on every call, so adding or clearing one updates them without a rebake.
### Work budget
@@ -117,7 +117,7 @@ Cost per frame (RTX 3060, `lit-interior`, medians of three alternating rounds of
| `maxResolution` | 128 | 4 to 256 | Largest lightmap side for one part. |
| `maxSeconds` | 60 | 1 to 600 | Wall-clock limit. Passing it throws; a bake never returns a partial result. |
-Also checked before any ray is traced: at most 256 parts, 200,000 triangles in total, 16 point lights, 1,000,000 texels and 400 million units of ray work (texels, samples, bounces and lights multiplied). Positions, indices, matrices, colours and lights must be finite and in range, and an error names the field.
+Also checked before any ray is traced: at most 256 parts (1,024 for the irradiance grid and probes, which trace on the CPU), 200,000 triangles in total, 16 point lights, 1,000,000 texels and 400 million units of ray work (texels, samples, bounces and lights multiplied). Positions, indices, matrices, colours and lights must be finite and in range, and an error names the field.
The result is deterministic: the same parts, lights and options give the same bytes, with no `Math.random` and no clock in the output. `report.seconds` is the only value that varies from run to run.
diff --git a/src/agent-bake.js b/src/agent-bake.js
index 4c8a87d3..e6a413b4 100644
--- a/src/agent-bake.js
+++ b/src/agent-bake.js
@@ -154,7 +154,7 @@ export function bakeSkippedDiagnostic(reason) {
return {
kind: 'bake-skipped', severity: 'warning', target: 'bake',
message: `The edit is applied but the light bake did not run, so the old bake was dropped and the scene is drawn without baked light. ${reason}`,
- fix: 'Fit the bake to the scene: fewer parts, a lower bake.samples or bake.texelsPerUnit (scene_apply set-bake), or remove bake.irradianceGrid and bake.probes when the part limit is theirs (they trace on the CPU, 256 parts). The bake runs again on the next edit.',
+ fix: 'Fit the bake to the scene: fewer parts, a lower bake.samples or bake.texelsPerUnit (scene_apply set-bake), or remove bake.irradianceGrid and bake.probes when the part limit is theirs (they trace on the CPU, 1,024 parts). The bake runs again on the next edit.',
};
}
diff --git a/src/irradiance-grid.js b/src/irradiance-grid.js
index 66cdc0f3..e7e5ddda 100644
--- a/src/irradiance-grid.js
+++ b/src/irradiance-grid.js
@@ -2,9 +2,9 @@ import { createTracer } from './ray-query.js';
import { readTriangle } from './triangle-math.js';
import { registerShaderFeatureCode, layerTextureSupport } from './shader-registry.js';
import {
- MAX_BAKE_PARTS, MAX_GPU_BAKE_PARTS, buildWorld, createDirectIrradiance, createGatherer, diffuseAlbedo, emittedRadiance, normalizeLights, sceneScale, validatePart, withReach,
+ buildWorld, createDirectIrradiance, createGatherer, diffuseAlbedo, emittedRadiance, normalizeLights, sceneScale, validatePart, withReach,
} from './light-bake.js';
-import { worldBounds } from './probe-trace.js';
+import { MAX_PROBE_GRID_PARTS, worldBounds } from './probe-trace.js';
import { createGridMedium, MAXIMUM_FOG_SCATTERS } from './grid-medium.js';
// A baked grid of diffuse light: at each node of a 3D grid the light that other surfaces bounce toward it (the sun's lit
@@ -236,8 +236,8 @@ function requireTraceSettings(resolution, samples) {
* their neighbours. Returns `{ origin, cellSize, size, data, seconds, nodes, solidNodes }`; the same input gives the same bytes.
*/
export function traceIrradianceGrid(parts, lighting, { resolution = true, samples = DEFAULT_GRID_SAMPLES, bounces = 3, maxSeconds = 60 } = {}) {
- if (!Array.isArray(parts) || parts.length === 0 || parts.length > MAX_BAKE_PARTS) {
- throw new RangeError(`The irradiance grid takes from 1 to ${MAX_BAKE_PARTS} parts: it traces on the CPU, and only lightmaps trace on the GPU (up to ${MAX_GPU_BAKE_PARTS} parts). Use fewer parts or drop bake.irradianceGrid.`);
+ if (!Array.isArray(parts) || parts.length === 0 || parts.length > MAX_PROBE_GRID_PARTS) {
+ throw new RangeError(`The irradiance grid takes from 1 to ${MAX_PROBE_GRID_PARTS} parts: it traces on the CPU. Use fewer parts or drop bake.irradianceGrid.`);
}
parts.forEach(validatePart);
requireTraceSettings(resolution, samples);
diff --git a/src/probe-trace.js b/src/probe-trace.js
index e2f93a82..00a284cb 100644
--- a/src/probe-trace.js
+++ b/src/probe-trace.js
@@ -2,7 +2,7 @@ import { computeIrradianceCoefficients, evaluateIrradiance } from './environment
import { createTracer } from './ray-query.js';
import { isLiveGeometry } from './live-geometry.js';
import {
- MAX_BAKE_PARTS, MAX_GPU_BAKE_PARTS, averageMapColor, buildWorld, createDirectIrradiance, createGatherer, emittedRadiance, hitNormal, normalizeLights, sceneScale, validatePart, withReach,
+ averageMapColor, buildWorld, createDirectIrradiance, createGatherer, emittedRadiance, hitNormal, normalizeLights, sceneScale, validatePart, withReach,
} from './light-bake.js';
// The half of reflection probes that needs no GPU and no renderer: validating a probe list, placing the automatic probe
@@ -10,6 +10,9 @@ import {
// into maps and gives parts their probe.
export const MAXIMUM_PROBES = 4;
+// Probes and the irradiance grid trace on the CPU, and their work grows with the node count, samples and the time limit rather
+// than with the part count, so they take as many parts as the GPU lightmap bake does (#1218).
+export const MAX_PROBE_GRID_PARTS = 1024;
export const PROBE_MAP_WIDTH = 64;
// An automatic probe is only worth placing in a room: below this share of rays hitting a part the scene is open air.
export const ENCLOSED_HIT_FRACTION = 0.9;
@@ -46,7 +49,7 @@ export function probeAlbedo(material) {
export function traceProbeMaps(parts, lighting, positions, { width = 64, samples = 32, bounces = 2, rotation = 0, missRadiance = null, skyIrradiance = null, maxSeconds = 60 } = {}) {
const height = width / 2;
if (!Number.isInteger(width) || width < 8 || width % 2 !== 0 || width * height > MAX_PROBE_PIXELS) throw new RangeError(`Probe width must be an even integer from 8 whose map has at most ${MAX_PROBE_PIXELS} pixels.`);
- if (!Array.isArray(parts) || parts.length === 0 || parts.length > MAX_BAKE_PARTS) throw new RangeError(`Probes take from 1 to ${MAX_BAKE_PARTS} parts: they trace on the CPU, and only lightmaps trace on the GPU (up to ${MAX_GPU_BAKE_PARTS} parts). Use fewer parts or drop bake.probes.`);
+ if (!Array.isArray(parts) || parts.length === 0 || parts.length > MAX_PROBE_GRID_PARTS) throw new RangeError(`Probes take from 1 to ${MAX_PROBE_GRID_PARTS} parts: they trace on the CPU. Use fewer parts or drop bake.probes.`);
parts.forEach(validatePart);
const lights = normalizeLights(lighting);
const world = buildWorld(parts);
@@ -291,9 +294,9 @@ export function traceObjectProbes(parts, lighting, options = {}) {
if (isReflectivePart(part.material)) reflective.push(index);
});
// Many small metal parts (lamp posts, spires) read as shapes and not as mirrors, and each probe costs a trace and a draw batch.
- const tooManyOthers = parts.length - 1 > MAX_BAKE_PARTS;
+ const tooManyOthers = parts.length - 1 > MAX_PROBE_GRID_PARTS;
const wanted = reflective.length > MAXIMUM_OBJECT_PROBES || tooManyOthers ? [] : reflective;
- const skipped = wanted.length > 0 ? null : reflective.length > MAXIMUM_OBJECT_PROBES ? `more than ${MAXIMUM_OBJECT_PROBES} reflective parts` : tooManyOthers ? `more than ${MAX_BAKE_PARTS} other parts` : 'no reflective part';
+ const skipped = wanted.length > 0 ? null : reflective.length > MAXIMUM_OBJECT_PROBES ? `more than ${MAXIMUM_OBJECT_PROBES} reflective parts` : tooManyOthers ? `more than ${MAX_PROBE_GRID_PARTS} other parts` : 'no reflective part';
if (wanted.length === 0 || parts.length < 2) {
return { traced: [], automatic: true, requested: reflective.length, skipped, seconds: 0 };
}
diff --git a/tests/agent-bake-refusal.test.js b/tests/agent-bake-refusal.test.js
index 7458cd18..31610bf0 100644
--- a/tests/agent-bake-refusal.test.js
+++ b/tests/agent-bake-refusal.test.js
@@ -2,25 +2,22 @@ import './support/load-agent-scene-modules.mjs';
import assert from 'node:assert/strict';
import test from 'node:test';
import { createAgentScene } from '../src/agent-scene.js';
-import { MAX_BAKE_PARTS, MAX_GPU_BAKE_PARTS } from '../src/light-bake.js';
import { traceIrradianceGrid } from '../src/irradiance-grid.js';
-import { traceProbeMaps } from '../src/probe-trace.js';
+import { MAX_PROBE_GRID_PARTS, traceProbeMaps } from '../src/probe-trace.js';
import { growToOversizedOperations, shrinkFromOversizedOperations, largeRoom, oversizedRoom } from './support/agent-bake-rooms.mjs';
const FITTING_BAKE = { samples: 8, bounces: 1, texelsPerUnit: 2 };
const OVER_THE_PATH_WORK_LIMIT = { samples: 32, bounces: 2, texelsPerUnit: 3 };
function tooManyParts() {
- return Array.from({ length: MAX_BAKE_PARTS + 1 }, () => ({}));
+ return Array.from({ length: MAX_PROBE_GRID_PARTS + 1 }, () => ({}));
}
-test('the irradiance grid and the probes say they trace on the CPU, so their part cap stays at the CPU cap', () => {
- assert.ok(MAX_GPU_BAKE_PARTS > MAX_BAKE_PARTS);
+test('the irradiance grid and the probes say they trace on the CPU and name their own part cap', () => {
for (const trace of [() => traceIrradianceGrid(tooManyParts(), {}), () => traceProbeMaps(tooManyParts(), {}, [[0, 0, 0]])]) {
assert.throws(trace, error => error instanceof RangeError
- && error.message.includes(`1 to ${MAX_BAKE_PARTS} parts`)
- && /on the CPU/.test(error.message)
- && error.message.includes(String(MAX_GPU_BAKE_PARTS)));
+ && error.message.includes(`1 to ${MAX_PROBE_GRID_PARTS} parts`)
+ && /on the CPU/.test(error.message));
}
});
diff --git a/tests/probe-grid-part-cap.test.js b/tests/probe-grid-part-cap.test.js
new file mode 100644
index 00000000..0486eb31
--- /dev/null
+++ b/tests/probe-grid-part-cap.test.js
@@ -0,0 +1,44 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+
+import { MAX_BAKE_PARTS } from '../src/light-bake.js';
+import { traceIrradianceGrid } from '../src/irradiance-grid.js';
+import { MAX_PROBE_GRID_PARTS, traceObjectProbes, traceProbeMaps } from '../src/probe-trace.js';
+import { manyPartInterior } from './support/many-part-interior.mjs';
+
+const sun = { keyColor: [3, 3, 3], lightDirection: [0.2, 1, 0.1] };
+const LARGER_THAN_THE_LIGHTMAP_CAP = MAX_BAKE_PARTS + 44;
+
+function brightness(data) {
+ return data.reduce((total, value) => total + value, 0);
+}
+
+test('probes and the irradiance grid have their own cap, above the lightmap cap (#1218)', () => {
+ assert.ok(MAX_PROBE_GRID_PARTS > MAX_BAKE_PARTS);
+ assert.equal(manyPartInterior(LARGER_THAN_THE_LIGHTMAP_CAP).length, LARGER_THAN_THE_LIGHTMAP_CAP);
+});
+
+test('a 300 part interior bakes an irradiance grid with light in it (#1218)', () => {
+ const grid = traceIrradianceGrid(manyPartInterior(LARGER_THAN_THE_LIGHTMAP_CAP), sun, { resolution: 10, samples: 4, bounces: 1 });
+ assert.ok(grid.nodes > 0 && brightness(grid.data) > 0);
+});
+
+test('a 300 part interior bakes light probes (#1218)', () => {
+ const roofless = manyPartInterior(LARGER_THAN_THE_LIGHTMAP_CAP).filter(part => part.name !== 'ceiling');
+ const [map] = traceProbeMaps(roofless, sun, [[0, 1.5, 0]], { width: 16, samples: 4, bounces: 1 });
+ assert.ok(brightness(map.data) > 0);
+});
+
+test('a smooth metal part in a 300 part interior gets an object probe instead of being skipped (#1218)', () => {
+ const parts = manyPartInterior(LARGER_THAN_THE_LIGHTMAP_CAP);
+ parts[10].material = { ...parts[10].material, metallic: 1, roughness: 0.1 };
+ const result = traceObjectProbes(parts, sun, { samples: 4, bounces: 1, width: 16 });
+ assert.equal(result.skipped, null);
+ assert.equal(result.traced.length, 1);
+});
+
+test('more parts than the probe and grid cap are refused with the cap in the message (#1218)', () => {
+ const crowd = Array.from({ length: MAX_PROBE_GRID_PARTS + 1 }, () => ({}));
+ assert.throws(() => traceIrradianceGrid(crowd, sun), error => error instanceof RangeError && error.message.includes(`1 to ${MAX_PROBE_GRID_PARTS} parts`));
+ assert.throws(() => traceProbeMaps(crowd, sun, [[0, 0, 0]]), error => error instanceof RangeError && error.message.includes(`1 to ${MAX_PROBE_GRID_PARTS} parts`));
+});
diff --git a/tests/reflection-probes.test.js b/tests/reflection-probes.test.js
index a502e363..38be3e50 100644
--- a/tests/reflection-probes.test.js
+++ b/tests/reflection-probes.test.js
@@ -162,11 +162,11 @@ test('a scene with no reflective part, or too many, traces nothing', () => {
assert.match(trace.skipped, /more than 8/);
const largeScene = [
placed('mirror', ball, [0, 0.5, 0], [0.5, 0.5, 0.5], { metallic: 1, roughness: 0.3 }),
- ...Array.from({ length: 257 }, (item, index) => placed(`box-${index}`, cube, [index, 0.5, 0], [1, 1, 1])),
+ ...Array.from({ length: 1025 }, (item, index) => placed(`box-${index}`, cube, [index, 0.5, 0], [1, 1, 1])),
];
const largeTrace = traceObjectProbes(largeScene, openAir);
assert.equal(largeTrace.traced.length, 0);
- assert.match(largeTrace.skipped, /more than 256 other parts/);
+ assert.match(largeTrace.skipped, /more than 1024 other parts/);
});
test('rough metal and plain surfaces are not reflective', () => {
diff --git a/tests/support/many-part-interior.mjs b/tests/support/many-part-interior.mjs
new file mode 100644
index 00000000..b194d4e3
--- /dev/null
+++ b/tests/support/many-part-interior.mjs
@@ -0,0 +1,33 @@
+import { box } from '../../src/geometry.js';
+
+const cube = box(0, 1);
+
+function placed(name, translation, scale, color) {
+ const matrix = new Float32Array([scale[0], 0, 0, 0, 0, scale[1], 0, 0, 0, 0, scale[2], 0, translation[0], translation[1], translation[2], 1]);
+ return { name, geometry: cube, matrix, material: { tag: 'surface', color, metallic: 0, roughness: 0.8, emission: 0 } };
+}
+
+/**
+ * A closed 12 by 12 room with `partCount` parts in total: a floor, a ceiling, four walls and a deterministic grid of
+ * furniture boxes. The same count always gives the same parts.
+ */
+export function manyPartInterior(partCount) {
+ const white = [0.8, 0.8, 0.8];
+ const parts = [
+ placed('floor', [0, -0.05, 0], [12, 0.1, 12], [0.8, 0.4, 0.1]),
+ placed('ceiling', [0, 3.05, 0], [12, 0.1, 12], white),
+ placed('back', [0, 1.5, -6.05], [12.2, 3.2, 0.1], white),
+ placed('front', [0, 1.5, 6.05], [12.2, 3.2, 0.1], white),
+ placed('left', [-6.05, 1.5, 0], [0.1, 3.2, 12], white),
+ placed('right', [6.05, 1.5, 0], [0.1, 3.2, 12], white),
+ ];
+ const columns = 32;
+ for (let index = 0; parts.length < partCount; index++) {
+ const column = index % columns;
+ const row = Math.floor(index / columns) % columns;
+ const level = Math.floor(index / (columns * columns));
+ const color = [0.3 + 0.5 * ((index * 7) % 5) / 4, 0.4, 0.3 + 0.4 * ((index * 3) % 4) / 3];
+ parts.push(placed(`box-${index}`, [-5.5 + column * 0.35, 0.15 + level * 0.4, -5.5 + row * 0.35], [0.25, 0.3, 0.25], color));
+ }
+ return parts;
+}