@onerjs/core 8.54.3 → 8.54.5

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 (211) hide show
  1. package/DeviceInput/webDeviceInputSystem.js +4 -0
  2. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  3. package/Engines/WebGPU/Extensions/engine.cubeTexture.pure.js +1 -1
  4. package/Engines/WebGPU/Extensions/engine.cubeTexture.pure.js.map +1 -1
  5. package/Engines/WebGPU/Extensions/engine.rawTexture.pure.js +2 -2
  6. package/Engines/WebGPU/Extensions/engine.rawTexture.pure.js.map +1 -1
  7. package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -0
  8. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +18 -4
  9. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  10. package/Engines/WebGPU/webgpuCacheTextureView.d.ts +13 -0
  11. package/Engines/WebGPU/webgpuCacheTextureView.js +32 -0
  12. package/Engines/WebGPU/webgpuCacheTextureView.js.map +1 -0
  13. package/Engines/WebGPU/webgpuRenderTargetWrapper.d.ts +10 -0
  14. package/Engines/WebGPU/webgpuRenderTargetWrapper.js +10 -0
  15. package/Engines/WebGPU/webgpuRenderTargetWrapper.js.map +1 -1
  16. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.pure.js +57 -4
  17. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.pure.js.map +1 -1
  18. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
  19. package/Engines/WebGPU/webgpuTextureManager.js +4 -2
  20. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  21. package/Engines/abstractEngine.pure.js +2 -2
  22. package/Engines/abstractEngine.pure.js.map +1 -1
  23. package/Engines/thinNativeEngine.pure.d.ts +5 -0
  24. package/Engines/thinNativeEngine.pure.js +29 -6
  25. package/Engines/thinNativeEngine.pure.js.map +1 -1
  26. package/Engines/webgpuEngine.pure.d.ts +1 -0
  27. package/Engines/webgpuEngine.pure.js +21 -8
  28. package/Engines/webgpuEngine.pure.js.map +1 -1
  29. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.d.ts +95 -1
  30. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js +169 -4
  31. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js.map +1 -1
  32. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.d.ts +21 -6
  33. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.js +28 -26
  34. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.js.map +1 -1
  35. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.d.ts +30 -2
  36. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.js +111 -29
  37. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.js.map +1 -1
  38. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.d.ts +56 -2
  39. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.js +99 -14
  40. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.js.map +1 -1
  41. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js +10 -2
  42. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js.map +1 -1
  43. package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js +21 -1
  44. package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js.map +1 -1
  45. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +18 -0
  46. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +29 -2
  47. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
  48. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.d.ts +15 -0
  49. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js +44 -7
  50. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js.map +1 -1
  51. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.d.ts +9 -0
  52. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js +9 -1
  53. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js.map +1 -1
  54. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.d.ts +7 -0
  55. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js +8 -1
  56. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js.map +1 -1
  57. package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.d.ts +5 -0
  58. package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.js +8 -0
  59. package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.js.map +1 -0
  60. package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.d.ts +37 -0
  61. package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.js +44 -0
  62. package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.js.map +1 -0
  63. package/FlowGraph/Blocks/Event/index.d.ts +1 -0
  64. package/FlowGraph/Blocks/Event/index.js +1 -0
  65. package/FlowGraph/Blocks/Event/index.js.map +1 -1
  66. package/FlowGraph/Blocks/Event/pure.d.ts +1 -0
  67. package/FlowGraph/Blocks/Event/pure.js +1 -0
  68. package/FlowGraph/Blocks/Event/pure.js.map +1 -1
  69. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.d.ts +4 -1
  70. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.js +67 -2
  71. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.js.map +1 -1
  72. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.d.ts +13 -0
  73. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js +102 -7
  74. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js.map +1 -1
  75. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js +5 -1
  76. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js.map +1 -1
  77. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js +5 -1
  78. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js.map +1 -1
  79. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.d.ts +11 -2
  80. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js +21 -3
  81. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js.map +1 -1
  82. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.pure.js +25 -4
  83. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.pure.js.map +1 -1
  84. package/FlowGraph/Blocks/flowGraphBlockFactory.js +18 -0
  85. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  86. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +9 -0
  87. package/FlowGraph/Blocks/flowGraphBlockNames.js +9 -0
  88. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
  89. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +17 -3
  90. package/FlowGraph/CustomTypes/flowGraphMatrix.js +27 -21
  91. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
  92. package/FlowGraph/flowGraphContext.d.ts +23 -0
  93. package/FlowGraph/flowGraphContext.js +29 -0
  94. package/FlowGraph/flowGraphContext.js.map +1 -1
  95. package/FlowGraph/flowGraphCoordinator.d.ts +58 -1
  96. package/FlowGraph/flowGraphCoordinator.js +72 -0
  97. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  98. package/FlowGraph/flowGraphDelayRegistry.d.ts +31 -0
  99. package/FlowGraph/flowGraphDelayRegistry.js +50 -0
  100. package/FlowGraph/flowGraphDelayRegistry.js.map +1 -0
  101. package/FlowGraph/flowGraphHostResolver.d.ts +69 -0
  102. package/FlowGraph/flowGraphHostResolver.js +25 -0
  103. package/FlowGraph/flowGraphHostResolver.js.map +1 -0
  104. package/FlowGraph/flowGraphMath.d.ts +48 -1
  105. package/FlowGraph/flowGraphMath.js +169 -4
  106. package/FlowGraph/flowGraphMath.js.map +1 -1
  107. package/FlowGraph/flowGraphPathConverterComponent.d.ts +14 -3
  108. package/FlowGraph/flowGraphPathConverterComponent.js +110 -18
  109. package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -1
  110. package/FlowGraph/flowGraphSignalConnection.pure.js +7 -1
  111. package/FlowGraph/flowGraphSignalConnection.pure.js.map +1 -1
  112. package/FlowGraph/index.d.ts +2 -0
  113. package/FlowGraph/index.js +2 -0
  114. package/FlowGraph/index.js.map +1 -1
  115. package/FlowGraph/pure.d.ts +2 -0
  116. package/FlowGraph/pure.js +2 -0
  117. package/FlowGraph/pure.js.map +1 -1
  118. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +3 -1
  119. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
  120. package/Maths/math.vector.pure.d.ts +10 -0
  121. package/Maths/math.vector.pure.js +13 -0
  122. package/Maths/math.vector.pure.js.map +1 -1
  123. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +216 -1
  124. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +714 -67
  125. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  126. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +81 -4
  127. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +487 -54
  128. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  129. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.d.ts +19 -0
  130. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js +24 -0
  131. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js.map +1 -1
  132. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +48 -10
  133. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -1
  134. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +5 -1
  135. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js.map +1 -1
  136. package/Meshes/abstractMesh.pure.js +5 -3
  137. package/Meshes/abstractMesh.pure.js.map +1 -1
  138. package/Misc/greasedLineTools.js +1 -1
  139. package/Misc/greasedLineTools.js.map +1 -1
  140. package/Misc/tools.pure.js +14 -2
  141. package/Misc/tools.pure.js.map +1 -1
  142. package/Particles/gpuParticleSystem.pure.d.ts +66 -1
  143. package/Particles/gpuParticleSystem.pure.js +189 -49
  144. package/Particles/gpuParticleSystem.pure.js.map +1 -1
  145. package/Physics/v2/Plugins/havokPlugin.d.ts +15 -0
  146. package/Physics/v2/Plugins/havokPlugin.js +16 -6
  147. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  148. package/Physics/v2/characterController.js +71 -19
  149. package/Physics/v2/characterController.js.map +1 -1
  150. package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.d.ts +5 -0
  151. package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.js +29 -0
  152. package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.js.map +1 -0
  153. package/ShadersWGSL/ShadersInclude/lightFragment.js +2 -3
  154. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
  155. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
  156. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +2 -17
  157. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  158. package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.d.ts +6 -0
  159. package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js +123 -0
  160. package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -0
  161. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.d.ts +1 -1
  162. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +2 -111
  163. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  164. package/ShadersWGSL/background.fragment.js +2 -1
  165. package/ShadersWGSL/background.fragment.js.map +1 -1
  166. package/ShadersWGSL/default.fragment.js +2 -1
  167. package/ShadersWGSL/default.fragment.js.map +1 -1
  168. package/ShadersWGSL/openpbr.fragment.js +2 -1
  169. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  170. package/ShadersWGSL/pbr.fragment.js +2 -1
  171. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  172. package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +3 -9
  173. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js +4 -11
  174. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -1
  175. package/XR/features/WebXRAbstractFeature.d.ts +9 -0
  176. package/XR/features/WebXRAbstractFeature.js +16 -0
  177. package/XR/features/WebXRAbstractFeature.js.map +1 -1
  178. package/XR/features/WebXRDepthSensing.pure.d.ts +7 -0
  179. package/XR/features/WebXRDepthSensing.pure.js +350 -39
  180. package/XR/features/WebXRDepthSensing.pure.js.map +1 -1
  181. package/XR/features/WebXRImageTracking.pure.js.map +1 -1
  182. package/XR/features/WebXRLayers.pure.d.ts +6 -5
  183. package/XR/features/WebXRLayers.pure.js +65 -8
  184. package/XR/features/WebXRLayers.pure.js.map +1 -1
  185. package/XR/features/WebXRRawCameraAccess.pure.js +9 -2
  186. package/XR/features/WebXRRawCameraAccess.pure.js.map +1 -1
  187. package/XR/features/WebXRSpaceWarp.pure.d.ts +0 -1
  188. package/XR/features/WebXRSpaceWarp.pure.js +13 -4
  189. package/XR/features/WebXRSpaceWarp.pure.js.map +1 -1
  190. package/XR/features/WebXRWalkingLocomotion.pure.js.map +1 -1
  191. package/XR/webXRCamera.js +27 -0
  192. package/XR/webXRCamera.js.map +1 -1
  193. package/XR/webXRFeatureWarningRegistry.d.ts +14 -0
  194. package/XR/webXRFeatureWarningRegistry.js +19 -0
  195. package/XR/webXRFeatureWarningRegistry.js.map +1 -0
  196. package/XR/webXRFeaturesManager.d.ts +5 -0
  197. package/XR/webXRFeaturesManager.js +23 -4
  198. package/XR/webXRFeaturesManager.js.map +1 -1
  199. package/XR/webXRGraphicsBinding.d.ts +17 -10
  200. package/XR/webXRGraphicsBinding.js +8 -5
  201. package/XR/webXRGraphicsBinding.js.map +1 -1
  202. package/XR/webXRSessionManager.d.ts +3 -5
  203. package/XR/webXRSessionManager.js +1 -3
  204. package/XR/webXRSessionManager.js.map +1 -1
  205. package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +21 -5
  206. package/XR/webXRWebGPURenderTargetTextureProvider.js +38 -10
  207. package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -1
  208. package/package.json +1 -1
  209. package/scene.pure.d.ts +7 -0
  210. package/scene.pure.js +8 -0
  211. package/scene.pure.js.map +1 -1
