3D engine that AI agents drive
Merge remote-tracking branch 'origin/main' into HEAD
Nguyen Xuan Anc0199de099e8
diff --cc CHANGELOG.mdindex 87809bc9,84e136cb..b98dd117--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -2,8 -2,12 +2,13 @@@## Unreleased+- Make the first frame and the SwiftShader frame cost less, with the same pixels. The main fragment shader now compiles only the features that a scene uses (maps, splat layers, moss, alpha and the special material tags), and a part that needs another feature later recompiles it. All programs, with the environment prefilter, now start together and use `KHR_parallel_shader_compile`. On an RTX 3060 the first frame went from 3.7 to 4.4 seconds down to 0.5 to 1.0 seconds, and a SwiftShader frame costs 0.4 to 0.5 times what it did. `bench/runtime/PROFILE.md` has the profile+ - Add `subdivide` as a mesh edit and stack node: Catmull-Clark subdivision to 4 levels with semi-sharp creases picked by an edge rule, sharp boundaries, kept corners, n-gon support, and tags, UVs and edge attributes carried through each level. The size is checked before it allocates. Counts, area and positions match Blender at levels 1 to 3; the `pebble` task joins the agent modeling suite+ - Remove `67js/addons/film` from the npm package. It held the 187-second trailer demo with its baked physics recording, 75 KB gzip of the archive. Nothing else in the package used it. To keep using it, copy `src/film.js`, `src/film-rig.js`, `src/film-character.js`, `src/film-physics-definition.js` and `src/film-physics-clip.json` from the repository, or read the trailer on the site at `/film.html`. The archive goes from 901,314 to 829,085 bytes+ - Remove three.js from modeling and the agent scene: `lathe`, `extrude` and `tube` no longer import it, and `scene:agent-scene` drops from 185,681 to 117,290 bytes gzip. `lathe` and `tube` output is identical to before, vertex for vertex. `extrude` walls, bevels, UVs, normals and bounds are identical, and volume matches within 1e-4. Extrusion caps use a new ear-clipping triangulation, so a cap can split along other diagonals, and a cap with collinear points can add or drop a seam vertex. A clockwise hole under a clockwise contour is now flipped to face outward, where it used to keep inward walls- Load glTF without Three.js: the addon has its own GLB and glTF parser, node sampler and animation clips, so a box with the addon drops from 159,422 to 67,467 bytes gzip. Draco, meshopt and KTX2 still come from the decoders you pass in `options.decoders`. Only the default scene is decoded, and a node outside it is decoded only when a skin or an animation names it+ - Remove three.js from modeling and the agent scene: `lathe`, `extrude` and `tube` no longer import it, and `scene:agent-scene` drops from 185,681 to 117,290 bytes gzip. `lathe` and `tube` output is identical to before, vertex for vertex. `extrude` walls, bevels, UVs, normals and bounds are identical, and volume matches within 1e-4. Extrusion caps use a new ear-clipping triangulation, so a cap can split along other diagonals, and a cap with collinear points can add or drop a seam vertex. A clockwise hole under a clockwise contour is now flipped to face outward, where it used to keep inward walls+ - Remove three.js and three-mesh-bvh from mesh queries, shrinkwrap and surface patches: a typed-array BVH and its own triangle tests replace them, so no source file in `src/` except the benchmark page imports three.js and the npm archive drops from 856,115 to 798,532 bytes. `entry:mesh-query` drops from 85,555 to 15,535 bytes gzip, `entry:shrinkwrap` from 86,779 to 17,860 and `entry:surface` from 72,974 to 9,838. Nearest, project, raycast and pair results match three-mesh-bvh on fixtures and random queries. Nearest queries on 100k triangles are about 20 percent slower and a pair query with one mesh shifted against itself is slower (21 ms against 2 ms), while a closed-solid pair is 2.4 times faster. The surface patch clipper follows DecalGeometry and keeps its triangle order- Update the bundled `zod` to 4.6.7, which fixes a memory exhaustion advisory in the validation of oversized collections- Make the MCP preview server reject requests with another Host header, which closes DNS rebinding- Check the size of a mesh `array` before it allocates. Before this, the check ran after the copies existeddiff --cc bench/size/baseline.jsonindex 1de5d156,3d451328..476f67cf--- a/bench/size/baseline.json+++ b/bench/size/baseline.json@@@ -14,9 -14,9 +14,9 @@@},"bundles": {"entry:core": {- "min": 232566,- "gzip": 65748,- "brotli": 56102- "min": 232549,- "gzip": 65747,- "brotli": 56178++ "min": 235430,++ "gzip": 66762,++ "brotli": 57079},"entry:model": {"min": 40093,@@@ -44,14 -39,14 +39,14 @@@"brotli": 7331},"entry:gltf": {-- "min": 139564,-- "gzip": 43172,-- "brotli": 37021++ "min": 140408,++ "gzip": 43596,++ "brotli": 37426},"entry:modeling": {- "min": 309436,- "gzip": 74404,- "brotli": 61979+ "min": 15517,+ "gzip": 6416,+ "brotli": 5712},"entry:sculpt": {"min": 5937,@@@ -59,24 -54,24 +54,24 @@@"brotli": 2184},"entry:surface": {-- "min": 314055,-- "gzip": 72974,-- "brotli": 60264++ "min": 29893,++ "gzip": 9838,++ "brotli": 7937},"entry:mesh-query": {-- "min": 344039,-- "gzip": 85555,-- "brotli": 71174++ "min": 45212,++ "gzip": 15535,++ "brotli": 12998},"entry:mesh": {-- "min": 95797,-- "gzip": 32819,-- "brotli": 29011++ "min": 102839,++ "gzip": 34854,++ "brotli": 30681},"entry:shrinkwrap": {-- "min": 348855,-- "gzip": 86779,-- "brotli": 72407++ "min": 56188,++ "gzip": 17860,++ "brotli": 14972},"entry:surface-attachment": {"min": 36920,@@@ -134,14 -129,14 +129,14 @@@"brotli": 762},"entry:agent-scene": {- "min": 586522,- "gzip": 161526,- "brotli": 135640- "min": 292317,- "gzip": 93166,- "brotli": 80011++ "min": 300204,++ "gzip": 95674,++ "brotli": 82113},"entry:agent-asset": {- "min": 613124,- "gzip": 168953,- "brotli": 141724- "min": 318835,- "gzip": 100520,- "brotli": 85995++ "min": 326722,++ "gzip": 103016,++ "brotli": 88262},"entry:hdri": {"min": 8075,@@@ -149,19 -144,19 +144,19 @@@"brotli": 2801},"scene:lit-box": {-- "min": 178412,-- "gzip": 48762,-- "brotli": 41832++ "min": 181287,++ "gzip": 49762,++ "brotli": 42779},"scene:gltf-box": {-- "min": 235553,-- "gzip": 67467,-- "brotli": 58083++ "min": 238435,++ "gzip": 68451,++ "brotli": 59082},"scene:agent-scene": {- "min": 678793,- "gzip": 185681,- "brotli": 155804- "min": 384588,- "gzip": 117290,- "brotli": 100238++ "min": 394513,++ "gzip": 120389,++ "brotli": 102907}}}diff --cc bench/size/budgets.jsonindex 2165567c,f307371c..68016236--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@@ -5,19 -5,18 +5,18 @@@"agent-scene": 100000},"budgets": {-- "entry:core": 67100,++ "entry:core": 68100,"entry:model": 14400,"entry:nature": 13200,- "entry:film": 156800,"entry:motion": 13600,"entry:canvas2d": 9400,-- "entry:gltf": 44100,- "entry:modeling": 75900,++ "entry:gltf": 44500,+ "entry:modeling": 6600,"entry:sculpt": 2500,-- "entry:surface": 74500,-- "entry:mesh-query": 87300,- "entry:mesh": 33500,- "entry:mesh": 34900,-- "entry:shrinkwrap": 88600,++ "entry:surface": 10100,++ "entry:mesh-query": 15900,++ "entry:mesh": 35600,++ "entry:shrinkwrap": 18300,"entry:surface-attachment": 11800,"entry:physics": 16500,"entry:spume": 9000,@@@ -29,11 -28,11 +28,11 @@@"entry:grass": 4400,"entry:clutter": 5300,"entry:texture-set": 900,- "entry:agent-scene": 164800,- "entry:agent-asset": 172400,- "entry:agent-scene": 95300,- "entry:agent-asset": 102600,++ "entry:agent-scene": 97600,++ "entry:agent-asset": 105100,"entry:hdri": 3300,-- "scene:lit-box": 49800,-- "scene:gltf-box": 68900,- "scene:agent-scene": 189400- "scene:agent-scene": 119700++ "scene:lit-box": 50800,++ "scene:gltf-box": 69900,++ "scene:agent-scene": 122800}}