@threenative/core 0.3.6 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.md +3 -5
  2. package/capabilities.json +739 -50
  3. package/dist/{assets-CqvE429w.d.ts → assets-YUbXa3-Y.d.ts} +101 -2
  4. package/dist/{canvas-layer-C1-5CviZ.d.ts → canvas-layer-vCtanIeB.d.ts} +1 -1
  5. package/dist/{game-Jz4Fdoeb.d.ts → game-cb99J-YE.d.ts} +100 -31
  6. package/dist/hot.d.ts +4 -4
  7. package/dist/hot.js +23 -5
  8. package/dist/index.d.ts +1742 -29
  9. package/dist/index.js +22443 -12423
  10. package/dist/{model-lod-BDAUYgsS.d.ts → model-lod-CTpZ6imz.d.ts} +1 -1
  11. package/dist/net.js +39 -12
  12. package/dist/playtest.d.ts +4 -4
  13. package/dist/playtest.js +48 -9
  14. package/dist/react-css.js +23 -0
  15. package/dist/react.d.ts +2 -2
  16. package/dist/{renderer-9yEo9hPa.d.ts → renderer-rZm0hVqq.d.ts} +178 -5
  17. package/dist/ui-layer.d.ts +11 -2
  18. package/dist/ui-layer.js +76 -4
  19. package/dist/worker.d.ts +36 -0
  20. package/dist/worker.js +1088 -0
  21. package/dist/world.d.ts +11 -3
  22. package/dist/world.js +1117 -197
  23. package/mcp/animation-server.mjs +265 -0
  24. package/mcp/animation.mjs +22 -0
  25. package/mcp/call.mjs +105 -0
  26. package/mcp/devtools.mjs +5 -0
  27. package/mcp/engine-server.mjs +713 -37
  28. package/mcp/launch.mjs +3 -2
  29. package/mcp/servers.d.mts +2 -0
  30. package/mcp/servers.mjs +33 -8
  31. package/package.json +12 -8
  32. package/patches/three@0.185.1-prd269-upgrade.patch +308 -0
  33. package/patches/three@0.185.1.patch +481 -272
  34. package/src/animation-packet-state.ts +88 -0
  35. package/src/animation-pose-packet.ts +537 -0
  36. package/src/animation.ts +779 -31
  37. package/src/asset-cache.ts +719 -0
  38. package/src/assets.ts +521 -152
  39. package/src/audio.ts +29 -3
  40. package/src/auto-batch.ts +792 -0
  41. package/src/config.ts +2 -0
  42. package/src/frame-budget.ts +268 -2
  43. package/src/game.ts +525 -105
  44. package/src/grounding.ts +7 -6
  45. package/src/hot.ts +19 -5
  46. package/src/index.ts +381 -6
  47. package/src/input.ts +21 -2
  48. package/src/interpolation.ts +19 -1
  49. package/src/launch-diagnostics.ts +7 -2
  50. package/src/look/ao-multibounce.ts +29 -0
  51. package/src/look/ao-reach.ts +39 -0
  52. package/src/look/auto-exposure.ts +264 -0
  53. package/src/look/default-tone-mapping.ts +44 -0
  54. package/src/look/exposure-graph.ts +208 -0
  55. package/src/look/exposure-readback.ts +97 -0
  56. package/src/look/exposure-settings.ts +132 -0
  57. package/src/look/filmic-tone-mapping.ts +852 -0
  58. package/src/look/gi-registry.ts +55 -0
  59. package/src/look/local-exposure.ts +507 -0
  60. package/src/look/look-diagnostics.ts +24 -0
  61. package/src/look/motion-blur.ts +42 -0
  62. package/src/look/quality.ts +309 -0
  63. package/src/look/reflection-trace.ts +344 -0
  64. package/src/look/unreal-bloom.ts +295 -0
  65. package/src/look/vignette.ts +14 -0
  66. package/src/look/world-environment.ts +2033 -0
  67. package/src/loop.ts +25 -1
  68. package/src/merge-parts.ts +25 -10
  69. package/src/model-lod.ts +14 -0
  70. package/src/net-session.ts +58 -14
  71. package/src/ocean/spectral.ts +41 -7
  72. package/src/picking.ts +72 -5
  73. package/src/platform.ts +29 -1
  74. package/src/playtest.ts +54 -8
  75. package/src/profiling/FrameCounters.ts +166 -5
  76. package/src/profiling/FrameStages.ts +289 -0
  77. package/src/profiling/Spans.ts +39 -25
  78. package/src/profiling/debug-telemetry.ts +312 -0
  79. package/src/profiling/scene-warning.ts +42 -6
  80. package/src/projection-apply.ts +11 -3
  81. package/src/projection-content.ts +189 -0
  82. package/src/projection-marker.ts +6 -2
  83. package/src/projection-plan.ts +279 -28
  84. package/src/projection-skinned.ts +620 -5
  85. package/src/projection-stability.ts +16 -0
  86. package/src/projection-uniform.ts +5 -1
  87. package/src/quiet-markers.ts +56 -0
  88. package/src/render/budget-ladder.ts +256 -0
  89. package/src/render/chain.ts +89 -7
  90. package/src/render/exposure-units.ts +59 -0
  91. package/src/render/frame-time-budget.ts +162 -0
  92. package/src/render/gi-budget.ts +231 -0
  93. package/src/render/gi-visualize.ts +49 -0
  94. package/src/render/material-key.ts +1 -0
  95. package/src/render/probe-volume.ts +196 -36
  96. package/src/render/rough-diffuse.ts +177 -0
  97. package/src/render/scene-trace.ts +532 -0
  98. package/src/render/shadow-filter-budget.ts +237 -0
  99. package/src/render/sky-capture.ts +194 -0
  100. package/src/render/soft-shadow.ts +607 -0
  101. package/src/render/surface-cache.ts +418 -0
  102. package/src/render/traced-reflections.ts +408 -0
  103. package/src/render/two-sided-foliage.ts +120 -0
  104. package/src/render/virtual-shadow-pages.ts +112 -12
  105. package/src/render/virtual-shadow.ts +386 -38
  106. package/src/render-camera-cull.ts +536 -31
  107. package/src/render-pass-budget.ts +140 -22
  108. package/src/renderProjection.ts +65 -9
  109. package/src/renderer-config.ts +3 -2
  110. package/src/renderer.ts +289 -14
  111. package/src/resolution-scaler.ts +65 -7
  112. package/src/skeletal-mesh.ts +4 -0
  113. package/src/snow-field.ts +46 -0
  114. package/src/softbody.ts +6 -5
  115. package/src/startup-offscreen-bytes.ts +168 -0
  116. package/src/startup-readiness.ts +137 -2
  117. package/src/ui-bridge.ts +38 -0
  118. package/src/ui-hit-regions.ts +6 -2
  119. package/src/ui-layer.ts +1 -0
  120. package/src/ui-state.ts +32 -3
  121. package/src/version.ts +1 -1
  122. package/src/viewport.ts +8 -5
  123. package/src/warmup.ts +76 -10
  124. package/src/worker-audio.ts +579 -0
  125. package/src/worker.ts +842 -0
  126. package/src/world-cells.ts +4 -1
  127. package/gpl/LICENSE.GPL +0 -117
  128. package/gpl/convert.py +0 -192
  129. package/gpl/fixtures/make_world_fixture.py +0 -184
  130. package/gpl/recipes/_common.py +0 -180
  131. package/gpl/recipes/bake_ao.py +0 -111
  132. package/gpl/recipes/decimate.py +0 -70
  133. package/gpl/recipes/export_world.py +0 -699
  134. package/gpl/recipes/retarget.py +0 -131
  135. package/gpl/recipes/unwrap.py +0 -71
  136. package/mcp/blender-server.mjs +0 -689
  137. package/mcp/blender.mjs +0 -26