@@ -82,7 +82,7 @@ export class PhysicsCharacterController {
82
82
  this._stepUpSavedManifold = [];
83
83
  this._contactAngleSensitivity = 10.0;
84
84
  this._tmpMatrix = new Matrix();
85
- this._tmpVecs = BuildArray(32, Vector3.Zero);
85
+ this._tmpVecs = BuildArray(36, Vector3.Zero);
86
86
  /**
87
87
  * minimum distance to make contact
88
88
  * default 0.05
@@ -1346,13 +1346,26 @@ export class PhysicsCharacterController {
1346
1346
  const horizDir = this._tmpVecs[30];
1347
1347
  horizVel.scaleToRef(1 / horizVelLen, horizDir);
1348
1348
  const horizDist = horizVelLen * remainingTime;
1349
- if (horizDist <= eps) {
1350
- return -1;
1351
- }
1352
1349
  // 2. Solver must have hit a blocking, non-walkable, opposing constraint
1353
1350
  if (this._findBlockingConstraintIndex(simplexOutput, constraints, horizDir) < 0) {
1354
1351
  return -1;
1355
1352
  }
1353
+ // 基于实际接触点计算前向最小扫描距离。
1354
+ // 角色被台阶垂直面阻挡时,接触点位于角色形状边界与墙面交点处。
1355
+ // 前向扫描需要超过这个距离,下扫描才能落在台阶顶面而非垂直面上。
1356
+ let minForwardDist = this.keepDistance;
1357
+ for (let i = 0; i < this._manifold.length; i++) {
1358
+ const contact = this._manifold[i];
1359
+ if (contact.normal.dot(horizDir) >= -1e-3) {
1360
+ continue;
1361
+ }
1362
+ contact.position.subtractToRef(this._position, this._tmpVecs[31]);
1363
+ const horizContactDist = this._tmpVecs[31].dot(horizDir);
1364
+ if (horizContactDist > 0) {
1365
+ minForwardDist = Math.max(minForwardDist, horizContactDist + this.keepDistance);
1366
+ }
1367
+ }
1368
+ const sweepDist = Math.max(horizDist, minForwardDist);
1356
1369
  // 3. Up-cast: find available head-room up to stepHeight
1357
1370
  const upEnd = this._tmpVecs[31];
1358
1371
  upUnit.scaleToRef(stepHeight, upEnd);
@@ -1369,10 +1382,10 @@ export class PhysicsCharacterController {
1369
1382
  if (stepClear <= eps) {
1370
1383
  return -1;
1371
1384
  }
1372
- // 4. Forward-cast: sweep from the elevated position by the requested horizontal distance
1373
- const elevated = upUnit.scale(stepClear);
1385
+ // 4. Forward-cast: sweep from the elevated position by sweepDist
1386
+ const elevated = upUnit.scaleToRef(stepClear, this._tmpVecs[32]);
1374
1387
  elevated.addInPlace(this._position);
1375
- const fwdEnd = horizDir.scale(horizDist);
1388
+ const fwdEnd = horizDir.scaleToRef(sweepDist, this._tmpVecs[33]);
1376
1389
  fwdEnd.addInPlace(elevated);
1377
1390
  this._castWithCollectors(elevated, fwdEnd, this._castCollector);
1378
1391
  let fwdFrac = 1.0;
@@ -1383,16 +1396,16 @@ export class PhysicsCharacterController {
1383
1396
  }
1384
1397
  fwdFrac = fwdHit.fraction;
1385
1398
  }
1386
- // Backoff by keepDistance along horizDir
1387
- const fwdFracAdjusted = Math.max(0, Math.min(1, fwdFrac - this.keepDistance / horizDist));
1399
+ // Backoff by keepDistance along horizDir, using sweepDist
1400
+ const fwdFracAdjusted = Math.max(0, Math.min(1, fwdFrac - this.keepDistance / sweepDist));
1388
1401
  if (fwdFracAdjusted <= eps) {
1389
1402
  return -1;
1390
1403
  }
1391
- const fwdEndAdjusted = horizDir.scale(horizDist * fwdFracAdjusted);
1404
+ const fwdEndAdjusted = horizDir.scaleToRef(sweepDist * fwdFracAdjusted, this._tmpVecs[34]);
1392
1405
  fwdEndAdjusted.addInPlace(elevated);
1393
1406
  // 5. Down-cast: drop from forward position to find walkable landing
1394
1407
  const downDist = stepClear + 2 * this.keepDistance;
1395
- const downEnd = upUnit.scale(-downDist);
1408
+ const downEnd = upUnit.scaleToRef(-downDist, this._tmpVecs[35]);
1396
1409
  downEnd.addInPlace(fwdEndAdjusted);
1397
1410
  this._castWithCollectors(fwdEndAdjusted, downEnd, this._castCollector);
1398
1411
  const downHit = this._getClosestCastHit();
@@ -1435,7 +1448,7 @@ export class PhysicsCharacterController {
1435
1448
  for (let i = 0; i < this._manifold.length; i++) {
1436
1449
  const c = this._manifold[i];
1437
1450
  if (c.normal.dot(upUnit) < maxSlope && c.distance < -this.keepDistance) {
1438
- // Penetrating a non-walkable surface at landing — reject and restore manifold
1451
+ // Penetrating a non-walkable surface at landing - reject and restore manifold
1439
1452
  this._manifold.length = savedManifold.length;
1440
1453
  for (let j = 0; j < savedManifold.length; j++) {
1441
1454
  this._manifold[j] = savedManifold[j];
@@ -1443,11 +1456,50 @@ export class PhysicsCharacterController {
1443
1456
  return -1;
1444
1457
  }
1445
1458
  }
1446
- // 7. Commit
1447
- const displacement = landingPos.subtract(this._position);
1448
- this._lastDisplacement.copyFrom(displacement);
1449
- this._position.copyFrom(landingPos);
1450
- return remainingTime * fwdFracAdjusted;
1459
+ // 7. Commit - 分帧抬升 + 水平限速
1460
+ // 每帧只抬高 horizDist(速度×dt),分多帧完成垂直跨越。
1461
+ // 当累积高度足够时,接触点从胶囊圆柱体转移到底部半球,
1462
+ // simplex solver 自然接管,产生平滑滑行收尾。
1463
+ const verticalLimit = Math.min(horizDist, this.keepContactTolerance);
1464
+ if (heightDelta > verticalLimit) {
1465
+ // 渐进抬升:本帧只抬高 verticalLimit,不前进,下帧继续
1466
+ const partialUp = this._tmpVecs[28];
1467
+ upUnit.scaleToRef(verticalLimit, partialUp);
1468
+ this._position.addInPlace(partialUp);
1469
+ // 设置水平方向预测位移,供下次迭代 cast 使用
1470
+ this._velocity.scaleToRef(remainingTime, this._lastDisplacement);
1471
+ // 在新高度刷新流形
1472
+ this._refreshManifoldAtPosition(this._position);
1473
+ // 消耗全部剩余时间,本帧结束,下帧继续抬升
1474
+ return remainingTime;
1475
+ }
1476
+ // 最终抬升:剩余高度不足一帧位移,抬升到位并水平前进
1477
+ const verticalMove = this._tmpVecs[28];
1478
+ upUnit.scaleToRef(heightDelta, verticalMove);
1479
+ const horizontalMove = this._tmpVecs[29];
1480
+ landingDelta.subtractToRef(verticalMove, horizontalMove);
1481
+ const horizontalDist = horizontalMove.length();
1482
+ // 垂直:抬起到台阶顶面高度
1483
+ this._position.addInPlace(verticalMove);
1484
+ // 水平:限制为本帧速度位移
1485
+ let timeConsumed;
1486
+ if (horizontalDist > eps) {
1487
+ if (horizontalDist > horizDist) {
1488
+ horizontalMove.scaleInPlace(horizDist / horizontalDist);
1489
+ timeConsumed = remainingTime;
1490
+ }
1491
+ else {
1492
+ timeConsumed = Math.min(horizontalDist / horizVelLen, remainingTime);
1493
+ }
1494
+ this._position.addInPlace(horizontalMove);
1495
+ this._lastDisplacement.copyFrom(horizontalMove);
1496
+ }
1497
+ else {
1498
+ this._velocity.scaleToRef(remainingTime, this._lastDisplacement);
1499
+ timeConsumed = 0;
1500
+ }
1501
+ this._refreshManifoldAtPosition(this._position);
1502
+ return timeConsumed;
1451
1503
  }
1452
1504
  _resolveContacts(deltaTime, gravity) {
1453
1505
  const eps = 1e-12;
@@ -1537,9 +1589,9 @@ export class PhysicsCharacterController {
1537
1589
  const ir = invOrientation.getRowToRef(0, TmpVectors.Vector4[0]);
1538
1590
  it.setRowFromFloats(0, mp.inertia.x * ir.x, mp.inertia.x * ir.y, mp.inertia.x * ir.z, 0);
1539
1591
  invOrientation.getRowToRef(1, ir);
1540
- it.setRowFromFloats(0, mp.inertia.y * ir.x, mp.inertia.y * ir.y, mp.inertia.y * ir.z, 0);
1592
+ it.setRowFromFloats(1, mp.inertia.y * ir.x, mp.inertia.y * ir.y, mp.inertia.y * ir.z, 0);
1541
1593
  invOrientation.getRowToRef(2, ir);
1542
- it.setRowFromFloats(0, mp.inertia.z * ir.x, mp.inertia.z * ir.y, mp.inertia.z * ir.z, 0);
1594
+ it.setRowFromFloats(2, mp.inertia.z * ir.x, mp.inertia.z * ir.y, mp.inertia.z * ir.z, 0);
1543
1595
  invOrientation.multiplyToRef(it, this._tmpMatrix);
1544
1596
  return this._tmpMatrix;
1545
1597
  }