@onerjs/core 8.41.5 → 8.41.7
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/Animations/animation.d.ts +6 -2
- package/Animations/animation.js +28 -4
- package/Animations/animation.js.map +1 -1
- package/Animations/animationGroup.d.ts +2 -1
- package/Animations/animationGroup.js +3 -2
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/animatorAvatar.d.ts +161 -0
- package/Animations/animatorAvatar.js +573 -0
- package/Animations/animatorAvatar.js.map +1 -0
- package/Animations/index.d.ts +1 -0
- package/Animations/index.js +1 -0
- package/Animations/index.js.map +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.d.ts +2 -2
- package/AudioV2/webAudio/webAudioSoundSource.js +12 -2
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
- package/Bones/index.d.ts +1 -0
- package/Bones/index.js +1 -0
- package/Bones/index.js.map +1 -1
- package/Bones/skeleton.d.ts +13 -0
- package/Bones/skeleton.functions.d.ts +26 -0
- package/Bones/skeleton.functions.js +91 -0
- package/Bones/skeleton.functions.js.map +1 -0
- package/Bones/skeleton.js +26 -0
- package/Bones/skeleton.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +16 -0
- package/Cameras/Inputs/geospatialCameraPointersInput.js +19 -3
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Limits/geospatialLimits.d.ts +0 -6
- package/Cameras/Limits/geospatialLimits.js +0 -6
- package/Cameras/Limits/geospatialLimits.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +5 -0
- package/Cameras/geospatialCamera.js +54 -25
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +8 -1
- package/Cameras/geospatialCameraMovement.js +29 -8
- package/Cameras/geospatialCameraMovement.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +11 -0
- package/Collisions/gpuPicker.js +148 -19
- package/Collisions/gpuPicker.js.map +1 -1
- package/Debug/skeletonViewer.d.ts +4 -8
- package/Debug/skeletonViewer.js +13 -22
- package/Debug/skeletonViewer.js.map +1 -1
- package/Engines/Extensions/engine.multiview.d.ts +2 -0
- package/Engines/Extensions/engine.multiview.js +7 -3
- package/Engines/Extensions/engine.multiview.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -2
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +4 -0
- package/Engines/constants.js +4 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -4
- package/Engines/webgpuEngine.js +8 -6
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/frameGraphContext.js +1 -1
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.js +2 -2
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/Instrumentation/engineInstrumentation.js +2 -1
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Layers/effectLayer.js +1 -3
- package/Layers/effectLayer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +2 -2
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +3 -4
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/lightingVolume.js +1 -1
- package/Lights/lightingVolume.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +37 -2
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.d.ts +109 -0
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js +210 -0
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +71 -15
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +86 -0
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +161 -0
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -0
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +0 -6
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +0 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +0 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.d.ts +14 -0
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +14 -0
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +20 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +20 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/depthSourceBlock.d.ts +13 -0
- package/Materials/Node/Blocks/Dual/depthSourceBlock.js +13 -0
- package/Materials/Node/Blocks/Dual/depthSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.d.ts +21 -0
- package/Materials/Node/Blocks/Dual/fogBlock.js +21 -0
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.d.ts +21 -0
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +21 -0
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.d.ts +38 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js +38 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +29 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +29 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.d.ts +5 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +5 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +16 -0
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +16 -0
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.d.ts +16 -0
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +16 -0
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +34 -0
- package/Materials/Node/Blocks/Dual/textureBlock.js +34 -0
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.d.ts +17 -0
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +17 -2
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.d.ts +7 -0
- package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.js +7 -0
- package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +21 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +21 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +10 -0
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +10 -0
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.d.ts +28 -0
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +28 -0
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +30 -0
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +30 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.d.ts +4 -0
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +4 -0
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.d.ts +5 -0
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +5 -0
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/twirlBlock.d.ts +3 -0
- package/Materials/Node/Blocks/Fragment/twirlBlock.js +3 -0
- package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.d.ts +6 -0
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -0
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.d.ts +16 -0
- package/Materials/Node/Blocks/Input/inputBlock.js +16 -1
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/prePassTextureBlock.d.ts +5 -0
- package/Materials/Node/Blocks/Input/prePassTextureBlock.js +5 -0
- package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +10 -0
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +10 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +23 -0
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +23 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.d.ts +17 -0
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js +17 -0
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +41 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +41 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +21 -0
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +21 -0
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.d.ts +29 -0
- package/Materials/Node/Blocks/PBR/refractionBlock.js +29 -0
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.d.ts +14 -0
- package/Materials/Node/Blocks/PBR/sheenBlock.js +14 -0
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.d.ts +7 -0
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +7 -0
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.d.ts +23 -0
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js +23 -0
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportInBlock.d.ts +6 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js +6 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.d.ts +17 -0
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +17 -0
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.d.ts +22 -0
- package/Materials/Node/Blocks/Vertex/bonesBlock.js +22 -0
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.d.ts +13 -0
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +13 -0
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +20 -0
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +20 -0
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +27 -0
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +27 -0
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/clampBlock.d.ts +10 -0
- package/Materials/Node/Blocks/clampBlock.js +10 -0
- package/Materials/Node/Blocks/clampBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.d.ts +10 -0
- package/Materials/Node/Blocks/cloudBlock.js +10 -0
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.d.ts +10 -0
- package/Materials/Node/Blocks/colorMergerBlock.js +10 -0
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/conditionalBlock.d.ts +14 -0
- package/Materials/Node/Blocks/conditionalBlock.js +14 -0
- package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
- package/Materials/Node/Blocks/curveBlock.d.ts +10 -0
- package/Materials/Node/Blocks/curveBlock.js +10 -0
- package/Materials/Node/Blocks/curveBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.d.ts +10 -0
- package/Materials/Node/Blocks/customBlock.js +10 -0
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/debugBlock.d.ts +10 -0
- package/Materials/Node/Blocks/debugBlock.js +10 -0
- package/Materials/Node/Blocks/debugBlock.js.map +1 -1
- package/Materials/Node/Blocks/fresnelBlock.d.ts +4 -0
- package/Materials/Node/Blocks/fresnelBlock.js +4 -0
- package/Materials/Node/Blocks/fresnelBlock.js.map +1 -1
- package/Materials/Node/Blocks/gradientBlock.d.ts +10 -0
- package/Materials/Node/Blocks/gradientBlock.js +10 -0
- package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/loopBlock.d.ts +10 -0
- package/Materials/Node/Blocks/loopBlock.js +10 -0
- package/Materials/Node/Blocks/loopBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixBuilderBlock.d.ts +1 -0
- package/Materials/Node/Blocks/matrixBuilderBlock.js +1 -0
- package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.d.ts +10 -0
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +10 -0
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/pannerBlock.d.ts +5 -0
- package/Materials/Node/Blocks/pannerBlock.js +5 -0
- package/Materials/Node/Blocks/pannerBlock.js.map +1 -1
- package/Materials/Node/Blocks/remapBlock.d.ts +10 -0
- package/Materials/Node/Blocks/remapBlock.js +10 -0
- package/Materials/Node/Blocks/remapBlock.js.map +1 -1
- package/Materials/Node/Blocks/rotate2dBlock.d.ts +1 -0
- package/Materials/Node/Blocks/rotate2dBlock.js +1 -0
- package/Materials/Node/Blocks/rotate2dBlock.js.map +1 -1
- package/Materials/Node/Blocks/transformBlock.d.ts +10 -0
- package/Materials/Node/Blocks/transformBlock.js +10 -0
- package/Materials/Node/Blocks/transformBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +22 -0
- package/Materials/Node/Blocks/triPlanarBlock.js +22 -0
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.d.ts +10 -0
- package/Materials/Node/Blocks/trigonometryBlock.js +10 -0
- package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.d.ts +10 -0
- package/Materials/Node/Blocks/vectorMergerBlock.js +10 -0
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/viewDirectionBlock.d.ts +5 -0
- package/Materials/Node/Blocks/viewDirectionBlock.js +5 -0
- package/Materials/Node/Blocks/viewDirectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/waveBlock.d.ts +10 -0
- package/Materials/Node/Blocks/waveBlock.js +10 -0
- package/Materials/Node/Blocks/waveBlock.js.map +1 -1
- package/Materials/Node/Blocks/worleyNoise3DBlock.d.ts +1 -0
- package/Materials/Node/Blocks/worleyNoise3DBlock.js +1 -0
- package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +13 -0
- package/Materials/Node/nodeMaterial.js +14 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.d.ts +0 -3
- package/Materials/Node/nodeMaterialBlock.js +1 -6
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +1 -2
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +1 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/index.d.ts +2 -0
- package/Materials/index.js +2 -0
- package/Materials/index.js.map +1 -1
- package/Maths/math.constants.d.ts +2 -1
- package/Maths/math.constants.js +3 -2
- package/Maths/math.constants.js.map +1 -1
- package/Meshes/Builders/capsuleBuilder.js +0 -3
- package/Meshes/Builders/capsuleBuilder.js.map +1 -1
- package/Meshes/Builders/cylinderBuilder.d.ts +1 -1
- package/Meshes/Builders/cylinderBuilder.js +1 -2
- package/Meshes/Builders/cylinderBuilder.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +2 -0
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/Builders/discBuilder.js +0 -1
- package/Meshes/Builders/discBuilder.js.map +1 -1
- package/Meshes/Builders/groundBuilder.d.ts +50 -54
- package/Meshes/Builders/groundBuilder.js +50 -54
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.d.ts +0 -26
- package/Meshes/Builders/tiledBoxBuilder.js +0 -26
- package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
- package/Meshes/Builders/tiledPlaneBuilder.d.ts +0 -25
- package/Meshes/Builders/tiledPlaneBuilder.js +0 -25
- package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
- package/Meshes/Builders/torusBuilder.d.ts +0 -13
- package/Meshes/Builders/torusBuilder.js +0 -13
- package/Meshes/Builders/torusBuilder.js.map +1 -1
- package/Meshes/Builders/torusKnotBuilder.d.ts +0 -19
- package/Meshes/Builders/torusKnotBuilder.js +0 -19
- package/Meshes/Builders/torusKnotBuilder.js.map +1 -1
- package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.types.d.ts +11 -0
- package/Meshes/Compression/dracoDecoder.types.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.js +0 -2
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +17 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +0 -8
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/scalingBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Matrices/scalingBlock.js +1 -0
- package/Meshes/Node/Blocks/Matrices/scalingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/translationBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Matrices/translationBlock.js +1 -0
- package/Meshes/Node/Blocks/Matrices/translationBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/aggregatorBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/aggregatorBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/aggregatorBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/latticeBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/latticeBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/boxBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/capsuleBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/cylinderBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/discBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/discBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/gridBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.js +1 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/planeBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/planeBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/pointListBlock.d.ts +2 -1
- package/Meshes/Node/Blocks/Sources/pointListBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/pointListBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/sphereBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/sphereBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/torusBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/torusBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js +1 -0
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.d.ts +3 -0
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +3 -0
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js +1 -0
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/cleanGeometryBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/cleanGeometryBlock.js +1 -0
- package/Meshes/Node/Blocks/cleanGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/conditionBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/conditionBlock.js +2 -0
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryClampBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryClampBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCollectionBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryCollectionBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryCollectionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCurveBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/geometryCurveBlock.js +2 -0
- package/Meshes/Node/Blocks/geometryCurveBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryEaseBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/geometryEaseBlock.js +2 -0
- package/Meshes/Node/Blocks/geometryEaseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.d.ts +3 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js +3 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryTransformBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +2 -0
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mappingBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/mappingBlock.js +1 -0
- package/Meshes/Node/Blocks/mappingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/mathBlock.js +1 -0
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mergeGeometryBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/mergeGeometryBlock.js +1 -0
- package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/randomBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/randomBlock.js +2 -0
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
- package/Meshes/Node/Blocks/subdivideBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/subdivideBlock.js +1 -0
- package/Meshes/Node/Blocks/subdivideBlock.js.map +1 -1
- package/Meshes/Node/Interfaces/nodeGeometryTextureData.d.ts +3 -0
- package/Meshes/Node/Interfaces/nodeGeometryTextureData.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +0 -2
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +0 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +0 -1
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/WebGL/webGLDataBuffer.d.ts +2 -0
- package/Meshes/WebGL/webGLDataBuffer.js +2 -0
- package/Meshes/WebGL/webGLDataBuffer.js.map +1 -1
- package/Meshes/WebGPU/webgpuDataBuffer.d.ts +4 -0
- package/Meshes/WebGPU/webgpuDataBuffer.js +4 -0
- package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +1 -0
- package/Meshes/abstractMesh.decalMap.d.ts +1 -0
- package/Meshes/abstractMesh.decalMap.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -6
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg.js +0 -6
- package/Meshes/csg.js.map +1 -1
- package/Meshes/csg2.js +1 -2
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/geodesicMesh.d.ts +26 -0
- package/Meshes/geodesicMesh.js +18 -3
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/groundMesh.d.ts +1 -0
- package/Meshes/groundMesh.js +1 -0
- package/Meshes/groundMesh.js.map +1 -1
- package/Meshes/index.js +0 -2
- package/Meshes/index.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +18 -3
- package/Meshes/instancedMesh.js +11 -3
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +291 -204
- package/Meshes/mesh.js +290 -213
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +15 -19
- package/Meshes/mesh.vertexData.js +15 -19
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/meshSimplification.d.ts +0 -1
- package/Meshes/meshSimplification.js +6 -1
- package/Meshes/meshSimplification.js.map +1 -1
- package/Meshes/meshSimplificationSceneComponent.d.ts +2 -0
- package/Meshes/meshSimplificationSceneComponent.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.d.ts +1 -0
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Meshes/polygonMesh.js +4 -0
- package/Meshes/polygonMesh.js.map +1 -1
- package/Meshes/subMesh.project.d.ts +1 -0
- package/Meshes/subMesh.project.js.map +1 -1
- package/Meshes/thinInstanceMesh.d.ts +5 -0
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Meshes/transformNode.d.ts +1 -1
- package/Meshes/transformNode.js +1 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/dataStorage.d.ts +13 -0
- package/Misc/dataStorage.js +25 -0
- package/Misc/dataStorage.js.map +1 -1
- package/Morph/morphTarget.d.ts +9 -5
- package/Morph/morphTarget.js +15 -7
- package/Morph/morphTarget.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +3 -1
- package/Morph/morphTargetManager.js +5 -2
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/emitters.functions.js +3 -3
- package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +2 -2
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateNoiseBlock.js +7 -7
- package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleLocalVariableBlock.js +2 -2
- package/Particles/Node/Blocks/particleLocalVariableBlock.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +7 -7
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +9 -4
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/particle.d.ts +73 -61
- package/Particles/particle.js +106 -91
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.js +5 -5
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.function.js +83 -83
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +8 -8
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +89 -3
- package/Physics/v2/Plugins/havokPlugin.js +388 -53
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Probes/reflectionProbe.js +10 -7
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/depthRenderer.js +1 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +3 -1
- package/Rendering/objectRenderer.js +28 -8
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/reflectiveShadowMap.js +1 -1
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Rendering/thinDepthPeelingRenderer.js +8 -0
- package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
- package/Shaders/gaussianSplatting.fragment.js +8 -2
- package/Shaders/gaussianSplatting.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +8 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js +7 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +8 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +22 -4
- package/scene.js +33 -20
- package/scene.js.map +1 -1
|
@@ -11,6 +11,7 @@ import { InstancedMesh } from "../../../Meshes/instancedMesh.js";
|
|
|
11
11
|
import { VertexBuffer } from "../../../Buffers/buffer.js";
|
|
12
12
|
import { BuildArray } from "../../../Misc/arrayTools.js";
|
|
13
13
|
import { Observable } from "../../../Misc/observable.js";
|
|
14
|
+
import { FloatingOriginCurrentScene } from "../../../Materials/floatingOriginMatrixOverrides.js";
|
|
14
15
|
class MeshAccumulator {
|
|
15
16
|
/**
|
|
16
17
|
* Constructor of the mesh accumulator
|
|
@@ -210,6 +211,137 @@ class TriggerEvent {
|
|
|
210
211
|
* The Havok Physics plugin
|
|
211
212
|
*/
|
|
212
213
|
export class HavokPlugin {
|
|
214
|
+
/**
|
|
215
|
+
* Finds an existing world region that contains the given world position,
|
|
216
|
+
* or creates a new world region centered at that position.
|
|
217
|
+
*
|
|
218
|
+
* When floatingOriginMode is enabled, we use multiple Havok worlds to maintain
|
|
219
|
+
* float32 precision across a large world. Each world region has its own fixed
|
|
220
|
+
* floating origin, and bodies within that region are simulated relative to it.
|
|
221
|
+
*
|
|
222
|
+
* @param worldPosition - The world position of the body being created
|
|
223
|
+
* @returns The world region to use for this body
|
|
224
|
+
*/
|
|
225
|
+
_getOrCreateWorldRegion(worldPosition) {
|
|
226
|
+
// Check if floating origin mode is enabled
|
|
227
|
+
const scene = FloatingOriginCurrentScene.getScene();
|
|
228
|
+
if (!scene?.floatingOriginMode) {
|
|
229
|
+
// When floating origin mode is disabled, use the default world region
|
|
230
|
+
return this._worldRegions[0];
|
|
231
|
+
}
|
|
232
|
+
// Find an existing region that contains this position
|
|
233
|
+
for (const region of this._worldRegions) {
|
|
234
|
+
const distance = Vector3.Distance(worldPosition, region.floatingOrigin);
|
|
235
|
+
if (distance <= this._floatingOriginWorldRadius) {
|
|
236
|
+
return region;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// No existing region found - create a new one centered at this position
|
|
240
|
+
const newWorld = this._hknp.HP_World_Create()[1];
|
|
241
|
+
// Apply stored gravity to new world
|
|
242
|
+
this._hknp.HP_World_SetGravity(newWorld, this._currentGravity);
|
|
243
|
+
// Copy velocity limits from main world
|
|
244
|
+
this._hknp.HP_World_SetSpeedLimit(newWorld, this.getMaxLinearVelocity(), this.getMaxAngularVelocity());
|
|
245
|
+
const newRegion = {
|
|
246
|
+
world: newWorld,
|
|
247
|
+
floatingOrigin: worldPosition.clone(),
|
|
248
|
+
gravity: [...this._currentGravity],
|
|
249
|
+
};
|
|
250
|
+
this._worldRegions.push(newRegion);
|
|
251
|
+
return newRegion;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Checks if a body's world position has left its current region and, if so,
|
|
255
|
+
* moves it to the correct region (existing or newly created).
|
|
256
|
+
* This preserves linear and angular velocity across the transition.
|
|
257
|
+
*
|
|
258
|
+
* @param pluginData - The plugin data for the body (or instance) to check
|
|
259
|
+
*/
|
|
260
|
+
_reRegionBodyPluginData(pluginData) {
|
|
261
|
+
const currentRegion = pluginData.worldRegion;
|
|
262
|
+
if (!currentRegion) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
// Read the body's current local transform from Havok
|
|
266
|
+
const bodyTransform = this._hknp.HP_Body_GetQTransform(pluginData.hpBodyId)[1];
|
|
267
|
+
const localPos = bodyTransform[0];
|
|
268
|
+
const orientation = bodyTransform[1];
|
|
269
|
+
// Compute world position = local position + floating origin
|
|
270
|
+
const worldPos = TmpVectors.Vector3[2];
|
|
271
|
+
worldPos.set(localPos[0] + currentRegion.floatingOrigin._x, localPos[1] + currentRegion.floatingOrigin._y, localPos[2] + currentRegion.floatingOrigin._z);
|
|
272
|
+
// Check if still within the current region.
|
|
273
|
+
// Use a 20% hysteresis margin so that bodies near the boundary
|
|
274
|
+
// don't oscillate between regions every frame.
|
|
275
|
+
const distToCurrent = Vector3.Distance(worldPos, currentRegion.floatingOrigin);
|
|
276
|
+
if (distToCurrent <= this._floatingOriginWorldRadius * 1.2) {
|
|
277
|
+
return; // still in region (with hysteresis), nothing to do
|
|
278
|
+
}
|
|
279
|
+
// Body has left its region. Use velocity to look ahead and find the best
|
|
280
|
+
// region to join. This prevents creating throwaway intermediate regions
|
|
281
|
+
// when a fast body is heading toward an existing region (e.g. a target).
|
|
282
|
+
const linVel = this._hknp.HP_Body_GetLinearVelocity(pluginData.hpBodyId)[1];
|
|
283
|
+
const angVel = this._hknp.HP_Body_GetAngularVelocity(pluginData.hpBodyId)[1];
|
|
284
|
+
// Project position forward by one second of travel to find a suitable existing region.
|
|
285
|
+
// This is purely for region selection — the body's actual position is not changed.
|
|
286
|
+
const lookAheadPos = TmpVectors.Vector3[3];
|
|
287
|
+
lookAheadPos.set(worldPos._x + linVel[0], worldPos._y + linVel[1], worldPos._z + linVel[2]);
|
|
288
|
+
// Try to find the best region: first check if look-ahead position falls in an existing region
|
|
289
|
+
let newRegion = this._findExistingRegion(lookAheadPos);
|
|
290
|
+
if (!newRegion || newRegion === currentRegion) {
|
|
291
|
+
// Fall back to current position
|
|
292
|
+
newRegion = this._findExistingRegion(worldPos);
|
|
293
|
+
}
|
|
294
|
+
if (!newRegion || newRegion === currentRegion) {
|
|
295
|
+
// No existing region works — create one at the current position
|
|
296
|
+
newRegion = this._getOrCreateWorldRegion(worldPos);
|
|
297
|
+
}
|
|
298
|
+
if (newRegion === currentRegion) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
// Remove from old world
|
|
302
|
+
this._hknp.HP_World_RemoveBody(currentRegion.world, pluginData.hpBodyId);
|
|
303
|
+
// Set transform relative to the new region's floating origin
|
|
304
|
+
const newOffset = newRegion.floatingOrigin;
|
|
305
|
+
const newLocalPos = [worldPos._x - newOffset._x, worldPos._y - newOffset._y, worldPos._z - newOffset._z];
|
|
306
|
+
this._hknp.HP_Body_SetQTransform(pluginData.hpBodyId, [newLocalPos, orientation]);
|
|
307
|
+
// Add to new world
|
|
308
|
+
this._hknp.HP_World_AddBody(newRegion.world, pluginData.hpBodyId, false);
|
|
309
|
+
// Restore velocity
|
|
310
|
+
this._hknp.HP_Body_SetLinearVelocity(pluginData.hpBodyId, linVel);
|
|
311
|
+
this._hknp.HP_Body_SetAngularVelocity(pluginData.hpBodyId, angVel);
|
|
312
|
+
// Update the region reference and world transform offset
|
|
313
|
+
pluginData.worldRegion = newRegion;
|
|
314
|
+
pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(pluginData.hpBodyId)[1];
|
|
315
|
+
// Garbage-collect the old region if it has no bodies left and it's not the default world
|
|
316
|
+
if (currentRegion !== this._worldRegions[0]) {
|
|
317
|
+
const bodyCount = this._hknp.HP_World_GetNumBodies(currentRegion.world)[1];
|
|
318
|
+
if (bodyCount === 0) {
|
|
319
|
+
this._hknp.HP_World_Release(currentRegion.world);
|
|
320
|
+
const idx = this._worldRegions.indexOf(currentRegion);
|
|
321
|
+
if (idx > 0) {
|
|
322
|
+
this._worldRegions.splice(idx, 1);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Searches existing world regions for one that contains the given position.
|
|
329
|
+
* @param worldPosition - The world position to find a region for
|
|
330
|
+
* @returns null if no existing region contains it (does NOT create a new one).
|
|
331
|
+
*/
|
|
332
|
+
_findExistingRegion(worldPosition) {
|
|
333
|
+
const scene = FloatingOriginCurrentScene.getScene();
|
|
334
|
+
if (!scene?.floatingOriginMode) {
|
|
335
|
+
return this._worldRegions[0];
|
|
336
|
+
}
|
|
337
|
+
for (const region of this._worldRegions) {
|
|
338
|
+
const distance = Vector3.Distance(worldPosition, region.floatingOrigin);
|
|
339
|
+
if (distance <= this._floatingOriginWorldRadius) {
|
|
340
|
+
return region;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
213
345
|
constructor(_useDeltaForWorldStep = true, hpInjection = HK, parameters = {}) {
|
|
214
346
|
this._useDeltaForWorldStep = _useDeltaForWorldStep;
|
|
215
347
|
/**
|
|
@@ -230,6 +362,20 @@ export class HavokPlugin {
|
|
|
230
362
|
// Map from constraint id to the pair of bodies, where the first is the parent and the second is the child
|
|
231
363
|
this._constraintToBodyIdPair = new Map();
|
|
232
364
|
this._bodyCollisionEndedObservable = new Map();
|
|
365
|
+
/**
|
|
366
|
+
* Array of world regions. The first region is always the default world with origin at Vector3.Zero.
|
|
367
|
+
* Additional regions are created as needed for floating origin mode.
|
|
368
|
+
*/
|
|
369
|
+
this._worldRegions = [];
|
|
370
|
+
/**
|
|
371
|
+
* Stored gravity value to apply to new world regions.
|
|
372
|
+
*/
|
|
373
|
+
this._currentGravity = [0, -9.81, 0];
|
|
374
|
+
/**
|
|
375
|
+
* Radius of each floating origin world region.
|
|
376
|
+
* Bodies within this radius of a world region's origin will use that world.
|
|
377
|
+
*/
|
|
378
|
+
this._floatingOriginWorldRadius = 100000;
|
|
233
379
|
/**
|
|
234
380
|
* Observable for collision started and collision continued events
|
|
235
381
|
*/
|
|
@@ -254,8 +400,15 @@ export class HavokPlugin {
|
|
|
254
400
|
return;
|
|
255
401
|
}
|
|
256
402
|
this.world = this._hknp.HP_World_Create()[1];
|
|
403
|
+
// Add the default world as the first region with origin at zero
|
|
404
|
+
this._worldRegions.push({
|
|
405
|
+
world: this.world,
|
|
406
|
+
floatingOrigin: Vector3.Zero(),
|
|
407
|
+
gravity: [...this._currentGravity],
|
|
408
|
+
});
|
|
257
409
|
this._queryCollector = this._hknp.HP_QueryCollector_Create(1)[1];
|
|
258
410
|
this.setMaxQueryCollectorHits(parameters.maxQueryCollectorHits ?? 1);
|
|
411
|
+
this._floatingOriginWorldRadius = parameters.floatingOriginWorldRadius ?? 100000;
|
|
259
412
|
}
|
|
260
413
|
/**
|
|
261
414
|
* If this plugin is supported
|
|
@@ -268,10 +421,41 @@ export class HavokPlugin {
|
|
|
268
421
|
* Sets the gravity of the physics world.
|
|
269
422
|
*
|
|
270
423
|
* @param gravity - The gravity vector to set.
|
|
424
|
+
* @param worldPosition - Optional world position to specify which region's gravity to set.
|
|
425
|
+
* If provided, only the region containing this position will be updated.
|
|
426
|
+
* If not provided, all regions will be updated (default behavior).
|
|
427
|
+
* This is useful for planetary scenarios where gravity direction varies by location.
|
|
428
|
+
*/
|
|
429
|
+
setGravity(gravity, worldPosition) {
|
|
430
|
+
const gravityArray = this._bVecToV3(gravity);
|
|
431
|
+
if (worldPosition) {
|
|
432
|
+
// Set gravity for a specific region based on world position
|
|
433
|
+
const region = this._getOrCreateWorldRegion(worldPosition);
|
|
434
|
+
region.gravity = gravityArray;
|
|
435
|
+
this._hknp.HP_World_SetGravity(region.world, gravityArray);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
// Set gravity for all regions (default behavior)
|
|
439
|
+
this._currentGravity = gravityArray;
|
|
440
|
+
for (const region of this._worldRegions) {
|
|
441
|
+
region.gravity = gravityArray;
|
|
442
|
+
this._hknp.HP_World_SetGravity(region.world, gravityArray);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Gets the gravity of the physics world or a specific region.
|
|
271
448
|
*
|
|
449
|
+
* @param worldPosition - Optional world position to get the gravity for that region.
|
|
450
|
+
* If not provided, returns the default gravity.
|
|
451
|
+
* @returns The gravity vector.
|
|
272
452
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
453
|
+
getGravity(worldPosition) {
|
|
454
|
+
if (worldPosition) {
|
|
455
|
+
const region = this._getOrCreateWorldRegion(worldPosition);
|
|
456
|
+
return new Vector3(region.gravity[0], region.gravity[1], region.gravity[2]);
|
|
457
|
+
}
|
|
458
|
+
return new Vector3(this._currentGravity[0], this._currentGravity[1], this._currentGravity[2]);
|
|
275
459
|
}
|
|
276
460
|
/**
|
|
277
461
|
* Sets the fixed time step for the physics engine.
|
|
@@ -327,6 +511,21 @@ export class HavokPlugin {
|
|
|
327
511
|
* to accurately simulate the physics bodies in the world.
|
|
328
512
|
*/
|
|
329
513
|
executeStep(delta, physicsBodies) {
|
|
514
|
+
// Re-region bodies that have moved outside their current world region
|
|
515
|
+
// BEFORE pre-step and stepping, so the body participates in the correct
|
|
516
|
+
// world's step and its body buffer transform is valid when sync reads it.
|
|
517
|
+
if (this._worldRegions.length > 1 || FloatingOriginCurrentScene.getScene()?.floatingOriginMode) {
|
|
518
|
+
for (const physicsBody of physicsBodies) {
|
|
519
|
+
if (physicsBody._pluginDataInstances.length > 0) {
|
|
520
|
+
for (const instance of physicsBody._pluginDataInstances) {
|
|
521
|
+
this._reRegionBodyPluginData(instance);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
else if (physicsBody._pluginData) {
|
|
525
|
+
this._reRegionBodyPluginData(physicsBody._pluginData);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
330
529
|
for (const physicsBody of physicsBodies) {
|
|
331
530
|
if (physicsBody.disablePreStep) {
|
|
332
531
|
continue;
|
|
@@ -334,16 +533,21 @@ export class HavokPlugin {
|
|
|
334
533
|
this.setPhysicsBodyTransformation(physicsBody, physicsBody.transformNode);
|
|
335
534
|
}
|
|
336
535
|
const deltaTime = this._useDeltaForWorldStep ? delta : this._fixedTimeStep;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
536
|
+
// Step all world regions
|
|
537
|
+
for (const region of this._worldRegions) {
|
|
538
|
+
this._hknp.HP_World_SetIdealStepTime(region.world, deltaTime);
|
|
539
|
+
this._hknp.HP_World_Step(region.world, deltaTime);
|
|
540
|
+
}
|
|
340
541
|
for (const physicsBody of physicsBodies) {
|
|
341
542
|
if (!physicsBody.disableSync) {
|
|
342
543
|
this.sync(physicsBody);
|
|
343
544
|
}
|
|
344
545
|
}
|
|
345
|
-
|
|
346
|
-
this.
|
|
546
|
+
// Notify collisions and triggers for all world regions
|
|
547
|
+
for (const region of this._worldRegions) {
|
|
548
|
+
this._notifyCollisions(region.world);
|
|
549
|
+
this._notifyTriggers(region.world);
|
|
550
|
+
}
|
|
347
551
|
}
|
|
348
552
|
/**
|
|
349
553
|
* Returns the version of the physics engine plugin.
|
|
@@ -361,7 +565,9 @@ export class HavokPlugin {
|
|
|
361
565
|
* @param maxAngularVelocity maximum allowed angular velocity
|
|
362
566
|
*/
|
|
363
567
|
setVelocityLimits(maxLinearVelocity, maxAngularVelocity) {
|
|
364
|
-
|
|
568
|
+
for (const region of this._worldRegions) {
|
|
569
|
+
this._hknp.HP_World_SetSpeedLimit(region.world, maxLinearVelocity, maxAngularVelocity);
|
|
570
|
+
}
|
|
365
571
|
}
|
|
366
572
|
/**
|
|
367
573
|
* @returns maximum allowed linear velocity
|
|
@@ -391,9 +597,13 @@ export class HavokPlugin {
|
|
|
391
597
|
initBody(body, motionType, position, orientation) {
|
|
392
598
|
body._pluginData = new BodyPluginData(this._hknp.HP_Body_Create()[1]);
|
|
393
599
|
this._internalSetMotionType(body._pluginData, motionType);
|
|
394
|
-
|
|
600
|
+
// Get the world region for this body's position
|
|
601
|
+
const worldRegion = this._getOrCreateWorldRegion(position);
|
|
602
|
+
body._pluginData.worldRegion = worldRegion;
|
|
603
|
+
const offset = worldRegion.floatingOrigin;
|
|
604
|
+
const transform = [[position._x - offset._x, position._y - offset._y, position._z - offset._z], this._bQuatToV4(orientation)];
|
|
395
605
|
this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, transform);
|
|
396
|
-
this._hknp.HP_World_AddBody(
|
|
606
|
+
this._hknp.HP_World_AddBody(worldRegion.world, body._pluginData.hpBodyId, body.startAsleep);
|
|
397
607
|
this._bodies.set(body._pluginData.hpBodyId[0], { body: body, index: 0 });
|
|
398
608
|
}
|
|
399
609
|
/**
|
|
@@ -405,13 +615,13 @@ export class HavokPlugin {
|
|
|
405
615
|
if (body._pluginDataInstances && body._pluginDataInstances.length > 0) {
|
|
406
616
|
for (const instance of body._pluginDataInstances) {
|
|
407
617
|
this._bodyCollisionObservable.delete(instance.hpBodyId[0]);
|
|
408
|
-
this._hknp.HP_World_RemoveBody(
|
|
618
|
+
this._hknp.HP_World_RemoveBody(instance.worldRegion.world, instance.hpBodyId);
|
|
409
619
|
this._bodies.delete(instance.hpBodyId[0]);
|
|
410
620
|
}
|
|
411
621
|
}
|
|
412
622
|
if (body._pluginData) {
|
|
413
623
|
this._bodyCollisionObservable.delete(body._pluginData.hpBodyId[0]);
|
|
414
|
-
this._hknp.HP_World_RemoveBody(
|
|
624
|
+
this._hknp.HP_World_RemoveBody(body._pluginData.worldRegion.world, body._pluginData.hpBodyId);
|
|
415
625
|
this._bodies.delete(body._pluginData.hpBodyId[0]);
|
|
416
626
|
}
|
|
417
627
|
}
|
|
@@ -443,15 +653,29 @@ export class HavokPlugin {
|
|
|
443
653
|
_createOrUpdateBodyInstances(body, motionType, matrixData, startIndex, endIndex, update) {
|
|
444
654
|
const rotation = TmpVectors.Quaternion[0];
|
|
445
655
|
const rotationMatrix = Matrix.Identity();
|
|
656
|
+
const worldPos = TmpVectors.Vector3[0];
|
|
446
657
|
for (let i = startIndex; i < endIndex; i++) {
|
|
447
|
-
|
|
658
|
+
// Get world position for this instance
|
|
659
|
+
worldPos.set(matrixData[i * 16 + 12], matrixData[i * 16 + 13], matrixData[i * 16 + 14]);
|
|
448
660
|
let hkbody;
|
|
661
|
+
let pluginData;
|
|
449
662
|
if (!update) {
|
|
450
663
|
hkbody = this._hknp.HP_Body_Create()[1];
|
|
664
|
+
pluginData = new BodyPluginData(hkbody);
|
|
665
|
+
if (body._pluginDataInstances.length) {
|
|
666
|
+
// If an instance already exists, copy any user-provided mass properties
|
|
667
|
+
pluginData.userMassProps = body._pluginDataInstances[0].userMassProps;
|
|
668
|
+
}
|
|
451
669
|
}
|
|
452
670
|
else {
|
|
453
|
-
|
|
671
|
+
pluginData = body._pluginDataInstances[i];
|
|
672
|
+
hkbody = pluginData.hpBodyId;
|
|
454
673
|
}
|
|
674
|
+
// Get the world region for this instance's position
|
|
675
|
+
const worldRegion = this._getOrCreateWorldRegion(worldPos);
|
|
676
|
+
const offset = worldRegion.floatingOrigin;
|
|
677
|
+
// Subtract floating origin offset to get small coordinates for Havok (float32 precision)
|
|
678
|
+
const position = [worldPos._x - offset._x, worldPos._y - offset._y, worldPos._z - offset._z];
|
|
455
679
|
rotationMatrix.setRowFromFloats(0, matrixData[i * 16 + 0], matrixData[i * 16 + 1], matrixData[i * 16 + 2], 0);
|
|
456
680
|
rotationMatrix.setRowFromFloats(1, matrixData[i * 16 + 4], matrixData[i * 16 + 5], matrixData[i * 16 + 6], 0);
|
|
457
681
|
rotationMatrix.setRowFromFloats(2, matrixData[i * 16 + 8], matrixData[i * 16 + 9], matrixData[i * 16 + 10], 0);
|
|
@@ -459,15 +683,12 @@ export class HavokPlugin {
|
|
|
459
683
|
const transform = [position, [rotation.x, rotation.y, rotation.z, rotation.w]];
|
|
460
684
|
this._hknp.HP_Body_SetQTransform(hkbody, transform);
|
|
461
685
|
if (!update) {
|
|
462
|
-
const pluginData = new BodyPluginData(hkbody);
|
|
463
|
-
if (body._pluginDataInstances.length) {
|
|
464
|
-
// If an instance already exists, copy any user-provided mass properties
|
|
465
|
-
pluginData.userMassProps = body._pluginDataInstances[0].userMassProps;
|
|
466
|
-
}
|
|
467
686
|
this._internalSetMotionType(pluginData, motionType);
|
|
468
687
|
this._internalUpdateMassProperties(pluginData);
|
|
469
688
|
body._pluginDataInstances.push(pluginData);
|
|
470
|
-
|
|
689
|
+
// Add to the appropriate world
|
|
690
|
+
pluginData.worldRegion = worldRegion;
|
|
691
|
+
this._hknp.HP_World_AddBody(worldRegion.world, hkbody, body.startAsleep);
|
|
471
692
|
pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(hkbody)[1];
|
|
472
693
|
}
|
|
473
694
|
}
|
|
@@ -504,7 +725,7 @@ export class HavokPlugin {
|
|
|
504
725
|
for (let i = 0; i < instancesToRemove; i++) {
|
|
505
726
|
const hkbody = body._pluginDataInstances.pop();
|
|
506
727
|
this._bodies.delete(hkbody.hpBodyId[0]);
|
|
507
|
-
this._hknp.HP_World_RemoveBody(
|
|
728
|
+
this._hknp.HP_World_RemoveBody(hkbody.worldRegion.world, hkbody.hpBodyId);
|
|
508
729
|
this._hknp.HP_Body_Release(hkbody.hpBodyId);
|
|
509
730
|
}
|
|
510
731
|
this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, true);
|
|
@@ -535,6 +756,8 @@ export class HavokPlugin {
|
|
|
535
756
|
* physical behavior of the body.
|
|
536
757
|
*/
|
|
537
758
|
syncTransform(body, transformNode) {
|
|
759
|
+
// Get the floating origin offset - this was subtracted when positions were sent to Havok
|
|
760
|
+
// We need to add it back to get the correct world position
|
|
538
761
|
if (body._pluginDataInstances.length) {
|
|
539
762
|
// instances
|
|
540
763
|
const m = transformNode;
|
|
@@ -544,26 +767,41 @@ export class HavokPlugin {
|
|
|
544
767
|
}
|
|
545
768
|
const instancesCount = body._pluginDataInstances.length;
|
|
546
769
|
for (let i = 0; i < instancesCount; i++) {
|
|
547
|
-
const
|
|
548
|
-
|
|
770
|
+
const pluginData = body._pluginDataInstances[i];
|
|
771
|
+
// Use instance's world region offset
|
|
772
|
+
const instanceOffset = pluginData.worldRegion.floatingOrigin;
|
|
773
|
+
// Get body buffer from the instance's own world region (not always the default world)
|
|
774
|
+
const bodyBuffer = this._hknp.HP_World_GetBodyBuffer(pluginData.worldRegion.world)[1];
|
|
775
|
+
const bufOffset = pluginData.worldTransformOffset;
|
|
776
|
+
const transformBuffer = new Float32Array(this._hknp.HEAPU8.buffer, bodyBuffer + bufOffset, 16);
|
|
549
777
|
const index = i * 16;
|
|
550
778
|
for (let mi = 0; mi < 15; mi++) {
|
|
551
779
|
if ((mi & 3) != 3) {
|
|
552
780
|
matrixData[index + mi] = transformBuffer[mi];
|
|
553
781
|
}
|
|
554
782
|
}
|
|
783
|
+
// Add back the floating origin offset to get world position
|
|
784
|
+
// (Havok stores position - offset, so we add offset back)
|
|
785
|
+
matrixData[index + 12] += instanceOffset._x;
|
|
786
|
+
matrixData[index + 13] += instanceOffset._y;
|
|
787
|
+
matrixData[index + 14] += instanceOffset._z;
|
|
555
788
|
matrixData[index + 15] = 1;
|
|
556
789
|
}
|
|
557
790
|
m.thinInstanceBufferUpdated("matrix");
|
|
558
791
|
}
|
|
559
792
|
else {
|
|
560
793
|
try {
|
|
561
|
-
// regular
|
|
562
794
|
const bodyTransform = this._hknp.HP_Body_GetQTransform(body._pluginData.hpBodyId)[1];
|
|
563
795
|
const bodyTranslation = bodyTransform[0];
|
|
564
796
|
const bodyOrientation = bodyTransform[1];
|
|
565
797
|
const quat = TmpVectors.Quaternion[0];
|
|
798
|
+
// Use body's world region offset
|
|
799
|
+
const offset = body._pluginData.worldRegion.floatingOrigin;
|
|
566
800
|
quat.set(bodyOrientation[0], bodyOrientation[1], bodyOrientation[2], bodyOrientation[3]);
|
|
801
|
+
// Add back the floating origin offset to get world position
|
|
802
|
+
const worldX = bodyTranslation[0] + offset._x;
|
|
803
|
+
const worldY = bodyTranslation[1] + offset._y;
|
|
804
|
+
const worldZ = bodyTranslation[2] + offset._z;
|
|
567
805
|
const parent = transformNode.parent;
|
|
568
806
|
// transform position/orientation in parent space
|
|
569
807
|
if (parent && !parent.getWorldMatrix().isIdentity()) {
|
|
@@ -573,7 +811,7 @@ export class HavokPlugin {
|
|
|
573
811
|
quat.normalize();
|
|
574
812
|
const finalTransform = TmpVectors.Matrix[0];
|
|
575
813
|
const finalTranslation = TmpVectors.Vector3[0];
|
|
576
|
-
finalTranslation.copyFromFloats(
|
|
814
|
+
finalTranslation.copyFromFloats(worldX, worldY, worldZ);
|
|
577
815
|
Matrix.ComposeToRef(transformNode.absoluteScaling, quat, finalTranslation, finalTransform);
|
|
578
816
|
const parentInverseTransform = TmpVectors.Matrix[1];
|
|
579
817
|
parent.getWorldMatrix().invertToRef(parentInverseTransform);
|
|
@@ -585,7 +823,7 @@ export class HavokPlugin {
|
|
|
585
823
|
transformNode.scaling.copyFrom(TmpVectors.Vector3[1]);
|
|
586
824
|
}
|
|
587
825
|
else {
|
|
588
|
-
transformNode.position.set(
|
|
826
|
+
transformNode.position.set(worldX, worldY, worldZ);
|
|
589
827
|
if (transformNode.rotationQuaternion) {
|
|
590
828
|
transformNode.rotationQuaternion.copyFrom(quat);
|
|
591
829
|
}
|
|
@@ -938,7 +1176,8 @@ export class HavokPlugin {
|
|
|
938
1176
|
*/
|
|
939
1177
|
applyImpulse(body, impulse, location, instanceIndex) {
|
|
940
1178
|
this._applyToBodyOrInstances(body, (pluginRef) => {
|
|
941
|
-
|
|
1179
|
+
const offset = pluginRef.worldRegion.floatingOrigin;
|
|
1180
|
+
this._hknp.HP_Body_ApplyImpulse(pluginRef.hpBodyId, this._bVecToV3WithOffset(location, offset), this._bVecToV3(impulse));
|
|
942
1181
|
}, instanceIndex);
|
|
943
1182
|
}
|
|
944
1183
|
/**
|
|
@@ -1036,8 +1275,45 @@ export class HavokPlugin {
|
|
|
1036
1275
|
this._createOrUpdateBodyInstances(body, body.getMotionType(), matrixData, 0, instancesCount, true);
|
|
1037
1276
|
}
|
|
1038
1277
|
else {
|
|
1039
|
-
//
|
|
1040
|
-
|
|
1278
|
+
// Check if the node's new world position requires a region change.
|
|
1279
|
+
// This ensures teleports (e.g. toggling disablePreStep after moving
|
|
1280
|
+
// the transform node) immediately land in the correct region with
|
|
1281
|
+
// correct local coordinates, avoiding a one-frame precision glitch.
|
|
1282
|
+
const pluginData = body._pluginData;
|
|
1283
|
+
if (pluginData.worldRegion && (this._worldRegions.length > 1 || FloatingOriginCurrentScene.getScene()?.floatingOriginMode)) {
|
|
1284
|
+
// Get world position of the node
|
|
1285
|
+
const worldPos = TmpVectors.Vector3[3];
|
|
1286
|
+
if (node.parent) {
|
|
1287
|
+
node.computeWorldMatrix(true);
|
|
1288
|
+
worldPos.copyFrom(node.absolutePosition);
|
|
1289
|
+
}
|
|
1290
|
+
else {
|
|
1291
|
+
worldPos.copyFrom(node.position);
|
|
1292
|
+
}
|
|
1293
|
+
const currentRegion = pluginData.worldRegion;
|
|
1294
|
+
const distToCurrent = Vector3.Distance(worldPos, currentRegion.floatingOrigin);
|
|
1295
|
+
if (distToCurrent > this._floatingOriginWorldRadius * 1.2) {
|
|
1296
|
+
// Teleporting outside current region - re-region before setting transform
|
|
1297
|
+
const newRegion = this._getOrCreateWorldRegion(worldPos);
|
|
1298
|
+
if (newRegion !== currentRegion) {
|
|
1299
|
+
// Save velocity before removing from old world
|
|
1300
|
+
const linVel = this._hknp.HP_Body_GetLinearVelocity(pluginData.hpBodyId)[1];
|
|
1301
|
+
const angVel = this._hknp.HP_Body_GetAngularVelocity(pluginData.hpBodyId)[1];
|
|
1302
|
+
// Remove from old world, add to new world
|
|
1303
|
+
this._hknp.HP_World_RemoveBody(currentRegion.world, pluginData.hpBodyId);
|
|
1304
|
+
this._hknp.HP_World_AddBody(newRegion.world, pluginData.hpBodyId, false);
|
|
1305
|
+
// Restore velocity
|
|
1306
|
+
this._hknp.HP_Body_SetLinearVelocity(pluginData.hpBodyId, linVel);
|
|
1307
|
+
this._hknp.HP_Body_SetAngularVelocity(pluginData.hpBodyId, angVel);
|
|
1308
|
+
// Update region reference and cached world transform offset
|
|
1309
|
+
pluginData.worldRegion = newRegion;
|
|
1310
|
+
pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(pluginData.hpBodyId)[1];
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
// Set transform using the (possibly updated) region offset
|
|
1315
|
+
const offset = body._pluginData.worldRegion.floatingOrigin;
|
|
1316
|
+
this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, this._getTransformInfos(node, offset));
|
|
1041
1317
|
}
|
|
1042
1318
|
}
|
|
1043
1319
|
else if (body.getPrestepType() == PhysicsPrestepType.ACTION) {
|
|
@@ -1059,7 +1335,8 @@ export class HavokPlugin {
|
|
|
1059
1335
|
*/
|
|
1060
1336
|
setTargetTransform(body, position, rotation, instanceIndex) {
|
|
1061
1337
|
this._applyToBodyOrInstances(body, (pluginRef) => {
|
|
1062
|
-
|
|
1338
|
+
const offset = pluginRef.worldRegion.floatingOrigin;
|
|
1339
|
+
this._hknp.HP_Body_SetTargetQTransform(pluginRef.hpBodyId, [this._bVecToV3WithOffset(position, offset), this._bQuatToV4(rotation)]);
|
|
1063
1340
|
}, instanceIndex);
|
|
1064
1341
|
}
|
|
1065
1342
|
/**
|
|
@@ -1341,12 +1618,13 @@ export class HavokPlugin {
|
|
|
1341
1618
|
* It first checks if the node has a rotation quaternion, and if not, it creates one from the node's rotation.
|
|
1342
1619
|
* It then creates an array containing the position and orientation of the node and returns it.
|
|
1343
1620
|
* @param node - The transform node.
|
|
1621
|
+
* @param offset - The floating origin offset to apply.
|
|
1344
1622
|
* @returns An array containing the position and orientation of the node.
|
|
1345
1623
|
*/
|
|
1346
|
-
_getTransformInfos(node) {
|
|
1624
|
+
_getTransformInfos(node, offset) {
|
|
1347
1625
|
if (node.parent) {
|
|
1348
1626
|
node.computeWorldMatrix(true);
|
|
1349
|
-
return [this.
|
|
1627
|
+
return [this._bVecToV3WithOffset(node.absolutePosition, offset), this._bQuatToV4(node.absoluteRotationQuaternion)];
|
|
1350
1628
|
}
|
|
1351
1629
|
let orientation = TmpVectors.Quaternion[0];
|
|
1352
1630
|
if (node.rotationQuaternion) {
|
|
@@ -1356,7 +1634,7 @@ export class HavokPlugin {
|
|
|
1356
1634
|
const r = node.rotation;
|
|
1357
1635
|
Quaternion.FromEulerAnglesToRef(r.x, r.y, r.z, orientation);
|
|
1358
1636
|
}
|
|
1359
|
-
const transform = [this.
|
|
1637
|
+
const transform = [this._bVecToV3WithOffset(node.position, offset), this._bQuatToV4(orientation)];
|
|
1360
1638
|
return transform;
|
|
1361
1639
|
}
|
|
1362
1640
|
/**
|
|
@@ -1905,7 +2183,10 @@ export class HavokPlugin {
|
|
|
1905
2183
|
const hitPos = hitData[3];
|
|
1906
2184
|
const hitNormal = hitData[4];
|
|
1907
2185
|
const hitTriangle = hitData[5];
|
|
1908
|
-
|
|
2186
|
+
// Add floating origin offset back to hit position using the hit body's world region offset
|
|
2187
|
+
// If no hit body (shouldn't happen), use zero offset from default region
|
|
2188
|
+
const offset = hitBody?.body?._pluginData?.worldRegion?.floatingOrigin ?? this._worldRegions[0].floatingOrigin;
|
|
2189
|
+
result.setHitData({ x: hitNormal[0], y: hitNormal[1], z: hitNormal[2] }, { x: hitPos[0] + offset._x, y: hitPos[1] + offset._y, z: hitPos[2] + offset._z }, hitTriangle);
|
|
1909
2190
|
}
|
|
1910
2191
|
/**
|
|
1911
2192
|
* Performs a raycast from a given start point to a given end point and stores the result in a given PhysicsRaycastResult object.
|
|
@@ -1929,9 +2210,15 @@ export class HavokPlugin {
|
|
|
1929
2210
|
for (const raycastResult of results) {
|
|
1930
2211
|
raycastResult.reset(from, to);
|
|
1931
2212
|
}
|
|
1932
|
-
|
|
2213
|
+
// Use the ignored body's world region if available, otherwise use default region
|
|
2214
|
+
const worldRegion = query?.ignoreBody?._pluginData?.worldRegion ?? this._worldRegions[0];
|
|
2215
|
+
const offset = worldRegion.floatingOrigin;
|
|
2216
|
+
const world = worldRegion.world;
|
|
2217
|
+
const offsetFrom = this._bVecToV3WithOffset(from, offset);
|
|
2218
|
+
const offsetTo = this._bVecToV3WithOffset(to, offset);
|
|
2219
|
+
const hkQuery = [offsetFrom, offsetTo, [queryMembership, queryCollideWith], shouldHitTriggers, bodyToIgnore];
|
|
1933
2220
|
const queryCollector = results.length === 1 || !this._multiQueryCollector ? this._queryCollector : this._multiQueryCollector;
|
|
1934
|
-
this._hknp.HP_World_CastRayWithCollector(
|
|
2221
|
+
this._hknp.HP_World_CastRayWithCollector(world, queryCollector, hkQuery);
|
|
1935
2222
|
const numHits = this._hknp.HP_QueryCollector_GetNumHits(queryCollector)[1];
|
|
1936
2223
|
if (numHits <= 0) {
|
|
1937
2224
|
return;
|
|
@@ -1948,7 +2235,8 @@ export class HavokPlugin {
|
|
|
1948
2235
|
for (let i = 0; i < numHits; i++) {
|
|
1949
2236
|
const [, hitData] = this._hknp.HP_QueryCollector_GetCastRayResult(queryCollector, i)[1];
|
|
1950
2237
|
const hitPos = hitData[3];
|
|
1951
|
-
|
|
2238
|
+
// Use offsetFrom for distance calculation since hitPos is in Havok's offset space
|
|
2239
|
+
this._tmpVec3[0].set(offsetFrom[0] - hitPos[0], offsetFrom[1] - hitPos[1], offsetFrom[2] - hitPos[2]);
|
|
1952
2240
|
const distance = this._tmpVec3[0].lengthSquared();
|
|
1953
2241
|
hitDatas[i] = {
|
|
1954
2242
|
hitData,
|
|
@@ -1974,8 +2262,12 @@ export class HavokPlugin {
|
|
|
1974
2262
|
const queryCollideWith = query?.collisionFilter?.collideWith ?? ~0;
|
|
1975
2263
|
result.reset();
|
|
1976
2264
|
const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];
|
|
1977
|
-
|
|
1978
|
-
|
|
2265
|
+
// Use the ignored body's world region if available, otherwise use default region
|
|
2266
|
+
const worldRegion = query.ignoreBody?._pluginData?.worldRegion ?? this._worldRegions[0];
|
|
2267
|
+
const offset = worldRegion.floatingOrigin;
|
|
2268
|
+
const world = worldRegion.world;
|
|
2269
|
+
const hkQuery = [this._bVecToV3WithOffset(query.position, offset), query.maxDistance, [queryMembership, queryCollideWith], query.shouldHitTriggers, bodyToIgnore];
|
|
2270
|
+
this._hknp.HP_World_PointProximityWithCollector(world, this._queryCollector, hkQuery);
|
|
1979
2271
|
if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {
|
|
1980
2272
|
const [distance, hitData] = this._hknp.HP_QueryCollector_GetPointProximityResult(this._queryCollector, 0)[1];
|
|
1981
2273
|
this._populateHitData(hitData, result);
|
|
@@ -1993,8 +2285,12 @@ export class HavokPlugin {
|
|
|
1993
2285
|
hitShapeResult.reset();
|
|
1994
2286
|
const shapeId = query.shape._pluginData;
|
|
1995
2287
|
const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];
|
|
1996
|
-
|
|
1997
|
-
|
|
2288
|
+
// Use the ignored body's world region if available, otherwise use default region
|
|
2289
|
+
const worldRegion = query.ignoreBody?._pluginData?.worldRegion ?? this._worldRegions[0];
|
|
2290
|
+
const offset = worldRegion.floatingOrigin;
|
|
2291
|
+
const world = worldRegion.world;
|
|
2292
|
+
const hkQuery = [shapeId, this._bVecToV3WithOffset(query.position, offset), this._bQuatToV4(query.rotation), query.maxDistance, query.shouldHitTriggers, bodyToIgnore];
|
|
2293
|
+
this._hknp.HP_World_ShapeProximityWithCollector(world, this._queryCollector, hkQuery);
|
|
1998
2294
|
if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {
|
|
1999
2295
|
const [distance, hitInputData, hitShapeData] = this._hknp.HP_QueryCollector_GetShapeProximityResult(this._queryCollector, 0)[1];
|
|
2000
2296
|
this._populateHitData(hitInputData, inputShapeResult);
|
|
@@ -2014,8 +2310,19 @@ export class HavokPlugin {
|
|
|
2014
2310
|
hitShapeResult.reset();
|
|
2015
2311
|
const shapeId = query.shape._pluginData;
|
|
2016
2312
|
const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];
|
|
2017
|
-
|
|
2018
|
-
|
|
2313
|
+
// Use the ignored body's world region if available, otherwise use default region
|
|
2314
|
+
const worldRegion = query.ignoreBody?._pluginData?.worldRegion ?? this._worldRegions[0];
|
|
2315
|
+
const offset = worldRegion.floatingOrigin;
|
|
2316
|
+
const world = worldRegion.world;
|
|
2317
|
+
const hkQuery = [
|
|
2318
|
+
shapeId,
|
|
2319
|
+
this._bQuatToV4(query.rotation),
|
|
2320
|
+
this._bVecToV3WithOffset(query.startPosition, offset),
|
|
2321
|
+
this._bVecToV3WithOffset(query.endPosition, offset),
|
|
2322
|
+
query.shouldHitTriggers,
|
|
2323
|
+
bodyToIgnore,
|
|
2324
|
+
];
|
|
2325
|
+
this._hknp.HP_World_ShapeCastWithCollector(world, this._queryCollector, hkQuery);
|
|
2019
2326
|
if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {
|
|
2020
2327
|
const [fractionAlongRay, hitInputData, hitShapeData] = this._hknp.HP_QueryCollector_GetShapeCastResult(this._queryCollector, 0)[1];
|
|
2021
2328
|
this._populateHitData(hitInputData, inputShapeResult);
|
|
@@ -2093,8 +2400,9 @@ export class HavokPlugin {
|
|
|
2093
2400
|
this._hknp.HP_Body_SetEventMask(body._pluginData.hpBodyId, currentCollideEvents);
|
|
2094
2401
|
}
|
|
2095
2402
|
}
|
|
2096
|
-
_notifyTriggers() {
|
|
2097
|
-
|
|
2403
|
+
_notifyTriggers(world) {
|
|
2404
|
+
const targetWorld = world ?? this.world;
|
|
2405
|
+
let eventAddress = this._hknp.HP_World_GetTriggerEvents(targetWorld)[1];
|
|
2098
2406
|
const event = new TriggerEvent();
|
|
2099
2407
|
while (eventAddress) {
|
|
2100
2408
|
TriggerEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);
|
|
@@ -2111,20 +2419,30 @@ export class HavokPlugin {
|
|
|
2111
2419
|
};
|
|
2112
2420
|
this.onTriggerCollisionObservable.notifyObservers(triggerCollisionInfo);
|
|
2113
2421
|
}
|
|
2114
|
-
eventAddress = this._hknp.HP_World_GetNextTriggerEvent(
|
|
2422
|
+
eventAddress = this._hknp.HP_World_GetNextTriggerEvent(targetWorld, eventAddress);
|
|
2115
2423
|
}
|
|
2116
2424
|
}
|
|
2117
2425
|
/**
|
|
2118
2426
|
* Runs thru all detected collisions and filter by body
|
|
2427
|
+
* @param world optional world to check collisions for (defaults to main world)
|
|
2119
2428
|
*/
|
|
2120
|
-
_notifyCollisions() {
|
|
2121
|
-
|
|
2429
|
+
_notifyCollisions(world) {
|
|
2430
|
+
const targetWorld = world ?? this.world;
|
|
2431
|
+
let eventAddress = this._hknp.HP_World_GetCollisionEvents(targetWorld)[1];
|
|
2122
2432
|
const event = new CollisionEvent();
|
|
2123
|
-
const worldAddr = Number(
|
|
2433
|
+
const worldAddr = Number(targetWorld);
|
|
2434
|
+
// Find the region for this world to get the correct floating origin offset.
|
|
2435
|
+
// All bodies in a collision share the same world, so use one offset for both.
|
|
2436
|
+
const region = this._worldRegions.find((r) => Number(r.world) === worldAddr) ?? this._worldRegions[0];
|
|
2437
|
+
const regionOffset = region.floatingOrigin;
|
|
2124
2438
|
while (eventAddress) {
|
|
2125
2439
|
CollisionEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);
|
|
2126
2440
|
const bodyInfoA = this._bodies.get(event.contactOnA.bodyId);
|
|
2127
2441
|
const bodyInfoB = this._bodies.get(event.contactOnB.bodyId);
|
|
2442
|
+
// Add floating origin offset back to collision contact positions.
|
|
2443
|
+
// Both contacts are in the same world, so use the region's floating origin.
|
|
2444
|
+
event.contactOnA.position.addInPlace(regionOffset);
|
|
2445
|
+
event.contactOnB.position.addInPlace(regionOffset);
|
|
2128
2446
|
// Bodies may have been disposed between events. Check both still exist.
|
|
2129
2447
|
if (bodyInfoA && bodyInfoB) {
|
|
2130
2448
|
const collisionInfo = {
|
|
@@ -2212,12 +2530,16 @@ export class HavokPlugin {
|
|
|
2212
2530
|
}
|
|
2213
2531
|
if (this._multiQueryCollector) {
|
|
2214
2532
|
this._hknp.HP_QueryCollector_Release(this._multiQueryCollector);
|
|
2215
|
-
this._multiQueryCollector;
|
|
2533
|
+
this._multiQueryCollector = undefined;
|
|
2216
2534
|
}
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2535
|
+
// Dispose all world regions (includes the default world)
|
|
2536
|
+
for (const region of this._worldRegions) {
|
|
2537
|
+
if (region.world) {
|
|
2538
|
+
this._hknp.HP_World_Release(region.world);
|
|
2539
|
+
}
|
|
2220
2540
|
}
|
|
2541
|
+
this._worldRegions.length = 0;
|
|
2542
|
+
this.world = undefined;
|
|
2221
2543
|
}
|
|
2222
2544
|
_v3ToBvecRef(v, vec3) {
|
|
2223
2545
|
vec3.set(v[0], v[1], v[2]);
|
|
@@ -2225,6 +2547,19 @@ export class HavokPlugin {
|
|
|
2225
2547
|
_bVecToV3(v) {
|
|
2226
2548
|
return [v._x, v._y, v._z];
|
|
2227
2549
|
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Converts a Vector3 to Havok format with floating origin offset subtracted.
|
|
2552
|
+
* Use this for world-space positions being sent to Havok.
|
|
2553
|
+
* @param v - The vector to convert
|
|
2554
|
+
* @param offset - Optional offset to use. If not provided, no offset is applied.
|
|
2555
|
+
* @returns The converted vector
|
|
2556
|
+
*/
|
|
2557
|
+
_bVecToV3WithOffset(v, offset) {
|
|
2558
|
+
if (offset) {
|
|
2559
|
+
return [v._x - offset._x, v._y - offset._y, v._z - offset._z];
|
|
2560
|
+
}
|
|
2561
|
+
return [v._x, v._y, v._z];
|
|
2562
|
+
}
|
|
2228
2563
|
_bQuatToV4(q) {
|
|
2229
2564
|
return [q._x, q._y, q._z, q._w];
|
|
2230
2565
|
}
|