@babylonjs/core 6.14.2 → 6.16.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.js +8 -3
- package/Actions/actionManager.js.map +1 -1
- package/Behaviors/Cameras/framingBehavior.d.ts +2 -1
- package/Behaviors/Cameras/framingBehavior.js +3 -1
- package/Behaviors/Cameras/framingBehavior.js.map +1 -1
- package/Bones/skeleton.js +1 -0
- package/Bones/skeleton.js.map +1 -1
- package/Compute/computeEffect.js +1 -1
- package/Compute/computeEffect.js.map +1 -1
- package/{Materials/Node/nodeMaterialDecorator.d.ts → Decorators/nodeDecorator.d.ts} +6 -7
- package/{Materials/Node/nodeMaterialDecorator.js → Decorators/nodeDecorator.js} +3 -3
- package/Decorators/nodeDecorator.js.map +1 -0
- package/Engines/Processors/shaderCodeNode.js +1 -1
- package/Engines/Processors/shaderCodeNode.js.map +1 -1
- package/Engines/WebGL/webGL2ShaderProcessors.js +2 -1
- package/Engines/WebGL/webGL2ShaderProcessors.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessor.js +3 -0
- package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +11 -10
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +3 -3
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/nativeEngine.js +5 -4
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +2 -0
- package/Engines/thinEngine.js +35 -4
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +12 -2
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.d.ts +34 -0
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js +29 -0
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js.map +1 -0
- package/FlowGraph/Blocks/Data/index.d.ts +1 -0
- package/FlowGraph/Blocks/Data/index.js +2 -0
- package/FlowGraph/Blocks/Data/index.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +23 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +51 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +20 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +29 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/index.d.ts +2 -0
- package/FlowGraph/Blocks/Event/index.js +3 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.d.ts +43 -0
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js +40 -0
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.d.ts +18 -0
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +21 -0
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/index.d.ts +2 -0
- package/FlowGraph/Blocks/Execution/index.js +3 -0
- package/FlowGraph/Blocks/Execution/index.js.map +1 -0
- package/FlowGraph/Blocks/index.d.ts +3 -0
- package/FlowGraph/Blocks/index.js +5 -0
- package/FlowGraph/Blocks/index.js.map +1 -0
- package/FlowGraph/flowGraph.d.ts +34 -0
- package/FlowGraph/flowGraph.js +54 -0
- package/FlowGraph/flowGraph.js.map +1 -0
- package/FlowGraph/flowGraphBlock.d.ts +33 -0
- package/FlowGraph/flowGraphBlock.js +39 -0
- package/FlowGraph/flowGraphBlock.js.map +1 -0
- package/FlowGraph/flowGraphConnection.d.ts +38 -0
- package/FlowGraph/flowGraphConnection.js +40 -0
- package/FlowGraph/flowGraphConnection.js.map +1 -0
- package/FlowGraph/flowGraphDataConnection.d.ts +15 -0
- package/FlowGraph/flowGraphDataConnection.js +30 -0
- package/FlowGraph/flowGraphDataConnection.js.map +1 -0
- package/FlowGraph/flowGraphEventBlock.d.ts +20 -0
- package/FlowGraph/flowGraphEventBlock.js +15 -0
- package/FlowGraph/flowGraphEventBlock.js.map +1 -0
- package/FlowGraph/flowGraphExecutionBlock.d.ts +24 -0
- package/FlowGraph/flowGraphExecutionBlock.js +27 -0
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -0
- package/FlowGraph/flowGraphSignalConnection.d.ts +14 -0
- package/FlowGraph/flowGraphSignalConnection.js +22 -0
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -0
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +7 -0
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +8 -0
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -0
- package/FlowGraph/index.d.ts +6 -0
- package/FlowGraph/index.js +8 -0
- package/FlowGraph/index.js.map +1 -0
- package/Gizmos/lightGizmo.d.ts +5 -0
- package/Gizmos/lightGizmo.js +21 -7
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.d.ts +6 -0
- package/Gizmos/planeRotationGizmo.js +5 -1
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +8 -0
- package/Gizmos/rotationGizmo.js +15 -0
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Layers/layer.js +1 -1
- package/Layers/layer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.d.ts +2 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +4 -3
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +3 -1
- package/Lights/Shadows/shadowGenerator.js +4 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/directionalLight.d.ts +1 -1
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/hemisphericLight.d.ts +1 -1
- package/Lights/hemisphericLight.js.map +1 -1
- package/Lights/light.d.ts +1 -1
- package/Lights/light.js.map +1 -1
- package/Lights/pointLight.d.ts +1 -1
- package/Lights/pointLight.js.map +1 -1
- package/Lights/spotLight.d.ts +1 -1
- package/Lights/spotLight.js.map +1 -1
- package/Loading/sceneLoader.js +2 -0
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +13 -13
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js +6 -6
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +11 -11
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +16 -16
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +27 -27
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +8 -8
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +28 -28
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +3 -5
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/derivativeBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/derivativeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/discardBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/discardBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragCoordBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/fragCoordBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragDepthBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/fragDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +15 -15
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/frontFacingBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/frontFacingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +6 -6
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +13 -13
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +13 -13
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +5 -5
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +7 -7
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/twirlBlock.js +3 -3
- package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +11 -11
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +6 -6
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +9 -9
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +47 -47
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +9 -9
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +14 -14
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js +4 -4
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js +8 -8
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/index.d.ts +2 -0
- package/Materials/Node/Blocks/Teleport/index.js +3 -0
- package/Materials/Node/Blocks/Teleport/index.js.map +1 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.d.ts +42 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js +83 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -0
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.d.ts +59 -0
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +122 -0
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -0
- package/Materials/Node/Blocks/Vertex/bonesBlock.js +5 -5
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +11 -11
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +11 -11
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +39 -39
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js +3 -3
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/addBlock.js +1 -1
- package/Materials/Node/Blocks/addBlock.js.map +1 -1
- package/Materials/Node/Blocks/arcTan2Block.js +1 -1
- package/Materials/Node/Blocks/arcTan2Block.js.map +1 -1
- package/Materials/Node/Blocks/clampBlock.js +4 -4
- package/Materials/Node/Blocks/clampBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js +7 -7
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +8 -8
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorSplitterBlock.js +5 -5
- package/Materials/Node/Blocks/colorSplitterBlock.js.map +1 -1
- package/Materials/Node/Blocks/conditionalBlock.js +10 -10
- package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
- package/Materials/Node/Blocks/crossBlock.js +1 -1
- package/Materials/Node/Blocks/crossBlock.js.map +1 -1
- package/Materials/Node/Blocks/curveBlock.js +5 -5
- package/Materials/Node/Blocks/curveBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js +4 -4
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/desaturateBlock.js +4 -4
- package/Materials/Node/Blocks/desaturateBlock.js.map +1 -1
- package/Materials/Node/Blocks/distanceBlock.js +1 -1
- package/Materials/Node/Blocks/distanceBlock.js.map +1 -1
- package/Materials/Node/Blocks/divideBlock.js +1 -1
- package/Materials/Node/Blocks/divideBlock.js.map +1 -1
- package/Materials/Node/Blocks/dotBlock.js +1 -1
- package/Materials/Node/Blocks/dotBlock.js.map +1 -1
- package/Materials/Node/Blocks/elbowBlock.js +1 -1
- package/Materials/Node/Blocks/elbowBlock.js.map +1 -1
- package/Materials/Node/Blocks/fresnelBlock.js +1 -1
- package/Materials/Node/Blocks/fresnelBlock.js.map +1 -1
- package/Materials/Node/Blocks/gradientBlock.js +8 -8
- package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/index.d.ts +1 -0
- package/Materials/Node/Blocks/index.js +1 -0
- package/Materials/Node/Blocks/index.js.map +1 -1
- package/Materials/Node/Blocks/lengthBlock.js +1 -1
- package/Materials/Node/Blocks/lengthBlock.js.map +1 -1
- package/Materials/Node/Blocks/lerpBlock.js +1 -1
- package/Materials/Node/Blocks/lerpBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixBuilderBlock.js +1 -1
- package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixDeterminantBlock.js +1 -1
- package/Materials/Node/Blocks/matrixDeterminantBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixTransposeBlock.js +1 -1
- package/Materials/Node/Blocks/matrixTransposeBlock.js.map +1 -1
- package/Materials/Node/Blocks/maxBlock.js +1 -1
- package/Materials/Node/Blocks/maxBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +7 -7
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/minBlock.js +1 -1
- package/Materials/Node/Blocks/minBlock.js.map +1 -1
- package/Materials/Node/Blocks/modBlock.js +1 -1
- package/Materials/Node/Blocks/modBlock.js.map +1 -1
- package/Materials/Node/Blocks/multiplyBlock.js +1 -1
- package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/nLerpBlock.js +1 -1
- package/Materials/Node/Blocks/nLerpBlock.js.map +1 -1
- package/Materials/Node/Blocks/negateBlock.js +1 -1
- package/Materials/Node/Blocks/negateBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalBlendBlock.js +6 -6
- package/Materials/Node/Blocks/normalBlendBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalizeBlock.js +1 -1
- package/Materials/Node/Blocks/normalizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/oneMinusBlock.js +1 -1
- package/Materials/Node/Blocks/oneMinusBlock.js.map +1 -1
- package/Materials/Node/Blocks/posterizeBlock.js +1 -1
- package/Materials/Node/Blocks/posterizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/powBlock.js +1 -1
- package/Materials/Node/Blocks/powBlock.js.map +1 -1
- package/Materials/Node/Blocks/randomNumberBlock.js +1 -1
- package/Materials/Node/Blocks/randomNumberBlock.js.map +1 -1
- package/Materials/Node/Blocks/reciprocalBlock.js +2 -2
- package/Materials/Node/Blocks/reciprocalBlock.js.map +1 -1
- package/Materials/Node/Blocks/reflectBlock.js +1 -1
- package/Materials/Node/Blocks/reflectBlock.js.map +1 -1
- package/Materials/Node/Blocks/refractBlock.js +1 -1
- package/Materials/Node/Blocks/refractBlock.js.map +1 -1
- package/Materials/Node/Blocks/remapBlock.js +4 -4
- package/Materials/Node/Blocks/remapBlock.js.map +1 -1
- package/Materials/Node/Blocks/replaceColorBlock.js +6 -6
- package/Materials/Node/Blocks/replaceColorBlock.js.map +1 -1
- package/Materials/Node/Blocks/rotate2dBlock.js +1 -1
- package/Materials/Node/Blocks/rotate2dBlock.js.map +1 -1
- package/Materials/Node/Blocks/scaleBlock.js +1 -1
- package/Materials/Node/Blocks/scaleBlock.js.map +1 -1
- package/Materials/Node/Blocks/simplexPerlin3DBlock.js +41 -41
- package/Materials/Node/Blocks/simplexPerlin3DBlock.js.map +1 -1
- package/Materials/Node/Blocks/smoothStepBlock.js +1 -1
- package/Materials/Node/Blocks/smoothStepBlock.js.map +1 -1
- package/Materials/Node/Blocks/stepBlock.js +1 -1
- package/Materials/Node/Blocks/stepBlock.js.map +1 -1
- package/Materials/Node/Blocks/subtractBlock.js +1 -1
- package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
- package/Materials/Node/Blocks/transformBlock.js +13 -14
- package/Materials/Node/Blocks/transformBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js +17 -17
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js +2 -2
- package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js +22 -22
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorSplitterBlock.js +8 -8
- package/Materials/Node/Blocks/vectorSplitterBlock.js.map +1 -1
- package/Materials/Node/Blocks/viewDirectionBlock.js +1 -1
- package/Materials/Node/Blocks/viewDirectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/voronoiNoiseBlock.js +5 -5
- package/Materials/Node/Blocks/voronoiNoiseBlock.js.map +1 -1
- package/Materials/Node/Blocks/waveBlock.js +3 -4
- package/Materials/Node/Blocks/waveBlock.js.map +1 -1
- package/Materials/Node/Blocks/worleyNoise3DBlock.js +155 -155
- package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
- package/Materials/Node/index.d.ts +1 -1
- package/Materials/Node/index.js +1 -1
- package/Materials/Node/index.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +1 -0
- package/Materials/Node/nodeMaterial.js +50 -15
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.d.ts +14 -2
- package/Materials/Node/nodeMaterialBlock.js +34 -11
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +36 -36
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildStateSharedData.js +4 -4
- package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +1 -0
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/effect.js +1 -1
- package/Materials/effect.js.map +1 -1
- package/Materials/effectRenderer.d.ts +4 -0
- package/Materials/effectRenderer.js +8 -2
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/greasedLinePluginMaterial.d.ts +4 -0
- package/Materials/greasedLinePluginMaterial.js +12 -1
- package/Materials/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/materialPluginManager.js +5 -5
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/meshDebugPluginMaterial.d.ts +4 -15
- package/Materials/meshDebugPluginMaterial.js +8 -29
- package/Materials/meshDebugPluginMaterial.js.map +1 -1
- package/Materials/shadowDepthWrapper.js +5 -5
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Meshes/Builders/boxBuilder.d.ts +31 -0
- package/Meshes/Builders/boxBuilder.js +65 -1
- package/Meshes/Builders/boxBuilder.js.map +1 -1
- package/Meshes/Builders/capsuleBuilder.js +3 -3
- package/Meshes/Builders/capsuleBuilder.js.map +1 -1
- package/Meshes/Builders/cylinderBuilder.js +2 -2
- package/Meshes/Builders/cylinderBuilder.js.map +1 -1
- package/Meshes/Builders/groundBuilder.js +2 -2
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/Builders/icoSphereBuilder.js +1 -1
- package/Meshes/Builders/icoSphereBuilder.js.map +1 -1
- package/Meshes/Builders/linesBuilder.d.ts +1 -1
- package/Meshes/Builders/linesBuilder.js +1 -1
- package/Meshes/Builders/linesBuilder.js.map +1 -1
- package/Meshes/Builders/sphereBuilder.js +1 -1
- package/Meshes/Builders/sphereBuilder.js.map +1 -1
- package/Meshes/Builders/torusBuilder.js +1 -1
- package/Meshes/Builders/torusBuilder.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +85 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +210 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +68 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +186 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -0
- package/Meshes/Node/Blocks/IntFloatConverterBlock.d.ts +35 -0
- package/Meshes/Node/Blocks/IntFloatConverterBlock.js +81 -0
- package/Meshes/Node/Blocks/IntFloatConverterBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Matrices/alignBlock.d.ts +31 -0
- package/Meshes/Node/Blocks/Matrices/alignBlock.js +58 -0
- package/Meshes/Node/Blocks/Matrices/alignBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Matrices/rotationXBlock.d.ts +28 -0
- package/Meshes/Node/Blocks/Matrices/rotationXBlock.js +53 -0
- package/Meshes/Node/Blocks/Matrices/rotationXBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Matrices/rotationYBlock.d.ts +28 -0
- package/Meshes/Node/Blocks/Matrices/rotationYBlock.js +53 -0
- package/Meshes/Node/Blocks/Matrices/rotationYBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Matrices/rotationZBlock.d.ts +28 -0
- package/Meshes/Node/Blocks/Matrices/rotationZBlock.js +53 -0
- package/Meshes/Node/Blocks/Matrices/rotationZBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Matrices/scalingBlock.d.ts +28 -0
- package/Meshes/Node/Blocks/Matrices/scalingBlock.js +54 -0
- package/Meshes/Node/Blocks/Matrices/scalingBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Matrices/translationBlock.d.ts +28 -0
- package/Meshes/Node/Blocks/Matrices/translationBlock.js +54 -0
- package/Meshes/Node/Blocks/Matrices/translationBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +44 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js +91 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +36 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +84 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +44 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js +91 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +44 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js +82 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +44 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js +91 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +55 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +145 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/boxBlock.d.ts +68 -0
- package/Meshes/Node/Blocks/Sources/boxBlock.js +175 -0
- package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/capsuleBlock.d.ts +52 -0
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js +117 -0
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/cylinderBlock.d.ts +64 -0
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js +143 -0
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/discBlock.d.ts +48 -0
- package/Meshes/Node/Blocks/Sources/discBlock.js +104 -0
- package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/gridBlock.d.ts +56 -0
- package/Meshes/Node/Blocks/Sources/gridBlock.js +125 -0
- package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.d.ts +56 -0
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +120 -0
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +38 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.js +78 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/planeBlock.d.ts +48 -0
- package/Meshes/Node/Blocks/Sources/planeBlock.js +118 -0
- package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/sphereBlock.d.ts +64 -0
- package/Meshes/Node/Blocks/Sources/sphereBlock.js +136 -0
- package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/torusBlock.d.ts +48 -0
- package/Meshes/Node/Blocks/Sources/torusBlock.js +104 -0
- package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.d.ts +37 -0
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js +75 -0
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.d.ts +50 -0
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +105 -0
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -0
- package/Meshes/Node/Blocks/computeNormalsBlock.d.ts +26 -0
- package/Meshes/Node/Blocks/computeNormalsBlock.js +49 -0
- package/Meshes/Node/Blocks/computeNormalsBlock.js.map +1 -0
- package/Meshes/Node/Blocks/conditionBlock.d.ts +72 -0
- package/Meshes/Node/Blocks/conditionBlock.js +174 -0
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -0
- package/Meshes/Node/Blocks/debugBlock.d.ts +34 -0
- package/Meshes/Node/Blocks/debugBlock.js +63 -0
- package/Meshes/Node/Blocks/debugBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryElbowBlock.d.ts +31 -0
- package/Meshes/Node/Blocks/geometryElbowBlock.js +53 -0
- package/Meshes/Node/Blocks/geometryElbowBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryInputBlock.d.ts +71 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js +218 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryOutputBlock.d.ts +30 -0
- package/Meshes/Node/Blocks/geometryOutputBlock.js +42 -0
- package/Meshes/Node/Blocks/geometryOutputBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +53 -0
- package/Meshes/Node/Blocks/geometryTransformBlock.js +134 -0
- package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +77 -0
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +248 -0
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -0
- package/Meshes/Node/Blocks/mapRangeBlock.d.ts +42 -0
- package/Meshes/Node/Blocks/mapRangeBlock.js +84 -0
- package/Meshes/Node/Blocks/mapRangeBlock.js.map +1 -0
- package/Meshes/Node/Blocks/mathBlock.d.ts +58 -0
- package/Meshes/Node/Blocks/mathBlock.js +233 -0
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -0
- package/Meshes/Node/Blocks/mergeGeometryBlock.d.ts +55 -0
- package/Meshes/Node/Blocks/mergeGeometryBlock.js +123 -0
- package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -0
- package/Meshes/Node/Blocks/noiseBlock.d.ts +49 -0
- package/Meshes/Node/Blocks/noiseBlock.js +149 -0
- package/Meshes/Node/Blocks/noiseBlock.js.map +1 -0
- package/Meshes/Node/Blocks/normalizeVectorBlock.d.ts +27 -0
- package/Meshes/Node/Blocks/normalizeVectorBlock.js +51 -0
- package/Meshes/Node/Blocks/normalizeVectorBlock.js.map +1 -0
- package/Meshes/Node/Blocks/randomBlock.d.ts +31 -0
- package/Meshes/Node/Blocks/randomBlock.js +99 -0
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -0
- package/Meshes/Node/Blocks/vectorConverterBlock.d.ts +84 -0
- package/Meshes/Node/Blocks/vectorConverterBlock.js +238 -0
- package/Meshes/Node/Blocks/vectorConverterBlock.js.map +1 -0
- package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.d.ts +27 -0
- package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.js +29 -0
- package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.js.map +1 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +33 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js +35 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -0
- package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.d.ts +25 -0
- package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.js +2 -0
- package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.js.map +1 -0
- package/Meshes/Node/index.d.ts +49 -0
- package/Meshes/Node/index.js +50 -0
- package/Meshes/Node/index.js.map +1 -0
- package/Meshes/Node/nodeGeometry.d.ts +180 -0
- package/Meshes/Node/nodeGeometry.js +529 -0
- package/Meshes/Node/nodeGeometry.js.map +1 -0
- package/Meshes/Node/nodeGeometryBlock.d.ts +166 -0
- package/Meshes/Node/nodeGeometryBlock.js +432 -0
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +176 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +305 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -0
- package/Meshes/Node/nodeGeometryBuildState.d.ts +57 -0
- package/Meshes/Node/nodeGeometryBuildState.js +178 -0
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -0
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +37 -2
- package/Meshes/mesh.vertexData.js +425 -95
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.js +1 -0
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Particles/IGPUParticleSystemPlatform.d.ts +1 -0
- package/Particles/IGPUParticleSystemPlatform.js.map +1 -1
- package/Particles/computeShaderParticleSystem.d.ts +1 -0
- package/Particles/computeShaderParticleSystem.js +5 -0
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.js +11 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/webgl2ParticleSystem.d.ts +1 -0
- package/Particles/webgl2ParticleSystem.js +5 -0
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +20 -2
- package/Physics/v2/IPhysicsEnginePlugin.js +8 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +27 -2
- package/Physics/v2/Plugins/havokPlugin.js +98 -11
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +4 -0
- package/Physics/v2/physicsAggregate.js +3 -0
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +7 -0
- package/Physics/v2/physicsBody.js +10 -0
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsShape.d.ts +3 -0
- package/Physics/v2/physicsShape.js +11 -0
- package/Physics/v2/physicsShape.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js +6 -4
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js.map +1 -1
- package/PostProcesses/blurPostProcess.js +5 -5
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.js +1 -1
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.d.ts +0 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +0 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/backgroundFragmentDeclaration.js +16 -8
- package/Shaders/ShadersInclude/backgroundFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js +9 -4
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/backgroundVertexDeclaration.js +8 -4
- package/Shaders/ShadersInclude/backgroundVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/bakedVertexAnimation.js +20 -10
- package/Shaders/ShadersInclude/bakedVertexAnimation.js.map +1 -1
- package/Shaders/ShadersInclude/bakedVertexAnimationDeclaration.js +7 -3
- package/Shaders/ShadersInclude/bakedVertexAnimationDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/bayerDitherFunctions.js +9 -1
- package/Shaders/ShadersInclude/bayerDitherFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/bonesDeclaration.js +13 -6
- package/Shaders/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/bonesVertex.js +36 -18
- package/Shaders/ShadersInclude/bonesVertex.js.map +1 -1
- package/Shaders/ShadersInclude/boundingBoxRendererFragmentDeclaration.js +2 -1
- package/Shaders/ShadersInclude/boundingBoxRendererFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/boundingBoxRendererUboDeclaration.js +6 -3
- package/Shaders/ShadersInclude/boundingBoxRendererUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/boundingBoxRendererVertexDeclaration.js +4 -2
- package/Shaders/ShadersInclude/boundingBoxRendererVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/bumpFragment.js +40 -20
- package/Shaders/ShadersInclude/bumpFragment.js.map +1 -1
- package/Shaders/ShadersInclude/bumpFragmentFunctions.js +11 -1
- package/Shaders/ShadersInclude/bumpFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +57 -7
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js +2 -1
- package/Shaders/ShadersInclude/bumpVertex.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js +2 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/clipPlaneFragment.js +20 -7
- package/Shaders/ShadersInclude/clipPlaneFragment.js.map +1 -1
- package/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js +12 -6
- package/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.js +12 -6
- package/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.js.map +1 -1
- package/Shaders/ShadersInclude/clipPlaneVertex.js +12 -6
- package/Shaders/ShadersInclude/clipPlaneVertex.js.map +1 -1
- package/Shaders/ShadersInclude/clipPlaneVertexDeclaration.js +12 -6
- package/Shaders/ShadersInclude/clipPlaneVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/clipPlaneVertexDeclaration2.js +12 -6
- package/Shaders/ShadersInclude/clipPlaneVertexDeclaration2.js.map +1 -1
- package/Shaders/ShadersInclude/decalFragment.js +6 -3
- package/Shaders/ShadersInclude/decalFragment.js.map +1 -1
- package/Shaders/ShadersInclude/decalFragmentDeclaration.js +2 -1
- package/Shaders/ShadersInclude/decalFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/decalVertexDeclaration.js +2 -1
- package/Shaders/ShadersInclude/decalVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js +48 -24
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/defaultUboDeclaration.js +5 -2
- package/Shaders/ShadersInclude/defaultUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/defaultVertexDeclaration.js +22 -11
- package/Shaders/ShadersInclude/defaultVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/depthPrePass.js +2 -1
- package/Shaders/ShadersInclude/depthPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/diffusionProfile.js +1 -1
- package/Shaders/ShadersInclude/diffusionProfile.js.map +1 -1
- package/Shaders/ShadersInclude/fibonacci.js +4 -1
- package/Shaders/ShadersInclude/fibonacci.js.map +1 -1
- package/Shaders/ShadersInclude/fogFragment.js +6 -3
- package/Shaders/ShadersInclude/fogFragment.js.map +1 -1
- package/Shaders/ShadersInclude/fogFragmentDeclaration.js +9 -1
- package/Shaders/ShadersInclude/fogFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/fogVertex.js +2 -1
- package/Shaders/ShadersInclude/fogVertex.js.map +1 -1
- package/Shaders/ShadersInclude/fogVertexDeclaration.js +2 -1
- package/Shaders/ShadersInclude/fogVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/fresnelFunction.js +3 -1
- package/Shaders/ShadersInclude/fresnelFunction.js.map +1 -1
- package/Shaders/ShadersInclude/geometryVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/geometryVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/harmonicsFunctions.js +20 -2
- package/Shaders/ShadersInclude/harmonicsFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +48 -17
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +98 -28
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/imageProcessingCompatibility.js +2 -1
- package/Shaders/ShadersInclude/imageProcessingCompatibility.js.map +1 -1
- package/Shaders/ShadersInclude/imageProcessingDeclaration.js +18 -9
- package/Shaders/ShadersInclude/imageProcessingDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/imageProcessingFunctions.js +71 -28
- package/Shaders/ShadersInclude/imageProcessingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/importanceSampling.js +4 -1
- package/Shaders/ShadersInclude/importanceSampling.js.map +1 -1
- package/Shaders/ShadersInclude/instancesDeclaration.js +14 -7
- package/Shaders/ShadersInclude/instancesDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/instancesVertex.js +12 -6
- package/Shaders/ShadersInclude/instancesVertex.js.map +1 -1
- package/Shaders/ShadersInclude/kernelBlurFragment.js +9 -4
- package/Shaders/ShadersInclude/kernelBlurFragment.js.map +1 -1
- package/Shaders/ShadersInclude/kernelBlurFragment2.js +8 -4
- package/Shaders/ShadersInclude/kernelBlurFragment2.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +186 -93
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js +54 -22
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightUboDeclaration.js +51 -20
- package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js +18 -9
- package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js +15 -7
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +48 -20
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/logDepthDeclaration.js +2 -1
- package/Shaders/ShadersInclude/logDepthDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/logDepthFragment.js +2 -1
- package/Shaders/ShadersInclude/logDepthFragment.js.map +1 -1
- package/Shaders/ShadersInclude/logDepthVertex.js +2 -1
- package/Shaders/ShadersInclude/logDepthVertex.js.map +1 -1
- package/Shaders/ShadersInclude/mainUVVaryingDeclaration.js +2 -1
- package/Shaders/ShadersInclude/mainUVVaryingDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/meshFragmentDeclaration.js +2 -1
- package/Shaders/ShadersInclude/meshFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/meshUboDeclaration.js +5 -2
- package/Shaders/ShadersInclude/meshUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/meshVertexDeclaration.js +2 -1
- package/Shaders/ShadersInclude/meshVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertex.js +16 -8
- package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js +8 -4
- package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertexGlobal.js +2 -1
- package/Shaders/ShadersInclude/morphTargetsVertexGlobal.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.js +7 -2
- package/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/oitDeclaration.js +5 -2
- package/Shaders/ShadersInclude/oitDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/oitFragment.js +24 -12
- package/Shaders/ShadersInclude/oitFragment.js.map +1 -1
- package/Shaders/ShadersInclude/packingFunctions.js +4 -1
- package/Shaders/ShadersInclude/packingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js +118 -42
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +49 -20
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlphaFresnel.js +25 -8
- package/Shaders/ShadersInclude/pbrBlockAlphaFresnel.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAmbientOcclusion.js +26 -11
- package/Shaders/ShadersInclude/pbrBlockAmbientOcclusion.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAnisotropic.js +32 -12
- package/Shaders/ShadersInclude/pbrBlockAnisotropic.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js +194 -84
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockDirectLighting.js +12 -6
- package/Shaders/ShadersInclude/pbrBlockDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalColorComposition.js +30 -14
- package/Shaders/ShadersInclude/pbrBlockFinalColorComposition.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +56 -28
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js +18 -9
- package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockGeometryInfo.js +14 -7
- package/Shaders/ShadersInclude/pbrBlockGeometryInfo.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockImageProcessing.js +8 -4
- package/Shaders/ShadersInclude/pbrBlockImageProcessing.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockIridescence.js +36 -15
- package/Shaders/ShadersInclude/pbrBlockIridescence.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockLightmapInit.js +8 -4
- package/Shaders/ShadersInclude/pbrBlockLightmapInit.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js +8 -4
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockNormalGeometric.js +10 -5
- package/Shaders/ShadersInclude/pbrBlockNormalGeometric.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js +12 -6
- package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance0.js +8 -4
- package/Shaders/ShadersInclude/pbrBlockReflectance0.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +197 -77
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js +79 -36
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSheen.js +145 -60
- package/Shaders/ShadersInclude/pbrBlockSheen.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +226 -100
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js +146 -67
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.js +34 -8
- package/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +53 -22
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js +12 -5
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +88 -44
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.js +10 -5
- package/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +30 -15
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrHelperFunctions.js +27 -8
- package/Shaders/ShadersInclude/pbrHelperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrIBLFunctions.js +9 -4
- package/Shaders/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +4 -2
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +64 -32
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pointCloudVertex.js +2 -1
- package/Shaders/ShadersInclude/pointCloudVertex.js.map +1 -1
- package/Shaders/ShadersInclude/pointCloudVertexDeclaration.js +2 -1
- package/Shaders/ShadersInclude/pointCloudVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/prePassVertex.js +24 -12
- package/Shaders/ShadersInclude/prePassVertex.js.map +1 -1
- package/Shaders/ShadersInclude/prePassVertexDeclaration.js +4 -2
- package/Shaders/ShadersInclude/prePassVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/reflectionFunction.js +52 -17
- package/Shaders/ShadersInclude/reflectionFunction.js.map +1 -1
- package/Shaders/ShadersInclude/samplerFragmentAlternateDeclaration.js +2 -1
- package/Shaders/ShadersInclude/samplerFragmentAlternateDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/samplerFragmentDeclaration.js +4 -2
- package/Shaders/ShadersInclude/samplerFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/samplerVertexDeclaration.js +2 -1
- package/Shaders/ShadersInclude/samplerVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/samplerVertexImplementation.js +18 -6
- package/Shaders/ShadersInclude/samplerVertexImplementation.js.map +1 -1
- package/Shaders/ShadersInclude/sceneFragmentDeclaration.js +6 -3
- package/Shaders/ShadersInclude/sceneFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/sceneUboDeclaration.js +6 -3
- package/Shaders/ShadersInclude/sceneUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/sceneVertexDeclaration.js +6 -3
- package/Shaders/ShadersInclude/sceneVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/screenSpaceRayTrace.js +109 -24
- package/Shaders/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
- package/Shaders/ShadersInclude/shadowMapFragment.js +20 -10
- package/Shaders/ShadersInclude/shadowMapFragment.js.map +1 -1
- package/Shaders/ShadersInclude/shadowMapFragmentExtraDeclaration.js +10 -5
- package/Shaders/ShadersInclude/shadowMapFragmentExtraDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow.js +2 -1
- package/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow.js.map +1 -1
- package/Shaders/ShadersInclude/shadowMapUboDeclaration.js +2 -1
- package/Shaders/ShadersInclude/shadowMapUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/shadowMapVertexExtraDeclaration.js +8 -4
- package/Shaders/ShadersInclude/shadowMapVertexExtraDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/shadowMapVertexMetric.js +12 -6
- package/Shaders/ShadersInclude/shadowMapVertexMetric.js.map +1 -1
- package/Shaders/ShadersInclude/shadowMapVertexNormalBias.js +6 -3
- package/Shaders/ShadersInclude/shadowMapVertexNormalBias.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +311 -54
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsVertex.js +14 -7
- package/Shaders/ShadersInclude/shadowsVertex.js.map +1 -1
- package/Shaders/ShadersInclude/subSurfaceScatteringFunctions.js +2 -1
- package/Shaders/ShadersInclude/subSurfaceScatteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/uvAttributeDeclaration.js +2 -1
- package/Shaders/ShadersInclude/uvAttributeDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/uvVariableDeclaration.js +4 -2
- package/Shaders/ShadersInclude/uvVariableDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/vertexColorMixing.js +8 -4
- package/Shaders/ShadersInclude/vertexColorMixing.js.map +1 -1
- package/Shaders/anaglyph.fragment.js +4 -2
- package/Shaders/anaglyph.fragment.js.map +1 -1
- package/Shaders/background.fragment.js +133 -62
- package/Shaders/background.fragment.js.map +1 -1
- package/Shaders/background.vertex.js +63 -30
- package/Shaders/background.vertex.js.map +1 -1
- package/Shaders/blackAndWhite.fragment.js +5 -2
- package/Shaders/blackAndWhite.fragment.js.map +1 -1
- package/Shaders/bloomMerge.fragment.js +5 -2
- package/Shaders/bloomMerge.fragment.js.map +1 -1
- package/Shaders/blur.fragment.js +6 -2
- package/Shaders/blur.fragment.js.map +1 -1
- package/Shaders/boundingBoxRenderer.fragment.js +4 -2
- package/Shaders/boundingBoxRenderer.fragment.js.map +1 -1
- package/Shaders/boundingBoxRenderer.vertex.js +12 -6
- package/Shaders/boundingBoxRenderer.vertex.js.map +1 -1
- package/Shaders/chromaticAberration.fragment.js +8 -2
- package/Shaders/chromaticAberration.fragment.js.map +1 -1
- package/Shaders/circleOfConfusion.fragment.js +9 -4
- package/Shaders/circleOfConfusion.fragment.js.map +1 -1
- package/Shaders/clearQuad.fragment.js +2 -1
- package/Shaders/clearQuad.fragment.js.map +1 -1
- package/Shaders/clearQuad.vertex.js +11 -4
- package/Shaders/clearQuad.vertex.js.map +1 -1
- package/Shaders/color.fragment.js +10 -5
- package/Shaders/color.fragment.js.map +1 -1
- package/Shaders/color.vertex.js +18 -9
- package/Shaders/color.vertex.js.map +1 -1
- package/Shaders/colorCorrection.fragment.js +10 -2
- package/Shaders/colorCorrection.fragment.js.map +1 -1
- package/Shaders/convolution.fragment.js +23 -2
- package/Shaders/convolution.fragment.js.map +1 -1
- package/Shaders/copyTextureToTexture.fragment.js +12 -5
- package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
- package/Shaders/default.fragment.js +142 -71
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/default.vertex.js +58 -29
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/depth.fragment.js +24 -11
- package/Shaders/depth.fragment.js.map +1 -1
- package/Shaders/depth.vertex.js +35 -17
- package/Shaders/depth.vertex.js.map +1 -1
- package/Shaders/depthBoxBlur.fragment.js +6 -2
- package/Shaders/depthBoxBlur.fragment.js.map +1 -1
- package/Shaders/depthOfField.fragment.js +28 -3
- package/Shaders/depthOfField.fragment.js.map +1 -1
- package/Shaders/depthOfFieldMerge.fragment.js +17 -8
- package/Shaders/depthOfFieldMerge.fragment.js.map +1 -1
- package/Shaders/displayPass.fragment.js +4 -2
- package/Shaders/displayPass.fragment.js.map +1 -1
- package/Shaders/extractHighlights.fragment.js +4 -2
- package/Shaders/extractHighlights.fragment.js.map +1 -1
- package/Shaders/filter.fragment.js +4 -2
- package/Shaders/filter.fragment.js.map +1 -1
- package/Shaders/fluidRenderingBilateralBlur.fragment.js +4 -1
- package/Shaders/fluidRenderingBilateralBlur.fragment.js.map +1 -1
- package/Shaders/fluidRenderingParticleDepth.fragment.js +22 -11
- package/Shaders/fluidRenderingParticleDepth.fragment.js.map +1 -1
- package/Shaders/fluidRenderingParticleDepth.vertex.js +10 -5
- package/Shaders/fluidRenderingParticleDepth.vertex.js.map +1 -1
- package/Shaders/fluidRenderingParticleDiffuse.fragment.js +2 -1
- package/Shaders/fluidRenderingParticleDiffuse.fragment.js.map +1 -1
- package/Shaders/fluidRenderingParticleDiffuse.vertex.js +0 -1
- package/Shaders/fluidRenderingParticleDiffuse.vertex.js.map +1 -1
- package/Shaders/fluidRenderingParticleThickness.fragment.js +2 -1
- package/Shaders/fluidRenderingParticleThickness.fragment.js.map +1 -1
- package/Shaders/fluidRenderingParticleThickness.vertex.js +2 -1
- package/Shaders/fluidRenderingParticleThickness.vertex.js.map +1 -1
- package/Shaders/fluidRenderingRender.fragment.js +76 -35
- package/Shaders/fluidRenderingRender.fragment.js.map +1 -1
- package/Shaders/fluidRenderingStandardBlur.fragment.js +4 -1
- package/Shaders/fluidRenderingStandardBlur.fragment.js.map +1 -1
- package/Shaders/fxaa.fragment.js +47 -6
- package/Shaders/fxaa.fragment.js.map +1 -1
- package/Shaders/fxaa.vertex.js +6 -3
- package/Shaders/fxaa.vertex.js.map +1 -1
- package/Shaders/geometry.fragment.js +85 -42
- package/Shaders/geometry.fragment.js.map +1 -1
- package/Shaders/geometry.vertex.js +91 -45
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/glowBlurPostProcess.fragment.js +7 -2
- package/Shaders/glowBlurPostProcess.fragment.js.map +1 -1
- package/Shaders/glowMapGeneration.fragment.js +46 -22
- package/Shaders/glowMapGeneration.fragment.js.map +1 -1
- package/Shaders/glowMapGeneration.vertex.js +41 -20
- package/Shaders/glowMapGeneration.vertex.js.map +1 -1
- package/Shaders/glowMapMerge.fragment.js +20 -10
- package/Shaders/glowMapMerge.fragment.js.map +1 -1
- package/Shaders/glowMapMerge.vertex.js +6 -3
- package/Shaders/glowMapMerge.vertex.js.map +1 -1
- package/Shaders/gpuRenderParticles.fragment.js +16 -8
- package/Shaders/gpuRenderParticles.fragment.js.map +1 -1
- package/Shaders/gpuRenderParticles.vertex.js +77 -39
- package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
- package/Shaders/gpuUpdateParticles.fragment.js +2 -1
- package/Shaders/gpuUpdateParticles.fragment.js.map +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js +206 -100
- package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
- package/Shaders/grain.fragment.js +5 -2
- package/Shaders/grain.fragment.js.map +1 -1
- package/Shaders/hdrFiltering.fragment.js +1 -1
- package/Shaders/hdrFiltering.fragment.js.map +1 -1
- package/Shaders/hdrFiltering.vertex.js +6 -3
- package/Shaders/hdrFiltering.vertex.js.map +1 -1
- package/Shaders/highlights.fragment.js +4 -2
- package/Shaders/highlights.fragment.js.map +1 -1
- package/Shaders/imageProcessing.fragment.js +12 -6
- package/Shaders/imageProcessing.fragment.js.map +1 -1
- package/Shaders/kernelBlur.fragment.js +24 -11
- package/Shaders/kernelBlur.fragment.js.map +1 -1
- package/Shaders/kernelBlur.vertex.js +10 -5
- package/Shaders/kernelBlur.vertex.js.map +1 -1
- package/Shaders/layer.fragment.js +13 -6
- package/Shaders/layer.fragment.js.map +1 -1
- package/Shaders/layer.vertex.js +6 -3
- package/Shaders/layer.vertex.js.map +1 -1
- package/Shaders/lensFlare.fragment.js +6 -3
- package/Shaders/lensFlare.fragment.js.map +1 -1
- package/Shaders/lensFlare.vertex.js +6 -3
- package/Shaders/lensFlare.vertex.js.map +1 -1
- package/Shaders/lensHighlights.fragment.js +14 -5
- package/Shaders/lensHighlights.fragment.js.map +1 -1
- package/Shaders/line.fragment.js +6 -3
- package/Shaders/line.fragment.js.map +1 -1
- package/Shaders/line.vertex.js +8 -4
- package/Shaders/line.vertex.js.map +1 -1
- package/Shaders/meshUVSpaceRenderer.fragment.js +3 -1
- package/Shaders/meshUVSpaceRenderer.fragment.js.map +1 -1
- package/Shaders/meshUVSpaceRenderer.vertex.js +14 -7
- package/Shaders/meshUVSpaceRenderer.vertex.js.map +1 -1
- package/Shaders/minmaxRedux.fragment.js +21 -8
- package/Shaders/minmaxRedux.fragment.js.map +1 -1
- package/Shaders/motionBlur.fragment.js +35 -14
- package/Shaders/motionBlur.fragment.js.map +1 -1
- package/Shaders/noise.fragment.js +13 -2
- package/Shaders/noise.fragment.js.map +1 -1
- package/Shaders/oitBackBlend.fragment.js +2 -1
- package/Shaders/oitBackBlend.fragment.js.map +1 -1
- package/Shaders/oitFinal.fragment.js +4 -1
- package/Shaders/oitFinal.fragment.js.map +1 -1
- package/Shaders/outline.fragment.js +11 -5
- package/Shaders/outline.fragment.js.map +1 -1
- package/Shaders/outline.vertex.js +27 -13
- package/Shaders/outline.vertex.js.map +1 -1
- package/Shaders/particles.fragment.js +18 -9
- package/Shaders/particles.fragment.js.map +1 -1
- package/Shaders/particles.vertex.js +58 -29
- package/Shaders/particles.vertex.js.map +1 -1
- package/Shaders/pass.fragment.js +4 -2
- package/Shaders/pass.fragment.js.map +1 -1
- package/Shaders/passCube.fragment.js +17 -8
- package/Shaders/passCube.fragment.js.map +1 -1
- package/Shaders/pbr.fragment.js +389 -154
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +70 -35
- package/Shaders/pbr.vertex.js.map +1 -1
- package/Shaders/postprocess.vertex.js +6 -3
- package/Shaders/postprocess.vertex.js.map +1 -1
- package/Shaders/procedural.vertex.js +6 -3
- package/Shaders/procedural.vertex.js.map +1 -1
- package/Shaders/refraction.fragment.js +1 -1
- package/Shaders/refraction.fragment.js.map +1 -1
- package/Shaders/rgbdDecode.fragment.js +4 -2
- package/Shaders/rgbdDecode.fragment.js.map +1 -1
- package/Shaders/rgbdEncode.fragment.js +4 -2
- package/Shaders/rgbdEncode.fragment.js.map +1 -1
- package/Shaders/screenSpaceCurvature.fragment.js +11 -3
- package/Shaders/screenSpaceCurvature.fragment.js.map +1 -1
- package/Shaders/screenSpaceReflection.fragment.js +57 -15
- package/Shaders/screenSpaceReflection.fragment.js.map +1 -1
- package/Shaders/screenSpaceReflection2.fragment.js +125 -51
- package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
- package/Shaders/screenSpaceReflection2Blur.fragment.js +7 -1
- package/Shaders/screenSpaceReflection2Blur.fragment.js.map +1 -1
- package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js +28 -13
- package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
- package/Shaders/shadowMap.fragment.js +14 -6
- package/Shaders/shadowMap.fragment.js.map +1 -1
- package/Shaders/shadowMap.vertex.js +35 -17
- package/Shaders/shadowMap.vertex.js.map +1 -1
- package/Shaders/sharpen.fragment.js +8 -2
- package/Shaders/sharpen.fragment.js.map +1 -1
- package/Shaders/spriteMap.fragment.js +17 -4
- package/Shaders/spriteMap.fragment.js.map +1 -1
- package/Shaders/spriteMap.vertex.js +2 -1
- package/Shaders/spriteMap.vertex.js.map +1 -1
- package/Shaders/sprites.fragment.js +17 -7
- package/Shaders/sprites.fragment.js.map +1 -1
- package/Shaders/sprites.vertex.js +10 -4
- package/Shaders/sprites.vertex.js.map +1 -1
- package/Shaders/ssao.fragment.js +0 -2
- package/Shaders/ssao.fragment.js.map +1 -1
- package/Shaders/ssao2.fragment.js +0 -2
- package/Shaders/ssao2.fragment.js.map +1 -1
- package/Shaders/ssaoCombine.fragment.js +8 -4
- package/Shaders/ssaoCombine.fragment.js.map +1 -1
- package/Shaders/standard.fragment.js +101 -25
- package/Shaders/standard.fragment.js.map +1 -1
- package/Shaders/stereoscopicInterlace.fragment.js +14 -6
- package/Shaders/stereoscopicInterlace.fragment.js.map +1 -1
- package/Shaders/subSurfaceScattering.fragment.js +58 -12
- package/Shaders/subSurfaceScattering.fragment.js.map +1 -1
- package/Shaders/tonemap.fragment.js +21 -9
- package/Shaders/tonemap.fragment.js.map +1 -1
- package/Shaders/velocity.fragment.js +8 -4
- package/Shaders/velocity.fragment.js.map +1 -1
- package/Shaders/velocity.vertex.js +18 -9
- package/Shaders/velocity.vertex.js.map +1 -1
- package/Shaders/volumetricLightScattering.fragment.js +9 -4
- package/Shaders/volumetricLightScattering.fragment.js.map +1 -1
- package/Shaders/volumetricLightScatteringPass.fragment.js +12 -5
- package/Shaders/volumetricLightScatteringPass.fragment.js.map +1 -1
- package/Shaders/volumetricLightScatteringPass.vertex.js +23 -11
- package/Shaders/volumetricLightScatteringPass.vertex.js.map +1 -1
- package/Shaders/vrDistortionCorrection.fragment.js +6 -2
- package/Shaders/vrDistortionCorrection.fragment.js.map +1 -1
- package/Shaders/vrMultiviewToSingleview.fragment.js +4 -2
- package/Shaders/vrMultiviewToSingleview.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bakedVertexAnimation.js +24 -12
- package/ShadersWGSL/ShadersInclude/bakedVertexAnimation.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bakedVertexAnimationDeclaration.js +7 -3
- package/ShadersWGSL/ShadersInclude/bakedVertexAnimationDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +14 -6
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesVertex.js +36 -18
- package/ShadersWGSL/ShadersInclude/bonesVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clipPlaneFragment.js +20 -7
- package/ShadersWGSL/ShadersInclude/clipPlaneFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clipPlaneFragmentDeclaration.js +12 -6
- package/ShadersWGSL/ShadersInclude/clipPlaneFragmentDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clipPlaneVertex.js +12 -6
- package/ShadersWGSL/ShadersInclude/clipPlaneVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clipPlaneVertexDeclaration.js +12 -6
- package/ShadersWGSL/ShadersInclude/clipPlaneVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/instancesDeclaration.js +14 -7
- package/ShadersWGSL/ShadersInclude/instancesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/instancesVertex.js +16 -8
- package/ShadersWGSL/ShadersInclude/instancesVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/meshUboDeclaration.js +3 -1
- package/ShadersWGSL/ShadersInclude/meshUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +16 -8
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js +8 -4
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexGlobal.js +2 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexGlobal.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexGlobalDeclaration.js +6 -2
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexGlobalDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js +8 -3
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +229 -90
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/ShadersWGSL/postprocess.vertex.js +9 -4
- package/ShadersWGSL/postprocess.vertex.js.map +1 -1
- package/assetContainer.d.ts +7 -0
- package/assetContainer.js +46 -0
- package/assetContainer.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +5 -0
- package/scene.js.map +1 -1
- package/Materials/Node/nodeMaterialDecorator.js.map +0 -1
|
@@ -54,6 +54,10 @@ export interface PhysicsAggregateParameters {
|
|
|
54
54
|
* Physics engine will try to make this body sleeping and not active
|
|
55
55
|
*/
|
|
56
56
|
startAsleep?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* If true, mark the created shape as a trigger shape
|
|
59
|
+
*/
|
|
60
|
+
isTriggerShape?: boolean;
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
63
|
* Helper class to create and interact with a PhysicsAggregate.
|
|
@@ -59,6 +59,9 @@ export class PhysicsAggregate {
|
|
|
59
59
|
else {
|
|
60
60
|
this.shape = new PhysicsShape({ type: type, parameters: this._options }, this._scene);
|
|
61
61
|
}
|
|
62
|
+
if (this._options.isTriggerShape) {
|
|
63
|
+
this.shape.isTrigger = true;
|
|
64
|
+
}
|
|
62
65
|
this.material = { friction: this._options.friction, restitution: this._options.restitution };
|
|
63
66
|
this.body.shape = this.shape;
|
|
64
67
|
this.shape.material = this.material;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsAggregate.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsAggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM7E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AA6DxD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAoBzB;IACI;;OAEG;IACI,aAA4B;IACnC;;OAEG;IACI,IAAqC,EACpC,WAAuC,EAAE,IAAI,EAAE,CAAC,EAAE,EAClD,MAAc;;QANf,kBAAa,GAAb,aAAa,CAAe;QAI5B,SAAI,GAAJ,IAAI,CAAiC;QACpC,aAAQ,GAAR,QAAQ,CAA0C;QAClD,WAAM,GAAN,MAAM,CAAQ;QAdlB,8BAAyB,GAAG,IAAI,CAAC;QAgBrC,eAAe;QACf,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACrB,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;YACvE,OAAO;SACV;QACD,MAAM,CAAC,GAAG,aAAqB,CAAC;QAChC,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE;YAC7E,MAAM,CAAC,IAAI,CACP,qKAAqK,CACxK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,oBAAoB,GAAG,IAAI,CAAC;SACpC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,yBAAyB,EAAE;YAChC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;SACxB;IACL,CAAC;CACJ","sourcesContent":["import { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { PhysicsShape } from \"./physicsShape\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { PhysicsMotionType, PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Node } from \"../../node\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { BoundingBox } from \"../../Culling/boundingBox\";\r\n\r\n/**\r\n * The interface for the physics aggregate parameters\r\n */\r\nexport interface PhysicsAggregateParameters {\r\n /**\r\n * The mass of the physics aggregate\r\n */\r\n mass: number;\r\n\r\n /**\r\n * The friction of the physics aggregate\r\n */\r\n friction?: number;\r\n\r\n /**\r\n * The coefficient of restitution of the physics aggregate\r\n */\r\n restitution?: number;\r\n\r\n /**\r\n * Radius for sphere, cylinder and capsule\r\n */\r\n radius?: number;\r\n\r\n /**\r\n * Starting point for cylinder/capsule\r\n */\r\n pointA?: Vector3;\r\n\r\n /**\r\n * Ending point for cylinder/capsule\r\n */\r\n pointB?: Vector3;\r\n\r\n /**\r\n * Extents for box\r\n */\r\n extents?: Vector3;\r\n\r\n /**\r\n * Orientation for box\r\n */\r\n rotation?: Quaternion;\r\n\r\n /**\r\n * mesh local center\r\n */\r\n center?: Vector3;\r\n\r\n /**\r\n * mesh object. Used for mesh and convex hull aggregates.\r\n */\r\n mesh?: Mesh;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n startAsleep?: boolean;\r\n}\r\n/**\r\n * Helper class to create and interact with a PhysicsAggregate.\r\n * This is a transition object that works like Physics Plugin V1 Impostors.\r\n * This helper instanciate all mandatory physics objects to get a body/shape and material.\r\n * It's less efficient that handling body and shapes independently but for prototyping or\r\n * a small numbers of physics objects, it's good enough.\r\n */\r\nexport class PhysicsAggregate {\r\n /**\r\n * The body that is associated with this aggregate\r\n */\r\n public body: PhysicsBody;\r\n\r\n /**\r\n * The shape that is associated with this aggregate\r\n */\r\n public shape: PhysicsShape;\r\n\r\n /**\r\n * The material that is associated with this aggregate\r\n */\r\n public material: PhysicsMaterial;\r\n\r\n private _disposeShapeWhenDisposed = true;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n constructor(\r\n /**\r\n * The physics-enabled object used as the physics aggregate\r\n */\r\n public transformNode: TransformNode,\r\n /**\r\n * The type of the physics aggregate\r\n */\r\n public type: PhysicsShapeType | PhysicsShape,\r\n private _options: PhysicsAggregateParameters = { mass: 0 },\r\n private _scene?: Scene\r\n ) {\r\n //sanity check!\r\n if (!this.transformNode) {\r\n Logger.Error(\"No object was provided. A physics object is obligatory\");\r\n return;\r\n }\r\n const m = transformNode as Mesh;\r\n if (this.transformNode.parent && this._options.mass !== 0 && m.hasThinInstances) {\r\n Logger.Warn(\r\n \"A physics body has been created for an object which has a parent and thin instances. Babylon physics currently works in local space so unexpected issues may occur.\"\r\n );\r\n }\r\n\r\n // Legacy support for old syntax.\r\n if (!this._scene && transformNode.getScene) {\r\n this._scene = transformNode.getScene();\r\n }\r\n\r\n if (!this._scene) {\r\n return;\r\n }\r\n\r\n //default options params\r\n this._options.mass = _options.mass === void 0 ? 0 : _options.mass;\r\n this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;\r\n this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;\r\n\r\n const motionType = this._options.mass === 0 ? PhysicsMotionType.STATIC : PhysicsMotionType.DYNAMIC;\r\n const startAsleep = this._options.startAsleep ?? false;\r\n this.body = new PhysicsBody(transformNode, motionType, startAsleep, this._scene);\r\n this._addSizeOptions();\r\n if ((type as any).getClassName && (type as any).getClassName() === \"PhysicsShape\") {\r\n this.shape = type as PhysicsShape;\r\n this._disposeShapeWhenDisposed = false;\r\n } else {\r\n this.shape = new PhysicsShape({ type: type as PhysicsShapeType, parameters: this._options as any }, this._scene);\r\n }\r\n\r\n this.material = { friction: this._options.friction, restitution: this._options.restitution };\r\n this.body.shape = this.shape;\r\n this.shape.material = this.material;\r\n\r\n this.body.setMassProperties({ mass: this._options.mass });\r\n\r\n this._nodeDisposeObserver = this.transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n private _getObjectBoundingBox() {\r\n if ((this.transformNode as AbstractMesh).getRawBoundingInfo) {\r\n return (this.transformNode as AbstractMesh).getRawBoundingInfo().boundingBox;\r\n } else {\r\n return new BoundingBox(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5));\r\n }\r\n }\r\n\r\n private _hasVertices(node: TransformNode): boolean {\r\n return (node as any)?.getTotalVertices() > 0;\r\n }\r\n\r\n private _addSizeOptions(): void {\r\n this.transformNode.computeWorldMatrix(true);\r\n const bb = this._getObjectBoundingBox();\r\n const extents = TmpVectors.Vector3[0];\r\n extents.copyFrom(bb.extendSize);\r\n extents.scaleInPlace(2);\r\n extents.multiplyInPlace(this.transformNode.scaling);\r\n\r\n const min = TmpVectors.Vector3[1];\r\n min.copyFrom(bb.minimum);\r\n min.multiplyInPlace(this.transformNode.scaling);\r\n\r\n if (!this._options.center) {\r\n const center = new Vector3();\r\n center.copyFrom(bb.center);\r\n center.multiplyInPlace(this.transformNode.scaling);\r\n this._options.center = center;\r\n }\r\n\r\n switch (this.type) {\r\n case PhysicsShapeType.SPHERE:\r\n if (!this._options.radius && Scalar.WithinEpsilon(extents.x, extents.y, 0.0001) && Scalar.WithinEpsilon(extents.x, extents.z, 0.0001)) {\r\n this._options.radius = extents.x / 2;\r\n } else if (!this._options.radius) {\r\n Logger.Warn(\"Non uniform scaling is unsupported for sphere shapes. Setting the radius to the biggest bounding box extent.\");\r\n this._options.radius = Math.max(extents.x, extents.y, extents.z) / 2;\r\n }\r\n break;\r\n case PhysicsShapeType.CAPSULE:\r\n {\r\n const capRadius = extents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, min.y + capRadius, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y - capRadius, 0);\r\n }\r\n break;\r\n case PhysicsShapeType.CYLINDER:\r\n {\r\n const capRadius = extents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, min.y, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y, 0);\r\n }\r\n break;\r\n case PhysicsShapeType.MESH:\r\n case PhysicsShapeType.CONVEX_HULL:\r\n if (!this._options.mesh && this._hasVertices(this.transformNode)) {\r\n this._options.mesh = this.transformNode as Mesh;\r\n } else if (!this._options.mesh || !this._hasVertices(this._options.mesh)) {\r\n throw new Error(\r\n \"No valid mesh was provided for mesh or convex hull shape parameter. Please provide a mesh with valid geometry (number of vertices greater than 0).\"\r\n );\r\n }\r\n break;\r\n case PhysicsShapeType.BOX:\r\n this._options.extents = this._options.extents ?? new Vector3(extents.x, extents.y, extents.z);\r\n this._options.rotation = this._options.rotation ?? Quaternion.Identity();\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Releases the body, shape and material\r\n */\r\n public dispose(): void {\r\n if (this._nodeDisposeObserver) {\r\n this.body.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this.body.dispose();\r\n if (this._disposeShapeWhenDisposed) {\r\n this.shape.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsAggregate.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsAggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM7E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAkExD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAoBzB;IACI;;OAEG;IACI,aAA4B;IACnC;;OAEG;IACI,IAAqC,EACpC,WAAuC,EAAE,IAAI,EAAE,CAAC,EAAE,EAClD,MAAc;;QANf,kBAAa,GAAb,aAAa,CAAe;QAI5B,SAAI,GAAJ,IAAI,CAAiC;QACpC,aAAQ,GAAR,QAAQ,CAA0C;QAClD,WAAM,GAAN,MAAM,CAAQ;QAdlB,8BAAyB,GAAG,IAAI,CAAC;QAgBrC,eAAe;QACf,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACrB,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;YACvE,OAAO;SACV;QACD,MAAM,CAAC,GAAG,aAAqB,CAAC;QAChC,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE;YAC7E,MAAM,CAAC,IAAI,CACP,qKAAqK,CACxK,CAAC;SACL;QAED,iCAAiC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Aa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAC9E,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;SACpC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,yBAAyB,EAAE;YAChC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;SACxB;IACL,CAAC;CACJ","sourcesContent":["import { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { PhysicsShape } from \"./physicsShape\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { PhysicsMotionType, PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Node } from \"../../node\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { BoundingBox } from \"../../Culling/boundingBox\";\r\n\r\n/**\r\n * The interface for the physics aggregate parameters\r\n */\r\nexport interface PhysicsAggregateParameters {\r\n /**\r\n * The mass of the physics aggregate\r\n */\r\n mass: number;\r\n\r\n /**\r\n * The friction of the physics aggregate\r\n */\r\n friction?: number;\r\n\r\n /**\r\n * The coefficient of restitution of the physics aggregate\r\n */\r\n restitution?: number;\r\n\r\n /**\r\n * Radius for sphere, cylinder and capsule\r\n */\r\n radius?: number;\r\n\r\n /**\r\n * Starting point for cylinder/capsule\r\n */\r\n pointA?: Vector3;\r\n\r\n /**\r\n * Ending point for cylinder/capsule\r\n */\r\n pointB?: Vector3;\r\n\r\n /**\r\n * Extents for box\r\n */\r\n extents?: Vector3;\r\n\r\n /**\r\n * Orientation for box\r\n */\r\n rotation?: Quaternion;\r\n\r\n /**\r\n * mesh local center\r\n */\r\n center?: Vector3;\r\n\r\n /**\r\n * mesh object. Used for mesh and convex hull aggregates.\r\n */\r\n mesh?: Mesh;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n startAsleep?: boolean;\r\n\r\n /**\r\n * If true, mark the created shape as a trigger shape\r\n */\r\n isTriggerShape?: boolean;\r\n}\r\n/**\r\n * Helper class to create and interact with a PhysicsAggregate.\r\n * This is a transition object that works like Physics Plugin V1 Impostors.\r\n * This helper instanciate all mandatory physics objects to get a body/shape and material.\r\n * It's less efficient that handling body and shapes independently but for prototyping or\r\n * a small numbers of physics objects, it's good enough.\r\n */\r\nexport class PhysicsAggregate {\r\n /**\r\n * The body that is associated with this aggregate\r\n */\r\n public body: PhysicsBody;\r\n\r\n /**\r\n * The shape that is associated with this aggregate\r\n */\r\n public shape: PhysicsShape;\r\n\r\n /**\r\n * The material that is associated with this aggregate\r\n */\r\n public material: PhysicsMaterial;\r\n\r\n private _disposeShapeWhenDisposed = true;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n constructor(\r\n /**\r\n * The physics-enabled object used as the physics aggregate\r\n */\r\n public transformNode: TransformNode,\r\n /**\r\n * The type of the physics aggregate\r\n */\r\n public type: PhysicsShapeType | PhysicsShape,\r\n private _options: PhysicsAggregateParameters = { mass: 0 },\r\n private _scene?: Scene\r\n ) {\r\n //sanity check!\r\n if (!this.transformNode) {\r\n Logger.Error(\"No object was provided. A physics object is obligatory\");\r\n return;\r\n }\r\n const m = transformNode as Mesh;\r\n if (this.transformNode.parent && this._options.mass !== 0 && m.hasThinInstances) {\r\n Logger.Warn(\r\n \"A physics body has been created for an object which has a parent and thin instances. Babylon physics currently works in local space so unexpected issues may occur.\"\r\n );\r\n }\r\n\r\n // Legacy support for old syntax.\r\n if (!this._scene && transformNode.getScene) {\r\n this._scene = transformNode.getScene();\r\n }\r\n\r\n if (!this._scene) {\r\n return;\r\n }\r\n\r\n //default options params\r\n this._options.mass = _options.mass === void 0 ? 0 : _options.mass;\r\n this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;\r\n this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;\r\n\r\n const motionType = this._options.mass === 0 ? PhysicsMotionType.STATIC : PhysicsMotionType.DYNAMIC;\r\n const startAsleep = this._options.startAsleep ?? false;\r\n this.body = new PhysicsBody(transformNode, motionType, startAsleep, this._scene);\r\n this._addSizeOptions();\r\n if ((type as any).getClassName && (type as any).getClassName() === \"PhysicsShape\") {\r\n this.shape = type as PhysicsShape;\r\n this._disposeShapeWhenDisposed = false;\r\n } else {\r\n this.shape = new PhysicsShape({ type: type as PhysicsShapeType, parameters: this._options as any }, this._scene);\r\n }\r\n\r\n if (this._options.isTriggerShape) {\r\n this.shape.isTrigger = true;\r\n }\r\n\r\n this.material = { friction: this._options.friction, restitution: this._options.restitution };\r\n this.body.shape = this.shape;\r\n this.shape.material = this.material;\r\n\r\n this.body.setMassProperties({ mass: this._options.mass });\r\n\r\n this._nodeDisposeObserver = this.transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n private _getObjectBoundingBox() {\r\n if ((this.transformNode as AbstractMesh).getRawBoundingInfo) {\r\n return (this.transformNode as AbstractMesh).getRawBoundingInfo().boundingBox;\r\n } else {\r\n return new BoundingBox(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5));\r\n }\r\n }\r\n\r\n private _hasVertices(node: TransformNode): boolean {\r\n return (node as any)?.getTotalVertices() > 0;\r\n }\r\n\r\n private _addSizeOptions(): void {\r\n this.transformNode.computeWorldMatrix(true);\r\n const bb = this._getObjectBoundingBox();\r\n const extents = TmpVectors.Vector3[0];\r\n extents.copyFrom(bb.extendSize);\r\n extents.scaleInPlace(2);\r\n extents.multiplyInPlace(this.transformNode.scaling);\r\n\r\n const min = TmpVectors.Vector3[1];\r\n min.copyFrom(bb.minimum);\r\n min.multiplyInPlace(this.transformNode.scaling);\r\n\r\n if (!this._options.center) {\r\n const center = new Vector3();\r\n center.copyFrom(bb.center);\r\n center.multiplyInPlace(this.transformNode.scaling);\r\n this._options.center = center;\r\n }\r\n\r\n switch (this.type) {\r\n case PhysicsShapeType.SPHERE:\r\n if (!this._options.radius && Scalar.WithinEpsilon(extents.x, extents.y, 0.0001) && Scalar.WithinEpsilon(extents.x, extents.z, 0.0001)) {\r\n this._options.radius = extents.x / 2;\r\n } else if (!this._options.radius) {\r\n Logger.Warn(\"Non uniform scaling is unsupported for sphere shapes. Setting the radius to the biggest bounding box extent.\");\r\n this._options.radius = Math.max(extents.x, extents.y, extents.z) / 2;\r\n }\r\n break;\r\n case PhysicsShapeType.CAPSULE:\r\n {\r\n const capRadius = extents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, min.y + capRadius, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y - capRadius, 0);\r\n }\r\n break;\r\n case PhysicsShapeType.CYLINDER:\r\n {\r\n const capRadius = extents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, min.y, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y, 0);\r\n }\r\n break;\r\n case PhysicsShapeType.MESH:\r\n case PhysicsShapeType.CONVEX_HULL:\r\n if (!this._options.mesh && this._hasVertices(this.transformNode)) {\r\n this._options.mesh = this.transformNode as Mesh;\r\n } else if (!this._options.mesh || !this._hasVertices(this._options.mesh)) {\r\n throw new Error(\r\n \"No valid mesh was provided for mesh or convex hull shape parameter. Please provide a mesh with valid geometry (number of vertices greater than 0).\"\r\n );\r\n }\r\n break;\r\n case PhysicsShapeType.BOX:\r\n this._options.extents = this._options.extents ?? new Vector3(extents.x, extents.y, extents.z);\r\n this._options.rotation = this._options.rotation ?? Quaternion.Identity();\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Releases the body, shape and material\r\n */\r\n public dispose(): void {\r\n if (this._nodeDisposeObserver) {\r\n this.body.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this.body.dispose();\r\n if (this._disposeShapeWhenDisposed) {\r\n this.shape.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -308,6 +308,13 @@ export declare class PhysicsBody {
|
|
|
308
308
|
* @returns the gravity factor
|
|
309
309
|
*/
|
|
310
310
|
getGravityFactor(instanceIndex?: number): number;
|
|
311
|
+
/**
|
|
312
|
+
* Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target
|
|
313
|
+
* @param position The target position
|
|
314
|
+
* @param rotation The target rotation
|
|
315
|
+
* @param instanceIndex The index of the instance in an instanced body
|
|
316
|
+
*/
|
|
317
|
+
setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number): void;
|
|
311
318
|
/**
|
|
312
319
|
* Disposes the body from the physics engine.
|
|
313
320
|
*
|
|
@@ -458,6 +458,15 @@ export class PhysicsBody {
|
|
|
458
458
|
getGravityFactor(instanceIndex) {
|
|
459
459
|
return this._physicsPlugin.getGravityFactor(this, instanceIndex);
|
|
460
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target
|
|
463
|
+
* @param position The target position
|
|
464
|
+
* @param rotation The target rotation
|
|
465
|
+
* @param instanceIndex The index of the instance in an instanced body
|
|
466
|
+
*/
|
|
467
|
+
setTargetTransform(position, rotation, instanceIndex) {
|
|
468
|
+
this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);
|
|
469
|
+
}
|
|
461
470
|
/**
|
|
462
471
|
* Disposes the body from the physics engine.
|
|
463
472
|
*
|
|
@@ -475,6 +484,7 @@ export class PhysicsBody {
|
|
|
475
484
|
this._physicsEngine.removeBody(this);
|
|
476
485
|
this._physicsPlugin.removeBody(this);
|
|
477
486
|
this._physicsPlugin.disposeBody(this);
|
|
487
|
+
this.transformNode.physicsBody = null;
|
|
478
488
|
this._pluginData = null;
|
|
479
489
|
this._pluginDataInstances.length = 0;
|
|
480
490
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1E,OAAO,EAAE,KAAK,EAAE,iCAA6B;AAO7C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAsCpB;;;;;;;;;;;;;OAaG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,YAAqB,EAAE,KAAY;QAnD5G;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAS7C;;WAEG;QACK,wBAAmB,GAAY,KAAK,CAAC;QAK7C;;;WAGG;QACH,mBAAc,GAAY,IAAI,CAAC;QAwB3B,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAmB,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QA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CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * intial values, which you can then customize.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for all collisions happening for event-enabled bodies\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /*\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /*\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":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,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * intial values, which you can then customize.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for all collisions happening for event-enabled bodies\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /*\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /*\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
|
|
@@ -40,6 +40,7 @@ export declare class PhysicsShape {
|
|
|
40
40
|
private _physicsPlugin;
|
|
41
41
|
private _type;
|
|
42
42
|
private _material;
|
|
43
|
+
private _isTrigger;
|
|
43
44
|
/**
|
|
44
45
|
* Constructs a new physics shape.
|
|
45
46
|
* @param options The options for the physics shape. These are:
|
|
@@ -152,6 +153,8 @@ export declare class PhysicsShape {
|
|
|
152
153
|
* @returns The bounding box of the physics shape.
|
|
153
154
|
*/
|
|
154
155
|
getBoundingBox(): BoundingBox;
|
|
156
|
+
set isTrigger(isTrigger: boolean);
|
|
157
|
+
get isTrigger(): boolean;
|
|
155
158
|
/**
|
|
156
159
|
* Dispose the shape and release its associated resources.
|
|
157
160
|
*/
|
|
@@ -25,6 +25,7 @@ export class PhysicsShape {
|
|
|
25
25
|
* V2 Physics plugin private data for single shape
|
|
26
26
|
*/
|
|
27
27
|
this._pluginData = undefined;
|
|
28
|
+
this._isTrigger = false;
|
|
28
29
|
if (!scene) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
@@ -187,6 +188,16 @@ export class PhysicsShape {
|
|
|
187
188
|
getBoundingBox() {
|
|
188
189
|
return this._physicsPlugin.getBoundingBox(this);
|
|
189
190
|
}
|
|
191
|
+
set isTrigger(isTrigger) {
|
|
192
|
+
if (this._isTrigger === isTrigger) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
this._isTrigger = isTrigger;
|
|
196
|
+
this._physicsPlugin.setTrigger(this, isTrigger);
|
|
197
|
+
}
|
|
198
|
+
get isTrigger() {
|
|
199
|
+
return this._isTrigger;
|
|
200
|
+
}
|
|
190
201
|
/**
|
|
191
202
|
* Dispose the shape and release its associated resources.
|
|
192
203
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsShape.js","sour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E,IAAI,EAAE,gBAAgB,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACrF,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9C;;;;OAIG;IACH,YAAY,IAAU,EAAE,KAAY;QAChC,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD;;;OAGG;IACH,YAAY,KAAY;QACpB,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { Matrix, Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\n\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Options for creating a physics shape\r\n */\r\nexport interface PhysicShapeOptions {\r\n /**\r\n * The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n */\r\n type?: PhysicsShapeType;\r\n /**\r\n * The parameters of the shape. Varies depending of the shape type.\r\n */\r\n parameters?: PhysicsShapeParameters;\r\n /**\r\n * Reference to an already existing physics shape in the plugin.\r\n */\r\n pluginData?: any;\r\n}\r\n\r\n/**\r\n * PhysicsShape class.\r\n * This class is useful for creating a physics shape that can be used in a physics engine.\r\n * A Physic Shape determine how collision are computed. It must be attached to a body.\r\n */\r\nexport class PhysicsShape {\r\n /**\r\n * V2 Physics plugin private data for single shape\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n private _type: PhysicsShapeType;\r\n\r\n private _material: PhysicsMaterial;\r\n\r\n /**\r\n * Constructs a new physics shape.\r\n * @param options The options for the physics shape. These are:\r\n * * type: The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n * * parameters: The parameters of the shape.\r\n * * pluginData: The plugin data of the shape. This is used if you already have a reference to the object on the plugin side.\r\n * You need to specify either type or pluginData.\r\n * @param scene The scene the shape belongs to.\r\n *\r\n * This code is useful for creating a new physics shape with the given type, options, and scene.\r\n * It also checks that the physics engine and plugin version are correct.\r\n * If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.\r\n */\r\n constructor(options: PhysicShapeOptions, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n\r\n if (options.pluginData !== undefined && options.pluginData !== null) {\r\n this._pluginData = options.pluginData;\r\n this._type = this._physicsPlugin.getShapeType(this);\r\n } else if (options.type !== undefined && options.type !== null) {\r\n this._type = options.type;\r\n const parameters = options.parameters ?? {};\r\n this._physicsPlugin.initShape(this, options.type, parameters);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsShape\".\r\n * @returns \"PhysicsShape\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsShape\";\r\n }\r\n\r\n /**\r\n * Returns the type of the physics shape.\r\n * @returns The type of the physics shape.\r\n */\r\n public get type(): PhysicsShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Set the membership mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which the shape is a member. This is used in combination\r\n * with the collide mask to determine if this shape should collide with\r\n * another.\r\n *\r\n * @param membershipMask Bitfield of categories of this shape.\r\n */\r\n public set filterMembershipMask(membershipMask: number) {\r\n this._physicsPlugin.setShapeFilterMembershipMask(this, membershipMask);\r\n }\r\n\r\n /**\r\n * Get the membership mask of a shape.\r\n * @returns Bitmask of categories which this shape is a member of.\r\n */\r\n public get filterMembershipMask(): number {\r\n return this._physicsPlugin.getShapeFilterMembershipMask(this);\r\n }\r\n\r\n /**\r\n * Sets the collide mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which this shape collides with. Given two shapes,\r\n * the engine will check if the collide mask and membership overlap:\r\n * shapeA.filterMembershipMask & shapeB.filterCollideMask\r\n *\r\n * If this value is zero (i.e. shapeB only collides with categories\r\n * which shapeA is _not_ a member of) then the shapes will not collide.\r\n *\r\n * Note, the engine will also perform the same test with shapeA and\r\n * shapeB swapped; the shapes will not collide if either shape has\r\n * a collideMask which prevents collision with the other shape.\r\n *\r\n * @param collideMask Bitmask of categories this shape should collide with\r\n */\r\n public set filterCollideMask(collideMask: number) {\r\n this._physicsPlugin.setShapeFilterCollideMask(this, collideMask);\r\n }\r\n\r\n /**\r\n *\r\n * @returns Bitmask of categories that this shape should collide with\r\n */\r\n public get filterCollideMask(): number {\r\n return this._physicsPlugin.getShapeFilterCollideMask(this);\r\n }\r\n /**\r\n *\r\n * @param material\r\n */\r\n public set material(material: PhysicsMaterial) {\r\n this._physicsPlugin.setMaterial(this, material);\r\n this._material = material;\r\n }\r\n\r\n /**\r\n * Returns the material of the physics shape.\r\n * @returns The material of the physics shape.\r\n */\r\n public get material(): PhysicsMaterial {\r\n return this._material;\r\n }\r\n\r\n /**\r\n * Sets the density of the physics shape.\r\n * @param density The density of the physics shape.\r\n */\r\n public set density(density: number) {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n * Returns the density of the physics shape.\r\n * @returns The density of the physics shape.\r\n */\r\n public get density(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n * Utility to add a child shape to this container,\r\n * automatically computing the relative transform between\r\n * the container shape and the child instance.\r\n *\r\n * @param parentTransform The transform node associated with this shape\r\n * @param newChild The new PhysicsShape to add\r\n * @param childTransform The transform node associated with the child shape\r\n */\r\n public addChildFromParent(parentTransform: TransformNode, newChild: PhysicsShape, childTransform: TransformNode): void {\r\n const childToWorld = childTransform.computeWorldMatrix(true);\r\n const parentToWorld = parentTransform.computeWorldMatrix(true);\r\n const childToParent = TmpVectors.Matrix[0];\r\n childToWorld.multiplyToRef(Matrix.Invert(parentToWorld), childToParent);\r\n const translation = TmpVectors.Vector3[0];\r\n const rotation = TmpVectors.Quaternion[0];\r\n const scale = TmpVectors.Vector3[1];\r\n childToParent.decompose(scale, rotation, translation);\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Adds a child shape to a container with an optional transform\r\n * @param newChild The new PhysicsShape to add\r\n * @param translation Optional position of the child shape relative to this shape\r\n * @param rotation Optional rotation of the child shape relative to this shape\r\n * @param scale Optional scale of the child shape relative to this shape\r\n */\r\n public addChild(newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void {\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Removes a child shape from this shape.\r\n * @param childIndex The index of the child shape to remove\r\n */\r\n public removeChild(childIndex: number): void {\r\n this._physicsPlugin.removeChild(this, childIndex);\r\n }\r\n\r\n /**\r\n * Returns the number of children of a physics shape.\r\n * @returns The number of children of a physics shape.\r\n */\r\n public getNumChildren(): number {\r\n return this._physicsPlugin.getNumChildren(this);\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics shape.\r\n * @returns The bounding box of the physics shape.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBoundingBox(this);\r\n }\r\n\r\n /**\r\n * Dispose the shape and release its associated resources.\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeShape(this);\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a sphere shape\r\n */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /**\r\n * Constructor for the Sphere Shape\r\n * @param center local center of the sphere\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.SPHERE, parameters: { center: center, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate sphere from the mesh.\r\n * @param mesh node from which to derive the sphere shape\r\n * @returns PhysicsShapeSphere\r\n */\r\n static FromMesh(mesh: AbstractMesh) {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingSphere.center;\r\n const he = bounds.boundingBox.extendSize;\r\n const radius = Math.max(he.x, he.y, he.z);\r\n return new PhysicsShapeSphere(centerLocal, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a capsule shape\r\n */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the capsule segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CAPSULE, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate capsule from the mesh. Note, this is\r\n * not the optimal bounding capsule.\r\n * @param mesh Node from which to derive a cylinder shape\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCapsule {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y - radius, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCapsule(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a cylinder shape\r\n */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the cylinder segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CYLINDER, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate cylinder from the mesh. Note, this is\r\n * not the optimal bounding cylinder.\r\n * @param mesh Node from which to derive a cylinder shape\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCylinder {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCylinder(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a box shape\r\n */\r\nexport class PhysicsShapeBox extends PhysicsShape {\r\n /**\r\n *\r\n * @param center local center of the box\r\n * @param rotation local orientation\r\n * @param extents size of the box in each direction\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super({ type: PhysicsShapeType.BOX, parameters: { center: center, rotation: rotation, extents: extents } }, scene);\r\n }\r\n\r\n /**\r\n *\r\n * @param mesh\r\n * @returns PhysicsShapeBox\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeBox {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingBox.center;\r\n const extents = bounds.boundingBox.extendSize.scale(2.0); //<todo.eoin extendSize seems to really be half-extents?\r\n return new PhysicsShapeBox(centerLocal, Quaternion.Identity(), extents, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a convex hull shape\r\n */\r\nexport class PhysicsShapeConvexHull extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh to be used as topology infos for the convex hull\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.CONVEX_HULL, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a mesh shape\r\n */\r\nexport class PhysicsShapeMesh extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh topology that will be used to create the shape\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.MESH, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * A shape container holds a variable number of shapes. Use AddChild to append to newly created parent container.\r\n */\r\nexport class PhysicsShapeContainer extends PhysicsShape {\r\n /**\r\n * Constructor of the Shape container\r\n * @param scene scene to attach to\r\n */\r\n constructor(scene: Scene) {\r\n super({ type: PhysicsShapeType.CONTAINER, parameters: {} }, scene);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsShape.ts"],"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AAC,wDAAwD;QAClH,OAAO,IAAI,eAAe,CAAC,WAAW,EAAE,UAAU,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC7F,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,YAAY;IACpD;;;;OAIG;IACH,YAAY,IAAU,EAAE,KAAY;QAChC,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACrF,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9C;;;;OAIG;IACH,YAAY,IAAU,EAAE,KAAY;QAChC,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD;;;OAGG;IACH,YAAY,KAAY;QACpB,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { Matrix, Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\n\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Options for creating a physics shape\r\n */\r\nexport interface PhysicShapeOptions {\r\n /**\r\n * The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n */\r\n type?: PhysicsShapeType;\r\n /**\r\n * The parameters of the shape. Varies depending of the shape type.\r\n */\r\n parameters?: PhysicsShapeParameters;\r\n /**\r\n * Reference to an already existing physics shape in the plugin.\r\n */\r\n pluginData?: any;\r\n}\r\n\r\n/**\r\n * PhysicsShape class.\r\n * This class is useful for creating a physics shape that can be used in a physics engine.\r\n * A Physic Shape determine how collision are computed. It must be attached to a body.\r\n */\r\nexport class PhysicsShape {\r\n /**\r\n * V2 Physics plugin private data for single shape\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n private _type: PhysicsShapeType;\r\n\r\n private _material: PhysicsMaterial;\r\n\r\n private _isTrigger: boolean = false;\r\n\r\n /**\r\n * Constructs a new physics shape.\r\n * @param options The options for the physics shape. These are:\r\n * * type: The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n * * parameters: The parameters of the shape.\r\n * * pluginData: The plugin data of the shape. This is used if you already have a reference to the object on the plugin side.\r\n * You need to specify either type or pluginData.\r\n * @param scene The scene the shape belongs to.\r\n *\r\n * This code is useful for creating a new physics shape with the given type, options, and scene.\r\n * It also checks that the physics engine and plugin version are correct.\r\n * If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.\r\n */\r\n constructor(options: PhysicShapeOptions, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n\r\n if (options.pluginData !== undefined && options.pluginData !== null) {\r\n this._pluginData = options.pluginData;\r\n this._type = this._physicsPlugin.getShapeType(this);\r\n } else if (options.type !== undefined && options.type !== null) {\r\n this._type = options.type;\r\n const parameters = options.parameters ?? {};\r\n this._physicsPlugin.initShape(this, options.type, parameters);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsShape\".\r\n * @returns \"PhysicsShape\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsShape\";\r\n }\r\n\r\n /**\r\n * Returns the type of the physics shape.\r\n * @returns The type of the physics shape.\r\n */\r\n public get type(): PhysicsShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Set the membership mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which the shape is a member. This is used in combination\r\n * with the collide mask to determine if this shape should collide with\r\n * another.\r\n *\r\n * @param membershipMask Bitfield of categories of this shape.\r\n */\r\n public set filterMembershipMask(membershipMask: number) {\r\n this._physicsPlugin.setShapeFilterMembershipMask(this, membershipMask);\r\n }\r\n\r\n /**\r\n * Get the membership mask of a shape.\r\n * @returns Bitmask of categories which this shape is a member of.\r\n */\r\n public get filterMembershipMask(): number {\r\n return this._physicsPlugin.getShapeFilterMembershipMask(this);\r\n }\r\n\r\n /**\r\n * Sets the collide mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which this shape collides with. Given two shapes,\r\n * the engine will check if the collide mask and membership overlap:\r\n * shapeA.filterMembershipMask & shapeB.filterCollideMask\r\n *\r\n * If this value is zero (i.e. shapeB only collides with categories\r\n * which shapeA is _not_ a member of) then the shapes will not collide.\r\n *\r\n * Note, the engine will also perform the same test with shapeA and\r\n * shapeB swapped; the shapes will not collide if either shape has\r\n * a collideMask which prevents collision with the other shape.\r\n *\r\n * @param collideMask Bitmask of categories this shape should collide with\r\n */\r\n public set filterCollideMask(collideMask: number) {\r\n this._physicsPlugin.setShapeFilterCollideMask(this, collideMask);\r\n }\r\n\r\n /**\r\n *\r\n * @returns Bitmask of categories that this shape should collide with\r\n */\r\n public get filterCollideMask(): number {\r\n return this._physicsPlugin.getShapeFilterCollideMask(this);\r\n }\r\n /**\r\n *\r\n * @param material\r\n */\r\n public set material(material: PhysicsMaterial) {\r\n this._physicsPlugin.setMaterial(this, material);\r\n this._material = material;\r\n }\r\n\r\n /**\r\n * Returns the material of the physics shape.\r\n * @returns The material of the physics shape.\r\n */\r\n public get material(): PhysicsMaterial {\r\n return this._material;\r\n }\r\n\r\n /**\r\n * Sets the density of the physics shape.\r\n * @param density The density of the physics shape.\r\n */\r\n public set density(density: number) {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n * Returns the density of the physics shape.\r\n * @returns The density of the physics shape.\r\n */\r\n public get density(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n * Utility to add a child shape to this container,\r\n * automatically computing the relative transform between\r\n * the container shape and the child instance.\r\n *\r\n * @param parentTransform The transform node associated with this shape\r\n * @param newChild The new PhysicsShape to add\r\n * @param childTransform The transform node associated with the child shape\r\n */\r\n public addChildFromParent(parentTransform: TransformNode, newChild: PhysicsShape, childTransform: TransformNode): void {\r\n const childToWorld = childTransform.computeWorldMatrix(true);\r\n const parentToWorld = parentTransform.computeWorldMatrix(true);\r\n const childToParent = TmpVectors.Matrix[0];\r\n childToWorld.multiplyToRef(Matrix.Invert(parentToWorld), childToParent);\r\n const translation = TmpVectors.Vector3[0];\r\n const rotation = TmpVectors.Quaternion[0];\r\n const scale = TmpVectors.Vector3[1];\r\n childToParent.decompose(scale, rotation, translation);\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Adds a child shape to a container with an optional transform\r\n * @param newChild The new PhysicsShape to add\r\n * @param translation Optional position of the child shape relative to this shape\r\n * @param rotation Optional rotation of the child shape relative to this shape\r\n * @param scale Optional scale of the child shape relative to this shape\r\n */\r\n public addChild(newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void {\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Removes a child shape from this shape.\r\n * @param childIndex The index of the child shape to remove\r\n */\r\n public removeChild(childIndex: number): void {\r\n this._physicsPlugin.removeChild(this, childIndex);\r\n }\r\n\r\n /**\r\n * Returns the number of children of a physics shape.\r\n * @returns The number of children of a physics shape.\r\n */\r\n public getNumChildren(): number {\r\n return this._physicsPlugin.getNumChildren(this);\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics shape.\r\n * @returns The bounding box of the physics shape.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBoundingBox(this);\r\n }\r\n\r\n public set isTrigger(isTrigger: boolean) {\r\n if (this._isTrigger === isTrigger) {\r\n return;\r\n }\r\n this._isTrigger = isTrigger;\r\n this._physicsPlugin.setTrigger(this, isTrigger);\r\n }\r\n\r\n public get isTrigger(): boolean {\r\n return this._isTrigger;\r\n }\r\n\r\n /**\r\n * Dispose the shape and release its associated resources.\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeShape(this);\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a sphere shape\r\n */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /**\r\n * Constructor for the Sphere Shape\r\n * @param center local center of the sphere\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.SPHERE, parameters: { center: center, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate sphere from the mesh.\r\n * @param mesh node from which to derive the sphere shape\r\n * @returns PhysicsShapeSphere\r\n */\r\n static FromMesh(mesh: AbstractMesh) {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingSphere.center;\r\n const he = bounds.boundingBox.extendSize;\r\n const radius = Math.max(he.x, he.y, he.z);\r\n return new PhysicsShapeSphere(centerLocal, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a capsule shape\r\n */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the capsule segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CAPSULE, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate capsule from the mesh. Note, this is\r\n * not the optimal bounding capsule.\r\n * @param mesh Node from which to derive a cylinder shape\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCapsule {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y - radius, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCapsule(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a cylinder shape\r\n */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the cylinder segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CYLINDER, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate cylinder from the mesh. Note, this is\r\n * not the optimal bounding cylinder.\r\n * @param mesh Node from which to derive a cylinder shape\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCylinder {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCylinder(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a box shape\r\n */\r\nexport class PhysicsShapeBox extends PhysicsShape {\r\n /**\r\n *\r\n * @param center local center of the box\r\n * @param rotation local orientation\r\n * @param extents size of the box in each direction\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super({ type: PhysicsShapeType.BOX, parameters: { center: center, rotation: rotation, extents: extents } }, scene);\r\n }\r\n\r\n /**\r\n *\r\n * @param mesh\r\n * @returns PhysicsShapeBox\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeBox {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingBox.center;\r\n const extents = bounds.boundingBox.extendSize.scale(2.0); //<todo.eoin extendSize seems to really be half-extents?\r\n return new PhysicsShapeBox(centerLocal, Quaternion.Identity(), extents, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a convex hull shape\r\n */\r\nexport class PhysicsShapeConvexHull extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh to be used as topology infos for the convex hull\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.CONVEX_HULL, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a mesh shape\r\n */\r\nexport class PhysicsShapeMesh extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh topology that will be used to create the shape\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.MESH, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * A shape container holds a variable number of shapes. Use AddChild to append to newly created parent container.\r\n */\r\nexport class PhysicsShapeContainer extends PhysicsShape {\r\n /**\r\n * Constructor of the Shape container\r\n * @param scene scene to attach to\r\n */\r\n constructor(scene: Scene) {\r\n super({ type: PhysicsShapeType.CONTAINER, parameters: {} }, scene);\r\n }\r\n}\r\n"]}
|
|
@@ -105,6 +105,7 @@ export class PostProcessRenderEffect {
|
|
|
105
105
|
if (this._cameras[cameraName]) {
|
|
106
106
|
this._cameras[cameraName] = null;
|
|
107
107
|
}
|
|
108
|
+
delete this._indicesForCamera[cameraName];
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
@@ -120,11 +121,12 @@ export class PostProcessRenderEffect {
|
|
|
120
121
|
for (let i = 0; i < cams.length; i++) {
|
|
121
122
|
const camera = cams[i];
|
|
122
123
|
const cameraName = camera.name;
|
|
124
|
+
const cameraKey = this._singleInstance ? 0 : cameraName;
|
|
123
125
|
for (let j = 0; j < this._indicesForCamera[cameraName].length; j++) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
const index = this._indicesForCamera[cameraName][j];
|
|
127
|
+
const postProcess = camera._postProcesses[index];
|
|
128
|
+
if (postProcess === undefined || postProcess === null) {
|
|
129
|
+
cams[i].attachPostProcess(this._postProcesses[cameraKey][j], index);
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postProcessRenderEffect.js","sourceRoot":"","sources":["../../../../../dev/core/src/PostProcesses/RenderPipeline/postProcessRenderEffect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAA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AC,eAAe,EAAE;YACtB,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;SACjC;aAAM;YACH,IAAI,CAAC,MAAM,EAAE;gBACT,OAAO,IAAI,CAAC;aACf;YACD,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC3C;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\n/**\r\n * This represents a set of one or more post processes in Babylon.\r\n * A post process can be used to apply a shader to a texture after it is rendered.\r\n * @example https://doc.babylonjs.com/features/featuresDeepDive/postProcesses/postProcessRenderPipeline\r\n */\r\nexport class PostProcessRenderEffect {\r\n private _postProcesses: { [Key: string]: Array<PostProcess> };\r\n private _getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>;\r\n\r\n private _singleInstance: boolean;\r\n\r\n private _cameras: { [key: string]: Nullable<Camera> };\r\n private _indicesForCamera: { [key: string]: number[] };\r\n\r\n /**\r\n * Name of the effect\r\n * @internal\r\n */\r\n public _name: string;\r\n\r\n /**\r\n * Instantiates a post process render effect.\r\n * A post process can be used to apply a shader to a texture after it is rendered.\r\n * @param engine The engine the effect is tied to\r\n * @param name The name of the effect\r\n * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.\r\n * @param singleInstance False if this post process can be run on multiple cameras. (default: true)\r\n */\r\n constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean) {\r\n this._name = name;\r\n this._singleInstance = singleInstance || true;\r\n\r\n this._getPostProcesses = getPostProcesses;\r\n\r\n this._cameras = {};\r\n this._indicesForCamera = {};\r\n\r\n this._postProcesses = {};\r\n }\r\n\r\n /**\r\n * Checks if all the post processes in the effect are supported.\r\n */\r\n public get isSupported(): boolean {\r\n for (const index in this._postProcesses) {\r\n if (Object.prototype.hasOwnProperty.call(this._postProcesses, index)) {\r\n const pps = this._postProcesses[index];\r\n for (let ppIndex = 0; ppIndex < pps.length; ppIndex++) {\r\n if (!pps[ppIndex].isSupported) {\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Updates the current state of the effect\r\n * @internal\r\n */\r\n public _update(): void {}\r\n\r\n /**\r\n * Attaches the effect on cameras\r\n * @param cameras The camera to attach to.\r\n * @internal\r\n */\r\n public _attachCameras(cameras: Camera): void;\r\n /**\r\n * Attaches the effect on cameras\r\n * @param cameras The camera to attach to.\r\n * @internal\r\n */\r\n public _attachCameras(cameras: Camera[]): void;\r\n /**\r\n * Attaches the effect on cameras\r\n * @param cameras The camera to attach to.\r\n * @internal\r\n */\r\n public _attachCameras(cameras: any): void {\r\n let cameraKey;\r\n\r\n const cams = Tools.MakeArray(cameras || this._cameras);\r\n\r\n if (!cams) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < cams.length; i++) {\r\n const camera = cams[i];\r\n if (!camera) {\r\n continue;\r\n }\r\n\r\n const cameraName = camera.name;\r\n\r\n if (this._singleInstance) {\r\n cameraKey = 0;\r\n } else {\r\n cameraKey = cameraName;\r\n }\r\n\r\n if (!this._postProcesses[cameraKey]) {\r\n const postProcess = this._getPostProcesses();\r\n if (postProcess) {\r\n this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];\r\n }\r\n }\r\n\r\n if (!this._indicesForCamera[cameraName]) {\r\n this._indicesForCamera[cameraName] = [];\r\n }\r\n\r\n this._postProcesses[cameraKey].forEach((postProcess: PostProcess) => {\r\n const index = camera.attachPostProcess(postProcess);\r\n\r\n this._indicesForCamera[cameraName].push(index);\r\n });\r\n\r\n if (!this._cameras[cameraName]) {\r\n this._cameras[cameraName] = camera;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Detaches the effect on cameras\r\n * @param cameras The camera to detach from.\r\n * @internal\r\n */\r\n public _detachCameras(cameras: Camera): void;\r\n /**\r\n * Detaches the effect on cameras\r\n * @param cameras The camera to detach from.\r\n * @internal\r\n */\r\n public _detachCameras(cameras: Camera[]): void;\r\n /**\r\n * Detaches the effect on cameras\r\n * @param cameras The camera to detach from.\r\n * @internal\r\n */\r\n public _detachCameras(cameras: any): void {\r\n const cams = Tools.MakeArray(cameras || this._cameras);\r\n\r\n if (!cams) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < cams.length; i++) {\r\n const camera: Camera = cams[i];\r\n const cameraName: string = camera.name;\r\n const postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];\r\n\r\n if (postProcesses) {\r\n postProcesses.forEach((postProcess: PostProcess) => {\r\n camera.detachPostProcess(postProcess);\r\n });\r\n }\r\n\r\n if (this._cameras[cameraName]) {\r\n this._cameras[cameraName] = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Enables the effect on given cameras\r\n * @param cameras The camera to enable.\r\n * @internal\r\n */\r\n public _enable(cameras: Camera): void;\r\n /**\r\n * Enables the effect on given cameras\r\n * @param cameras The camera to enable.\r\n * @internal\r\n */\r\n public _enable(cameras: Nullable<Camera[]>): void;\r\n /**\r\n * Enables the effect on given cameras\r\n * @param cameras The camera to enable.\r\n * @internal\r\n */\r\n public _enable(cameras: any): void {\r\n const cams: Nullable<Array<Camera>> = Tools.MakeArray(cameras || this._cameras);\r\n\r\n if (!cams) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < cams.length; i++) {\r\n const camera = cams[i];\r\n const cameraName = camera.name;\r\n\r\n for (let j = 0; j < this._indicesForCamera[cameraName].length; j++) {\r\n if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {\r\n this._postProcesses[this._singleInstance ? 0 : cameraName].forEach((postProcess) => {\r\n cams![i].attachPostProcess(postProcess, this._indicesForCamera[cameraName][j]);\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disables the effect on the given cameras\r\n * @param cameras The camera to disable.\r\n * @internal\r\n */\r\n public _disable(cameras: Camera): void;\r\n /**\r\n * Disables the effect on the given cameras\r\n * @param cameras The camera to disable.\r\n * @internal\r\n */\r\n public _disable(cameras: Nullable<Camera[]>): void;\r\n /**\r\n * Disables the effect on the given cameras\r\n * @param cameras The camera to disable.\r\n * @internal\r\n */\r\n public _disable(cameras: any): void {\r\n const cams: Nullable<Array<Camera>> = Tools.MakeArray(cameras || this._cameras);\r\n\r\n if (!cams) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < cams.length; i++) {\r\n const camera = cams[i];\r\n const cameraName = camera.name;\r\n this._postProcesses[this._singleInstance ? 0 : cameraName].forEach((postProcess) => {\r\n camera.detachPostProcess(postProcess);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Gets a list of the post processes contained in the effect.\r\n * @param camera The camera to get the post processes on.\r\n * @returns The list of the post processes in the effect.\r\n */\r\n public getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>> {\r\n if (this._singleInstance) {\r\n return this._postProcesses[0];\r\n } else {\r\n if (!camera) {\r\n return null;\r\n }\r\n return this._postProcesses[camera.name];\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"postProcessRenderEffect.js","sourceRoot":"","sources":["../../../../../dev/core/src/PostProcesses/RenderPipeline/postProcessRenderEffect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC;;;;GAIG;AACH,MAAM,OAAO,uBAAuB;IAehC;;;;;;;OAOG;IACH,YAAY,MAAc,EAAE,IAAY,EAAE,gBAAkE,EAAE,cAAwB;QAClI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,cAAc,IAAI,IAAI,CAAC;QAE9C,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;QAE1C,IAAI,CAAC,QAAQ,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D,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,EAAE;oBACnD,IAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;iBACxE;aACJ;SACJ;IACL,CAAC;IAcD;;;;OAIG;IACI,QAAQ,CAAC,OAAY;QACxB,MAAM,IAAI,GAA4B,KAAK,CAAC,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhF,IAAI,CAAC,IAAI,EAAE;YACP,OAAO;SACV;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACvB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;YAC/B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;gBAC/E,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,MAAe;QACnC,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;SACjC;aAAM;YACH,IAAI,CAAC,MAAM,EAAE;gBACT,OAAO,IAAI,CAAC;aACf;YACD,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC3C;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\n/**\r\n * This represents a set of one or more post processes in Babylon.\r\n * A post process can be used to apply a shader to a texture after it is rendered.\r\n * @example https://doc.babylonjs.com/features/featuresDeepDive/postProcesses/postProcessRenderPipeline\r\n */\r\nexport class PostProcessRenderEffect {\r\n private _postProcesses: { [Key: string]: Array<PostProcess> };\r\n private _getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>;\r\n\r\n private _singleInstance: boolean;\r\n\r\n private _cameras: { [key: string]: Nullable<Camera> };\r\n private _indicesForCamera: { [key: string]: number[] };\r\n\r\n /**\r\n * Name of the effect\r\n * @internal\r\n */\r\n public _name: string;\r\n\r\n /**\r\n * Instantiates a post process render effect.\r\n * A post process can be used to apply a shader to a texture after it is rendered.\r\n * @param engine The engine the effect is tied to\r\n * @param name The name of the effect\r\n * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.\r\n * @param singleInstance False if this post process can be run on multiple cameras. (default: true)\r\n */\r\n constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean) {\r\n this._name = name;\r\n this._singleInstance = singleInstance || true;\r\n\r\n this._getPostProcesses = getPostProcesses;\r\n\r\n this._cameras = {};\r\n this._indicesForCamera = {};\r\n\r\n this._postProcesses = {};\r\n }\r\n\r\n /**\r\n * Checks if all the post processes in the effect are supported.\r\n */\r\n public get isSupported(): boolean {\r\n for (const index in this._postProcesses) {\r\n if (Object.prototype.hasOwnProperty.call(this._postProcesses, index)) {\r\n const pps = this._postProcesses[index];\r\n for (let ppIndex = 0; ppIndex < pps.length; ppIndex++) {\r\n if (!pps[ppIndex].isSupported) {\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Updates the current state of the effect\r\n * @internal\r\n */\r\n public _update(): void {}\r\n\r\n /**\r\n * Attaches the effect on cameras\r\n * @param cameras The camera to attach to.\r\n * @internal\r\n */\r\n public _attachCameras(cameras: Camera): void;\r\n /**\r\n * Attaches the effect on cameras\r\n * @param cameras The camera to attach to.\r\n * @internal\r\n */\r\n public _attachCameras(cameras: Camera[]): void;\r\n /**\r\n * Attaches the effect on cameras\r\n * @param cameras The camera to attach to.\r\n * @internal\r\n */\r\n public _attachCameras(cameras: any): void {\r\n let cameraKey;\r\n\r\n const cams = Tools.MakeArray(cameras || this._cameras);\r\n\r\n if (!cams) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < cams.length; i++) {\r\n const camera = cams[i];\r\n if (!camera) {\r\n continue;\r\n }\r\n\r\n const cameraName = camera.name;\r\n\r\n if (this._singleInstance) {\r\n cameraKey = 0;\r\n } else {\r\n cameraKey = cameraName;\r\n }\r\n\r\n if (!this._postProcesses[cameraKey]) {\r\n const postProcess = this._getPostProcesses();\r\n if (postProcess) {\r\n this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];\r\n }\r\n }\r\n\r\n if (!this._indicesForCamera[cameraName]) {\r\n this._indicesForCamera[cameraName] = [];\r\n }\r\n\r\n this._postProcesses[cameraKey].forEach((postProcess: PostProcess) => {\r\n const index = camera.attachPostProcess(postProcess);\r\n\r\n this._indicesForCamera[cameraName].push(index);\r\n });\r\n\r\n if (!this._cameras[cameraName]) {\r\n this._cameras[cameraName] = camera;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Detaches the effect on cameras\r\n * @param cameras The camera to detach from.\r\n * @internal\r\n */\r\n public _detachCameras(cameras: Camera): void;\r\n /**\r\n * Detaches the effect on cameras\r\n * @param cameras The camera to detach from.\r\n * @internal\r\n */\r\n public _detachCameras(cameras: Camera[]): void;\r\n /**\r\n * Detaches the effect on cameras\r\n * @param cameras The camera to detach from.\r\n * @internal\r\n */\r\n public _detachCameras(cameras: any): void {\r\n const cams = Tools.MakeArray(cameras || this._cameras);\r\n\r\n if (!cams) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < cams.length; i++) {\r\n const camera: Camera = cams[i];\r\n const cameraName: string = camera.name;\r\n const postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];\r\n\r\n if (postProcesses) {\r\n postProcesses.forEach((postProcess: PostProcess) => {\r\n camera.detachPostProcess(postProcess);\r\n });\r\n }\r\n\r\n if (this._cameras[cameraName]) {\r\n this._cameras[cameraName] = null;\r\n }\r\n\r\n delete this._indicesForCamera[cameraName];\r\n }\r\n }\r\n\r\n /**\r\n * Enables the effect on given cameras\r\n * @param cameras The camera to enable.\r\n * @internal\r\n */\r\n public _enable(cameras: Camera): void;\r\n /**\r\n * Enables the effect on given cameras\r\n * @param cameras The camera to enable.\r\n * @internal\r\n */\r\n public _enable(cameras: Nullable<Camera[]>): void;\r\n /**\r\n * Enables the effect on given cameras\r\n * @param cameras The camera to enable.\r\n * @internal\r\n */\r\n public _enable(cameras: any): void {\r\n const cams: Nullable<Array<Camera>> = Tools.MakeArray(cameras || this._cameras);\r\n\r\n if (!cams) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < cams.length; i++) {\r\n const camera = cams[i];\r\n const cameraName = camera.name;\r\n const cameraKey = this._singleInstance ? 0 : cameraName;\r\n\r\n for (let j = 0; j < this._indicesForCamera[cameraName].length; j++) {\r\n const index = this._indicesForCamera[cameraName][j];\r\n const postProcess = camera._postProcesses[index];\r\n if (postProcess === undefined || postProcess === null) {\r\n cams![i].attachPostProcess(this._postProcesses[cameraKey][j], index);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disables the effect on the given cameras\r\n * @param cameras The camera to disable.\r\n * @internal\r\n */\r\n public _disable(cameras: Camera): void;\r\n /**\r\n * Disables the effect on the given cameras\r\n * @param cameras The camera to disable.\r\n * @internal\r\n */\r\n public _disable(cameras: Nullable<Camera[]>): void;\r\n /**\r\n * Disables the effect on the given cameras\r\n * @param cameras The camera to disable.\r\n * @internal\r\n */\r\n public _disable(cameras: any): void {\r\n const cams: Nullable<Array<Camera>> = Tools.MakeArray(cameras || this._cameras);\r\n\r\n if (!cams) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < cams.length; i++) {\r\n const camera = cams[i];\r\n const cameraName = camera.name;\r\n this._postProcesses[this._singleInstance ? 0 : cameraName].forEach((postProcess) => {\r\n camera.detachPostProcess(postProcess);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Gets a list of the post processes contained in the effect.\r\n * @param camera The camera to get the post processes on.\r\n * @returns The list of the post processes in the effect.\r\n */\r\n public getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>> {\r\n if (this._singleInstance) {\r\n return this._postProcesses[0];\r\n } else {\r\n if (!camera) {\r\n return null;\r\n }\r\n return this._postProcesses[camera.name];\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -159,17 +159,17 @@ export class BlurPostProcess extends PostProcess {
|
|
|
159
159
|
defines += this._staticDefines;
|
|
160
160
|
// The DOF fragment should ignore the center pixel when looping as it is handled manually in the fragment shader.
|
|
161
161
|
if (this._staticDefines.indexOf("DOF") != -1) {
|
|
162
|
-
defines += `#define CENTER_WEIGHT ${this._glslFloat(weights[varyingCount - 1])}\
|
|
162
|
+
defines += `#define CENTER_WEIGHT ${this._glslFloat(weights[varyingCount - 1])}\n`;
|
|
163
163
|
varyingCount--;
|
|
164
164
|
}
|
|
165
165
|
for (let i = 0; i < varyingCount; i++) {
|
|
166
|
-
defines += `#define KERNEL_OFFSET${i} ${this._glslFloat(offsets[i])}\
|
|
167
|
-
defines += `#define KERNEL_WEIGHT${i} ${this._glslFloat(weights[i])}\
|
|
166
|
+
defines += `#define KERNEL_OFFSET${i} ${this._glslFloat(offsets[i])}\n`;
|
|
167
|
+
defines += `#define KERNEL_WEIGHT${i} ${this._glslFloat(weights[i])}\n`;
|
|
168
168
|
}
|
|
169
169
|
let depCount = 0;
|
|
170
170
|
for (let i = freeVaryingVec2; i < offsets.length; i++) {
|
|
171
|
-
defines += `#define KERNEL_DEP_OFFSET${depCount} ${this._glslFloat(offsets[i])}\
|
|
172
|
-
defines += `#define KERNEL_DEP_WEIGHT${depCount} ${this._glslFloat(weights[i])}\
|
|
171
|
+
defines += `#define KERNEL_DEP_OFFSET${depCount} ${this._glslFloat(offsets[i])}\n`;
|
|
172
|
+
defines += `#define KERNEL_DEP_WEIGHT${depCount} ${this._glslFloat(weights[i])}\n`;
|
|
173
173
|
depCount++;
|
|
174
174
|
}
|
|
175
175
|
if (this.packedFloat) {
|