@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.
- package/DeviceInput/webDeviceInputSystem.js +4 -0
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.pure.js +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.pure.js +2 -2
- package/Engines/WebGPU/Extensions/engine.rawTexture.pure.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -0
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +18 -4
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.d.ts +13 -0
- package/Engines/WebGPU/webgpuCacheTextureView.js +32 -0
- package/Engines/WebGPU/webgpuCacheTextureView.js.map +1 -0
- package/Engines/WebGPU/webgpuRenderTargetWrapper.d.ts +10 -0
- package/Engines/WebGPU/webgpuRenderTargetWrapper.js +10 -0
- package/Engines/WebGPU/webgpuRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.pure.js +57 -4
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.pure.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +4 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.pure.js +2 -2
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +5 -0
- package/Engines/thinNativeEngine.pure.js +29 -6
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +1 -0
- package/Engines/webgpuEngine.pure.js +21 -8
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.d.ts +95 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js +169 -4
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.d.ts +21 -6
- package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.js +28 -26
- package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.d.ts +30 -2
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.js +111 -29
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.d.ts +56 -2
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.js +99 -14
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js +10 -2
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js +21 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +18 -0
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +29 -2
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.d.ts +15 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js +44 -7
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.d.ts +9 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js +9 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.d.ts +7 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js +8 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.d.ts +5 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.js +8 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.d.ts +37 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.js +44 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Event/index.d.ts +1 -0
- package/FlowGraph/Blocks/Event/index.js +1 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/pure.d.ts +1 -0
- package/FlowGraph/Blocks/Event/pure.js +1 -0
- package/FlowGraph/Blocks/Event/pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.d.ts +4 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.js +67 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.d.ts +13 -0
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js +102 -7
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.d.ts +11 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js +21 -3
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.pure.js +25 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +18 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +9 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js +9 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +17 -3
- package/FlowGraph/CustomTypes/flowGraphMatrix.js +27 -21
- package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +23 -0
- package/FlowGraph/flowGraphContext.js +29 -0
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +58 -1
- package/FlowGraph/flowGraphCoordinator.js +72 -0
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphDelayRegistry.d.ts +31 -0
- package/FlowGraph/flowGraphDelayRegistry.js +50 -0
- package/FlowGraph/flowGraphDelayRegistry.js.map +1 -0
- package/FlowGraph/flowGraphHostResolver.d.ts +69 -0
- package/FlowGraph/flowGraphHostResolver.js +25 -0
- package/FlowGraph/flowGraphHostResolver.js.map +1 -0
- package/FlowGraph/flowGraphMath.d.ts +48 -1
- package/FlowGraph/flowGraphMath.js +169 -4
- package/FlowGraph/flowGraphMath.js.map +1 -1
- package/FlowGraph/flowGraphPathConverterComponent.d.ts +14 -3
- package/FlowGraph/flowGraphPathConverterComponent.js +110 -18
- package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.pure.js +7 -1
- package/FlowGraph/flowGraphSignalConnection.pure.js.map +1 -1
- package/FlowGraph/index.d.ts +2 -0
- package/FlowGraph/index.js +2 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/pure.d.ts +2 -0
- package/FlowGraph/pure.js +2 -0
- package/FlowGraph/pure.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +3 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
- package/Maths/math.vector.pure.d.ts +10 -0
- package/Maths/math.vector.pure.js +13 -0
- package/Maths/math.vector.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +216 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +714 -67
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +81 -4
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +487 -54
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.d.ts +19 -0
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js +24 -0
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +48 -10
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +5 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +5 -3
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Misc/greasedLineTools.js +1 -1
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/tools.pure.js +14 -2
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +66 -1
- package/Particles/gpuParticleSystem.pure.js +189 -49
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +15 -0
- package/Physics/v2/Plugins/havokPlugin.js +16 -6
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/characterController.js +71 -19
- package/Physics/v2/characterController.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.js +29 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +2 -3
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +2 -17
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js +123 -0
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.d.ts +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +2 -111
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/background.fragment.js +2 -1
- package/ShadersWGSL/background.fragment.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +2 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/openpbr.fragment.js +2 -1
- package/ShadersWGSL/openpbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +2 -1
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +3 -9
- package/XR/features/Layers/WebXRWebGPUCompositionLayer.js +4 -11
- package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -1
- package/XR/features/WebXRAbstractFeature.d.ts +9 -0
- package/XR/features/WebXRAbstractFeature.js +16 -0
- package/XR/features/WebXRAbstractFeature.js.map +1 -1
- package/XR/features/WebXRDepthSensing.pure.d.ts +7 -0
- package/XR/features/WebXRDepthSensing.pure.js +350 -39
- package/XR/features/WebXRDepthSensing.pure.js.map +1 -1
- package/XR/features/WebXRImageTracking.pure.js.map +1 -1
- package/XR/features/WebXRLayers.pure.d.ts +6 -5
- package/XR/features/WebXRLayers.pure.js +65 -8
- package/XR/features/WebXRLayers.pure.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.pure.js +9 -2
- package/XR/features/WebXRRawCameraAccess.pure.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.pure.d.ts +0 -1
- package/XR/features/WebXRSpaceWarp.pure.js +13 -4
- package/XR/features/WebXRSpaceWarp.pure.js.map +1 -1
- package/XR/features/WebXRWalkingLocomotion.pure.js.map +1 -1
- package/XR/webXRCamera.js +27 -0
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRFeatureWarningRegistry.d.ts +14 -0
- package/XR/webXRFeatureWarningRegistry.js +19 -0
- package/XR/webXRFeatureWarningRegistry.js.map +1 -0
- package/XR/webXRFeaturesManager.d.ts +5 -0
- package/XR/webXRFeaturesManager.js +23 -4
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRGraphicsBinding.d.ts +17 -10
- package/XR/webXRGraphicsBinding.js +8 -5
- package/XR/webXRGraphicsBinding.js.map +1 -1
- package/XR/webXRSessionManager.d.ts +3 -5
- package/XR/webXRSessionManager.js +1 -3
- package/XR/webXRSessionManager.js.map +1 -1
- package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +21 -5
- package/XR/webXRWebGPURenderTargetTextureProvider.js +38 -10
- package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +7 -0
- package/scene.pure.js +8 -0
- 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(
|
|
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
|
|
1373
|
-
const elevated = upUnit.
|
|
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.
|
|
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 /
|
|
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.
|
|
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.
|
|
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
|
|
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
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
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(
|
|
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(
|
|
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
|
}
|