package/mcp/launch.mjs CHANGED
@@ -43,7 +43,7 @@ function serverEntry(directory) {
43
43
 
44
44
  /** Runs an MCP server the project may or may not have installed. Nothing here may write to stdout:
45
45
  * that stream is the JSON-RPC transport, and one stray line makes the server unusable. */
46
- export async function launchMcpServer({ name, version, env = {} }) {
46
+ export async function launchMcpServer({ name, version, env = {}, args = [] }) {
47
47
  for (const [key, value] of Object.entries(env)) process.env[key] ??= value;
48
48
  const directory = packageDirectory(name);
49
49
  const entry = directory === undefined ? undefined : serverEntry(directory);
@@ -53,12 +53,13 @@ export async function launchMcpServer({ name, version, env = {} }) {
53
53
  // this line loads the module and starts nothing, and the host reports a server that connected
54
54
  // and then went silent.
55
55
  process.argv[1] = entry;
56
+ process.argv.push(...args);
56
57
  await import(pathToFileURL(entry).href);
57
58
  return;
58
59
  }
59
60
  // Not installed. `npx` keeps the server available in a project that never listed it, which is the
60
61
  // whole point of wiring these in from the library rather than from a scaffold.
61
- const child = spawn("npx", ["--yes", `${name}@${version}`], {
62
+ const child = spawn("npx", ["--yes", `${name}@${version}`, ...args], {
62
63
  env: process.env,
63
64
  stdio: "inherit",
64
65
  });
package/mcp/servers.d.mts CHANGED
@@ -10,6 +10,8 @@ export interface IMcpServerEntry {
10
10
  }
11
11
 
12
12
  export interface IMcpPackage {
13
+ /** Fixed command-line arguments the shim passes to the server, in every host. */
14
+ readonly args?: readonly string[];
13
15
  readonly name: string;
14
16
  readonly version: string;
15
17
  }
package/mcp/servers.mjs CHANGED
@@ -24,12 +24,19 @@ export const MCP_SERVERS = Object.freeze({
24
24
  command: "node",
25
25
  args: Object.freeze(["./node_modules/@threenative/core/mcp/engine.mjs"]),
26
26
  }),
27
- // Drives an installed Blender headlessly so a downloaded .fbx becomes a GLB. It ships no
28
- // Blender and probes for one only when a tool is called, so a project that never converts a
29
- // model pays nothing for having this server wired.
30
- "threenative-blender": Object.freeze({
27
+ // Inspects, attaches, edits and verifies character animation. Every operation is a build-time
28
+ // edit of one GLB, so a game that animates nothing pays for nothing.
29
+ "threenative-animation": Object.freeze({
31
30
  command: "node",
32
- args: Object.freeze(["./node_modules/@threenative/core/mcp/blender.mjs"]),
31
+ args: Object.freeze(["./node_modules/@threenative/core/mcp/animation.mjs"]),
32
+ }),
33
+ // Google's Chrome DevTools server: performance traces, GPU timing, network, heap and console of
34
+ // the running game. It starts Chrome only on its first tool call, so a project that never
35
+ // inspects a page pays nothing. Its async stack capture inflates CPU time several times, so
36
+ // `trace-a-slow-frame.md` sends absolute CPU questions to `playtest trace` first.
37
+ "threenative-devtools": Object.freeze({
38
+ command: "node",
39
+ args: Object.freeze(["./node_modules/@threenative/core/mcp/devtools.mjs"]),
33
40
  }),
34
41
  });
35
42
 
@@ -38,10 +45,28 @@ export const MCP_SERVERS = Object.freeze({
38
45
  * separately. The pinned engine version remains an emergency fallback for a legacy development
39
46
  * checkout whose bundle has not been built. */
40
47
  export const MCP_PACKAGES = Object.freeze({
41
- assets: Object.freeze({ name: "threenative-asset-mcp", version: "0.14.0" }),
48
+ assets: Object.freeze({ name: "threenative-asset-mcp", version: "0.15.0" }),
42
49
  sculpt: Object.freeze({ name: "threenative-sculpt-mcp", version: "0.2.2" }),
43
- engine: Object.freeze({ name: "threenative-engine-mcp", version: "0.2.6" }),
44
- blender: Object.freeze({ name: "threenative-blender-mcp", version: "0.1.6" }),
50
+ engine: Object.freeze({ name: "threenative-engine-mcp", version: "0.2.9" }),
51
+ animation: Object.freeze({ name: "threenative-animation-mcp", version: "0.1.3" }),
52
+ // `args` fixes the launch for every host. The Chrome flags are `WEBGPU_BROWSER_ARGS` from
53
+ // `@threenative/playtest`, so a DevTools trace profiles the same adapter a playtest does and not
54
+ // SwiftShader. An isolated profile keeps the user's own Chrome profile out, and the two opt-outs
55
+ // keep local game URLs from leaving the machine.
56
+ devtools: Object.freeze({
57
+ name: "chrome-devtools-mcp",
58
+ version: "1.11.0",
59
+ args: Object.freeze([
60
+ "--isolated",
61
+ "--no-usage-statistics",
62
+ "--no-performance-crux",
63
+ "--chromeArg=--ozone-platform=x11",
64
+ "--chromeArg=--enable-unsafe-webgpu",
65
+ "--chromeArg=--disable-gpu-sandbox",
66
+ "--chromeArg=--ignore-gpu-blocklist",
67
+ "--chromeArg=--enable-features=Vulkan",
68
+ ]),
69
+ }),
45
70
  });
46
71
 
47
72
  /** How one host spells a stdio MCP server. Hosts agree on what to run and disagree on where to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threenative/core",
3
- "version": "0.3.6",
3
+ "version": "0.3.9",
4
4
  "license": "MIT AND GPL-2.0-or-later",
5
5
  "description": "The small vanilla Three.js game runtime foundation.",
6
6
  "keywords": [
@@ -27,7 +27,6 @@
27
27
  "dist",
28
28
  "LICENSE",
29
29
  "mcp",
30
- "gpl",
31
30
  "scripts/apply-three-patch.mjs",
32
31
  "scripts/ensure-mcp.mjs",
33
32
  "scripts/postinstall.mjs",
@@ -64,6 +63,10 @@
64
63
  "types": "./dist/ui-layer.d.ts",
65
64
  "import": "./dist/ui-layer.js"
66
65
  },
66
+ "./worker": {
67
+ "types": "./dist/worker.d.ts",
68
+ "import": "./dist/worker.js"
69
+ },
67
70
  "./world": {
68
71
  "types": "./dist/world.d.ts",
69
72
  "import": "./dist/world.js"
@@ -79,9 +82,10 @@
79
82
  },
80
83
  "sideEffects": false,
81
84
  "dependencies": {
85
+ "chrome-devtools-mcp": "1.11.0",
82
86
  "three": "0.185.1",
83
87
  "three-mesh-bvh": "0.9.14",
84
- "threenative-asset-mcp": "0.14.0",
88
+ "threenative-asset-mcp": "0.15.0",
85
89
  "threenative-sculpt-mcp": "0.2.2",
86
90
  "zustand": "5.0.14"
87
91
  },
@@ -95,12 +99,12 @@
95
99
  "tsup": "8.5.1",
96
100
  "typescript": "npm:@typescript/typescript6@6.0.2",
97
101
  "@typescript/native": "npm:typescript@7.0.2",
98
- "threenative-engine-mcp": "0.2.6",
99
- "threenative-blender-mcp": "0.1.6",
100
- "@threenative/playtest": "0.3.6"
102
+ "@threenative/playtest": "0.3.9",
103
+ "threenative-engine-mcp": "0.2.9",
104
+ "threenative-animation-mcp": "0.1.6"
101
105
  },
102
106
  "peerDependencies": {
103
- "@threenative/playtest": ">=0.3.6 <0.4.0",
107
+ "@threenative/playtest": ">=0.3.9 <0.4.0",
104
108
  "react": ">=19.2.0 <20",
105
109
  "react-reconciler": ">=0.33.0 <0.34"
106
110
  },
@@ -117,7 +121,7 @@
117
121
  },
118
122
  "scripts": {
119
123
  "postinstall": "node ./scripts/postinstall.mjs",
120
- "build": "node scripts/generate-version.mjs && tsup --config tsup.config.ts && node scripts/bundle-engine-mcp.mjs && node scripts/bundle-blender-mcp.mjs && publint",
124
+ "build": "node scripts/generate-version.mjs && tsup --config tsup.config.ts && node scripts/bundle-engine-mcp.mjs && node scripts/bundle-animation-mcp.mjs && publint",
121
125
  "typecheck": "tsc --noEmit",
122
126
  "test": "publint --strict"
123
127
  }
@@ -22416,3 +22416,311 @@ index 2e3a84341d1d3af4e4b8c0327c4ad2cde4df0c5b..c4c33cf3060d8c75398000589ed4e3f9
22416
22416
 
22417
22417
  if ( texture.isCubeTexture ) {
22418
22418
 
22419
+ diff --git a/build/three.webgpu.js b/build/three.webgpu.js
22420
+ index d835e23ec85acea5fd8ba15a2b76c83b83561c3c..754d9674a2398367cacecbfaaaca526db6edcf41 100644
22421
+ --- a/build/three.webgpu.js
22422
+ +++ b/build/three.webgpu.js
22423
+ @@ -18829,6 +18829,31 @@ function getSkinnedNormalAndTangent( boneMatrices, normal, tangent, bindMatrix,
22424
+
22425
+ }
22426
+
22427
+ +/**
22428
+ + * The previous frame's bone matrices for one skeleton, created on first use at the current pose
22429
+ + * so a skeleton's first frame has zero skin motion.
22430
+ + *
22431
+ + * @param {Skeleton} skeleton - The skeleton.
22432
+ + * @returns {{previousBoneMatrices: Float32Array}} The skeleton's bone history.
22433
+ + */
22434
+ +function previousBoneMatricesData( skeleton ) {
22435
+ +
22436
+ + let data = _previousBoneMatricesData.get( skeleton );
22437
+ +
22438
+ + if ( data === undefined ) {
22439
+ +
22440
+ + skeleton.update();
22441
+ +
22442
+ + data = { previousBoneMatrices: new Float32Array( skeleton.boneMatrices ) };
22443
+ +
22444
+ + _previousBoneMatricesData.set( skeleton, data );
22445
+ +
22446
+ + }
22447
+ +
22448
+ + return data;
22449
+ +
22450
+ +}
22451
+ +
22452
+ /**
22453
+ * Retrieves or initializes the previous frame skinned position node for motion vectors.
22454
+ * Uses a WeakMap to cache previous frame bone matrix arrays and their TSL buffer nodes.
22455
+ @@ -18842,24 +18867,15 @@ function getSkinnedNormalAndTangent( boneMatrices, normal, tangent, bindMatrix,
22456
+ */
22457
+ function getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode ) {
22458
+
22459
+ - const skeleton = skinnedMesh.skeleton;
22460
+ -
22461
+ - let data = _previousBoneMatricesData.get( skeleton );
22462
+ -
22463
+ - if ( data === undefined ) {
22464
+ -
22465
+ - skeleton.update();
22466
+ + // Meshes that share a material and geometry share this program, so the bone history is the
22467
+ + // drawn object's own skeleton's, resolved per object like the current bones, never the
22468
+ + // skeleton the program happened to be built for.
22469
+ + const previousBoneMatricesNode = buffer( previousBoneMatricesData( skinnedMesh.skeleton ).previousBoneMatrices, 'mat4', skinnedMesh.skeleton.bones.length ).onObjectUpdate( ( { object } ) => {
22470
+
22471
+ - const previousBoneMatrices = new Float32Array( skeleton.boneMatrices );
22472
+ -
22473
+ - data = {
22474
+ - previousBoneMatrices,
22475
+ - node: buffer( previousBoneMatrices, 'mat4', skeleton.bones.length )
22476
+ - };
22477
+ -
22478
+ - _previousBoneMatricesData.set( skeleton, data );
22479
+ + const mesh = object?.isSkinnedMesh === true ? object : skinnedMesh;
22480
+ + return previousBoneMatricesData( mesh.skeleton ).previousBoneMatrices;
22481
+
22482
+ - }
22483
+ + } );
22484
+
22485
+ // The previous bones and world matrix must use the same frame's bind inverse.
22486
+ const previousBindMatrixInverse = uniform( skinnedMesh.bindMatrixInverse, 'mat4' ).onObjectUpdate( ( { object } ) => {
22487
+ @@ -18869,7 +18885,7 @@ function getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInve
22488
+
22489
+ } );
22490
+
22491
+ - return getSkinnedPosition( data.node, positionPrevious, bindMatrixNode, previousBindMatrixInverse, skinIndexNode, skinWeightNode );
22492
+ + return getSkinnedPosition( previousBoneMatricesNode, positionPrevious, bindMatrixNode, previousBindMatrixInverse, skinIndexNode, skinWeightNode );
22493
+
22494
+ }
22495
+
22496
+ @@ -18897,11 +18913,13 @@ const skinning = /*@__PURE__*/ Fn( ( [ skinnedMesh ], builder ) => {
22497
+
22498
+ _skeletonsUpdated.set( skeleton, frameId );
22499
+
22500
+ - const skeletonData = _previousBoneMatricesData.get( skeleton );
22501
+ + // A scheduled history means velocity is on: the skeleton gets its own history even when
22502
+ + // the program was built for another skeleton.
22503
+ + const scheduledPrevious = object[ Symbol.for( 'threenative.velocity.previousBoneMatrices' ) ];
22504
+ + const skeletonData = scheduledPrevious !== undefined ? previousBoneMatricesData( skeleton ) : _previousBoneMatricesData.get( skeleton );
22505
+
22506
+ if ( skeletonData !== undefined ) {
22507
+
22508
+ - const scheduledPrevious = object[ Symbol.for( 'threenative.velocity.previousBoneMatrices' ) ];
22509
+ skeletonData.previousBoneMatrices.set( scheduledPrevious ?? skeleton.boneMatrices );
22510
+
22511
+ }
22512
+ diff --git a/build/three.webgpu.nodes.js b/build/three.webgpu.nodes.js
22513
+ index d030da8cf893d8f222330d437b45297e3a06c0d0..46b9864470ab0489d095513c7ab6493e25ae5c17 100644
22514
+ --- a/build/three.webgpu.nodes.js
22515
+ +++ b/build/three.webgpu.nodes.js
22516
+ @@ -18815,6 +18815,31 @@ function getSkinnedNormalAndTangent( boneMatrices, normal, tangent, bindMatrix,
22517
+
22518
+ }
22519
+
22520
+ +/**
22521
+ + * The previous frame's bone matrices for one skeleton, created on first use at the current pose
22522
+ + * so a skeleton's first frame has zero skin motion.
22523
+ + *
22524
+ + * @param {Skeleton} skeleton - The skeleton.
22525
+ + * @returns {{previousBoneMatrices: Float32Array}} The skeleton's bone history.
22526
+ + */
22527
+ +function previousBoneMatricesData( skeleton ) {
22528
+ +
22529
+ + let data = _previousBoneMatricesData.get( skeleton );
22530
+ +
22531
+ + if ( data === undefined ) {
22532
+ +
22533
+ + skeleton.update();
22534
+ +
22535
+ + data = { previousBoneMatrices: new Float32Array( skeleton.boneMatrices ) };
22536
+ +
22537
+ + _previousBoneMatricesData.set( skeleton, data );
22538
+ +
22539
+ + }
22540
+ +
22541
+ + return data;
22542
+ +
22543
+ +}
22544
+ +
22545
+ /**
22546
+ * Retrieves or initializes the previous frame skinned position node for motion vectors.
22547
+ * Uses a WeakMap to cache previous frame bone matrix arrays and their TSL buffer nodes.
22548
+ @@ -18828,24 +18853,15 @@ function getSkinnedNormalAndTangent( boneMatrices, normal, tangent, bindMatrix,
22549
+ */
22550
+ function getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode ) {
22551
+
22552
+ - const skeleton = skinnedMesh.skeleton;
22553
+ -
22554
+ - let data = _previousBoneMatricesData.get( skeleton );
22555
+ -
22556
+ - if ( data === undefined ) {
22557
+ -
22558
+ - skeleton.update();
22559
+ + // Meshes that share a material and geometry share this program, so the bone history is the
22560
+ + // drawn object's own skeleton's, resolved per object like the current bones, never the
22561
+ + // skeleton the program happened to be built for.
22562
+ + const previousBoneMatricesNode = buffer( previousBoneMatricesData( skinnedMesh.skeleton ).previousBoneMatrices, 'mat4', skinnedMesh.skeleton.bones.length ).onObjectUpdate( ( { object } ) => {
22563
+
22564
+ - const previousBoneMatrices = new Float32Array( skeleton.boneMatrices );
22565
+ -
22566
+ - data = {
22567
+ - previousBoneMatrices,
22568
+ - node: buffer( previousBoneMatrices, 'mat4', skeleton.bones.length )
22569
+ - };
22570
+ -
22571
+ - _previousBoneMatricesData.set( skeleton, data );
22572
+ + const mesh = object?.isSkinnedMesh === true ? object : skinnedMesh;
22573
+ + return previousBoneMatricesData( mesh.skeleton ).previousBoneMatrices;
22574
+
22575
+ - }
22576
+ + } );
22577
+
22578
+ // The previous bones and world matrix must use the same frame's bind inverse.
22579
+ const previousBindMatrixInverse = uniform( skinnedMesh.bindMatrixInverse, 'mat4' ).onObjectUpdate( ( { object } ) => {
22580
+ @@ -18855,7 +18871,7 @@ function getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInve
22581
+
22582
+ } );
22583
+
22584
+ - return getSkinnedPosition( data.node, positionPrevious, bindMatrixNode, previousBindMatrixInverse, skinIndexNode, skinWeightNode );
22585
+ + return getSkinnedPosition( previousBoneMatricesNode, positionPrevious, bindMatrixNode, previousBindMatrixInverse, skinIndexNode, skinWeightNode );
22586
+
22587
+ }
22588
+
22589
+ diff --git a/src/nodes/accessors/Skinning.js b/src/nodes/accessors/Skinning.js
22590
+ index 76303e765bc29853cfd7f139dd3ec76545b70798..7e77f7559b7e988777d22585c64f37f72aa1f666 100644
22591
+ --- a/src/nodes/accessors/Skinning.js
22592
+ +++ b/src/nodes/accessors/Skinning.js
22593
+ @@ -85,6 +85,31 @@ function getSkinnedNormalAndTangent( boneMatrices, normal, tangent, bindMatrix,
22594
+
22595
+ }
22596
+
22597
+ +/**
22598
+ + * The previous frame's bone matrices for one skeleton, created on first use at the current pose
22599
+ + * so a skeleton's first frame has zero skin motion.
22600
+ + *
22601
+ + * @param {Skeleton} skeleton - The skeleton.
22602
+ + * @returns {{previousBoneMatrices: Float32Array}} The skeleton's bone history.
22603
+ + */
22604
+ +function previousBoneMatricesData( skeleton ) {
22605
+ +
22606
+ + let data = _previousBoneMatricesData.get( skeleton );
22607
+ +
22608
+ + if ( data === undefined ) {
22609
+ +
22610
+ + skeleton.update();
22611
+ +
22612
+ + data = { previousBoneMatrices: new Float32Array( skeleton.boneMatrices ) };
22613
+ +
22614
+ + _previousBoneMatricesData.set( skeleton, data );
22615
+ +
22616
+ + }
22617
+ +
22618
+ + return data;
22619
+ +
22620
+ +}
22621
+ +
22622
+ /**
22623
+ * Retrieves or initializes the previous frame skinned position node for motion vectors.
22624
+ * Uses a WeakMap to cache previous frame bone matrix arrays and their TSL buffer nodes.
22625
+ @@ -98,24 +123,15 @@ function getSkinnedNormalAndTangent( boneMatrices, normal, tangent, bindMatrix,
22626
+ */
22627
+ function getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode ) {
22628
+
22629
+ - const skeleton = skinnedMesh.skeleton;
22630
+ -
22631
+ - let data = _previousBoneMatricesData.get( skeleton );
22632
+ -
22633
+ - if ( data === undefined ) {
22634
+ + // Meshes that share a material and geometry share this program, so the bone history is the
22635
+ + // drawn object's own skeleton's, resolved per object like the current bones, never the
22636
+ + // skeleton the program happened to be built for.
22637
+ + const previousBoneMatricesNode = buffer( previousBoneMatricesData( skinnedMesh.skeleton ).previousBoneMatrices, 'mat4', skinnedMesh.skeleton.bones.length ).onObjectUpdate( ( { object } ) => {
22638
+
22639
+ - skeleton.update();
22640
+ -
22641
+ - const previousBoneMatrices = new Float32Array( skeleton.boneMatrices );
22642
+ -
22643
+ - data = {
22644
+ - previousBoneMatrices,
22645
+ - node: buffer( previousBoneMatrices, 'mat4', skeleton.bones.length )
22646
+ - };
22647
+ -
22648
+ - _previousBoneMatricesData.set( skeleton, data );
22649
+ + const mesh = object?.isSkinnedMesh === true ? object : skinnedMesh;
22650
+ + return previousBoneMatricesData( mesh.skeleton ).previousBoneMatrices;
22651
+
22652
+ - }
22653
+ + } );
22654
+
22655
+ // The previous bones and world matrix must use the same frame's bind inverse.
22656
+ const previousBindMatrixInverse = uniform( skinnedMesh.bindMatrixInverse, 'mat4' ).onObjectUpdate( ( { object } ) => {
22657
+ @@ -125,7 +141,7 @@ function getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInve
22658
+
22659
+ } );
22660
+
22661
+ - return getSkinnedPosition( data.node, positionPrevious, bindMatrixNode, previousBindMatrixInverse, skinIndexNode, skinWeightNode );
22662
+ + return getSkinnedPosition( previousBoneMatricesNode, positionPrevious, bindMatrixNode, previousBindMatrixInverse, skinIndexNode, skinWeightNode );
22663
+
22664
+ }
22665
+
22666
+ @@ -153,11 +169,13 @@ export const skinning = /*@__PURE__*/ Fn( ( [ skinnedMesh ], builder ) => {
22667
+
22668
+ _skeletonsUpdated.set( skeleton, frameId );
22669
+
22670
+ - const skeletonData = _previousBoneMatricesData.get( skeleton );
22671
+ + // A scheduled history means velocity is on: the skeleton gets its own history even when
22672
+ + // the program was built for another skeleton.
22673
+ + const scheduledPrevious = object[ Symbol.for( 'threenative.velocity.previousBoneMatrices' ) ];
22674
+ + const skeletonData = scheduledPrevious !== undefined ? previousBoneMatricesData( skeleton ) : _previousBoneMatricesData.get( skeleton );
22675
+
22676
+ if ( skeletonData !== undefined ) {
22677
+
22678
+ - const scheduledPrevious = object[ Symbol.for( 'threenative.velocity.previousBoneMatrices' ) ];
22679
+ skeletonData.previousBoneMatrices.set( scheduledPrevious ?? skeleton.boneMatrices );
22680
+
22681
+ }
22682
+ diff --git a/build/three.webgpu.js b/build/three.webgpu.js
22683
+ index 754d9674a2398367cacecbfaaaca526db6edcf41..1d93cf3172dedd2317007a44cd39dc1da932e96d 100644
22684
+ --- a/build/three.webgpu.js
22685
+ +++ b/build/three.webgpu.js
22686
+ @@ -26456,8 +26456,8 @@ class PMREMGenerator {
22687
+ try {
22688
+
22689
+ this._init( cubeUVRenderTarget );
22690
+ - // One fence covers as much queued work as the heaviest single face (the first GGX filter pass).
22691
+ - this._fenceBudget = this._sizeLods[ 1 ] * this._sizeLods[ 1 ] * GGX_SAMPLES;
22692
+ + // One fence covers the heaviest single face (the first GGX filter pass), never less than a 256 cube's: a fence waits behind every queued frame.
22693
+ + this._fenceBudget = Math.max( 128 * 128, this._sizeLods[ 1 ] * this._sizeLods[ 1 ] ) * GGX_SAMPLES;
22694
+ this._fencePending = 0;
22695
+ await this._textureToCubeUVAsync( texture, cubeUVRenderTarget );
22696
+ await this._applyPMREMAsync( cubeUVRenderTarget );
22697
+ diff --git a/build/three.webgpu.nodes.js b/build/three.webgpu.nodes.js
22698
+ index 46b9864470ab0489d095513c7ab6493e25ae5c17..aef965e3a94bfca6d3f04ebc2147bf03bdeff7c8 100644
22699
+ --- a/build/three.webgpu.nodes.js
22700
+ +++ b/build/three.webgpu.nodes.js
22701
+ @@ -26438,8 +26438,8 @@ class PMREMGenerator {
22702
+ try {
22703
+
22704
+ this._init( cubeUVRenderTarget );
22705
+ - // One fence covers as much queued work as the heaviest single face (the first GGX filter pass).
22706
+ - this._fenceBudget = this._sizeLods[ 1 ] * this._sizeLods[ 1 ] * GGX_SAMPLES;
22707
+ + // One fence covers the heaviest single face (the first GGX filter pass), never less than a 256 cube's: a fence waits behind every queued frame.
22708
+ + this._fenceBudget = Math.max( 128 * 128, this._sizeLods[ 1 ] * this._sizeLods[ 1 ] ) * GGX_SAMPLES;
22709
+ this._fencePending = 0;
22710
+ await this._textureToCubeUVAsync( texture, cubeUVRenderTarget );
22711
+ await this._applyPMREMAsync( cubeUVRenderTarget );
22712
+ diff --git a/src/renderers/common/extras/PMREMGenerator.js b/src/renderers/common/extras/PMREMGenerator.js
22713
+ index ace19db76fab3f08ed4d581d1e272066a24c34aa..15a57eaa1364af2efe5596a7c78ab7c487216f66 100644
22714
+ --- a/src/renderers/common/extras/PMREMGenerator.js
22715
+ +++ b/src/renderers/common/extras/PMREMGenerator.js
22716
+ @@ -419,8 +419,8 @@ class PMREMGenerator {
22717
+ try {
22718
+
22719
+ this._init( cubeUVRenderTarget );
22720
+ - // One fence covers as much queued work as the heaviest single face (the first GGX filter pass).
22721
+ - this._fenceBudget = this._sizeLods[ 1 ] * this._sizeLods[ 1 ] * GGX_SAMPLES;
22722
+ + // One fence covers the heaviest single face (the first GGX filter pass), never less than a 256 cube's: a fence waits behind every queued frame.
22723
+ + this._fenceBudget = Math.max( 128 * 128, this._sizeLods[ 1 ] * this._sizeLods[ 1 ] ) * GGX_SAMPLES;
22724
+ this._fencePending = 0;
22725
+ await this._textureToCubeUVAsync( texture, cubeUVRenderTarget );
22726
+ await this._applyPMREMAsync( cubeUVRenderTarget );