3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Stop reporting parts 100 mm or more apart as one plane (#2207)
Nguyen Xuan Anf3e16d000b3a
diff --git a/changes/2207.md b/changes/2207.mdnew file mode 100644index 00000000..42f3a16a--- /dev/null+++ b/changes/2207.md@@ -0,0 +1 @@+- A coplanar-overlap warning no longer flags parts 100 mm or more apart, however large the scene (#2207)diff --git a/changes/2207.size.md b/changes/2207.size.mdnew file mode 100644index 00000000..ca2b170b--- /dev/null+++ b/changes/2207.size.md@@ -0,0 +1 @@+- scene:agent-scene+lazy: the coplanar report now scales its reach to each pair of parts and caps it at 50 mm, so parts 100 mm apart stop being reported as one plane (91 bytes gzip)diff --git a/docs/agent-look.md b/docs/agent-look.mdindex 166099e9..4c950016 100644--- a/docs/agent-look.md+++ b/docs/agent-look.md@@ -121,7 +121,7 @@ Sky colors use display RGB, matching the renderer's existing environment contrac| `world` | `false` | Boolean world presentation flag. With `true` the setup environment is also the background || `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) |+| `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 (only pairs closer than the pair's own reach, never more than 50 mm). 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 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; the disc is drawn per pixel at `sunAngularRadius`, 0.5 degrees by default, so it stays a sharp round disc at any zoom, and it is not in the baked sky map). `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. || `sky` (gradient) | absent | `{ type: 'gradient', stops: [{ at, color }], horizonGlow: { color, width, intensity } }`: a sky whose colours you pick, for a mood that physics would not give (a teal anime sky with a bright cyan band at the horizon). `stops` holds 1 to 8 entries with `at` rising from 0 (horizon) to 1 (zenith, by elevation angle) and `color` as a `#rrggbb` hex in sRGB; below the horizon the first stop continues. `horizonGlow` is optional: `color` as hex, `width` 0.5 to 45 degrees of elevation (the half width of the band, default 6) and `intensity` 0 to 20 (default 1) multiplies the glow colour at the horizon, so 1 shows the colour as given; the band blends toward the glow colour, so it keeps its hue and does not wash to white until the colour itself is bright. The stop and glow colours are compensated for the scene's view transform and the display power, so the frame shows the hex you gave at the horizon, the stops, the zenith and the glow peak (measured within 1 level under `aces` and `neutral`); between stops the colours blend in OKLab, which keeps the lightness and hue steady and bands less than a blend of encoded values. The inverse assumes exposure 1, no look and no post effect, divides by `environmentIntensity`, and is exact for `aces`; `agx` and `neutral` are solved numerically, and a colour they cannot show (a saturated red under `neutral`, pure white under `agx`) lands on the nearest one they can. The scene light and the water reflection read the same compensated radiance, so a gradient lights the scene more strongly than the same hex taken as plain radiance would. The same colours are the background (with `world: true`), the light and reflections of the scene, and the water reflection. It sets `skyTop`, `skyBottom` and `fogColor` from the first and last stop and leaves the sun, the key light and the fog density to the setup and the recipe. A `set-environment` patch with `type: 'gradient'` replaces a physical sky; a patch without `type` edits the gradient in place. Raster first; the path tracer backends read the same map but are not checked against it. |diff --git a/src/coplanar-overlap.js b/src/coplanar-overlap.jsindex 94524027..06e64247 100644--- a/src/coplanar-overlap.js+++ b/src/coplanar-overlap.js@@ -17,6 +17,8 @@ export const COPLANAR_TOLERANCE = 0.001;export const COPLANAR_MINIMUM_AREA = 1e-4;/** The distance suggested in the fix text, in metres. */export const SUGGESTED_OFFSET = 0.002;+/** No pair is reported farther apart than this (metres): parts 100 mm or more apart are two planes, however large the scene. */+export const MAXIMUM_REPORTED_GAP = 0.05;const DEFAULT_WORK_BUDGET = 1_000_000;// Triangles whose planes are read in the first pass; a scene past it is searched part by part, smallest first.const DEFAULT_TRIANGLE_BUDGET = 600_000;@@ -262,7 +264,18 @@ function trianglesMeet(first, second, tolerance) {}return true;}+// The reach of one pair: scaled to the two parts, never past the scene's reach or MAXIMUM_REPORTED_GAP, so a big sea does not+// make a foam sheet 250 mm above it a fight.+function pairReach(first, second, sceneReach) {+ const spanned = diagonal([+ Math.min(first.bounds[0], second.bounds[0]), Math.min(first.bounds[1], second.bounds[1]), Math.min(first.bounds[2], second.bounds[2]),+ Math.max(first.bounds[3], second.bounds[3]), Math.max(first.bounds[4], second.bounds[4]), Math.max(first.bounds[5], second.bounds[5]),+ ]);+ return Math.min(sceneReach, nearTolerance(spanned));+}+function pairOverlap(first, second, region, tolerance, budget) {+ const reach = pairReach(first, second, tolerance);const bothSides = first.part.material?.doubleSided === true || second.part.material?.doubleSided === true;first.planes ??= worldTrianglesByPlane(first.part, tolerance);second.planes ??= worldTrianglesByPlane(second.part, tolerance);@@ -291,7 +304,7 @@ function pairOverlap(first, second, region, tolerance, budget) {if (!visibleTogether) continue;let largest = 0;for (let corner = 0; corner < 3; corner++) largest = Math.max(largest, Math.abs(planeDistance(firstTriangle, secondTriangle, corner)));- if (largest > tolerance) continue;+ if (largest > reach) continue;const shared = sharedArea(firstTriangle, secondTriangle);if (shared <= 0) continue;area += shared;@@ -403,7 +416,7 @@ export function findCoplanarOverlaps(parts, { tolerance: requestedTolerance = nustack.set(pose, copies + 1);entries.push({ part, bounds });}- const tolerance = requestedTolerance ?? Math.max(COPLANAR_TOLERANCE, nearTolerance(diagonal(sceneBoundsOf(entries))));+ const tolerance = requestedTolerance ?? Math.max(COPLANAR_TOLERANCE, Math.min(MAXIMUM_REPORTED_GAP, nearTolerance(diagonal(sceneBoundsOf(entries)))));const budget = { work: 0, limit: workBudget };const scanBudget = { triangles: triangleBudget, exhausted: false };const overlaps = [];diff --git a/tests/coplanar-overlap.test.js b/tests/coplanar-overlap.test.jsindex 667e0f8e..dc5fd324 100644--- a/tests/coplanar-overlap.test.js+++ b/tests/coplanar-overlap.test.js@@ -361,3 +361,18 @@ test('two dense overlapping meshes are found without one object per triangle (#1// Allocated per triangle: about 3200 bytes with the flat triangle table, about 5600 with one object per triangle.assert.ok(bytesPerTriangle < 4400, `plane search allocated ${Math.round(bytesPerTriangle)} bytes of heap per triangle`);});++// Two 20 m plates facing up, `gap` metres apart in height, in a scene stretched by a far-off marker so the scene-wide reach is large.+function platesApart(gap) {+ return coplanarWarnings([+ node('plate-low', [0, 0, 0], [20, 0.1, 20]),+ node('plate-high', [0, gap, 0], [20, 0.1, 20]),+ node('far-marker', [1500, 0, 0], [1, 1, 1]),+ ]).filter(warning => warning.parts?.includes('plate-high'));+}++test('plates 2 mm apart fight, plates 100 mm and 250 mm apart do not, even in a scene thousands of metres wide', () => {+ assert.equal(platesApart(0.002).length, 1);+ assert.deepEqual(platesApart(0.1), []);+ assert.deepEqual(platesApart(0.25), []);+});