3D engine that AI agents drive
Merge remote-tracking branch 'origin/main' into merged/feat-terrain-layers
Nguyen Xuan An1c1290083423
diff --cc CHANGELOG.mdindex b51863d1,01aa7b9a..dd55b57a--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -2,7 -2,7 +2,8 @@@## Unreleased+- Add terrain holes and a recipe `terrain` geometry (part of issue #64; layers beyond four and the navmesh are not built). `createTerrain({ holes: [{ center: [x, z], radius }] })` leaves no surface where a cell centre is inside a circle, and `terrain.isHole(x, z)` answers for a point; without `holes` the seeded meshes are byte-identical (a digest test). A recipe geometry `{ type: "terrain", size, resolution, seed, amplitude, holes }` builds one seeded ground mesh with the same holes; it loads on demand through the new `terrain` module (core did not grow), the tool schema entry is one line with the fields in `scene_capabilities` `terrain`, and the schema total budget did not change (scene_create and scene_apply rose by a few hundred bytes, mesh_edit fell by the same amount). New suite task `terrain-hole-walk` (ground with a 3 m opening and a walker that has to go around it) with the checks `groundRelief` and `walkPath`. Measured: Haiku passed it 2 of 2 (9 and 6 tool calls, $0.29 in all) and both exported recipes used the `terrain` geometry; there was no control run without the feature, so this shows agents find it, not how many could do without.+ - Bake patterned, textured and emissive parts, and skip hair hosts (part of issue #128). A recipe `bake` used to skip every part with a pattern, a map or emission (31 parts, the floor and every wall, in the demo room) and failed `scene_create` with "Textured geometry requires UV channel 0" on a node that hosts hair. Those parts now keep `uvs` and their look and take the bounced light through a new `lightMap` material slot on a second UV set (`geometry.lightUvs`); the fragment shader adds `color * (1 - metallic) * lightMap * lightMapScale`, so a brick pattern tints its own bounced light. Hair and particle host nodes are skipped and listed in `report.skipped`. The shader branch compiles out of scenes with no light map; the renderer carries about 650 bytes of gzip for it in `entry:core` (see `docs/light-bake.md` for the measured sizes). GLB export writes `TEXCOORD_1` and the light map as the emissive texture (an approximation: glTF has no light map slot). The path tracer ignores baked maps by design. New reference scene `brick-room` (a recipe-built closed brick room).- Make the path tracer about 2.8 times faster per thread and draw normal and metallic-roughness maps (part of issue #129; a 1080p still of the 181,708 triangle demo room at 64 samples still does not fit the 240 s job limit). Profiling the demo room showed the ray query dominating: 54 percent of the time sat in the generic BVH visitor, which called a closure per box and per triangle and kept distances in a boxed array. `createTracer` in `src/ray-query.js` now walks the BVH with typed stacks, a slab test on inverse directions and triangles packed in leaf order; pixels are bit-identical to before (checksum of a band unchanged) and it runs 1.2 times faster alone. The larger gain is shadow rays: the demo room has 11 light sources, and every bounce traced all of them. The first hit of a path still samples every light; later hits draw one at random and divide by its chance (and the environment multiple importance weights use that chance), which gives 23,300 paths a second per thread against 9,800, with the average moved by less than 1 percent in the demo room and 3 percent allowed by a test. Image jobs now use 8 workers, up from 4 (the machine limit). `normalMap` (with `normalScale`, tangent frame from the UVs as in the rasterizer) and `metallicRoughnessMap` (green scales roughness, blue scales metallic) are drawn on UV-mapped materials; on box-projected materials (`boxMapScale`) they are still ignored and `report.ignored` says so. The `entry:path-tracer` size budget goes from 12,900 to 13,800 bytes gzip for the maps, light selection and the packed ray query; `entry:core` did not change. Tests: maps tilt and mask the light, one light drawn at random keeps the average, and bands drawn in any order give the pixels of the whole image.diff --cc bench/size/baseline.jsonindex f8a6b805,ef9d4c90..fe433e1f--- a/bench/size/baseline.json+++ b/bench/size/baseline.json@@@ -114,9 -114,9 +114,9 @@@"brotli": 14786},"entry:terrain": {-- "min": 6661,-- "gzip": 3006,-- "brotli": 2712++ "min": 7387,++ "gzip": 3322,++ "brotli": 3012},"entry:grass": {"min": 9441,@@@ -144,24 -144,24 +144,24 @@@"brotli": 762},"entry:agent-scene": {- "min": 208967,- "gzip": 63945,- "brotli": 55786- "min": 209457,- "gzip": 64112,- "brotli": 55993++ "min": 209968,++ "gzip": 64321,++ "brotli": 56194},"entry:agent-scene+lazy": {- "min": 623239,- "gzip": 213035,- "brotli": 188048- "min": 626190,- "gzip": 214248,- "brotli": 189205++ "min": 635119,++ "gzip": 218126,++ "brotli": 192679},"entry:agent-asset": {- "min": 303069,- "gzip": 94728,- "brotli": 82813- "min": 303562,- "gzip": 94893,- "brotli": 82975++ "min": 303994,++ "gzip": 95078,++ "brotli": 83130},"entry:agent-asset+lazy": {- "min": 659080,- "gzip": 223845,- "brotli": 196982- "min": 662034,- "gzip": 225055,- "brotli": 198170++ "min": 670884,++ "gzip": 228911,++ "brotli": 201552},"entry:hdri": {"min": 8075,@@@ -179,34 -179,34 +179,34 @@@"brotli": 1425},"entry:material-layer-shaders": {- "min": 71379,- "gzip": 18505,- "brotli": 16205+ "min": 71833,+ "gzip": 18658,+ "brotli": 16359},"scene:lit-box": {- "min": 215844,- "gzip": 59286,- "brotli": 50588+ "min": 217804,+ "gzip": 59861,+ "brotli": 51117},"scene:gltf-box": {- "min": 275471,- "gzip": 79332,- "brotli": 68903+ "min": 277431,+ "gzip": 79898,+ "brotli": 69584},"scene:gltf-box+lazy": {- "min": 281904,- "gzip": 81319,- "brotli": 70712+ "min": 283864,+ "gzip": 81888,+ "brotli": 71399},"scene:agent-scene": {- "min": 318701,- "gzip": 94262,- "brotli": 81921- "min": 320697,- "gzip": 94869,- "brotli": 82532++ "min": 321129,++ "gzip": 95055,++ "brotli": 82718},"scene:agent-scene+lazy": {- "min": 732973,- "gzip": 243364,- "brotli": 214130- "min": 737430,- "gzip": 245010,- "brotli": 215663++ "min": 746280,++ "gzip": 248859,++ "brotli": 219206}}}diff --cc bench/size/budgets.jsonindex 843f3558,f84978af..505ff138--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@@ -26,24 -26,24 +26,24 @@@"entry:skeleton-pose": 19200,"entry:vehicle": 14700,"entry:vegetation": 17900,- "entry:terrain": 3330,- "entry:terrain": 3100,++ "entry:terrain": 3400,"entry:grass": 4400,"entry:clutter": 5300,- "entry:light-bake": 25400,+ "entry:light-bake": 25900,"entry:path-tracer": 13800,"entry:texture-set": 900,- "entry:agent-scene": 65300,- "entry:agent-scene+lazy": 217500,- "entry:agent-asset": 96700,- "entry:agent-asset+lazy": 228400,- "entry:agent-scene": 65400,- "entry:agent-scene+lazy": 218600,- "entry:agent-asset": 96800,- "entry:agent-asset+lazy": 229600,++ "entry:agent-scene": 65700,++ "entry:agent-scene+lazy": 222500,++ "entry:agent-asset": 97000,++ "entry:agent-asset+lazy": 233500,"entry:hdri": 3300,"entry:camera-effects": 8600,"entry:render-passes": 1700,- "entry:material-layer-shaders": 18900,- "scene:lit-box": 60500,- "scene:gltf-box": 81000,- "scene:gltf-box+lazy": 83000,- "scene:agent-scene": 96200,- "scene:agent-scene+lazy": 248300+ "entry:material-layer-shaders": 19100,+ "scene:lit-box": 61100,+ "scene:gltf-box": 81500,+ "scene:gltf-box+lazy": 83600,- "scene:agent-scene": 96800,- "scene:agent-scene+lazy": 250000++ "scene:agent-scene": 97000,++ "scene:agent-scene+lazy": 253900}}