3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Merge remote-tracking branch 'origin/main' into w2163m
Nguyen Xuan Anfa1a52ff4aa6
diff --cc docs/culling-lod.mdindex 4b46b96f,77018296..d98aead6--- a/docs/culling-lod.md+++ b/docs/culling-lod.md@@@ -58,8 -58,10 +58,12 @@@ A scan with about one triangle per pixe`generateGeometryLods` keeps the uvs, light uvs, colours and normals of a geometry that has them: each level is the geometry with some edges collapsed onto a vertex that stays, so no attribute is blended. Vertices on a UV seam, a hard edge or an open border never move, and a level can keep more triangles than its ratio when those vertices leave no safe collapse. `error` is the square root of the largest quadric cost of any collapse so far, an estimate of how far the surface moved, so it is a distance in the geometry's units (each plane counts once, so scaling the mesh by k scales it by k) and sits on the cautious side for small meshes with many seams. A geometry may have at most `MAXIMUM_SIMPLIFY_TRIANGLES` triangles and `MAXIMUM_SIMPLIFY_VERTICES` vertices (2 million each); a bigger one throws a RangeError, so split the part or skip levels for it (`addLodsToDenseParts` leaves such parts as they are).- `addLodsToDenseParts(parts, { pixels })` from `src/dense-lods.js` gives levels to the parts of a scene that has more than one triangle per pixel (`pixels` is the canvas width times its height times the pixel ratio squared). A part gets levels when it has at least `minimumTriangles` (default 20000) triangles and can take them; parts with the same geometry share one set. It returns `parts` itself for a scene under the density. It is not applied by itself, and it takes seconds on a million triangles, so call it once while loading. On the Monster scene (1.6 million triangles, 1280 by 720, 4 samples) called with the canvas size, the frame went from 5.8 to 1.9 ms, and Lone Monk (5.6 million) from 15.4 to 9.5 ms (measured before the error metric was changed to a distance); the picture changes slightly (root mean square 2.0 of 255), because far parts draw from coarser levels (#1163).+ `addLodsToDenseParts(parts, { pixels })` from `src/dense-lods.js` gives levels to the parts of a scene that has more than one triangle per pixel (`pixels` is the canvas width times its height times the pixel ratio squared). A part gets levels when it has at least `minimumTriangles` (default 4000, so a scene of many meshes with a few thousand triangles each gets them too, #2144, #2157) triangles and can take them; parts with the same geometry share one set. It returns `parts` itself for a scene under the density. It is not applied by itself, and it takes seconds on a million triangles, so call it once while loading. On the Monster scene (1.6 million triangles, 1280 by 720, 4 samples) called with the canvas size, the frame went from 5.8 to 1.9 ms, and Lone Monk (5.6 million) from 15.4 to 9.5 ms (measured before the error metric was changed to a distance); the picture changes slightly (root mean square 2.0 of 255), because far parts draw from coarser levels (#1163).- A scene file (`scene.json`, rendered by `scripts/render-media.mjs --scene file`) gets the same levels by default; `"renderer": { "denseLods": false }` keeps every triangle of a dense scan. With the option on, `partsForRendererOptions` in `src/dense-lods.js` calls `addLodsToDenseParts` at the canvas size and pixel ratio before the renderer is built (#1163).+ A scene file (`scene.json`, rendered by `scripts/render-media.mjs --scene file`) gets the same levels by default; `"renderer": { "denseLods": false }` keeps every triangle of a dense scan. A scene file also picks levels at `lodPixelError` 0.5, not the renderer's 1, so far detail shimmers less; `"renderer": { "lodPixelError": 1 }` restores the old choice (#2157). With the option on, `partsForRendererOptions` in `src/dense-lods.js` calls `addLodsToDenseParts` at the canvas size and pixel ratio before the renderer is built (#1163).++ On Lone Monk seen from the courtyard (a camera that shows the scene, 1280 by 720, 4 samples), drawing from the levels of parts of 4000 triangles and up, not 20000 and up, sent 1.06 million triangles instead of 1.80 million and cut the GPU frame from 4.36 to 3.38 ms (1500 and up: 3.51 to 3.62 ms, 8000 and up: 3.30 ms) (no levels at all: 3.26 million triangles, 7.12 ms). The picture differs from the 20000 floor by a root mean square of 1.74 of 255 (2.51 from no levels). `node bench/glaze-passes/run.mjs <out.json> <scene directories> whole '{"denseLods":true,"denseLodsMinimumTriangles":4000}'` measures it; `'{"engine":"three"}'` draws the same file with three.js, and `bench/glaze-passes/still-pair.mjs` writes the picture pair and the RMSE (#2144).++ A camera move shows what the levels add between frames (#2157). Add `"sequence":{"directory":"<frames>","frames":60}` to the options to write 60 frames of a dolly from 6 m behind the camera to 5 m in front of it, and run `node bench/glaze-passes/sequence-metrics.mjs <frames drawn with denseLods false> <frames>[,<frames>]`: it prints shimmer (the high-passed frame-to-frame difference over the detailed tenth of the picture), addedShimmer (the same on the error against the move without levels) and popSpike (the biggest jump of that error beyond its neighbours). On Lone Monk the floors 4000, 8000 and 1500 gave the same addedShimmer, 1.16 against 0.76 at 20000 (the move's own shimmer is 12.6 of 255, with or without levels), and a popSpike of 0.42 against 0.63 at 20000. The extra shimmer comes from the meshes of 8000 to 12000 triangles, which is also where the saved triangles are, so no floor between 1500 and 8000 separates speed from shimmer; `lodPixelError: 0.5` brought it to 0.87 for 1.28 million triangles and 4.04 ms.++`npm run bench:scene-frames -- <scene directory> [<scene directory>...]` renders each scene file's own camera at 320 by 180 and exits 1 when the frame is nearly one colour (mean luminance step between neighbouring pixels under 1 of 255). A camera behind a wall gave Lone Monk a white frame that no timing or RMSE could use (0.32 flat; the other benchmark scenes measure 2.4 to 7.8), and the same check flags the Barbershop scene (#2158). The detector is `bench/scene-frames/uniform-frame.mjs`. The scene directories are generated locally and are not in git, so the cameras that fix both scenes are committed in `bench/scene-frames/camera-overrides.json` (scene name to `eye` and `target`); the sweep writes them into each directory's `scene.json` before it renders.