@babylonjs/core 9.11.0 → 9.12.0
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/Actions/actionManager.d.ts +1 -1
- package/Actions/actionManager.js +8 -5
- package/Actions/actionManager.js.map +1 -1
- package/Animations/animatable.core.d.ts +1 -1
- package/Animations/animatable.core.js +2 -2
- package/Animations/animatable.core.js.map +1 -1
- package/Animations/animationPropertiesOverride.js +1 -1
- package/Animations/animationPropertiesOverride.js.map +1 -1
- package/Animations/animatorAvatar.d.ts +2 -2
- package/Animations/animatorAvatar.js +3 -3
- package/Animations/animatorAvatar.js.map +1 -1
- package/Animations/pathCursor.d.ts +1 -1
- package/Animations/pathCursor.js +1 -1
- package/Animations/pathCursor.js.map +1 -1
- package/Animations/runtimeAnimation.d.ts +1 -1
- package/Animations/runtimeAnimation.js +2 -2
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/analyser.js +1 -1
- package/Audio/analyser.js.map +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +1 -1
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +1 -1
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.d.ts +1 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js +1 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
- package/BakedVertexAnimation/vertexAnimationBaker.js +1 -1
- package/BakedVertexAnimation/vertexAnimationBaker.js.map +1 -1
- package/Behaviors/Cameras/bouncingBehavior.js +1 -1
- package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
- package/Behaviors/Cameras/framingBehavior.d.ts +1 -1
- package/Behaviors/Cameras/framingBehavior.js +2 -2
- package/Behaviors/Cameras/framingBehavior.js.map +1 -1
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +13 -1
- package/Behaviors/Cameras/interpolatingBehavior.js +13 -1
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
- package/Behaviors/Meshes/attachToBoxBehavior.js +1 -1
- package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
- package/Behaviors/Meshes/baseSixDofDragBehavior.d.ts +3 -3
- package/Behaviors/Meshes/baseSixDofDragBehavior.js +4 -4
- package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/followBehavior.js +1 -1
- package/Behaviors/Meshes/followBehavior.js.map +1 -1
- package/Behaviors/Meshes/handConstraintBehavior.js +2 -2
- package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
- package/Behaviors/Meshes/multiPointerScaleBehavior.js +1 -1
- package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.d.ts +3 -3
- package/Behaviors/Meshes/pointerDragBehavior.js +5 -5
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/sixDofDragBehavior.d.ts +1 -1
- package/Behaviors/Meshes/sixDofDragBehavior.js +2 -2
- package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/surfaceMagnetismBehavior.js +1 -1
- package/Behaviors/Meshes/surfaceMagnetismBehavior.js.map +1 -1
- package/Bones/boneIKController.d.ts +1 -1
- package/Bones/boneIKController.js +1 -1
- package/Bones/boneIKController.js.map +1 -1
- package/Bones/boneLookController.d.ts +1 -1
- package/Bones/boneLookController.js +1 -1
- package/Bones/boneLookController.js.map +1 -1
- package/Bones/skeleton.d.ts +2 -2
- package/Bones/skeleton.functions.d.ts +1 -1
- package/Bones/skeleton.functions.js +3 -3
- package/Bones/skeleton.functions.js.map +1 -1
- package/Bones/skeleton.js +3 -4
- package/Bones/skeleton.js.map +1 -1
- package/Buffers/buffer.align.pure.js +6 -0
- package/Buffers/buffer.align.pure.js.map +1 -1
- package/Buffers/buffer.nonFloatVertexBuffers.js +2 -1
- package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -1
- package/Buffers/buffer.pure.d.ts +8 -0
- package/Buffers/buffer.pure.js +31 -2
- package/Buffers/buffer.pure.js.map +1 -1
- package/Buffers/bufferUtils.js +17 -5
- package/Buffers/bufferUtils.js.map +1 -1
- package/Cameras/Inputs/BaseCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.js +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js +1 -1
- package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +2 -2
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraKeyboardInput.js +2 -2
- package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js +2 -2
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/followCameraKeyboardMoveInput.js +1 -1
- package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/followCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraGamepadInput.js +1 -1
- package/Cameras/Inputs/freeCameraGamepadInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +2 -2
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/freeCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js +2 -2
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js +1 -1
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
- package/Cameras/Limits/geospatialLimits.d.ts +1 -1
- package/Cameras/Limits/geospatialLimits.js +1 -1
- package/Cameras/Limits/geospatialLimits.js.map +1 -1
- package/Cameras/RigModes/stereoscopicAnaglyphRigMode.js +2 -2
- package/Cameras/RigModes/stereoscopicAnaglyphRigMode.js.map +1 -1
- package/Cameras/RigModes/stereoscopicRigMode.d.ts +1 -1
- package/Cameras/RigModes/stereoscopicRigMode.js +3 -3
- package/Cameras/RigModes/stereoscopicRigMode.js.map +1 -1
- package/Cameras/RigModes/vrRigMode.js +2 -2
- package/Cameras/RigModes/vrRigMode.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.d.ts +3 -3
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js +5 -5
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
- package/Cameras/VR/vrCameraMetrics.d.ts +1 -1
- package/Cameras/VR/vrCameraMetrics.js +1 -1
- package/Cameras/VR/vrCameraMetrics.js.map +1 -1
- package/Cameras/cameraInputsManager.d.ts +1 -1
- package/Cameras/cameraInputsManager.js +1 -1
- package/Cameras/cameraInputsManager.js.map +1 -1
- package/Collisions/collider.d.ts +1 -1
- package/Collisions/collider.js +1 -1
- package/Collisions/collider.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +1 -1
- package/Collisions/gpuPicker.js +5 -5
- package/Collisions/gpuPicker.js.map +1 -1
- package/Collisions/meshCollisionData.d.ts +1 -1
- package/Collisions/meshCollisionData.js +1 -1
- package/Collisions/meshCollisionData.js.map +1 -1
- package/Collisions/pickingInfo.d.ts +1 -1
- package/Collisions/pickingInfo.js +2 -2
- package/Collisions/pickingInfo.js.map +1 -1
- package/Culling/Octrees/octreeBlock.d.ts +1 -1
- package/Culling/Octrees/octreeBlock.js +1 -1
- package/Culling/Octrees/octreeBlock.js.map +1 -1
- package/Culling/boundingBox.d.ts +1 -1
- package/Culling/boundingBox.js +1 -1
- package/Culling/boundingBox.js.map +1 -1
- package/Culling/boundingInfo.d.ts +1 -1
- package/Culling/boundingInfo.js +1 -1
- package/Culling/boundingInfo.js.map +1 -1
- package/Culling/boundingSphere.d.ts +1 -1
- package/Culling/boundingSphere.js +1 -1
- package/Culling/boundingSphere.js.map +1 -1
- package/Culling/ray.core.d.ts +1 -1
- package/Culling/ray.core.js +1 -1
- package/Culling/ray.core.js.map +1 -1
- package/Debug/axesViewer.d.ts +1 -1
- package/Debug/axesViewer.js +3 -3
- package/Debug/axesViewer.js.map +1 -1
- package/Debug/boneAxesViewer.d.ts +1 -1
- package/Debug/boneAxesViewer.js +1 -1
- package/Debug/boneAxesViewer.js.map +1 -1
- package/Debug/directionalLightFrustumViewer.d.ts +1 -1
- package/Debug/directionalLightFrustumViewer.js +6 -6
- package/Debug/directionalLightFrustumViewer.js.map +1 -1
- package/Debug/rayHelper.d.ts +1 -1
- package/Debug/rayHelper.js +2 -2
- package/Debug/rayHelper.js.map +1 -1
- package/Debug/skeletonViewer.d.ts +2 -2
- package/Debug/skeletonViewer.js +10 -10
- package/Debug/skeletonViewer.js.map +1 -1
- package/DeviceInput/internalDeviceSourceManager.d.ts +1 -1
- package/DeviceInput/internalDeviceSourceManager.js +0 -1
- package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +1 -1
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +1 -1
- package/Engines/Extensions/engine.views.js +1 -1
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Native/nativeHelpers.js +4 -1
- package/Engines/Native/nativeHelpers.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +11 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuComputeContext.d.ts +1 -1
- package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
- package/Engines/WebGPU/webgpuTintWASM.js +1 -1
- package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
- package/Engines/abstractEngine.pure.js +2 -2
- package/Engines/abstractEngine.pure.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/engineFactory.d.ts +2 -2
- package/Engines/engineFactory.js +3 -3
- package/Engines/engineFactory.js.map +1 -1
- package/Events/pointerEvents.d.ts +1 -1
- package/Events/pointerEvents.js +1 -1
- package/Events/pointerEvents.js.map +1 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphCodeExecutionBlock.js +1 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphCodeExecutionBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphKeyboardEventBlock.js +1 -1
- package/FlowGraph/Blocks/Event/flowGraphKeyboardEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.js +3 -3
- package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.js.map +1 -1
- package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +1 -1
- package/FlowGraph/CustomTypes/flowGraphMatrix.js +1 -1
- package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
- package/FlowGraph/flowGraphBlock.d.ts +1 -1
- package/FlowGraph/flowGraphBlock.js +1 -1
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -1
- package/FlowGraph/flowGraphExecutionBlock.js +1 -1
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphMath.d.ts +1 -1
- package/FlowGraph/flowGraphMath.js +1 -1
- package/FlowGraph/flowGraphMath.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +1 -1
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/flowGraphPathConverterComponent.d.ts +1 -1
- package/FlowGraph/flowGraphPathConverterComponent.js +2 -2
- package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -1
- package/FlowGraph/flowGraphValidator.js.map +1 -1
- package/FlowGraph/serialization.js +4 -4
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/utils.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +2 -2
- package/FrameGraph/Node/nodeRenderGraph.js +7 -7
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +30 -0
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +28 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +2 -2
- package/FrameGraph/Tasks/Misc/computeShaderTask.js +2 -2
- package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.d.ts +1 -1
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js +2 -2
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/blurTask.d.ts +7 -0
- package/FrameGraph/Tasks/PostProcesses/blurTask.js +8 -1
- package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +2 -2
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js +3 -3
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +2 -2
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +6 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +14 -5
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.d.ts +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.js +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.d.ts +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.js +2 -2
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.d.ts +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.js +2 -2
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +7 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +7 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.js +1 -1
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +1 -1
- package/FrameGraph/frameGraphTextureManager.js +1 -1
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/Gamepads/gamepadManager.js +1 -1
- package/Gamepads/gamepadManager.js.map +1 -1
- package/Gizmos/axisDragGizmo.d.ts +5 -5
- package/Gizmos/axisDragGizmo.js +6 -6
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.d.ts +4 -4
- package/Gizmos/axisScaleGizmo.js +6 -6
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +5 -5
- package/Gizmos/boundingBoxGizmo.js +7 -7
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.d.ts +3 -3
- package/Gizmos/cameraGizmo.js +7 -7
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.d.ts +2 -2
- package/Gizmos/gizmo.js +3 -3
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.d.ts +2 -2
- package/Gizmos/gizmoManager.js +2 -2
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/lightGizmo.d.ts +4 -4
- package/Gizmos/lightGizmo.js +11 -11
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.d.ts +4 -4
- package/Gizmos/planeDragGizmo.js +5 -5
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +1 -1
- package/Gizmos/positionGizmo.js +2 -2
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +3 -3
- package/Gizmos/rotationGizmo.js +3 -3
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +2 -2
- package/Gizmos/scaleGizmo.js +4 -4
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Gizmos/spatialAudioGizmo.d.ts +2 -2
- package/Gizmos/spatialAudioGizmo.js +6 -6
- package/Gizmos/spatialAudioGizmo.js.map +1 -1
- package/Helpers/environmentHelper.d.ts +6 -6
- package/Helpers/environmentHelper.js +12 -12
- package/Helpers/environmentHelper.js.map +1 -1
- package/Helpers/materialConversionHelper.d.ts +1 -1
- package/Helpers/materialConversionHelper.js +1 -1
- package/Helpers/materialConversionHelper.js.map +1 -1
- package/Helpers/photoDome.d.ts +1 -1
- package/Helpers/photoDome.js +1 -1
- package/Helpers/photoDome.js.map +1 -1
- package/Helpers/textureDome.d.ts +4 -4
- package/Helpers/textureDome.js +6 -6
- package/Helpers/textureDome.js.map +1 -1
- package/Helpers/videoDome.d.ts +1 -1
- package/Helpers/videoDome.js +2 -2
- package/Helpers/videoDome.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +1 -1
- package/Inputs/scene.inputManager.js +1 -1
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Instrumentation/sceneInstrumentation.js +1 -1
- package/Instrumentation/sceneInstrumentation.js.map +1 -1
- package/Layers/effectLayer.d.ts +1 -1
- package/Layers/effectLayer.js +3 -3
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/layer.d.ts +2 -2
- package/Layers/layer.js +4 -4
- package/Layers/layer.js.map +1 -1
- package/Layers/thinEffectLayer.d.ts +2 -2
- package/Layers/thinEffectLayer.js +3 -3
- package/Layers/thinEffectLayer.js.map +1 -1
- package/Layers/thinGlowLayer.d.ts +1 -1
- package/Layers/thinGlowLayer.js +3 -3
- package/Layers/thinGlowLayer.js.map +1 -1
- package/Layers/thinHighlightLayer.d.ts +1 -1
- package/Layers/thinHighlightLayer.js +3 -3
- package/Layers/thinHighlightLayer.js.map +1 -1
- package/Layers/thinSelectionOutlineLayer.d.ts +1 -1
- package/Layers/thinSelectionOutlineLayer.js +3 -3
- package/Layers/thinSelectionOutlineLayer.js.map +1 -1
- package/Legacy/legacy.js +12 -1
- package/Legacy/legacy.js.map +1 -1
- package/LensFlares/lensFlare.d.ts +2 -2
- package/LensFlares/lensFlare.js +3 -3
- package/LensFlares/lensFlare.js.map +1 -1
- package/LensFlares/lensFlareSystem.d.ts +1 -1
- package/LensFlares/lensFlareSystem.js +6 -6
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Lights/LTC/ltcTextureTool.js +1 -1
- package/Lights/LTC/ltcTextureTool.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.d.ts +1 -285
- package/Lights/Shadows/cascadedShadowGenerator.js +3 -857
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.d.ts +290 -0
- package/Lights/Shadows/cascadedShadowGenerator.pure.js +868 -0
- package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -0
- package/Lights/Shadows/pure.d.ts +1 -0
- package/Lights/Shadows/pure.js +1 -0
- package/Lights/Shadows/pure.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +3 -3
- package/Lights/Shadows/shadowGenerator.js +7 -7
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/areaLight.d.ts +1 -1
- package/Lights/areaLight.js +0 -1
- package/Lights/areaLight.js.map +1 -1
- package/Lights/light.d.ts +2 -2
- package/Lights/light.js +2 -2
- package/Lights/light.js.map +1 -1
- package/Lights/shadowLight.d.ts +1 -1
- package/Lights/shadowLight.js +1 -1
- package/Lights/shadowLight.js.map +1 -1
- package/Loading/sceneLoader.d.ts +2 -2
- package/Loading/sceneLoader.js +3 -3
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GreasedLine/greasedLineMaterialDefaults.d.ts +1 -1
- package/Materials/GreasedLine/greasedLineMaterialDefaults.js +1 -1
- package/Materials/GreasedLine/greasedLineMaterialDefaults.js.map +1 -1
- package/Materials/GreasedLine/greasedLineSimpleMaterial.d.ts +3 -3
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js +3 -3
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.pure.js +6 -6
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.pure.js.map +1 -1
- package/Materials/Node/nodeMaterial.pure.d.ts +12 -0
- package/Materials/Node/nodeMaterial.pure.js +68 -13
- package/Materials/Node/nodeMaterial.pure.js.map +1 -1
- package/Materials/Node/nodeMaterialDefault.js +14 -14
- package/Materials/Node/nodeMaterialDefault.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js +19 -4
- package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +40 -2
- package/Materials/PBR/pbrAnisotropicConfiguration.js +41 -3
- package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBRDFConfiguration.d.ts +5 -1
- package/Materials/PBR/pbrBRDFConfiguration.js +5 -1
- package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +2 -2
- package/Materials/PBR/pbrBaseSimpleMaterial.js +2 -2
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.d.ts +42 -2
- package/Materials/PBR/pbrClearCoatConfiguration.js +42 -2
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.d.ts +38 -1
- package/Materials/PBR/pbrIridescenceConfiguration.js +38 -1
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.d.ts +41 -2
- package/Materials/PBR/pbrSheenConfiguration.js +41 -2
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +41 -2
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +42 -3
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.d.ts +1 -1
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +2 -2
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -1
- package/Materials/Textures/Loaders/EXR/exrLoader.core.d.ts +1 -1
- package/Materials/Textures/Loaders/EXR/exrLoader.core.js +5 -109
- package/Materials/Textures/Loaders/EXR/exrLoader.core.js.map +1 -1
- package/Materials/Textures/Loaders/EXR/exrLoader.decoder.js +1 -1
- package/Materials/Textures/Loaders/EXR/exrLoader.decoder.js.map +1 -1
- package/Materials/Textures/Loaders/basisTextureLoader.js +2 -2
- package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ddsTextureLoader.js +1 -1
- package/Materials/Textures/Loaders/ddsTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/envTextureLoader.js +3 -1
- package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +11 -2
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/MultiviewRenderTarget.d.ts +1 -1
- package/Materials/Textures/MultiviewRenderTarget.js +1 -1
- package/Materials/Textures/MultiviewRenderTarget.js.map +1 -1
- package/Materials/Textures/Packer/packer.d.ts +1 -1
- package/Materials/Textures/Packer/packer.js +6 -6
- package/Materials/Textures/Packer/packer.js.map +1 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.d.ts +2 -2
- package/Materials/Textures/Procedurals/customProceduralTexture.js +4 -4
- package/Materials/Textures/Procedurals/customProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js +4 -1
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTextureSceneComponent.js +1 -1
- package/Materials/Textures/Procedurals/proceduralTextureSceneComponent.js.map +1 -1
- package/Materials/Textures/prePassRenderTarget.d.ts +1 -1
- package/Materials/Textures/prePassRenderTarget.js +1 -1
- package/Materials/Textures/prePassRenderTarget.js.map +1 -1
- package/Materials/Textures/rawCubeTexture.d.ts +1 -1
- package/Materials/Textures/rawCubeTexture.js +2 -2
- package/Materials/Textures/rawCubeTexture.js.map +1 -1
- package/Materials/Textures/rawTexture.d.ts +1 -1
- package/Materials/Textures/rawTexture.js +1 -1
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/rawTexture2DArray.d.ts +1 -1
- package/Materials/Textures/rawTexture2DArray.js +1 -1
- package/Materials/Textures/rawTexture2DArray.js.map +1 -1
- package/Materials/Textures/rawTexture3D.d.ts +1 -1
- package/Materials/Textures/rawTexture3D.js +1 -1
- package/Materials/Textures/rawTexture3D.js.map +1 -1
- package/Materials/Textures/refractionTexture.d.ts +1 -1
- package/Materials/Textures/refractionTexture.js +1 -1
- package/Materials/Textures/refractionTexture.js.map +1 -1
- package/Materials/Textures/textureMerger.d.ts +1 -1
- package/Materials/Textures/textureMerger.js +1 -1
- package/Materials/Textures/textureMerger.js.map +1 -1
- package/Materials/Textures/textureProcessor.d.ts +1 -1
- package/Materials/Textures/textureProcessor.js +2 -2
- package/Materials/Textures/textureProcessor.js.map +1 -1
- package/Materials/Textures/thinRenderTargetTexture.d.ts +4 -4
- package/Materials/Textures/thinRenderTargetTexture.js +2 -2
- package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +1 -1
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/effectRenderer.pure.js +4 -2
- package/Materials/effectRenderer.pure.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +1 -1
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/material.detailMapConfiguration.d.ts +39 -1
- package/Materials/material.detailMapConfiguration.js +39 -1
- package/Materials/material.detailMapConfiguration.js.map +1 -1
- package/Materials/materialHelper.functions.js +45 -1
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.d.ts +1 -1
- package/Materials/materialHelper.geometryrendering.js +1 -1
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/materialPluginFactoryExport.js +2 -2
- package/Materials/materialPluginFactoryExport.js.map +1 -1
- package/Materials/pushMaterial.d.ts +7 -1
- package/Materials/pushMaterial.js +7 -1
- package/Materials/pushMaterial.js.map +1 -1
- package/Materials/uniformBuffer.js +1 -1
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.axis.d.ts +1 -1
- package/Maths/math.axis.js +1 -1
- package/Maths/math.axis.js.map +1 -1
- package/Maths/math.d.ts +2 -2
- package/Maths/math.functions.d.ts +1 -1
- package/Maths/math.functions.js +1 -1
- package/Maths/math.functions.js.map +1 -1
- package/Maths/math.isovector.d.ts +1 -1
- package/Maths/math.isovector.js +1 -1
- package/Maths/math.isovector.js.map +1 -1
- package/Maths/math.js +2 -2
- package/Maths/math.js.map +1 -1
- package/Maths/math.path.d.ts +1 -1
- package/Maths/math.path.js +1 -1
- package/Maths/math.path.js.map +1 -1
- package/Maths/math.plane.d.ts +1 -1
- package/Maths/math.plane.js +1 -1
- package/Maths/math.plane.js.map +1 -1
- package/Maths/math.polar.d.ts +1 -1
- package/Maths/math.polar.js +1 -1
- package/Maths/math.polar.js.map +1 -1
- package/Maths/math.vertexFormat.d.ts +1 -1
- package/Maths/math.vertexFormat.js +1 -1
- package/Maths/math.vertexFormat.js.map +1 -1
- package/Maths/pure.d.ts +1 -0
- package/Maths/pure.js +1 -0
- package/Maths/pure.js.map +1 -1
- package/Meshes/Builders/geodesicBuilder.js +1 -1
- package/Meshes/Builders/geodesicBuilder.js.map +1 -1
- package/Meshes/Builders/goldbergBuilder.d.ts +1 -1
- package/Meshes/Builders/goldbergBuilder.js +4 -4
- package/Meshes/Builders/goldbergBuilder.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +4 -4
- package/Meshes/Builders/greasedLineBuilder.js +5 -5
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/Builders/textBuilder.d.ts +2 -2
- package/Meshes/Builders/textBuilder.js +4 -4
- package/Meshes/Builders/textBuilder.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.d.ts +3 -3
- package/Meshes/Builders/tiledBoxBuilder.js +3 -3
- package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
- package/Meshes/Builders/tiledPlaneBuilder.d.ts +1 -1
- package/Meshes/Builders/tiledPlaneBuilder.js +1 -1
- package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
- package/Meshes/Compression/dracoCodec.js +1 -1
- package/Meshes/Compression/dracoCodec.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.js +1 -1
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.d.ts +1 -1
- package/Meshes/Compression/dracoEncoder.js +2 -2
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.js +1 -1
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +64 -3
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +2 -2
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +3 -3
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/Node/nodeGeometry.d.ts +2 -2
- package/Meshes/Node/nodeGeometry.js +4 -4
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.d.ts +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/abstractMesh.hotSpot.d.ts +1 -1
- package/Meshes/abstractMesh.hotSpot.js +2 -2
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +2 -13
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/buffer.d.ts +1 -1
- package/Meshes/buffer.js +1 -1
- package/Meshes/buffer.js.map +1 -1
- package/Meshes/csg.d.ts +3 -3
- package/Meshes/csg.js +4 -4
- package/Meshes/csg.js.map +1 -1
- package/Meshes/csg2.d.ts +1 -1
- package/Meshes/csg2.js +38 -11
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/geodesicMesh.d.ts +1 -1
- package/Meshes/geodesicMesh.js +1 -1
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/geometry.d.ts +2 -2
- package/Meshes/geometry.js +4 -4
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/lattice.d.ts +1 -1
- package/Meshes/lattice.js +1 -1
- package/Meshes/lattice.js.map +1 -1
- package/Meshes/lattice.material.d.ts +1 -1
- package/Meshes/lattice.material.js +1 -1
- package/Meshes/lattice.material.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +2 -2
- package/Meshes/mesh.vertexData.js +3 -4
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/mesh.vertexData.subdivide.js +1 -1
- package/Meshes/mesh.vertexData.subdivide.js.map +1 -1
- package/Meshes/meshBuilder.d.ts +18 -18
- package/Meshes/meshBuilder.js +18 -18
- package/Meshes/meshBuilder.js.map +1 -1
- package/Meshes/meshSimplification.d.ts +1 -1
- package/Meshes/meshSimplification.js +4 -4
- package/Meshes/meshSimplification.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.d.ts +1 -1
- package/Meshes/meshUVSpaceRenderer.js +0 -1
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Meshes/meshUtils.d.ts +1 -1
- package/Meshes/meshUtils.js +2 -2
- package/Meshes/meshUtils.js.map +1 -1
- package/Meshes/polygonMesh.d.ts +2 -2
- package/Meshes/polygonMesh.js +3 -3
- package/Meshes/polygonMesh.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +2 -2
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/HighDynamicRange/panoramaToCubemap.js +1 -1
- package/Misc/HighDynamicRange/panoramaToCubemap.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
- package/Misc/areaLightsTextureTools.d.ts +1 -1
- package/Misc/areaLightsTextureTools.js +3 -3
- package/Misc/areaLightsTextureTools.js.map +1 -1
- package/Misc/assetsManager.d.ts +4 -4
- package/Misc/assetsManager.js +5 -5
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/basisWorker.js +1 -1
- package/Misc/basisWorker.js.map +1 -1
- package/Misc/brdfTextureTools.js +1 -1
- package/Misc/brdfTextureTools.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +1 -1
- package/Misc/copyTextureToTexture.js +1 -1
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/decorators.serialization.js +2 -2
- package/Misc/decorators.serialization.js.map +1 -1
- package/Misc/depthReducer.d.ts +2 -2
- package/Misc/depthReducer.js +2 -2
- package/Misc/depthReducer.js.map +1 -1
- package/Misc/gradients.d.ts +1 -1
- package/Misc/gradients.js +1 -1
- package/Misc/gradients.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +1 -1
- package/Misc/greasedLineTools.js +3 -3
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/halfFloat.d.ts +17 -0
- package/Misc/halfFloat.js +131 -0
- package/Misc/halfFloat.js.map +1 -0
- package/Misc/khronosTextureContainer2.js +1 -1
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/meshExploder.js +1 -1
- package/Misc/meshExploder.js.map +1 -1
- package/Misc/pivotTools.js +1 -1
- package/Misc/pivotTools.js.map +1 -1
- package/Misc/rgbdTextureTools.js +1 -1
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/Misc/sceneOptimizer.js +1 -1
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Misc/sceneRecorder.js +7 -7
- package/Misc/sceneRecorder.js.map +1 -1
- package/Misc/sceneSerializer.js +3 -3
- package/Misc/sceneSerializer.js.map +1 -1
- package/Misc/snapshotRenderingHelper.js +1 -1
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/textureTools.d.ts +3 -13
- package/Misc/textureTools.js +6 -64
- package/Misc/textureTools.js.map +1 -1
- package/Misc/thinMinMaxReducer.d.ts +1 -1
- package/Misc/thinMinMaxReducer.js +1 -1
- package/Misc/thinMinMaxReducer.js.map +1 -1
- package/Misc/tools.internals.js +1 -1
- package/Misc/tools.internals.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Misc/trajectoryClassifier.d.ts +1 -1
- package/Misc/trajectoryClassifier.js +1 -1
- package/Misc/trajectoryClassifier.js.map +1 -1
- package/Misc/videoRecorder.js +1 -1
- package/Misc/videoRecorder.js.map +1 -1
- package/Misc/virtualJoystick.d.ts +1 -1
- package/Misc/virtualJoystick.js +1 -1
- package/Misc/virtualJoystick.js.map +1 -1
- package/Morph/morphTarget.js +1 -1
- package/Morph/morphTarget.js.map +1 -1
- package/Navigation/Plugins/recastJSPlugin.d.ts +1 -1
- package/Navigation/Plugins/recastJSPlugin.js +2 -2
- package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
- package/Particles/EmitterTypes/boxParticleEmitter.d.ts +1 -1
- package/Particles/EmitterTypes/boxParticleEmitter.js +1 -1
- package/Particles/EmitterTypes/boxParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/customParticleEmitter.d.ts +1 -1
- package/Particles/EmitterTypes/customParticleEmitter.js +1 -1
- package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.d.ts +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.js +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/hemisphericParticleEmitter.d.ts +1 -1
- package/Particles/EmitterTypes/hemisphericParticleEmitter.js +1 -1
- package/Particles/EmitterTypes/hemisphericParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/meshParticleEmitter.d.ts +1 -1
- package/Particles/EmitterTypes/meshParticleEmitter.js +2 -2
- package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/pointParticleEmitter.d.ts +1 -1
- package/Particles/EmitterTypes/pointParticleEmitter.js +1 -1
- package/Particles/EmitterTypes/pointParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +4 -4
- package/Particles/Node/nodeParticleBuildState.js +2 -2
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.d.ts +2 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +31 -31
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +8 -8
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/attractor.d.ts +1 -1
- package/Particles/attractor.js +1 -1
- package/Particles/attractor.js.map +1 -1
- package/Particles/flowMap.d.ts +7 -1
- package/Particles/flowMap.js +7 -1
- package/Particles/flowMap.js.map +1 -1
- package/Particles/particle.d.ts +2 -2
- package/Particles/particle.js +2 -2
- package/Particles/particle.js.map +1 -1
- package/Particles/particleHelper.js +5 -5
- package/Particles/particleHelper.js.map +1 -1
- package/Particles/particleSystem.functions.d.ts +1 -1
- package/Particles/particleSystem.functions.js +1 -1
- package/Particles/particleSystem.functions.js.map +1 -1
- package/Particles/particleSystemSet.d.ts +1 -1
- package/Particles/particleSystemSet.js +5 -5
- package/Particles/particleSystemSet.js.map +1 -1
- package/Particles/pointsCloudSystem.d.ts +1 -1
- package/Particles/pointsCloudSystem.js +6 -6
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Particles/solidParticle.d.ts +2 -2
- package/Particles/solidParticle.js +3 -3
- package/Particles/solidParticle.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +4 -4
- package/Particles/solidParticleSystem.js +7 -7
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/subEmitter.js +1 -1
- package/Particles/subEmitter.js.map +1 -1
- package/Particles/thinParticleSystem.function.js +2 -2
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Physics/Plugins/cannonJSPlugin.d.ts +1 -1
- package/Physics/Plugins/cannonJSPlugin.js +1 -1
- package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
- package/Physics/castingResult.d.ts +1 -1
- package/Physics/castingResult.js +1 -1
- package/Physics/castingResult.js.map +1 -1
- package/Physics/physicsHelper.d.ts +1 -1
- package/Physics/physicsHelper.js +4 -4
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/physicsImpostor.d.ts +1 -1
- package/Physics/physicsImpostor.js +1 -1
- package/Physics/physicsImpostor.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +1 -1
- package/Physics/physicsRaycastResult.js +1 -1
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v1/Plugins/ammoJSPlugin.d.ts +2 -2
- package/Physics/v1/Plugins/ammoJSPlugin.js +5 -5
- package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/v1/Plugins/oimoJSPlugin.d.ts +2 -2
- package/Physics/v1/Plugins/oimoJSPlugin.js +2 -2
- package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -1
- package/Physics/v1/physicsEngine.d.ts +1 -1
- package/Physics/v1/physicsEngine.js +1 -1
- package/Physics/v1/physicsEngine.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +14 -2
- package/Physics/v2/Plugins/havokPlugin.js +45 -7
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/characterController.d.ts +1 -1
- package/Physics/v2/characterController.js +2 -2
- package/Physics/v2/characterController.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +3 -3
- package/Physics/v2/physicsAggregate.js +10 -6
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +1 -1
- package/Physics/v2/physicsBody.js +1 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +1 -1
- package/Physics/v2/physicsEngine.js +1 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Physics/v2/physicsShape.d.ts +1 -1
- package/Physics/v2/physicsShape.js +1 -1
- package/Physics/v2/physicsShape.js.map +1 -1
- package/Physics/v2/ragdoll.d.ts +2 -2
- package/Physics/v2/ragdoll.js +2 -2
- package/Physics/v2/ragdoll.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js +8 -6
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +3 -2
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/bloomEffect.d.ts +1 -1
- package/PostProcesses/bloomEffect.js +4 -4
- package/PostProcesses/bloomEffect.js.map +1 -1
- package/PostProcesses/depthOfFieldEffect.d.ts +1 -1
- package/PostProcesses/depthOfFieldEffect.js +3 -3
- package/PostProcesses/depthOfFieldEffect.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.d.ts +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/highlightsPostProcess.d.ts +1 -1
- package/PostProcesses/highlightsPostProcess.js +1 -1
- package/PostProcesses/highlightsPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.d.ts +1 -1
- package/PostProcesses/imageProcessingPostProcess.js +1 -1
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/postProcessManager.d.ts +3 -0
- package/PostProcesses/postProcessManager.js +4 -1
- package/PostProcesses/postProcessManager.js.map +1 -1
- package/PostProcesses/subSurfaceScatteringPostProcess.pure.d.ts +1 -0
- package/PostProcesses/subSurfaceScatteringPostProcess.pure.js +10 -0
- package/PostProcesses/subSurfaceScatteringPostProcess.pure.js.map +1 -1
- package/PostProcesses/thinAnaglyphPostProcess.d.ts +1 -1
- package/PostProcesses/thinAnaglyphPostProcess.js +1 -1
- package/PostProcesses/thinAnaglyphPostProcess.js.map +1 -1
- package/PostProcesses/thinBlackAndWhitePostProcess.d.ts +1 -1
- package/PostProcesses/thinBlackAndWhitePostProcess.js +1 -1
- package/PostProcesses/thinBlackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/thinBloomEffect.js +1 -1
- package/PostProcesses/thinBloomEffect.js.map +1 -1
- package/PostProcesses/thinBloomMergePostProcess.d.ts +1 -1
- package/PostProcesses/thinBloomMergePostProcess.js +1 -1
- package/PostProcesses/thinBloomMergePostProcess.js.map +1 -1
- package/PostProcesses/thinBlurPostProcess.d.ts +1 -1
- package/PostProcesses/thinBlurPostProcess.js +1 -1
- package/PostProcesses/thinBlurPostProcess.js.map +1 -1
- package/PostProcesses/thinChromaticAberrationPostProcess.d.ts +2 -2
- package/PostProcesses/thinChromaticAberrationPostProcess.js +2 -2
- package/PostProcesses/thinChromaticAberrationPostProcess.js.map +1 -1
- package/PostProcesses/thinCircleOfConfusionPostProcess.d.ts +1 -1
- package/PostProcesses/thinCircleOfConfusionPostProcess.js +1 -1
- package/PostProcesses/thinCircleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/thinColorCorrectionPostProcess.d.ts +1 -1
- package/PostProcesses/thinColorCorrectionPostProcess.js +2 -2
- package/PostProcesses/thinColorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/thinConvolutionPostProcess.d.ts +1 -1
- package/PostProcesses/thinConvolutionPostProcess.js +1 -1
- package/PostProcesses/thinConvolutionPostProcess.js.map +1 -1
- package/PostProcesses/thinCustomPostProcess.d.ts +1 -1
- package/PostProcesses/thinCustomPostProcess.js +1 -1
- package/PostProcesses/thinCustomPostProcess.js.map +1 -1
- package/PostProcesses/thinDepthOfFieldEffect.d.ts +3 -0
- package/PostProcesses/thinDepthOfFieldEffect.js +4 -1
- package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -1
- package/PostProcesses/thinDepthOfFieldMergePostProcess.d.ts +1 -1
- package/PostProcesses/thinDepthOfFieldMergePostProcess.js +1 -1
- package/PostProcesses/thinDepthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/thinExtractHighlightsPostProcess.d.ts +1 -1
- package/PostProcesses/thinExtractHighlightsPostProcess.js +1 -1
- package/PostProcesses/thinExtractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/thinFXAAPostProcess.d.ts +2 -2
- package/PostProcesses/thinFXAAPostProcess.js +2 -2
- package/PostProcesses/thinFXAAPostProcess.js.map +1 -1
- package/PostProcesses/thinFilterPostProcess.d.ts +2 -2
- package/PostProcesses/thinFilterPostProcess.js +2 -2
- package/PostProcesses/thinFilterPostProcess.js.map +1 -1
- package/PostProcesses/thinGrainPostProcess.d.ts +1 -1
- package/PostProcesses/thinGrainPostProcess.js +1 -1
- package/PostProcesses/thinGrainPostProcess.js.map +1 -1
- package/PostProcesses/thinImageProcessingPostProcess.d.ts +2 -2
- package/PostProcesses/thinImageProcessingPostProcess.js +2 -2
- package/PostProcesses/thinImageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/thinMotionBlurPostProcess.d.ts +1 -1
- package/PostProcesses/thinMotionBlurPostProcess.js +2 -2
- package/PostProcesses/thinMotionBlurPostProcess.js.map +1 -1
- package/PostProcesses/thinPassPostProcess.d.ts +1 -1
- package/PostProcesses/thinPassPostProcess.js +1 -1
- package/PostProcesses/thinPassPostProcess.js.map +1 -1
- package/PostProcesses/thinSSAO2BlurPostProcess.d.ts +1 -1
- package/PostProcesses/thinSSAO2BlurPostProcess.js +1 -1
- package/PostProcesses/thinSSAO2BlurPostProcess.js.map +1 -1
- package/PostProcesses/thinSSAO2CombinePostProcess.d.ts +1 -1
- package/PostProcesses/thinSSAO2CombinePostProcess.js +2 -2
- package/PostProcesses/thinSSAO2CombinePostProcess.js.map +1 -1
- package/PostProcesses/thinSSAO2PostProcess.d.ts +7 -2
- package/PostProcesses/thinSSAO2PostProcess.js +36 -4
- package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
- package/PostProcesses/thinSSRBlurCombinerPostProcess.d.ts +1 -1
- package/PostProcesses/thinSSRBlurCombinerPostProcess.js +2 -2
- package/PostProcesses/thinSSRBlurCombinerPostProcess.js.map +1 -1
- package/PostProcesses/thinSSRBlurPostProcess.d.ts +2 -2
- package/PostProcesses/thinSSRBlurPostProcess.js +2 -2
- package/PostProcesses/thinSSRBlurPostProcess.js.map +1 -1
- package/PostProcesses/thinSSRPostProcess.d.ts +1 -1
- package/PostProcesses/thinSSRPostProcess.js +2 -2
- package/PostProcesses/thinSSRPostProcess.js.map +1 -1
- package/PostProcesses/thinScreenSpaceCurvaturePostProcess.d.ts +1 -1
- package/PostProcesses/thinScreenSpaceCurvaturePostProcess.js +1 -1
- package/PostProcesses/thinScreenSpaceCurvaturePostProcess.js.map +1 -1
- package/PostProcesses/thinSharpenPostProcess.d.ts +1 -1
- package/PostProcesses/thinSharpenPostProcess.js +1 -1
- package/PostProcesses/thinSharpenPostProcess.js.map +1 -1
- package/PostProcesses/thinTAAPostProcess.d.ts +3 -3
- package/PostProcesses/thinTAAPostProcess.js +4 -4
- package/PostProcesses/thinTAAPostProcess.js.map +1 -1
- package/PostProcesses/thinTonemapPostProcess.d.ts +1 -1
- package/PostProcesses/thinTonemapPostProcess.js +1 -1
- package/PostProcesses/thinTonemapPostProcess.js.map +1 -1
- package/PostProcesses/vrDistortionCorrectionPostProcess.d.ts +1 -1
- package/PostProcesses/vrDistortionCorrectionPostProcess.js +3 -3
- package/PostProcesses/vrDistortionCorrectionPostProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +2 -2
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +4 -4
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.d.ts +2 -2
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js +4 -4
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +3 -3
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +4 -4
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/depthPeelingRenderer.d.ts +1 -1
- package/Rendering/depthPeelingRenderer.js +2 -2
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.js +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.d.ts +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +2 -2
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.d.ts +3 -3
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +3 -3
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTextures.d.ts +2 -2
- package/Rendering/fluidRenderer/fluidRenderingTextures.js +3 -3
- package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
- package/Rendering/iblCdfGenerator.d.ts +3 -3
- package/Rendering/iblCdfGenerator.js +5 -5
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Rendering/renderingGroup.js +1 -1
- package/Rendering/renderingGroup.js.map +1 -1
- package/Rendering/subSurfaceConfiguration.d.ts +2 -2
- package/Rendering/subSurfaceConfiguration.js +2 -2
- package/Rendering/subSurfaceConfiguration.js.map +1 -1
- package/Rendering/utilityLayerRenderer.d.ts +2 -2
- package/Rendering/utilityLayerRenderer.js +4 -4
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/Shaders/ssao2.fragment.js +10 -2
- package/Shaders/ssao2.fragment.js.map +1 -1
- package/ShadersWGSL/ssao2.fragment.js +10 -2
- package/ShadersWGSL/ssao2.fragment.js.map +1 -1
- package/SmartAssets/smartAssetSerializer.js +1 -1
- package/SmartAssets/smartAssetSerializer.js.map +1 -1
- package/Sprites/sprite.d.ts +2 -2
- package/Sprites/sprite.js +2 -2
- package/Sprites/sprite.js.map +1 -1
- package/Sprites/spriteManager.d.ts +2 -2
- package/Sprites/spriteManager.js +4 -5
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spritePackedManager.js +1 -1
- package/Sprites/spritePackedManager.js.map +1 -1
- package/Sprites/spriteRenderer.js +2 -2
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRHitTestLegacy.d.ts +1 -1
- package/XR/features/WebXRHitTestLegacy.js +2 -2
- package/XR/features/WebXRHitTestLegacy.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.js +2 -2
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/motionController/webXRGenericMotionController.js +2 -2
- package/XR/motionController/webXRGenericMotionController.js.map +1 -1
- package/XR/motionController/webXRProfiledMotionController.js +4 -4
- package/XR/motionController/webXRProfiledMotionController.js.map +1 -1
- package/XR/webXRCamera.d.ts +3 -3
- package/XR/webXRCamera.js +4 -4
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRDefaultExperience.d.ts +4 -4
- package/XR/webXRDefaultExperience.js +4 -4
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXREnterExitUI.js +1 -1
- package/XR/webXREnterExitUI.js.map +1 -1
- package/XR/webXRExperienceHelper.js +2 -2
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/XR/webXRFeaturesManager.d.ts +47 -0
- package/XR/webXRFeaturesManager.js +1 -1
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRInput.js +1 -1
- package/XR/webXRInput.js.map +1 -1
- package/XR/webXRInputSource.js +4 -4
- package/XR/webXRInputSource.js.map +1 -1
- package/XR/webXRManagedOutputCanvas.js +1 -1
- package/XR/webXRManagedOutputCanvas.js.map +1 -1
- package/XR/webXRRenderTargetTextureProvider.d.ts +1 -1
- package/XR/webXRRenderTargetTextureProvider.js +1 -1
- package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
- package/assetContainer.d.ts +4 -4
- package/assetContainer.js +6 -6
- package/assetContainer.js.map +1 -1
- package/node.d.ts +1 -1
- package/node.js +6 -2
- package/node.js.map +1 -1
- package/package.json +44 -174
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meshCollisionData.js","sourceRoot":"","sources":["../../../../dev/core/src/Collisions/meshCollisionData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"meshCollisionData.js","sourceRoot":"","sources":["../../../../dev/core/src/Collisions/meshCollisionData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAMpD;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,kBAAkB;IAA/B;QACW,qBAAgB,GAAG,KAAK,CAAC;QACzB,mBAAc,GAAG,CAAC,CAAC,CAAC;QACpB,oBAAe,GAAG,CAAC,CAAC,CAAC;QACrB,uBAAkB,GAA6B,IAAI,CAAC;QACpD,cAAS,GAAuB,IAAI,CAAC;QACrC,8BAAyB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACjD,+BAA0B,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAGlD,uBAAkB,GAAG,IAAI,CAAC;IACrC,CAAC;CAAA","sourcesContent":["import { type Collider } from \"./collider\";\r\nimport { Vector3 } from \"../Maths/math.vector.pure\";\r\nimport { type Nullable } from \"../types\";\r\nimport { type Observer } from \"../Misc/observable\";\r\n\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _MeshCollisionData {\r\n public _checkCollisions = false;\r\n public _collisionMask = -1;\r\n public _collisionGroup = -1;\r\n public _surroundingMeshes: Nullable<AbstractMesh[]> = null;\r\n public _collider: Nullable<Collider> = null;\r\n public _oldPositionForCollisions = new Vector3(0, 0, 0);\r\n public _diffPositionForCollisions = new Vector3(0, 0, 0);\r\n public _onCollideObserver: Nullable<Observer<AbstractMesh>>;\r\n public _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;\r\n public _collisionResponse = true;\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Nullable } from "../types.js";
|
|
2
|
-
import { Vector3, Vector2 } from "../Maths/math.vector.js";
|
|
2
|
+
import { Vector3, Vector2 } from "../Maths/math.vector.pure.js";
|
|
3
3
|
import { type AbstractMesh } from "../Meshes/abstractMesh.js";
|
|
4
4
|
import { type TransformNode } from "../Meshes/transformNode.js";
|
|
5
5
|
import { type Sprite } from "../Sprites/sprite.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Matrix, Vector3, Vector2, TmpVectors } from "../Maths/math.vector.js";
|
|
2
|
-
import { VertexBuffer } from "../Buffers/buffer.js";
|
|
1
|
+
import { Matrix, Vector3, Vector2, TmpVectors } from "../Maths/math.vector.pure.js";
|
|
2
|
+
import { VertexBuffer } from "../Buffers/buffer.pure.js";
|
|
3
3
|
/**
|
|
4
4
|
* Information about the result of picking within a scene
|
|
5
5
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickingInfo.js","sourceRoot":"","sources":["../../../../dev/core/src/Collisions/pickingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMjD;;;GAGG;AACH,MAAM,OAAO,WAAW;IAAxB;QACI;;WAEG;QACI,QAAG,GAAG,KAAK,CAAC;QACnB;;WAEG;QACI,aAAQ,GAAG,CAAC,CAAC;QACpB;;WAEG;QACI,gBAAW,GAAsB,IAAI,CAAC;QAC7C;;WAEG;QACI,eAAU,GAA2B,IAAI,CAAC;QACjD,sIAAsI;QAC/H,OAAE,GAAG,CAAC,CAAC;QACd,sIAAsI;QAC/H,OAAE,GAAG,CAAC,CAAC;QACd,oHAAoH;QAC7G,WAAM,GAAG,CAAC,CAAC,CAAC;QACnB,uHAAuH;QAChH,kBAAa,GAAG,CAAC,CAAC,CAAC;QAC1B,wCAAwC;QACjC,cAAS,GAAG,CAAC,CAAC;QACrB,6EAA6E;QACtE,iBAAY,GAAqB,IAAI,CAAC;QAC7C,+FAA+F;QACxF,sBAAiB,GAAG,CAAC,CAAC,CAAC;QAC9B;;WAEG;QACI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,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAEnE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QAEzC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;CACJ","sourcesContent":["import { type Nullable, type FloatArray } from \"../types\";\r\nimport { Matrix, Vector3, Vector2, TmpVectors } from \"../Maths/math.vector\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { type TransformNode } from \"../Meshes/transformNode\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { type Sprite } from \"../Sprites/sprite\";\r\nimport { type Mesh } from \"../Meshes/mesh\";\r\n\r\nimport { type Ray } from \"../Culling/ray\";\r\n\r\n/**\r\n * Information about the result of picking within a scene\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions\r\n */\r\nexport class PickingInfo {\r\n /**\r\n * If the pick collided with an object\r\n */\r\n public hit = false;\r\n /**\r\n * Distance away where the pick collided\r\n */\r\n public distance = 0;\r\n /**\r\n * The location of pick collision\r\n */\r\n public pickedPoint: Nullable<Vector3> = null;\r\n /**\r\n * The mesh corresponding the pick collision\r\n */\r\n public pickedMesh: Nullable<AbstractMesh> = null;\r\n /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/\r\n public bu = 0;\r\n /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/\r\n public bv = 0;\r\n /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */\r\n public faceId = -1;\r\n /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */\r\n public subMeshFaceId = -1;\r\n /** Id of the submesh that was picked */\r\n public subMeshId = 0;\r\n /** If a sprite was picked, this will be the sprite the pick collided with */\r\n public pickedSprite: Nullable<Sprite> = null;\r\n /** If we are picking a mesh with thin instance, this will give you the picked thin instance */\r\n public thinInstanceIndex = -1;\r\n /**\r\n * The ray that was used to perform the picking.\r\n */\r\n public ray: Nullable<Ray> = null;\r\n /**\r\n * If a mesh was used to do the picking (eg. 6dof controller) as a \"near interaction\", this will be populated.\r\n */\r\n public originMesh: Nullable<AbstractMesh> = null;\r\n /**\r\n * The aim-space transform of the input used for picking, if it is an XR input source.\r\n */\r\n public aimTransform: Nullable<TransformNode> = null;\r\n /**\r\n * The grip-space transform of the input used for picking, if it is an XR input source.\r\n * Some XR sources, such as input coming from head mounted displays, do not have this.\r\n */\r\n public gripTransform: Nullable<TransformNode> = null;\r\n\r\n /**\r\n * Gets the normal corresponding to the face the pick collided with\r\n * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)\r\n * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map (default: true)\r\n * @returns The normal corresponding to the face the pick collided with\r\n * @remarks Note that the returned normal will always point towards the picking ray.\r\n */\r\n public getNormal(useWorldCoordinates = false, useVerticesNormals = true): Nullable<Vector3> {\r\n if (!this.pickedMesh || (useVerticesNormals && !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind))) {\r\n return null;\r\n }\r\n\r\n let indices = this.pickedMesh.getIndices();\r\n\r\n if (indices?.length === 0) {\r\n indices = null;\r\n }\r\n\r\n let result: Vector3;\r\n\r\n const tmp0 = TmpVectors.Vector3[0];\r\n const tmp1 = TmpVectors.Vector3[1];\r\n const tmp2 = TmpVectors.Vector3[2];\r\n\r\n if (useVerticesNormals) {\r\n const normals = <FloatArray>this.pickedMesh.getVerticesData(VertexBuffer.NormalKind);\r\n\r\n let normal0 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3] * 3, tmp0)\r\n : tmp0.copyFromFloats(normals[this.faceId * 3 * 3], normals[this.faceId * 3 * 3 + 1], normals[this.faceId * 3 * 3 + 2]);\r\n let normal1 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3 + 1] * 3, tmp1)\r\n : tmp1.copyFromFloats(normals[(this.faceId * 3 + 1) * 3], normals[(this.faceId * 3 + 1) * 3 + 1], normals[(this.faceId * 3 + 1) * 3 + 2]);\r\n let normal2 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3 + 2] * 3, tmp2)\r\n : tmp2.copyFromFloats(normals[(this.faceId * 3 + 2) * 3], normals[(this.faceId * 3 + 2) * 3 + 1], normals[(this.faceId * 3 + 2) * 3 + 2]);\r\n\r\n normal0 = normal0.scale(this.bu);\r\n normal1 = normal1.scale(this.bv);\r\n normal2 = normal2.scale(1.0 - this.bu - this.bv);\r\n\r\n result = new Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);\r\n } else {\r\n const positions = <FloatArray>this.pickedMesh.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n const vertex1 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3] * 3, tmp0)\r\n : tmp0.copyFromFloats(positions[this.faceId * 3 * 3], positions[this.faceId * 3 * 3 + 1], positions[this.faceId * 3 * 3 + 2]);\r\n const vertex2 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3 + 1] * 3, tmp1)\r\n : tmp1.copyFromFloats(positions[(this.faceId * 3 + 1) * 3], positions[(this.faceId * 3 + 1) * 3 + 1], positions[(this.faceId * 3 + 1) * 3 + 2]);\r\n const vertex3 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3 + 2] * 3, tmp2)\r\n : tmp2.copyFromFloats(positions[(this.faceId * 3 + 2) * 3], positions[(this.faceId * 3 + 2) * 3 + 1], positions[(this.faceId * 3 + 2) * 3 + 2]);\r\n\r\n const p1p2 = vertex1.subtract(vertex2);\r\n const p3p2 = vertex3.subtract(vertex2);\r\n\r\n result = Vector3.Cross(p1p2, p3p2);\r\n }\r\n\r\n const transformNormalToWorld = (pickedMesh: AbstractMesh, n: Vector3) => {\r\n if (this.thinInstanceIndex !== -1) {\r\n const thinMatrixData = (pickedMesh as Mesh)._thinInstanceDataStorage.matrixData;\r\n const index = this.thinInstanceIndex << 4;\r\n\r\n if (thinMatrixData && thinMatrixData.length > index) {\r\n const tm = TmpVectors.Matrix[0];\r\n Matrix.FromArrayToRef(thinMatrixData, index, tm);\r\n Vector3.TransformNormalToRef(n, tm, n);\r\n }\r\n }\r\n\r\n let wm = pickedMesh.getWorldMatrix();\r\n\r\n if (pickedMesh.nonUniformScaling) {\r\n TmpVectors.Matrix[0].copyFrom(wm);\r\n wm = TmpVectors.Matrix[0];\r\n wm.setTranslationFromFloats(0, 0, 0);\r\n wm.invert();\r\n wm.transposeToRef(TmpVectors.Matrix[1]);\r\n\r\n wm = TmpVectors.Matrix[1];\r\n }\r\n\r\n Vector3.TransformNormalToRef(n, wm, n);\r\n };\r\n\r\n if (useWorldCoordinates) {\r\n transformNormalToWorld(this.pickedMesh, result);\r\n }\r\n\r\n if (this.ray) {\r\n const normalForDirectionChecking = TmpVectors.Vector3[0].copyFrom(result);\r\n\r\n if (!useWorldCoordinates) {\r\n // the normal has not been transformed to world space as part as the normal processing, so we must do it now\r\n transformNormalToWorld(this.pickedMesh, normalForDirectionChecking);\r\n }\r\n\r\n // Flip the normal if the picking ray is in the same direction.\r\n if (Vector3.Dot(normalForDirectionChecking, this.ray.direction) > 0) {\r\n result.negateInPlace();\r\n }\r\n }\r\n\r\n result.normalize();\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates of where the pick occurred\r\n * @param uvSet The UV set to use to calculate the texture coordinates (default: VertexBuffer.UVKind)\r\n * @returns The vector containing the coordinates of the texture\r\n */\r\n public getTextureCoordinates(uvSet = VertexBuffer.UVKind): Nullable<Vector2> {\r\n if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(uvSet)) {\r\n return null;\r\n }\r\n\r\n const indices = this.pickedMesh.getIndices();\r\n if (!indices) {\r\n return null;\r\n }\r\n\r\n const uvs = this.pickedMesh.getVerticesData(uvSet);\r\n if (!uvs) {\r\n return null;\r\n }\r\n\r\n let uv0 = Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);\r\n let uv1 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);\r\n let uv2 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);\r\n\r\n uv0 = uv0.scale(this.bu);\r\n uv1 = uv1.scale(this.bv);\r\n uv2 = uv2.scale(1.0 - this.bu - this.bv);\r\n\r\n return new Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"pickingInfo.js","sourceRoot":"","sources":["../../../../dev/core/src/Collisions/pickingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGjF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAMtD;;;GAGG;AACH,MAAM,OAAO,WAAW;IAAxB;QACI;;WAEG;QACI,QAAG,GAAG,KAAK,CAAC;QACnB;;WAEG;QACI,aAAQ,GAAG,CAAC,CAAC;QACpB;;WAEG;QACI,gBAAW,GAAsB,IAAI,CAAC;QAC7C;;WAEG;QACI,eAAU,GAA2B,IAAI,CAAC;QACjD,sIAAsI;QAC/H,OAAE,GAAG,CAAC,CAAC;QACd,sIAAsI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AAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/D,IAAI,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,IAAI,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAEnE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QAEzC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;CACJ","sourcesContent":["import { type Nullable, type FloatArray } from \"../types\";\r\nimport { Matrix, Vector3, Vector2, TmpVectors } from \"../Maths/math.vector.pure\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { type TransformNode } from \"../Meshes/transformNode\";\r\nimport { VertexBuffer } from \"../Buffers/buffer.pure\";\r\nimport { type Sprite } from \"../Sprites/sprite\";\r\nimport { type Mesh } from \"../Meshes/mesh\";\r\n\r\nimport { type Ray } from \"../Culling/ray\";\r\n\r\n/**\r\n * Information about the result of picking within a scene\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions\r\n */\r\nexport class PickingInfo {\r\n /**\r\n * If the pick collided with an object\r\n */\r\n public hit = false;\r\n /**\r\n * Distance away where the pick collided\r\n */\r\n public distance = 0;\r\n /**\r\n * The location of pick collision\r\n */\r\n public pickedPoint: Nullable<Vector3> = null;\r\n /**\r\n * The mesh corresponding the pick collision\r\n */\r\n public pickedMesh: Nullable<AbstractMesh> = null;\r\n /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/\r\n public bu = 0;\r\n /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/\r\n public bv = 0;\r\n /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */\r\n public faceId = -1;\r\n /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */\r\n public subMeshFaceId = -1;\r\n /** Id of the submesh that was picked */\r\n public subMeshId = 0;\r\n /** If a sprite was picked, this will be the sprite the pick collided with */\r\n public pickedSprite: Nullable<Sprite> = null;\r\n /** If we are picking a mesh with thin instance, this will give you the picked thin instance */\r\n public thinInstanceIndex = -1;\r\n /**\r\n * The ray that was used to perform the picking.\r\n */\r\n public ray: Nullable<Ray> = null;\r\n /**\r\n * If a mesh was used to do the picking (eg. 6dof controller) as a \"near interaction\", this will be populated.\r\n */\r\n public originMesh: Nullable<AbstractMesh> = null;\r\n /**\r\n * The aim-space transform of the input used for picking, if it is an XR input source.\r\n */\r\n public aimTransform: Nullable<TransformNode> = null;\r\n /**\r\n * The grip-space transform of the input used for picking, if it is an XR input source.\r\n * Some XR sources, such as input coming from head mounted displays, do not have this.\r\n */\r\n public gripTransform: Nullable<TransformNode> = null;\r\n\r\n /**\r\n * Gets the normal corresponding to the face the pick collided with\r\n * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)\r\n * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map (default: true)\r\n * @returns The normal corresponding to the face the pick collided with\r\n * @remarks Note that the returned normal will always point towards the picking ray.\r\n */\r\n public getNormal(useWorldCoordinates = false, useVerticesNormals = true): Nullable<Vector3> {\r\n if (!this.pickedMesh || (useVerticesNormals && !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind))) {\r\n return null;\r\n }\r\n\r\n let indices = this.pickedMesh.getIndices();\r\n\r\n if (indices?.length === 0) {\r\n indices = null;\r\n }\r\n\r\n let result: Vector3;\r\n\r\n const tmp0 = TmpVectors.Vector3[0];\r\n const tmp1 = TmpVectors.Vector3[1];\r\n const tmp2 = TmpVectors.Vector3[2];\r\n\r\n if (useVerticesNormals) {\r\n const normals = <FloatArray>this.pickedMesh.getVerticesData(VertexBuffer.NormalKind);\r\n\r\n let normal0 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3] * 3, tmp0)\r\n : tmp0.copyFromFloats(normals[this.faceId * 3 * 3], normals[this.faceId * 3 * 3 + 1], normals[this.faceId * 3 * 3 + 2]);\r\n let normal1 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3 + 1] * 3, tmp1)\r\n : tmp1.copyFromFloats(normals[(this.faceId * 3 + 1) * 3], normals[(this.faceId * 3 + 1) * 3 + 1], normals[(this.faceId * 3 + 1) * 3 + 2]);\r\n let normal2 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3 + 2] * 3, tmp2)\r\n : tmp2.copyFromFloats(normals[(this.faceId * 3 + 2) * 3], normals[(this.faceId * 3 + 2) * 3 + 1], normals[(this.faceId * 3 + 2) * 3 + 2]);\r\n\r\n normal0 = normal0.scale(this.bu);\r\n normal1 = normal1.scale(this.bv);\r\n normal2 = normal2.scale(1.0 - this.bu - this.bv);\r\n\r\n result = new Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);\r\n } else {\r\n const positions = <FloatArray>this.pickedMesh.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n const vertex1 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3] * 3, tmp0)\r\n : tmp0.copyFromFloats(positions[this.faceId * 3 * 3], positions[this.faceId * 3 * 3 + 1], positions[this.faceId * 3 * 3 + 2]);\r\n const vertex2 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3 + 1] * 3, tmp1)\r\n : tmp1.copyFromFloats(positions[(this.faceId * 3 + 1) * 3], positions[(this.faceId * 3 + 1) * 3 + 1], positions[(this.faceId * 3 + 1) * 3 + 2]);\r\n const vertex3 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3 + 2] * 3, tmp2)\r\n : tmp2.copyFromFloats(positions[(this.faceId * 3 + 2) * 3], positions[(this.faceId * 3 + 2) * 3 + 1], positions[(this.faceId * 3 + 2) * 3 + 2]);\r\n\r\n const p1p2 = vertex1.subtract(vertex2);\r\n const p3p2 = vertex3.subtract(vertex2);\r\n\r\n result = Vector3.Cross(p1p2, p3p2);\r\n }\r\n\r\n const transformNormalToWorld = (pickedMesh: AbstractMesh, n: Vector3) => {\r\n if (this.thinInstanceIndex !== -1) {\r\n const thinMatrixData = (pickedMesh as Mesh)._thinInstanceDataStorage.matrixData;\r\n const index = this.thinInstanceIndex << 4;\r\n\r\n if (thinMatrixData && thinMatrixData.length > index) {\r\n const tm = TmpVectors.Matrix[0];\r\n Matrix.FromArrayToRef(thinMatrixData, index, tm);\r\n Vector3.TransformNormalToRef(n, tm, n);\r\n }\r\n }\r\n\r\n let wm = pickedMesh.getWorldMatrix();\r\n\r\n if (pickedMesh.nonUniformScaling) {\r\n TmpVectors.Matrix[0].copyFrom(wm);\r\n wm = TmpVectors.Matrix[0];\r\n wm.setTranslationFromFloats(0, 0, 0);\r\n wm.invert();\r\n wm.transposeToRef(TmpVectors.Matrix[1]);\r\n\r\n wm = TmpVectors.Matrix[1];\r\n }\r\n\r\n Vector3.TransformNormalToRef(n, wm, n);\r\n };\r\n\r\n if (useWorldCoordinates) {\r\n transformNormalToWorld(this.pickedMesh, result);\r\n }\r\n\r\n if (this.ray) {\r\n const normalForDirectionChecking = TmpVectors.Vector3[0].copyFrom(result);\r\n\r\n if (!useWorldCoordinates) {\r\n // the normal has not been transformed to world space as part as the normal processing, so we must do it now\r\n transformNormalToWorld(this.pickedMesh, normalForDirectionChecking);\r\n }\r\n\r\n // Flip the normal if the picking ray is in the same direction.\r\n if (Vector3.Dot(normalForDirectionChecking, this.ray.direction) > 0) {\r\n result.negateInPlace();\r\n }\r\n }\r\n\r\n result.normalize();\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates of where the pick occurred\r\n * @param uvSet The UV set to use to calculate the texture coordinates (default: VertexBuffer.UVKind)\r\n * @returns The vector containing the coordinates of the texture\r\n */\r\n public getTextureCoordinates(uvSet = VertexBuffer.UVKind): Nullable<Vector2> {\r\n if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(uvSet)) {\r\n return null;\r\n }\r\n\r\n const indices = this.pickedMesh.getIndices();\r\n if (!indices) {\r\n return null;\r\n }\r\n\r\n const uvs = this.pickedMesh.getVerticesData(uvSet);\r\n if (!uvs) {\r\n return null;\r\n }\r\n\r\n let uv0 = Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);\r\n let uv1 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);\r\n let uv2 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);\r\n\r\n uv0 = uv0.scale(this.bu);\r\n uv1 = uv1.scale(this.bv);\r\n uv2 = uv2.scale(1.0 - this.bu - this.bv);\r\n\r\n return new Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SmartArrayNoDuplicate } from "../../Misc/smartArray.js";
|
|
2
|
-
import { Vector3 } from "../../Maths/math.vector.js";
|
|
2
|
+
import { Vector3 } from "../../Maths/math.vector.pure.js";
|
|
3
3
|
import { type Ray } from "../../Culling/ray.js";
|
|
4
4
|
import { type Plane } from "../../Maths/math.plane.js";
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"octreeBlock.js","sourceRoot":"","sources":["../../../../../dev/core/src/Culling/Octrees/octreeBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAaxD;;;GAGG;AACH,MAAM,OAAO,WAAW;IAmBpB;;;;;;;;OAQG;IACH,YAAY,QAAiB,EAAE,QAAiB,EAAE,QAAgB,EAAE,KAAa,EAAE,QAAgB,EAAE,YAAuD;QA3B5J;;WAEG;QACI,YAAO,GAAQ,EAAE,CAAC;QAYjB,qBAAgB,GAAG,IAAI,KAAK,EAAW,CAAC;QAa5C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAElC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QAE7C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;QAExC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,gBAAgB,CAAC,CAA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from \"../../Misc/smartArray\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { type Ray } from \"../../Culling/ray\";\r\nimport { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { type Plane } from \"../../Maths/math.plane\";\r\n\r\n/**\r\n * Contains an array of blocks representing the octree\r\n */\r\nexport interface IOctreeContainer<T> {\r\n /**\r\n * Blocks within the octree\r\n */\r\n blocks: Array<OctreeBlock<T>>;\r\n}\r\n\r\n/**\r\n * Class used to store a cell in an octree\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeOctrees\r\n */\r\nexport class OctreeBlock<T> {\r\n /**\r\n * Gets the content of the current block\r\n */\r\n public entries: T[] = [];\r\n\r\n /**\r\n * Gets the list of block children\r\n */\r\n public blocks: Array<OctreeBlock<T>>;\r\n\r\n private _depth: number;\r\n private _maxDepth: number;\r\n private _capacity: number;\r\n private _minPoint: Vector3;\r\n private _maxPoint: Vector3;\r\n private _boundingVectors = new Array<Vector3>();\r\n private _creationFunc: (entry: T, block: OctreeBlock<T>) => void;\r\n\r\n /**\r\n * Creates a new block\r\n * @param minPoint defines the minimum vector (in world space) of the block's bounding box\r\n * @param maxPoint defines the maximum vector (in world space) of the block's bounding box\r\n * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)\r\n * @param depth defines the current depth of this block in the octree\r\n * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)\r\n * @param creationFunc defines a callback to call when an element is added to the block\r\n */\r\n constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void) {\r\n this._capacity = capacity;\r\n this._depth = depth;\r\n this._maxDepth = maxDepth;\r\n this._creationFunc = creationFunc;\r\n\r\n this._minPoint = minPoint;\r\n this._maxPoint = maxPoint;\r\n\r\n this._boundingVectors.push(minPoint.clone());\r\n this._boundingVectors.push(maxPoint.clone());\r\n\r\n this._boundingVectors.push(minPoint.clone());\r\n this._boundingVectors[2].x = maxPoint.x;\r\n\r\n this._boundingVectors.push(minPoint.clone());\r\n this._boundingVectors[3].y = maxPoint.y;\r\n\r\n this._boundingVectors.push(minPoint.clone());\r\n this._boundingVectors[4].z = maxPoint.z;\r\n\r\n this._boundingVectors.push(maxPoint.clone());\r\n this._boundingVectors[5].z = minPoint.z;\r\n\r\n this._boundingVectors.push(maxPoint.clone());\r\n this._boundingVectors[6].x = minPoint.x;\r\n\r\n this._boundingVectors.push(maxPoint.clone());\r\n this._boundingVectors[7].y = minPoint.y;\r\n }\r\n\r\n // Property\r\n\r\n /**\r\n * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)\r\n */\r\n public get capacity(): number {\r\n return this._capacity;\r\n }\r\n\r\n /**\r\n * Gets the minimum vector (in world space) of the block's bounding box\r\n */\r\n public get minPoint(): Vector3 {\r\n return this._minPoint;\r\n }\r\n\r\n /**\r\n * Gets the maximum vector (in world space) of the block's bounding box\r\n */\r\n public get maxPoint(): Vector3 {\r\n return this._maxPoint;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Add a new element to this block\r\n * @param entry defines the element to add\r\n */\r\n public addEntry(entry: T): void {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.addEntry(entry);\r\n }\r\n return;\r\n }\r\n\r\n this._creationFunc(entry, this);\r\n\r\n if (this.entries.length > this.capacity && this._depth < this._maxDepth) {\r\n this.createInnerBlocks();\r\n }\r\n }\r\n\r\n /**\r\n * Remove an element from this block\r\n * @param entry defines the element to remove\r\n */\r\n public removeEntry(entry: T): void {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.removeEntry(entry);\r\n }\r\n return;\r\n }\r\n\r\n const entryIndex = this.entries.indexOf(entry);\r\n\r\n if (entryIndex > -1) {\r\n this.entries.splice(entryIndex, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Add an array of elements to this block\r\n * @param entries defines the array of elements to add\r\n */\r\n public addEntries(entries: T[]): void {\r\n for (let index = 0; index < entries.length; index++) {\r\n const mesh = entries[index];\r\n this.addEntry(mesh);\r\n }\r\n }\r\n\r\n /**\r\n * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @param selection defines the array to store current content if selection is positive\r\n * @param allowDuplicate defines if the selection array can contains duplicated entries\r\n */\r\n public select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void {\r\n if (BoundingBox.IsInFrustum(this._boundingVectors, frustumPlanes)) {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.select(frustumPlanes, selection, allowDuplicate);\r\n }\r\n return;\r\n }\r\n\r\n if (allowDuplicate) {\r\n selection.concat(this.entries);\r\n } else {\r\n selection.concatWithNoDuplicate(this.entries);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array\r\n * @param sphereCenter defines the bounding sphere center\r\n * @param sphereRadius defines the bounding sphere radius\r\n * @param selection defines the array to store current content if selection is positive\r\n * @param allowDuplicate defines if the selection array can contains duplicated entries\r\n */\r\n public intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void {\r\n if (BoundingBox.IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);\r\n }\r\n return;\r\n }\r\n\r\n if (allowDuplicate) {\r\n selection.concat(this.entries);\r\n } else {\r\n selection.concatWithNoDuplicate(this.entries);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Test if the current block intersect with the given ray and if yes, then add its content to the selection array\r\n * @param ray defines the ray to test with\r\n * @param selection defines the array to store current content if selection is positive\r\n */\r\n public intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void {\r\n if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.intersectsRay(ray, selection);\r\n }\r\n return;\r\n }\r\n selection.concatWithNoDuplicate(this.entries);\r\n }\r\n }\r\n\r\n /**\r\n * Subdivide the content into child blocks (this block will then be empty)\r\n */\r\n public createInnerBlocks(): void {\r\n OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);\r\n this.entries.splice(0);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _CreateBlocks<T>(\r\n worldMin: Vector3,\r\n worldMax: Vector3,\r\n entries: T[],\r\n maxBlockCapacity: number,\r\n currentDepth: number,\r\n maxDepth: number,\r\n target: IOctreeContainer<T>,\r\n creationFunc: (entry: T, block: OctreeBlock<T>) => void\r\n ): void {\r\n target.blocks = new Array<OctreeBlock<T>>();\r\n const blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);\r\n\r\n // Segmenting space\r\n for (let x = 0; x < 2; x++) {\r\n for (let y = 0; y < 2; y++) {\r\n for (let z = 0; z < 2; z++) {\r\n const localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));\r\n const localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));\r\n\r\n const block = new OctreeBlock<T>(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);\r\n block.addEntries(entries);\r\n target.blocks.push(block);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"octreeBlock.js","sourceRoot":"","sources":["../../../../../dev/core/src/Culling/Octrees/octreeBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAA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GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAE3H,mBAAmB;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBACzB,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;oBACnE,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAE/E,MAAM,KAAK,GAAG,IAAI,WAAW,CAAI,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;oBACjH,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9B,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { type SmartArrayNoDuplicate } from \"../../Misc/smartArray\";\r\nimport { Vector3 } from \"../../Maths/math.vector.pure\";\r\nimport { type Ray } from \"../../Culling/ray\";\r\nimport { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { type Plane } from \"../../Maths/math.plane\";\r\n\r\n/**\r\n * Contains an array of blocks representing the octree\r\n */\r\nexport interface IOctreeContainer<T> {\r\n /**\r\n * Blocks within the octree\r\n */\r\n blocks: Array<OctreeBlock<T>>;\r\n}\r\n\r\n/**\r\n * Class used to store a cell in an octree\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeOctrees\r\n */\r\nexport class OctreeBlock<T> {\r\n /**\r\n * Gets the content of the current block\r\n */\r\n public entries: T[] = [];\r\n\r\n /**\r\n * Gets the list of block children\r\n */\r\n public blocks: Array<OctreeBlock<T>>;\r\n\r\n private _depth: number;\r\n private _maxDepth: number;\r\n private _capacity: number;\r\n private _minPoint: Vector3;\r\n private _maxPoint: Vector3;\r\n private _boundingVectors = new Array<Vector3>();\r\n private _creationFunc: (entry: T, block: OctreeBlock<T>) => void;\r\n\r\n /**\r\n * Creates a new block\r\n * @param minPoint defines the minimum vector (in world space) of the block's bounding box\r\n * @param maxPoint defines the maximum vector (in world space) of the block's bounding box\r\n * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)\r\n * @param depth defines the current depth of this block in the octree\r\n * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)\r\n * @param creationFunc defines a callback to call when an element is added to the block\r\n */\r\n constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void) {\r\n this._capacity = capacity;\r\n this._depth = depth;\r\n this._maxDepth = maxDepth;\r\n this._creationFunc = creationFunc;\r\n\r\n this._minPoint = minPoint;\r\n this._maxPoint = maxPoint;\r\n\r\n this._boundingVectors.push(minPoint.clone());\r\n this._boundingVectors.push(maxPoint.clone());\r\n\r\n this._boundingVectors.push(minPoint.clone());\r\n this._boundingVectors[2].x = maxPoint.x;\r\n\r\n this._boundingVectors.push(minPoint.clone());\r\n this._boundingVectors[3].y = maxPoint.y;\r\n\r\n this._boundingVectors.push(minPoint.clone());\r\n this._boundingVectors[4].z = maxPoint.z;\r\n\r\n this._boundingVectors.push(maxPoint.clone());\r\n this._boundingVectors[5].z = minPoint.z;\r\n\r\n this._boundingVectors.push(maxPoint.clone());\r\n this._boundingVectors[6].x = minPoint.x;\r\n\r\n this._boundingVectors.push(maxPoint.clone());\r\n this._boundingVectors[7].y = minPoint.y;\r\n }\r\n\r\n // Property\r\n\r\n /**\r\n * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)\r\n */\r\n public get capacity(): number {\r\n return this._capacity;\r\n }\r\n\r\n /**\r\n * Gets the minimum vector (in world space) of the block's bounding box\r\n */\r\n public get minPoint(): Vector3 {\r\n return this._minPoint;\r\n }\r\n\r\n /**\r\n * Gets the maximum vector (in world space) of the block's bounding box\r\n */\r\n public get maxPoint(): Vector3 {\r\n return this._maxPoint;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Add a new element to this block\r\n * @param entry defines the element to add\r\n */\r\n public addEntry(entry: T): void {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.addEntry(entry);\r\n }\r\n return;\r\n }\r\n\r\n this._creationFunc(entry, this);\r\n\r\n if (this.entries.length > this.capacity && this._depth < this._maxDepth) {\r\n this.createInnerBlocks();\r\n }\r\n }\r\n\r\n /**\r\n * Remove an element from this block\r\n * @param entry defines the element to remove\r\n */\r\n public removeEntry(entry: T): void {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.removeEntry(entry);\r\n }\r\n return;\r\n }\r\n\r\n const entryIndex = this.entries.indexOf(entry);\r\n\r\n if (entryIndex > -1) {\r\n this.entries.splice(entryIndex, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Add an array of elements to this block\r\n * @param entries defines the array of elements to add\r\n */\r\n public addEntries(entries: T[]): void {\r\n for (let index = 0; index < entries.length; index++) {\r\n const mesh = entries[index];\r\n this.addEntry(mesh);\r\n }\r\n }\r\n\r\n /**\r\n * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @param selection defines the array to store current content if selection is positive\r\n * @param allowDuplicate defines if the selection array can contains duplicated entries\r\n */\r\n public select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void {\r\n if (BoundingBox.IsInFrustum(this._boundingVectors, frustumPlanes)) {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.select(frustumPlanes, selection, allowDuplicate);\r\n }\r\n return;\r\n }\r\n\r\n if (allowDuplicate) {\r\n selection.concat(this.entries);\r\n } else {\r\n selection.concatWithNoDuplicate(this.entries);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array\r\n * @param sphereCenter defines the bounding sphere center\r\n * @param sphereRadius defines the bounding sphere radius\r\n * @param selection defines the array to store current content if selection is positive\r\n * @param allowDuplicate defines if the selection array can contains duplicated entries\r\n */\r\n public intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void {\r\n if (BoundingBox.IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);\r\n }\r\n return;\r\n }\r\n\r\n if (allowDuplicate) {\r\n selection.concat(this.entries);\r\n } else {\r\n selection.concatWithNoDuplicate(this.entries);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Test if the current block intersect with the given ray and if yes, then add its content to the selection array\r\n * @param ray defines the ray to test with\r\n * @param selection defines the array to store current content if selection is positive\r\n */\r\n public intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void {\r\n if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {\r\n if (this.blocks) {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.intersectsRay(ray, selection);\r\n }\r\n return;\r\n }\r\n selection.concatWithNoDuplicate(this.entries);\r\n }\r\n }\r\n\r\n /**\r\n * Subdivide the content into child blocks (this block will then be empty)\r\n */\r\n public createInnerBlocks(): void {\r\n OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);\r\n this.entries.splice(0);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _CreateBlocks<T>(\r\n worldMin: Vector3,\r\n worldMax: Vector3,\r\n entries: T[],\r\n maxBlockCapacity: number,\r\n currentDepth: number,\r\n maxDepth: number,\r\n target: IOctreeContainer<T>,\r\n creationFunc: (entry: T, block: OctreeBlock<T>) => void\r\n ): void {\r\n target.blocks = new Array<OctreeBlock<T>>();\r\n const blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);\r\n\r\n // Segmenting space\r\n for (let x = 0; x < 2; x++) {\r\n for (let y = 0; y < 2; y++) {\r\n for (let z = 0; z < 2; z++) {\r\n const localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));\r\n const localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));\r\n\r\n const block = new OctreeBlock<T>(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);\r\n block.addEntries(entries);\r\n target.blocks.push(block);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
package/Culling/boundingBox.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DeepImmutable, type Nullable } from "../types.js";
|
|
2
|
-
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
2
|
+
import { Matrix, Vector3 } from "../Maths/math.vector.pure.js";
|
|
3
3
|
import { type BoundingSphere } from "../Culling/boundingSphere.js";
|
|
4
4
|
import { type ICullable } from "./boundingInfo.js";
|
|
5
5
|
import { type Plane } from "../Maths/math.plane.js";
|
package/Culling/boundingBox.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildArray } from "../Misc/arrayTools.js";
|
|
2
|
-
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
2
|
+
import { Matrix, Vector3 } from "../Maths/math.vector.pure.js";
|
|
3
3
|
import { Epsilon } from "../Maths/math.constants.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class used to store bounding box information
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundingBox.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD;;GAEG;AACH,MAAM,OAAO,WAAW;IA2DpB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAhEzG;;WAEG;QACa,YAAO,GAAc,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE;;WAEG;QACa,WAAM,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACjD;;WAEG;QACa,gBAAW,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACtD;;WAEG;QACa,eAAU,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACrD;;WAEG;QACa,oBAAe,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1D;;WAEG;QACa,eAAU,GAAc,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACpE;;WAEG;QACa,iBAAY,GAAc,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACtE;;WAEG;QACa,iBAAY,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACvD;;WAEG;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,IAAI,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,cAAc,GAAG,KAAK,CAAC;oBACvB,MAAM;gBACV,CAAC;YACL,CAAC;YACD,IAAI,cAAc,EAAE,CAAC;gBACjB,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;AA9SuB,uBAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import { type DeepImmutable, type Nullable } from \"../types\";\r\nimport { BuildArray } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { type BoundingSphere } from \"../Culling/boundingSphere\";\r\n\r\nimport { type ICullable } from \"./boundingInfo\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { type Plane } from \"../Maths/math.plane\";\r\n\r\nimport { type DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\n/**\r\n * Class used to store bounding box information\r\n */\r\nexport class BoundingBox implements ICullable {\r\n /**\r\n * Gets the 8 vectors representing the bounding box in local space\r\n */\r\n public readonly vectors: Vector3[] = BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the center of the bounding box in local space\r\n */\r\n public readonly center: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the center of the bounding box in world space\r\n */\r\n public readonly centerWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSize: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSizeWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the OBB (object bounding box) directions\r\n */\r\n public readonly directions: Vector3[] = BuildArray(3, Vector3.Zero);\r\n /**\r\n * Gets the 8 vectors representing the bounding box in world space\r\n */\r\n public readonly vectorsWorld: Vector3[] = BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the minimum vector in world space\r\n */\r\n public readonly minimumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in world space\r\n */\r\n public readonly maximumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum: Vector3 = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * @internal\r\n */\r\n public _tag: number;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Creates a new bounding box\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Recreates the entire bounding box from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const vectors = this.vectors;\r\n\r\n this.minimum.copyFromFloats(minX, minY, minZ);\r\n this.maximum.copyFromFloats(maxX, maxY, maxZ);\r\n vectors[0].copyFromFloats(minX, minY, minZ);\r\n vectors[1].copyFromFloats(maxX, maxY, maxZ);\r\n vectors[2].copyFromFloats(maxX, minY, minZ);\r\n vectors[3].copyFromFloats(minX, maxY, minZ);\r\n vectors[4].copyFromFloats(minX, minY, maxZ);\r\n vectors[5].copyFromFloats(maxX, maxY, minZ);\r\n vectors[6].copyFromFloats(minX, maxY, maxZ);\r\n vectors[7].copyFromFloats(maxX, minY, maxZ);\r\n\r\n // OBB\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);\r\n\r\n this._worldMatrix = worldMatrix || Matrix.IdentityReadOnly;\r\n\r\n this._update(this._worldMatrix);\r\n }\r\n\r\n /**\r\n * Scale the current bounding box by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingBox {\r\n const tmpVectors = BoundingBox._TmpVector3;\r\n const diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);\r\n const len = diff.length();\r\n diff.normalizeFromLength(len);\r\n const distance = len * factor;\r\n const newRadius = diff.scaleInPlace(distance * 0.5);\r\n\r\n const min = this.center.subtractToRef(newRadius, tmpVectors[1]);\r\n const max = this.center.addToRef(newRadius, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _update(world: DeepImmutable<Matrix>): void {\r\n const minWorld = this.minimumWorld;\r\n const maxWorld = this.maximumWorld;\r\n const directions = this.directions;\r\n const vectorsWorld = this.vectorsWorld;\r\n const vectors = this.vectors;\r\n\r\n if (!world.isIdentity()) {\r\n minWorld.setAll(Number.MAX_VALUE);\r\n maxWorld.setAll(-Number.MAX_VALUE);\r\n\r\n for (let index = 0; index < 8; ++index) {\r\n const v = vectorsWorld[index];\r\n Vector3.TransformCoordinatesToRef(vectors[index], world, v);\r\n minWorld.minimizeInPlace(v);\r\n maxWorld.maximizeInPlace(v);\r\n }\r\n\r\n // Extend\r\n maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);\r\n maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);\r\n } else {\r\n minWorld.copyFrom(this.minimum);\r\n maxWorld.copyFrom(this.maximum);\r\n for (let index = 0; index < 8; ++index) {\r\n vectorsWorld[index].copyFrom(vectors[index]);\r\n }\r\n\r\n // Extend\r\n this.extendSizeWorld.copyFrom(this.extendSize);\r\n this.centerWorld.copyFrom(this.center);\r\n }\r\n\r\n Vector3.FromArrayToRef(world.m, 0, directions[0]);\r\n Vector3.FromArrayToRef(world.m, 4, directions[1]);\r\n Vector3.FromArrayToRef(world.m, 8, directions[2]);\r\n\r\n this._worldMatrix = world;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is entirely inside the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding box\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding box\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const min = this.minimumWorld;\r\n const max = this.maximumWorld;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const pointX = point.x,\r\n pointY = point.y,\r\n pointZ = point.z;\r\n const delta = -Epsilon;\r\n\r\n if (maxX - pointX < delta || delta > pointX - minX) {\r\n return false;\r\n }\r\n\r\n if (maxY - pointY < delta || delta > pointY - minY) {\r\n return false;\r\n }\r\n\r\n if (maxZ - pointZ < delta || delta > pointZ - minZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a bounding sphere\r\n * @param sphere defines the sphere to test\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean {\r\n return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a box defined by a min and max vectors\r\n * @param min defines the min vector to use\r\n * @param max defines the max vector to use\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean {\r\n const myMin = this.minimumWorld;\r\n const myMax = this.maximumWorld;\r\n const myMinX = myMin.x,\r\n myMinY = myMin.y,\r\n myMinZ = myMin.z,\r\n myMaxX = myMax.x,\r\n myMaxY = myMax.y,\r\n myMaxZ = myMax.z;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n if (myMaxX < minX || myMinX > maxX) {\r\n return false;\r\n }\r\n\r\n if (myMaxY < minY || myMinY > maxY) {\r\n return false;\r\n }\r\n\r\n if (myMaxZ < minZ || myMinZ > maxZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes the resources of the class\r\n */\r\n public dispose(): void {\r\n this._drawWrapperFront?.dispose();\r\n this._drawWrapperBack?.dispose();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Tests if two bounding boxes are intersections\r\n * @param box0 defines the first box to test\r\n * @param box1 defines the second box to test\r\n * @returns true if there is an intersection\r\n */\r\n public static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean {\r\n return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defines by a min/max vectors intersects a sphere\r\n * @param minPoint defines the minimum vector of the bounding box\r\n * @param maxPoint defines the maximum vector of the bounding box\r\n * @param sphereCenter defines the sphere center\r\n * @param sphereRadius defines the sphere radius\r\n * @returns true if there is an intersection\r\n */\r\n public static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean {\r\n const vector = BoundingBox._TmpVector3[0];\r\n Vector3.ClampToRef(sphereCenter, minPoint, maxPoint, vector);\r\n const num = Vector3.DistanceSquared(sphereCenter, vector);\r\n return num <= sphereRadius * sphereRadius;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors intersects frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n let canReturnFalse = true;\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {\r\n canReturnFalse = false;\r\n break;\r\n }\r\n }\r\n if (canReturnFalse) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"boundingBox.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAI5D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD;;GAEG;AACH,MAAM,OAAO,WAAW;IA2DpB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAhEzG;;WAEG;QACa,YAAO,GAAc,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE;;WAEG;QACa,WAAM,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACjD;;WAEG;QACa,gBAAW,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACtD;;WAEG;QACa,eAAU,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACrD;;WAEG;QACa,oBAAe,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1D;;WAEG;QACa,eAAU,GAAc,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACpE;;WAEG;QACa,iBAAY,GAAc,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACtE;;WAEG;QACa,iBAAY,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACvD;;WAEG;QACa,iBAAY,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACvD;;WAEG;QACa,YAAO,GAAY,OAAO,CAAC,IAAI,EAAE,CAA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AAK,CAAC;oBACvB,MAAM;gBACV,CAAC;YACL,CAAC;YACD,IAAI,cAAc,EAAE,CAAC;gBACjB,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;AA9SuB,uBAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import { type DeepImmutable, type Nullable } from \"../types\";\r\nimport { BuildArray } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector.pure\";\r\nimport { type BoundingSphere } from \"../Culling/boundingSphere\";\r\n\r\nimport { type ICullable } from \"./boundingInfo\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { type Plane } from \"../Maths/math.plane\";\r\n\r\nimport { type DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\n/**\r\n * Class used to store bounding box information\r\n */\r\nexport class BoundingBox implements ICullable {\r\n /**\r\n * Gets the 8 vectors representing the bounding box in local space\r\n */\r\n public readonly vectors: Vector3[] = BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the center of the bounding box in local space\r\n */\r\n public readonly center: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the center of the bounding box in world space\r\n */\r\n public readonly centerWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSize: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSizeWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the OBB (object bounding box) directions\r\n */\r\n public readonly directions: Vector3[] = BuildArray(3, Vector3.Zero);\r\n /**\r\n * Gets the 8 vectors representing the bounding box in world space\r\n */\r\n public readonly vectorsWorld: Vector3[] = BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the minimum vector in world space\r\n */\r\n public readonly minimumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in world space\r\n */\r\n public readonly maximumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum: Vector3 = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * @internal\r\n */\r\n public _tag: number;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Creates a new bounding box\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Recreates the entire bounding box from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const vectors = this.vectors;\r\n\r\n this.minimum.copyFromFloats(minX, minY, minZ);\r\n this.maximum.copyFromFloats(maxX, maxY, maxZ);\r\n vectors[0].copyFromFloats(minX, minY, minZ);\r\n vectors[1].copyFromFloats(maxX, maxY, maxZ);\r\n vectors[2].copyFromFloats(maxX, minY, minZ);\r\n vectors[3].copyFromFloats(minX, maxY, minZ);\r\n vectors[4].copyFromFloats(minX, minY, maxZ);\r\n vectors[5].copyFromFloats(maxX, maxY, minZ);\r\n vectors[6].copyFromFloats(minX, maxY, maxZ);\r\n vectors[7].copyFromFloats(maxX, minY, maxZ);\r\n\r\n // OBB\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);\r\n\r\n this._worldMatrix = worldMatrix || Matrix.IdentityReadOnly;\r\n\r\n this._update(this._worldMatrix);\r\n }\r\n\r\n /**\r\n * Scale the current bounding box by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingBox {\r\n const tmpVectors = BoundingBox._TmpVector3;\r\n const diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);\r\n const len = diff.length();\r\n diff.normalizeFromLength(len);\r\n const distance = len * factor;\r\n const newRadius = diff.scaleInPlace(distance * 0.5);\r\n\r\n const min = this.center.subtractToRef(newRadius, tmpVectors[1]);\r\n const max = this.center.addToRef(newRadius, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _update(world: DeepImmutable<Matrix>): void {\r\n const minWorld = this.minimumWorld;\r\n const maxWorld = this.maximumWorld;\r\n const directions = this.directions;\r\n const vectorsWorld = this.vectorsWorld;\r\n const vectors = this.vectors;\r\n\r\n if (!world.isIdentity()) {\r\n minWorld.setAll(Number.MAX_VALUE);\r\n maxWorld.setAll(-Number.MAX_VALUE);\r\n\r\n for (let index = 0; index < 8; ++index) {\r\n const v = vectorsWorld[index];\r\n Vector3.TransformCoordinatesToRef(vectors[index], world, v);\r\n minWorld.minimizeInPlace(v);\r\n maxWorld.maximizeInPlace(v);\r\n }\r\n\r\n // Extend\r\n maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);\r\n maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);\r\n } else {\r\n minWorld.copyFrom(this.minimum);\r\n maxWorld.copyFrom(this.maximum);\r\n for (let index = 0; index < 8; ++index) {\r\n vectorsWorld[index].copyFrom(vectors[index]);\r\n }\r\n\r\n // Extend\r\n this.extendSizeWorld.copyFrom(this.extendSize);\r\n this.centerWorld.copyFrom(this.center);\r\n }\r\n\r\n Vector3.FromArrayToRef(world.m, 0, directions[0]);\r\n Vector3.FromArrayToRef(world.m, 4, directions[1]);\r\n Vector3.FromArrayToRef(world.m, 8, directions[2]);\r\n\r\n this._worldMatrix = world;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is entirely inside the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding box\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding box\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const min = this.minimumWorld;\r\n const max = this.maximumWorld;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const pointX = point.x,\r\n pointY = point.y,\r\n pointZ = point.z;\r\n const delta = -Epsilon;\r\n\r\n if (maxX - pointX < delta || delta > pointX - minX) {\r\n return false;\r\n }\r\n\r\n if (maxY - pointY < delta || delta > pointY - minY) {\r\n return false;\r\n }\r\n\r\n if (maxZ - pointZ < delta || delta > pointZ - minZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a bounding sphere\r\n * @param sphere defines the sphere to test\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean {\r\n return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a box defined by a min and max vectors\r\n * @param min defines the min vector to use\r\n * @param max defines the max vector to use\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean {\r\n const myMin = this.minimumWorld;\r\n const myMax = this.maximumWorld;\r\n const myMinX = myMin.x,\r\n myMinY = myMin.y,\r\n myMinZ = myMin.z,\r\n myMaxX = myMax.x,\r\n myMaxY = myMax.y,\r\n myMaxZ = myMax.z;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n if (myMaxX < minX || myMinX > maxX) {\r\n return false;\r\n }\r\n\r\n if (myMaxY < minY || myMinY > maxY) {\r\n return false;\r\n }\r\n\r\n if (myMaxZ < minZ || myMinZ > maxZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes the resources of the class\r\n */\r\n public dispose(): void {\r\n this._drawWrapperFront?.dispose();\r\n this._drawWrapperBack?.dispose();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Tests if two bounding boxes are intersections\r\n * @param box0 defines the first box to test\r\n * @param box1 defines the second box to test\r\n * @returns true if there is an intersection\r\n */\r\n public static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean {\r\n return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defines by a min/max vectors intersects a sphere\r\n * @param minPoint defines the minimum vector of the bounding box\r\n * @param maxPoint defines the maximum vector of the bounding box\r\n * @param sphereCenter defines the sphere center\r\n * @param sphereRadius defines the sphere radius\r\n * @returns true if there is an intersection\r\n */\r\n public static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean {\r\n const vector = BoundingBox._TmpVector3[0];\r\n Vector3.ClampToRef(sphereCenter, minPoint, maxPoint, vector);\r\n const num = Vector3.DistanceSquared(sphereCenter, vector);\r\n return num <= sphereRadius * sphereRadius;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors intersects frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n let canReturnFalse = true;\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {\r\n canReturnFalse = false;\r\n break;\r\n }\r\n }\r\n if (canReturnFalse) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DeepImmutable } from "../types.js";
|
|
2
|
-
import { type Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
2
|
+
import { type Matrix, Vector3 } from "../Maths/math.vector.pure.js";
|
|
3
3
|
import { BoundingBox } from "./boundingBox.js";
|
|
4
4
|
import { BoundingSphere } from "./boundingSphere.js";
|
|
5
5
|
import { type Plane } from "../Maths/math.plane.js";
|
package/Culling/boundingInfo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildArray } from "../Misc/arrayTools.js";
|
|
2
|
-
import { TmpVectors, Vector3 } from "../Maths/math.vector.js";
|
|
2
|
+
import { TmpVectors, Vector3 } from "../Maths/math.vector.pure.js";
|
|
3
3
|
|
|
4
4
|
import { BoundingBox } from "./boundingBox.js";
|
|
5
5
|
import { BoundingSphere } from "./boundingSphere.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundingInfo.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAe,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKlD,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AACpC,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AACpC,MAAM,iBAAiB,GAAG,CAAC,I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,EAAE,CAAC;YAClF,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YAClF,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YAClF,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;;AAjRuB,wBAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import { type DeepImmutable } from \"../types\";\r\nimport { BuildArray } from \"../Misc/arrayTools\";\r\nimport { type Matrix, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { BoundingBox } from \"./boundingBox\";\r\nimport { BoundingSphere } from \"./boundingSphere\";\r\nimport { type Plane } from \"../Maths/math.plane\";\r\n\r\nimport { type Collider } from \"../Collisions/collider\";\r\n\r\nconst _Result0 = { min: 0, max: 0 };\r\nconst _Result1 = { min: 0, max: 0 };\r\nconst ComputeBoxExtents = (axis: DeepImmutable<Vector3>, box: DeepImmutable<BoundingBox>, result: { min: number; max: number }) => {\r\n const p = Vector3.Dot(box.centerWorld, axis);\r\n\r\n const r0 = Math.abs(Vector3.Dot(box.directions[0], axis)) * box.extendSize.x;\r\n const r1 = Math.abs(Vector3.Dot(box.directions[1], axis)) * box.extendSize.y;\r\n const r2 = Math.abs(Vector3.Dot(box.directions[2], axis)) * box.extendSize.z;\r\n\r\n const r = r0 + r1 + r2;\r\n result.min = p - r;\r\n result.max = p + r;\r\n};\r\n\r\nconst AxisOverlap = (axis: DeepImmutable<Vector3>, box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean => {\r\n ComputeBoxExtents(axis, box0, _Result0);\r\n ComputeBoxExtents(axis, box1, _Result1);\r\n return !(_Result0.min > _Result1.max || _Result1.min > _Result0.max);\r\n};\r\n\r\n/**\r\n * Interface for cullable objects\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/materials_introduction#back-face-culling\r\n */\r\nexport interface ICullable {\r\n /**\r\n * Checks if the object or part of the object is in the frustum\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n isInFrustum(frustumPlanes: Plane[]): boolean;\r\n /**\r\n * Checks if a cullable object (mesh...) is in the camera frustum\r\n * Unlike isInFrustum this checks the full bounding box\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;\r\n}\r\n\r\n/**\r\n * Info for a bounding data of a mesh\r\n */\r\nexport class BoundingInfo implements ICullable {\r\n /**\r\n * Bounding box for the mesh\r\n */\r\n public readonly boundingBox: BoundingBox;\r\n /**\r\n * Bounding sphere for the mesh\r\n */\r\n public readonly boundingSphere: BoundingSphere;\r\n\r\n private _isLocked = false;\r\n\r\n private static readonly _TmpVector3 = BuildArray(2, Vector3.Zero);\r\n\r\n /**\r\n * Constructs bounding info\r\n * @param minimum min vector of the bounding box/sphere\r\n * @param maximum max vector of the bounding box/sphere\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.boundingBox = new BoundingBox(minimum, maximum, worldMatrix);\r\n this.boundingSphere = new BoundingSphere(minimum, maximum, worldMatrix);\r\n }\r\n\r\n /**\r\n * Recreates the entire bounding info from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.boundingBox.reConstruct(min, max, worldMatrix);\r\n this.boundingSphere.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n /**\r\n * min vector of the bounding box/sphere\r\n */\r\n public get minimum(): Vector3 {\r\n return this.boundingBox.minimum;\r\n }\r\n\r\n /**\r\n * max vector of the bounding box/sphere\r\n */\r\n public get maximum(): Vector3 {\r\n return this.boundingBox.maximum;\r\n }\r\n\r\n /**\r\n * If the info is locked and won't be updated to avoid perf overhead\r\n */\r\n public get isLocked(): boolean {\r\n return this._isLocked;\r\n }\r\n\r\n public set isLocked(value: boolean) {\r\n this._isLocked = value;\r\n }\r\n\r\n // Methods\r\n /**\r\n * Updates the bounding sphere and box\r\n * @param world world matrix to be used to update\r\n */\r\n public update(world: DeepImmutable<Matrix>) {\r\n if (this._isLocked) {\r\n return;\r\n }\r\n this.boundingBox._update(world);\r\n this.boundingSphere._update(world);\r\n }\r\n\r\n /**\r\n * Recreate the bounding info to be centered around a specific point given a specific extend.\r\n * @param center New center of the bounding info\r\n * @param extend New extend of the bounding info\r\n * @returns the current bounding info\r\n */\r\n public centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo {\r\n const minimum = BoundingInfo._TmpVector3[0].copyFrom(center).subtractInPlace(extend);\r\n const maximum = BoundingInfo._TmpVector3[1].copyFrom(center).addInPlace(extend);\r\n\r\n this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Grows the bounding info to include the given point.\r\n * @param point The point that will be included in the current bounding info (in local space)\r\n * @returns the current bounding info\r\n */\r\n public encapsulate(point: Vector3): BoundingInfo {\r\n const minimum = Vector3.Minimize(this.minimum, point);\r\n const maximum = Vector3.Maximize(this.maximum, point);\r\n this.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Grows the bounding info to encapsulate the given bounding info.\r\n * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info\r\n * @returns the current bounding info\r\n */\r\n public encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo {\r\n const invw = TmpVectors.Matrix[0];\r\n this.boundingBox.getWorldMatrix().invertToRef(invw);\r\n\r\n const v = TmpVectors.Vector3[0];\r\n\r\n Vector3.TransformCoordinatesToRef(toEncapsulate.boundingBox.minimumWorld, invw, v);\r\n this.encapsulate(v);\r\n\r\n Vector3.TransformCoordinatesToRef(toEncapsulate.boundingBox.maximumWorld, invw, v);\r\n this.encapsulate(v);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Scale the current bounding info by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding info\r\n */\r\n public scale(factor: number): BoundingInfo {\r\n this.boundingBox.scale(factor);\r\n this.boundingSphere.scale(factor);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum to test\r\n * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)\r\n * The different strategies available are:\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD most accurate but slower @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_STANDARD\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY faster but less accurate @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION can be faster if always visible @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_OPTIMISTIC_INCLUSION\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY can be faster if always visible @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY\r\n * @returns true if the bounding info is in the frustum planes\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy: number = Constants.MESHES_CULLINGSTRATEGY_STANDARD): boolean {\r\n const inclusionTest =\r\n strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION || strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;\r\n if (inclusionTest) {\r\n if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!this.boundingSphere.isInFrustum(frustumPlanes)) {\r\n return false;\r\n }\r\n\r\n const bSphereOnlyTest =\r\n strategy === Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY || strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;\r\n if (bSphereOnlyTest) {\r\n return true;\r\n }\r\n\r\n return this.boundingBox.isInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Gets the world distance between the min and max points of the bounding box\r\n */\r\n public get diagonalLength(): number {\r\n const boundingBox = this.boundingBox;\r\n const diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo._TmpVector3[0]);\r\n return diag.length();\r\n }\r\n\r\n /**\r\n * Checks if a cullable object (mesh...) is in the camera frustum\r\n * Unlike isInFrustum this checks the full bounding box\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return this.boundingBox.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n /**\r\n * @internal\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);\r\n }\r\n\r\n /**\r\n * Checks if a point is inside the bounding box and bounding sphere or the mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect\r\n * @param point the point to check intersection with\r\n * @returns if the point intersects\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n if (!this.boundingSphere.centerWorld) {\r\n return false;\r\n }\r\n\r\n if (!this.boundingSphere.intersectsPoint(point)) {\r\n return false;\r\n }\r\n\r\n if (!this.boundingBox.intersectsPoint(point)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect\r\n * @param boundingInfo the bounding info to check intersection with\r\n * @param precise if the intersection should be done using OBB\r\n * @returns if the bounding info intersects\r\n */\r\n public intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean {\r\n if (!BoundingSphere.Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {\r\n return false;\r\n }\r\n\r\n if (!BoundingBox.Intersects(this.boundingBox, boundingInfo.boundingBox)) {\r\n return false;\r\n }\r\n\r\n if (!precise) {\r\n return true;\r\n }\r\n\r\n const box0 = this.boundingBox;\r\n const box1 = boundingInfo.boundingBox;\r\n\r\n if (!AxisOverlap(box0.directions[0], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box0.directions[1], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box0.directions[2], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box1.directions[0], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box1.directions[1], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box1.directions[2], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[0], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[0], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[0], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[1], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[1], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[1], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[2], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[2], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[2], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"boundingInfo.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAe,UAAU,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKlD,MAAM,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O,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YAClF,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YAClF,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YAClF,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;;AAjRuB,wBAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import { type DeepImmutable } from \"../types\";\r\nimport { BuildArray } from \"../Misc/arrayTools\";\r\nimport { type Matrix, TmpVectors, Vector3 } from \"../Maths/math.vector.pure\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { BoundingBox } from \"./boundingBox\";\r\nimport { BoundingSphere } from \"./boundingSphere\";\r\nimport { type Plane } from \"../Maths/math.plane\";\r\n\r\nimport { type Collider } from \"../Collisions/collider\";\r\n\r\nconst _Result0 = { min: 0, max: 0 };\r\nconst _Result1 = { min: 0, max: 0 };\r\nconst ComputeBoxExtents = (axis: DeepImmutable<Vector3>, box: DeepImmutable<BoundingBox>, result: { min: number; max: number }) => {\r\n const p = Vector3.Dot(box.centerWorld, axis);\r\n\r\n const r0 = Math.abs(Vector3.Dot(box.directions[0], axis)) * box.extendSize.x;\r\n const r1 = Math.abs(Vector3.Dot(box.directions[1], axis)) * box.extendSize.y;\r\n const r2 = Math.abs(Vector3.Dot(box.directions[2], axis)) * box.extendSize.z;\r\n\r\n const r = r0 + r1 + r2;\r\n result.min = p - r;\r\n result.max = p + r;\r\n};\r\n\r\nconst AxisOverlap = (axis: DeepImmutable<Vector3>, box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean => {\r\n ComputeBoxExtents(axis, box0, _Result0);\r\n ComputeBoxExtents(axis, box1, _Result1);\r\n return !(_Result0.min > _Result1.max || _Result1.min > _Result0.max);\r\n};\r\n\r\n/**\r\n * Interface for cullable objects\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/materials_introduction#back-face-culling\r\n */\r\nexport interface ICullable {\r\n /**\r\n * Checks if the object or part of the object is in the frustum\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n isInFrustum(frustumPlanes: Plane[]): boolean;\r\n /**\r\n * Checks if a cullable object (mesh...) is in the camera frustum\r\n * Unlike isInFrustum this checks the full bounding box\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;\r\n}\r\n\r\n/**\r\n * Info for a bounding data of a mesh\r\n */\r\nexport class BoundingInfo implements ICullable {\r\n /**\r\n * Bounding box for the mesh\r\n */\r\n public readonly boundingBox: BoundingBox;\r\n /**\r\n * Bounding sphere for the mesh\r\n */\r\n public readonly boundingSphere: BoundingSphere;\r\n\r\n private _isLocked = false;\r\n\r\n private static readonly _TmpVector3 = BuildArray(2, Vector3.Zero);\r\n\r\n /**\r\n * Constructs bounding info\r\n * @param minimum min vector of the bounding box/sphere\r\n * @param maximum max vector of the bounding box/sphere\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.boundingBox = new BoundingBox(minimum, maximum, worldMatrix);\r\n this.boundingSphere = new BoundingSphere(minimum, maximum, worldMatrix);\r\n }\r\n\r\n /**\r\n * Recreates the entire bounding info from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.boundingBox.reConstruct(min, max, worldMatrix);\r\n this.boundingSphere.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n /**\r\n * min vector of the bounding box/sphere\r\n */\r\n public get minimum(): Vector3 {\r\n return this.boundingBox.minimum;\r\n }\r\n\r\n /**\r\n * max vector of the bounding box/sphere\r\n */\r\n public get maximum(): Vector3 {\r\n return this.boundingBox.maximum;\r\n }\r\n\r\n /**\r\n * If the info is locked and won't be updated to avoid perf overhead\r\n */\r\n public get isLocked(): boolean {\r\n return this._isLocked;\r\n }\r\n\r\n public set isLocked(value: boolean) {\r\n this._isLocked = value;\r\n }\r\n\r\n // Methods\r\n /**\r\n * Updates the bounding sphere and box\r\n * @param world world matrix to be used to update\r\n */\r\n public update(world: DeepImmutable<Matrix>) {\r\n if (this._isLocked) {\r\n return;\r\n }\r\n this.boundingBox._update(world);\r\n this.boundingSphere._update(world);\r\n }\r\n\r\n /**\r\n * Recreate the bounding info to be centered around a specific point given a specific extend.\r\n * @param center New center of the bounding info\r\n * @param extend New extend of the bounding info\r\n * @returns the current bounding info\r\n */\r\n public centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo {\r\n const minimum = BoundingInfo._TmpVector3[0].copyFrom(center).subtractInPlace(extend);\r\n const maximum = BoundingInfo._TmpVector3[1].copyFrom(center).addInPlace(extend);\r\n\r\n this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Grows the bounding info to include the given point.\r\n * @param point The point that will be included in the current bounding info (in local space)\r\n * @returns the current bounding info\r\n */\r\n public encapsulate(point: Vector3): BoundingInfo {\r\n const minimum = Vector3.Minimize(this.minimum, point);\r\n const maximum = Vector3.Maximize(this.maximum, point);\r\n this.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Grows the bounding info to encapsulate the given bounding info.\r\n * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info\r\n * @returns the current bounding info\r\n */\r\n public encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo {\r\n const invw = TmpVectors.Matrix[0];\r\n this.boundingBox.getWorldMatrix().invertToRef(invw);\r\n\r\n const v = TmpVectors.Vector3[0];\r\n\r\n Vector3.TransformCoordinatesToRef(toEncapsulate.boundingBox.minimumWorld, invw, v);\r\n this.encapsulate(v);\r\n\r\n Vector3.TransformCoordinatesToRef(toEncapsulate.boundingBox.maximumWorld, invw, v);\r\n this.encapsulate(v);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Scale the current bounding info by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding info\r\n */\r\n public scale(factor: number): BoundingInfo {\r\n this.boundingBox.scale(factor);\r\n this.boundingSphere.scale(factor);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum to test\r\n * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)\r\n * The different strategies available are:\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD most accurate but slower @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_STANDARD\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY faster but less accurate @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION can be faster if always visible @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_OPTIMISTIC_INCLUSION\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY can be faster if always visible @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY\r\n * @returns true if the bounding info is in the frustum planes\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy: number = Constants.MESHES_CULLINGSTRATEGY_STANDARD): boolean {\r\n const inclusionTest =\r\n strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION || strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;\r\n if (inclusionTest) {\r\n if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!this.boundingSphere.isInFrustum(frustumPlanes)) {\r\n return false;\r\n }\r\n\r\n const bSphereOnlyTest =\r\n strategy === Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY || strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;\r\n if (bSphereOnlyTest) {\r\n return true;\r\n }\r\n\r\n return this.boundingBox.isInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Gets the world distance between the min and max points of the bounding box\r\n */\r\n public get diagonalLength(): number {\r\n const boundingBox = this.boundingBox;\r\n const diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo._TmpVector3[0]);\r\n return diag.length();\r\n }\r\n\r\n /**\r\n * Checks if a cullable object (mesh...) is in the camera frustum\r\n * Unlike isInFrustum this checks the full bounding box\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return this.boundingBox.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n /**\r\n * @internal\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);\r\n }\r\n\r\n /**\r\n * Checks if a point is inside the bounding box and bounding sphere or the mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect\r\n * @param point the point to check intersection with\r\n * @returns if the point intersects\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n if (!this.boundingSphere.centerWorld) {\r\n return false;\r\n }\r\n\r\n if (!this.boundingSphere.intersectsPoint(point)) {\r\n return false;\r\n }\r\n\r\n if (!this.boundingBox.intersectsPoint(point)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect\r\n * @param boundingInfo the bounding info to check intersection with\r\n * @param precise if the intersection should be done using OBB\r\n * @returns if the bounding info intersects\r\n */\r\n public intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean {\r\n if (!BoundingSphere.Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {\r\n return false;\r\n }\r\n\r\n if (!BoundingBox.Intersects(this.boundingBox, boundingInfo.boundingBox)) {\r\n return false;\r\n }\r\n\r\n if (!precise) {\r\n return true;\r\n }\r\n\r\n const box0 = this.boundingBox;\r\n const box1 = boundingInfo.boundingBox;\r\n\r\n if (!AxisOverlap(box0.directions[0], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box0.directions[1], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box0.directions[2], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box1.directions[0], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box1.directions[1], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(box1.directions[2], box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[0], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[0], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[0], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[1], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[1], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[1], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[2], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[2], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!AxisOverlap(Vector3.Cross(box0.directions[2], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DeepImmutable } from "../types.js";
|
|
2
|
-
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
2
|
+
import { Matrix, Vector3 } from "../Maths/math.vector.pure.js";
|
|
3
3
|
import { type Plane } from "../Maths/math.plane.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class used to store bounding sphere information
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundingSphere.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingSphere.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,cAAc;IA6BvB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAlCzG;;WAEG;QACa,WAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAKxC;;WAEG;QACa,gBAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAK7C;;WAEG;QACa,YAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QACzC;;WAEG;QACa,YAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAYrC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACI,WAAW,CAAC,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAC5G,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAE3B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAE5C,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,QAAQ,GAAG,GAAG,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,MAAM,CAAC,gBAAgB,CAAC,CA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CAAC,QAAQ,EAAE,CAAC;QAC5C,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;;AA9JuB,0BAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import { type DeepImmutable } from \"../types\";\r\nimport { BuildArray } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { type Plane } from \"../Maths/math.plane\";\r\n\r\n/**\r\n * Class used to store bounding sphere information\r\n */\r\nexport class BoundingSphere {\r\n /**\r\n * Gets the center of the bounding sphere in local space\r\n */\r\n public readonly center = Vector3.Zero();\r\n /**\r\n * Radius of the bounding sphere in local space\r\n */\r\n public radius: number;\r\n /**\r\n * Gets the center of the bounding sphere in world space\r\n */\r\n public readonly centerWorld = Vector3.Zero();\r\n /**\r\n * Radius of the bounding sphere in world space\r\n */\r\n public radiusWorld: number;\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * Creates a new bounding sphere\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n /**\r\n * Recreates the entire bounding sphere from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.minimum.copyFrom(min);\r\n this.maximum.copyFrom(max);\r\n\r\n const distance = Vector3.Distance(min, max);\r\n\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n this.radius = distance * 0.5;\r\n\r\n this._update(worldMatrix || Matrix.IdentityReadOnly);\r\n }\r\n\r\n /**\r\n * Scale the current bounding sphere by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingSphere {\r\n const newRadius = this.radius * factor;\r\n const tmpVectors = BoundingSphere._TmpVector3;\r\n const tempRadiusVector = tmpVectors[0].setAll(newRadius);\r\n const min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);\r\n const max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n // Methods\r\n /**\r\n * @internal\r\n */\r\n public _update(worldMatrix: DeepImmutable<Matrix>): void {\r\n if (!worldMatrix.isIdentity()) {\r\n Vector3.TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);\r\n const tempVector = BoundingSphere._TmpVector3[0];\r\n Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);\r\n this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;\r\n } else {\r\n this.centerWorld.copyFrom(this.center);\r\n this.radiusWorld = this.radius;\r\n }\r\n }\r\n\r\n /**\r\n * Tests if the bounding sphere is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n const center = this.centerWorld;\r\n const radius = this.radiusWorld;\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(center) <= -radius) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding sphere center is in between the frustum planes.\r\n * Used for optimistic fast inclusion.\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if the sphere center is in between the frustum planes\r\n */\r\n public isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n const center = this.centerWorld;\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(center) < 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding sphere\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding sphere\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const squareDistance = Vector3.DistanceSquared(this.centerWorld, point);\r\n if (this.radiusWorld * this.radiusWorld < squareDistance) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Checks if two sphere intersect\r\n * @param sphere0 sphere 0\r\n * @param sphere1 sphere 1\r\n * @returns true if the spheres intersect\r\n */\r\n public static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean {\r\n const squareDistance = Vector3.DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);\r\n const radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;\r\n\r\n if (radiusSum * radiusSum < squareDistance) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates a sphere from a center and a radius\r\n * @param center The center\r\n * @param radius radius\r\n * @param matrix Optional worldMatrix\r\n * @returns The sphere\r\n */\r\n public static CreateFromCenterAndRadius(center: DeepImmutable<Vector3>, radius: number, matrix?: DeepImmutable<Matrix>): BoundingSphere {\r\n this._TmpVector3[0].copyFrom(center);\r\n this._TmpVector3[1].copyFromFloats(0, 0, radius);\r\n this._TmpVector3[2].copyFrom(center);\r\n this._TmpVector3[0].addInPlace(this._TmpVector3[1]);\r\n this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);\r\n\r\n const sphere = new BoundingSphere(this._TmpVector3[0], this._TmpVector3[2]);\r\n\r\n if (matrix) {\r\n sphere._worldMatrix = matrix;\r\n } else {\r\n sphere._worldMatrix = Matrix.Identity();\r\n }\r\n\r\n return sphere;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"boundingSphere.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingSphere.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAG5D;;GAEG;AACH,MAAM,OAAO,cAAc;IA6BvB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAlCzG;;WAEG;QACa,WAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAKxC;;WAEG;QACa,gBAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAK7C;;WAEG;QACa,YAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QACzC;;WAEG;QACa,YAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAYrC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACI,WAAW,CAAC,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAC5G,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAE3B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAE5C,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC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W,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5E,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;QACjC,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC5C,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;;AA9JuB,0BAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import { type DeepImmutable } from \"../types\";\r\nimport { BuildArray } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector.pure\";\r\nimport { type Plane } from \"../Maths/math.plane\";\r\n\r\n/**\r\n * Class used to store bounding sphere information\r\n */\r\nexport class BoundingSphere {\r\n /**\r\n * Gets the center of the bounding sphere in local space\r\n */\r\n public readonly center = Vector3.Zero();\r\n /**\r\n * Radius of the bounding sphere in local space\r\n */\r\n public radius: number;\r\n /**\r\n * Gets the center of the bounding sphere in world space\r\n */\r\n public readonly centerWorld = Vector3.Zero();\r\n /**\r\n * Radius of the bounding sphere in world space\r\n */\r\n public radiusWorld: number;\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * Creates a new bounding sphere\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n /**\r\n * Recreates the entire bounding sphere from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.minimum.copyFrom(min);\r\n this.maximum.copyFrom(max);\r\n\r\n const distance = Vector3.Distance(min, max);\r\n\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n this.radius = distance * 0.5;\r\n\r\n this._update(worldMatrix || Matrix.IdentityReadOnly);\r\n }\r\n\r\n /**\r\n * Scale the current bounding sphere by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingSphere {\r\n const newRadius = this.radius * factor;\r\n const tmpVectors = BoundingSphere._TmpVector3;\r\n const tempRadiusVector = tmpVectors[0].setAll(newRadius);\r\n const min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);\r\n const max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n // Methods\r\n /**\r\n * @internal\r\n */\r\n public _update(worldMatrix: DeepImmutable<Matrix>): void {\r\n if (!worldMatrix.isIdentity()) {\r\n Vector3.TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);\r\n const tempVector = BoundingSphere._TmpVector3[0];\r\n Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);\r\n this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;\r\n } else {\r\n this.centerWorld.copyFrom(this.center);\r\n this.radiusWorld = this.radius;\r\n }\r\n }\r\n\r\n /**\r\n * Tests if the bounding sphere is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n const center = this.centerWorld;\r\n const radius = this.radiusWorld;\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(center) <= -radius) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding sphere center is in between the frustum planes.\r\n * Used for optimistic fast inclusion.\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if the sphere center is in between the frustum planes\r\n */\r\n public isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n const center = this.centerWorld;\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(center) < 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding sphere\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding sphere\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const squareDistance = Vector3.DistanceSquared(this.centerWorld, point);\r\n if (this.radiusWorld * this.radiusWorld < squareDistance) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Checks if two sphere intersect\r\n * @param sphere0 sphere 0\r\n * @param sphere1 sphere 1\r\n * @returns true if the spheres intersect\r\n */\r\n public static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean {\r\n const squareDistance = Vector3.DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);\r\n const radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;\r\n\r\n if (radiusSum * radiusSum < squareDistance) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates a sphere from a center and a radius\r\n * @param center The center\r\n * @param radius radius\r\n * @param matrix Optional worldMatrix\r\n * @returns The sphere\r\n */\r\n public static CreateFromCenterAndRadius(center: DeepImmutable<Vector3>, radius: number, matrix?: DeepImmutable<Matrix>): BoundingSphere {\r\n this._TmpVector3[0].copyFrom(center);\r\n this._TmpVector3[1].copyFromFloats(0, 0, radius);\r\n this._TmpVector3[2].copyFrom(center);\r\n this._TmpVector3[0].addInPlace(this._TmpVector3[1]);\r\n this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);\r\n\r\n const sphere = new BoundingSphere(this._TmpVector3[0], this._TmpVector3[2]);\r\n\r\n if (matrix) {\r\n sphere._worldMatrix = matrix;\r\n } else {\r\n sphere._worldMatrix = Matrix.Identity();\r\n }\r\n\r\n return sphere;\r\n }\r\n}\r\n"]}
|
package/Culling/ray.core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
1
|
+
import { Matrix, Vector3 } from "../Maths/math.vector.pure.js";
|
|
2
2
|
import { IntersectionInfo } from "../Collisions/intersectionInfo.js";
|
|
3
3
|
import { type BoundingBox } from "./boundingBox.js";
|
|
4
4
|
import { type BoundingSphere } from "./boundingSphere.js";
|
package/Culling/ray.core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Epsilon } from "../Maths/math.constants.js";
|
|
2
|
-
import { Matrix, TmpVectors, Vector3 } from "../Maths/math.vector.js";
|
|
2
|
+
import { Matrix, TmpVectors, Vector3 } from "../Maths/math.vector.pure.js";
|
|
3
3
|
import { BuildArray } from "../Misc/arrayTools.js";
|
|
4
4
|
import { IntersectionInfo } from "../Collisions/intersectionInfo.js";
|
|
5
5
|
import { PickingInfo } from "../Collisions/pickingInfo.js";
|