@babylonjs/core 8.36.1 → 8.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.js +1 -4
- package/Animations/animationGroup.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
- package/AudioV2/audioParameter.d.ts +5 -1
- package/AudioV2/audioParameter.js +4 -0
- package/AudioV2/audioParameter.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +58 -0
- package/Behaviors/Cameras/interpolatingBehavior.js +157 -0
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -0
- package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +5 -20
- package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -69
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +81 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js +223 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -0
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +17 -21
- package/Cameras/Inputs/geospatialCameraPointersInput.js +49 -71
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/orbitCameraPointersInput.d.ts +49 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js +105 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -0
- package/Cameras/Limits/geospatialLimits.d.ts +60 -0
- package/Cameras/Limits/geospatialLimits.js +89 -0
- package/Cameras/Limits/geospatialLimits.js.map +1 -0
- package/Cameras/camera.js +1 -0
- package/Cameras/camera.js.map +1 -1
- package/Cameras/cameraMovement.d.ts +150 -0
- package/Cameras/cameraMovement.js +190 -0
- package/Cameras/cameraMovement.js.map +1 -0
- package/Cameras/geospatialCamera.d.ts +78 -49
- package/Cameras/geospatialCamera.js +210 -191
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraInputsManager.d.ts +5 -0
- package/Cameras/geospatialCameraInputsManager.js +9 -0
- package/Cameras/geospatialCameraInputsManager.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +66 -0
- package/Cameras/geospatialCameraMovement.js +199 -0
- package/Cameras/geospatialCameraMovement.js.map +1 -0
- package/Cameras/targetCamera.js +0 -4
- package/Cameras/targetCamera.js.map +1 -1
- package/Culling/ray.core.js +1 -1
- package/Culling/ray.core.js.map +1 -1
- package/Debug/debugLayer.d.ts +1 -1
- package/Debug/debugLayer.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +9 -7
- package/Decorators/nodeDecorator.js +9 -7
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +14 -6
- package/Engines/Native/nativeInterfaces.js +6 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +4 -0
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +2 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
- package/FlowGraph/flowGraphMath.d.ts +25 -0
- package/FlowGraph/flowGraphMath.js +40 -0
- package/FlowGraph/flowGraphMath.js.map +1 -0
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +26 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +48 -22
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +3 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +14 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/{cullPass.d.ts → objectListPass.d.ts} +8 -8
- package/FrameGraph/Passes/{cullPass.js → objectListPass.js} +9 -9
- package/FrameGraph/Passes/objectListPass.js.map +1 -0
- package/FrameGraph/Passes/renderPass.d.ts +6 -2
- package/FrameGraph/Passes/renderPass.js +14 -2
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +2 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +3 -4
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +10 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +13 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +2 -3
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +1 -2
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +3 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +11 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -5
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +4 -0
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +7 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +10 -4
- package/FrameGraph/frameGraph.js +22 -9
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
- package/FrameGraph/frameGraphRenderContext.js +22 -3
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +3 -3
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -1
- package/FrameGraph/index.js +1 -1
- package/FrameGraph/index.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +5 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -5
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.js +2 -1
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +19 -0
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +9 -0
- package/Materials/shaderMaterial.js +39 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +5 -24
- package/Maths/math.vector.functions.js +32 -35
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +51 -16
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/Node/Blocks/randomBlock.js +11 -11
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
- package/Meshes/csg2.js +1 -1
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +15 -0
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +8 -1
- package/Misc/copyTextureToTexture.js +16 -2
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/fileTools.js.map +1 -1
- package/Misc/tools.d.ts +3 -0
- package/Misc/tools.js +43 -4
- package/Misc/tools.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +6 -4
- package/Particles/EmitterTypes/coneParticleEmitter.js +18 -12
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/customParticleEmitter.d.ts +5 -3
- package/Particles/EmitterTypes/customParticleEmitter.js +8 -6
- package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +15 -4
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +66 -36
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +0 -4
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +1 -8
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +13 -9
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +36 -23
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +16 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +67 -14
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +3 -3
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +3 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.d.ts +5 -2
- package/Particles/Node/Blocks/particleRandomBlock.js +40 -22
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +21 -9
- package/Particles/Node/Blocks/systemBlock.js +37 -22
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +7 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +6 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +5 -5
- package/Particles/Node/nodeParticleBuildState.js +14 -5
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +586 -148
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +1 -1
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/particle.d.ts +4 -0
- package/Particles/particle.js +2 -0
- package/Particles/particle.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +3 -7
- package/Particles/thinParticleSystem.function.d.ts +3 -3
- package/Particles/thinParticleSystem.function.js +11 -8
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +5 -7
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/prePassRenderer.js +4 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +5 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/copyTextureToTexture.fragment.js +2 -2
- package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +3 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js +2 -2
- package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +35 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/copyTextureToTexture.fragment.js +3 -3
- package/ShadersWGSL/copyTextureToTexture.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/XR/webXRSessionManager.js +4 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -3
- package/scene.js +8 -7
- package/scene.js.map +1 -1
- package/FrameGraph/Passes/cullPass.js.map +0 -1
|
@@ -116,6 +116,25 @@ function GetOffsetMatrix(uniformName, mat) {
|
|
|
116
116
|
case "worldViewProjection":
|
|
117
117
|
return OffsetWorldViewProjectionToRef(offset, mat, scene.getTransformMatrix(), scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);
|
|
118
118
|
default:
|
|
119
|
+
// Node material blocks uniforms are formatted u_BlockName, with trailing numbers if there are multiple blocks of the same name
|
|
120
|
+
// Check u_ first so that we can early out for non-node material uniforms
|
|
121
|
+
if (uniformName.startsWith("u_")) {
|
|
122
|
+
if (uniformName.startsWith("u_WorldViewProjection")) {
|
|
123
|
+
return OffsetWorldViewProjectionToRef(offset, mat, scene.getTransformMatrix(), scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);
|
|
124
|
+
}
|
|
125
|
+
if (uniformName.startsWith("u_ViewProjection")) {
|
|
126
|
+
return OffsetViewProjectionToRef(offset, scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);
|
|
127
|
+
}
|
|
128
|
+
if (uniformName.startsWith("u_WorldView")) {
|
|
129
|
+
return OffsetWorldViewToRef(offset, mat, scene.getViewMatrix(), TempFinalMat);
|
|
130
|
+
}
|
|
131
|
+
if (uniformName.startsWith("u_World")) {
|
|
132
|
+
return OffsetWorldToRef(offset, mat, TempFinalMat);
|
|
133
|
+
}
|
|
134
|
+
if (uniformName.startsWith("u_View")) {
|
|
135
|
+
return OffsetViewToRef(offset, mat, TempFinalMat);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
119
138
|
return mat;
|
|
120
139
|
}
|
|
121
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floatingOriginMatrixOverrides.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/floatingOriginMatrixOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAGxG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,YAAY,GAAW,IAAI,MAAM,EAAE,CAAC;AAC1C,MAAM,QAAQ,GAAW,IAAI,MAAM,EAAE,CAAC;AACtC,MAAM,QAAQ,GAAW,IAAI,MAAM,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACtC,QAAQ,EAAE,GAAG,EAAE,CAAC,SAA8B;IAC9C,WAAW,EAAE,IAAI,EAAE,+GAA+G;CACrI,CAAC;AAEF,SAAS,gBAAgB,CAAC,MAAoB,EAAE,KAAiC,EAAE,GAAW;IAC1F,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AwF;AACxF,MAAM,qBAAqB,GAAG,aAAoB,CAAC;AACnD,MAAM,cAAc,GAAG,MAAa,CAAC;AACrC,MAAM,8BAA8B,GAAG,qBAAqB,CAAC,SAAS,CAAC,uBAAuB,CAAC;AAC/F,MAAM,iBAAiB,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;AAErD,MAAM,UAAU,oBAAoB;IAChC,MAAM,CAAC,SAAS,CAAC,SAAS,GAAG,iBAAiB,CAAC;IAC/C,cAAc,CAAC,kBAAkB,GAAG,SAAS,CAAC;IAC9C,qBAAqB,CAAC,SAAS,CAAC,uBAAuB,GAAG,8BAA8B,CAAC;IACzF,qBAAqB,CAAC,SAAS,CAAC,+BAA+B,GAAG,SAAS,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,uBAAuB;IACnC,cAAc,CAAC,SAAS,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAChE,cAAc,CAAC,SAAS,CAAC,SAAS,GAAG,UAAU,WAAmB,EAAE,MAAmB;QACnF,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IACF,qBAAqB,CAAC,SAAS,CAAC,+BAA+B,GAAG,8BAA8B,CAAC;IACjG,qBAAqB,CAAC,SAAS,CAAC,uBAAuB,GAAG,UAAU,WAAmB,EAAE,MAAmB;QACxG,IAAI,CAAC,+BAA+B,CAAC,WAAW,EAAE,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5F,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { Effect } from \"../Materials/effect\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { IMatrixLike, IVector3Like } from \"../Maths/math.like\";\r\nimport { InvertMatrixToRef, MultiplyMatricesToRef } from \"../Maths/ThinMaths/thinMath.matrix.functions\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { UniformBuffer } from \"./uniformBuffer\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nconst TempFinalMat: Matrix = new Matrix();\r\nconst TempMat1: Matrix = new Matrix();\r\nconst TempMat2: Matrix = new Matrix();\r\n\r\n/**\r\n * When rendering, each scene will reset this to ensure the correct floating origin offset is when overriding the below functions\r\n */\r\nexport const FloatingOriginCurrentScene = {\r\n getScene: () => undefined as Scene | undefined,\r\n eyeAtCamera: true, // When true, we can assume viewMatrix translation is at origin. Otherwise, we must do full offset calculations\r\n};\r\n\r\nfunction OffsetWorldToRef(offset: IVector3Like, world: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n const refArray = ref.asArray();\r\n const worldArray = world.asArray();\r\n for (let i = 0; i < 16; i++) {\r\n refArray[i] = worldArray[i];\r\n }\r\n refArray[12] -= offset.x;\r\n refArray[13] -= offset.y;\r\n refArray[14] -= offset.z;\r\n ref.markAsUpdated();\r\n return ref;\r\n}\r\n\r\nfunction GetFullOffsetView(offset: IVector3Like, viewMatrix: DeepImmutable<IMatrixLike>, ref: IMatrixLike) {\r\n InvertMatrixToRef(viewMatrix, TempMat1); // TempMat1 = light world matrix (inverse of view)\r\n OffsetWorldToRef(offset, TempMat1, TempMat2); // TempMat2 = offset light world matrix\r\n InvertMatrixToRef(TempMat2, ref); // TempMat1 = offset view matrix\r\n return ref;\r\n}\r\n\r\nexport function OffsetViewToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n // When eye is not at camera, we cannot assume the translation of view matrix is at origin, so we perform full offset calculation\r\n if (!FloatingOriginCurrentScene.eyeAtCamera) {\r\n return GetFullOffsetView(offset, view, ref);\r\n }\r\n const refArray = ref.asArray();\r\n const viewArray = view.asArray();\r\n for (let i = 0; i < 16; i++) {\r\n refArray[i] = viewArray[i];\r\n }\r\n refArray[12] = 0;\r\n refArray[13] = 0;\r\n refArray[14] = 0;\r\n ref.markAsUpdated();\r\n return ref;\r\n}\r\n\r\nfunction OffsetViewProjectionToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, projection: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n MultiplyMatricesToRef(OffsetViewToRef(offset, view, ref), projection, ref);\r\n return ref;\r\n}\r\n\r\nexport function OffsetClipPlaneToRef(offset: Vector3, plane: Plane, ref: Plane): Plane {\r\n // Original clipplane is using equation normal.dot(p) + d = 0\r\n // Assume we have p' = p - offset, that means normal.dot(p') + d' = 0\r\n // So to get the offset plane,\r\n // normal.dot(p' + offset) + d = 0\r\n // normal.dot(p') + normal.dot(offset) + d = 0\r\n // -d' + normal.dot(offset) + d = 0\r\n // d' = d + normal.dot(offset)\r\n ref.normal.copyFrom(plane.normal);\r\n ref.d = plane.d + Vector3.Dot(plane.normal, offset);\r\n return ref;\r\n}\r\n\r\nexport function GetOffsetTransformMatrices(\r\n offset: IVector3Like,\r\n viewMatrices: Array<Matrix>,\r\n projectionMatrices: Array<Matrix>,\r\n length: number,\r\n resultArray: Float32Array\r\n): Float32Array {\r\n for (let cascadeIndex = 0; cascadeIndex < length; ++cascadeIndex) {\r\n GetFullOffsetViewProjectionToRef(offset, viewMatrices[cascadeIndex], projectionMatrices[cascadeIndex], TempMat1);\r\n TempMat1.copyToArray(resultArray, cascadeIndex * 16);\r\n }\r\n return resultArray;\r\n}\r\n\r\nfunction OffsetWorldViewToRef(offset: IVector3Like, worldView: DeepImmutable<IMatrixLike>, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n // ( world * view ) * inverse ( view ) = world\r\n InvertMatrixToRef(view, TempMat1); // TempMat1 = inverseView\r\n MultiplyMatricesToRef(worldView, TempMat1, TempMat2); // TempMat2 = world, TempMat1 can be reused\r\n\r\n // ( offsetWorld * offsetView ) = offsetWorldView\r\n OffsetWorldToRef(offset, TempMat2, TempMat1); // TempMat1 = offsetWorld\r\n OffsetViewToRef(offset, view, TempMat2); // TempMat2 = offsetView\r\n MultiplyMatricesToRef(TempMat1, TempMat2, ref);\r\n\r\n return ref;\r\n}\r\n\r\nexport function GetFullOffsetViewProjectionToRef(\r\n offset: IVector3Like,\r\n viewMatrix: DeepImmutable<IMatrixLike>,\r\n projectionMatrix: DeepImmutable<IMatrixLike>,\r\n ref: IMatrixLike\r\n): DeepImmutable<IMatrixLike> {\r\n GetFullOffsetView(offset, viewMatrix, TempMat2);\r\n MultiplyMatricesToRef(TempMat2, projectionMatrix, ref);\r\n return ref;\r\n}\r\n\r\nfunction OffsetWorldViewProjectionToRef(\r\n offset: IVector3Like,\r\n worldViewProjection: DeepImmutable<IMatrixLike>,\r\n viewProjection: DeepImmutable<IMatrixLike>,\r\n view: DeepImmutable<IMatrixLike>,\r\n projection: DeepImmutable<IMatrixLike>,\r\n ref: IMatrixLike\r\n): DeepImmutable<IMatrixLike> {\r\n // ( world * view * projection ) * inverse(projection) * inverse(view) = world\r\n // ( world * view * projection ) * inverse (view * projection) = world\r\n InvertMatrixToRef(viewProjection, TempMat1); // TempMat1 = inverse (view * projection)\r\n MultiplyMatricesToRef(worldViewProjection, TempMat1, TempMat2); // TempMat2 = world, TempMat1 can be reused\r\n\r\n // ( offsetWorld * offsetViewProjection) = offsetWorldViewProjection\r\n OffsetWorldToRef(offset, TempMat2, TempMat1); // TempMat1 = offsetWorld\r\n OffsetViewProjectionToRef(offset, view, projection, TempMat2); // TempMat2 = offsetViewProjection\r\n MultiplyMatricesToRef(TempMat1, TempMat2, ref);\r\n\r\n return ref;\r\n}\r\n\r\nfunction GetOffsetMatrix(uniformName: string, mat: IMatrixLike): IMatrixLike {\r\n const scene = FloatingOriginCurrentScene.getScene();\r\n // Early out for scenes that don't have floatingOriginMode enabled\r\n // Effect.setMatrix will call pipelineContext.setMatrix. In WebGPU, this will in turn call ubo.updateMatrix. To avoid double offset, early out if mat is TempFinalMat\r\n if (!scene || TempFinalMat === mat) {\r\n return mat;\r\n }\r\n TempFinalMat.updateFlag = mat.updateFlag;\r\n const offset = scene.floatingOriginOffset;\r\n switch (uniformName) {\r\n case \"world\":\r\n return OffsetWorldToRef(offset, mat, TempFinalMat);\r\n case \"view\":\r\n return OffsetViewToRef(offset, mat, TempFinalMat);\r\n case \"worldView\":\r\n return OffsetWorldViewToRef(offset, mat, scene.getViewMatrix(), TempFinalMat);\r\n case \"viewProjection\":\r\n return OffsetViewProjectionToRef(offset, scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n case \"worldViewProjection\":\r\n return OffsetWorldViewProjectionToRef(offset, mat, scene.getTransformMatrix(), scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n default:\r\n return mat;\r\n }\r\n}\r\n\r\n// ---- Overriding the prototypes of effect and uniformBuffer's setMatrix functions ----\r\nconst UniformBufferInternal = UniformBuffer as any;\r\nconst EffectInternal = Effect as any;\r\nconst OriginalUpdateMatrixForUniform = UniformBufferInternal.prototype._updateMatrixForUniform;\r\nconst OriginalSetMatrix = Effect.prototype.setMatrix;\r\n\r\nexport function ResetMatrixFunctions() {\r\n Effect.prototype.setMatrix = OriginalSetMatrix;\r\n EffectInternal._setMatrixOverride = undefined;\r\n UniformBufferInternal.prototype._updateMatrixForUniform = OriginalUpdateMatrixForUniform;\r\n UniformBufferInternal.prototype._updateMatrixForUniformOverride = undefined;\r\n}\r\n\r\nexport function OverrideMatrixFunctions() {\r\n EffectInternal.prototype._setMatrixOverride = OriginalSetMatrix;\r\n EffectInternal.prototype.setMatrix = function (uniformName: string, matrix: IMatrixLike) {\r\n this._setMatrixOverride(uniformName, GetOffsetMatrix(uniformName, matrix));\r\n return this;\r\n };\r\n UniformBufferInternal.prototype._updateMatrixForUniformOverride = OriginalUpdateMatrixForUniform;\r\n UniformBufferInternal.prototype._updateMatrixForUniform = function (uniformName: string, matrix: IMatrixLike) {\r\n this._updateMatrixForUniformOverride(uniformName, GetOffsetMatrix(uniformName, mat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,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IACF,qBAAqB,CAAC,SAAS,CAAC,+BAA+B,GAAG,8BAA8B,CAAC;IACjG,qBAAqB,CAAC,SAAS,CAAC,uBAAuB,GAAG,UAAU,WAAmB,EAAE,MAAmB;QACxG,IAAI,CAAC,+BAA+B,CAAC,WAAW,EAAE,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5F,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { Effect } from \"../Materials/effect\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { IMatrixLike, IVector3Like } from \"../Maths/math.like\";\r\nimport { InvertMatrixToRef, MultiplyMatricesToRef } from \"../Maths/ThinMaths/thinMath.matrix.functions\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { UniformBuffer } from \"./uniformBuffer\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nconst TempFinalMat: Matrix = new Matrix();\r\nconst TempMat1: Matrix = new Matrix();\r\nconst TempMat2: Matrix = new Matrix();\r\n\r\n/**\r\n * When rendering, each scene will reset this to ensure the correct floating origin offset is when overriding the below functions\r\n */\r\nexport const FloatingOriginCurrentScene = {\r\n getScene: () => undefined as Scene | undefined,\r\n eyeAtCamera: true, // When true, we can assume viewMatrix translation is at origin. Otherwise, we must do full offset calculations\r\n};\r\n\r\nfunction OffsetWorldToRef(offset: IVector3Like, world: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n const refArray = ref.asArray();\r\n const worldArray = world.asArray();\r\n for (let i = 0; i < 16; i++) {\r\n refArray[i] = worldArray[i];\r\n }\r\n refArray[12] -= offset.x;\r\n refArray[13] -= offset.y;\r\n refArray[14] -= offset.z;\r\n ref.markAsUpdated();\r\n return ref;\r\n}\r\n\r\nfunction GetFullOffsetView(offset: IVector3Like, viewMatrix: DeepImmutable<IMatrixLike>, ref: IMatrixLike) {\r\n InvertMatrixToRef(viewMatrix, TempMat1); // TempMat1 = light world matrix (inverse of view)\r\n OffsetWorldToRef(offset, TempMat1, TempMat2); // TempMat2 = offset light world matrix\r\n InvertMatrixToRef(TempMat2, ref); // TempMat1 = offset view matrix\r\n return ref;\r\n}\r\n\r\nexport function OffsetViewToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n // When eye is not at camera, we cannot assume the translation of view matrix is at origin, so we perform full offset calculation\r\n if (!FloatingOriginCurrentScene.eyeAtCamera) {\r\n return GetFullOffsetView(offset, view, ref);\r\n }\r\n const refArray = ref.asArray();\r\n const viewArray = view.asArray();\r\n for (let i = 0; i < 16; i++) {\r\n refArray[i] = viewArray[i];\r\n }\r\n refArray[12] = 0;\r\n refArray[13] = 0;\r\n refArray[14] = 0;\r\n ref.markAsUpdated();\r\n return ref;\r\n}\r\n\r\nfunction OffsetViewProjectionToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, projection: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n MultiplyMatricesToRef(OffsetViewToRef(offset, view, ref), projection, ref);\r\n return ref;\r\n}\r\n\r\nexport function OffsetClipPlaneToRef(offset: Vector3, plane: Plane, ref: Plane): Plane {\r\n // Original clipplane is using equation normal.dot(p) + d = 0\r\n // Assume we have p' = p - offset, that means normal.dot(p') + d' = 0\r\n // So to get the offset plane,\r\n // normal.dot(p' + offset) + d = 0\r\n // normal.dot(p') + normal.dot(offset) + d = 0\r\n // -d' + normal.dot(offset) + d = 0\r\n // d' = d + normal.dot(offset)\r\n ref.normal.copyFrom(plane.normal);\r\n ref.d = plane.d + Vector3.Dot(plane.normal, offset);\r\n return ref;\r\n}\r\n\r\nexport function GetOffsetTransformMatrices(\r\n offset: IVector3Like,\r\n viewMatrices: Array<Matrix>,\r\n projectionMatrices: Array<Matrix>,\r\n length: number,\r\n resultArray: Float32Array\r\n): Float32Array {\r\n for (let cascadeIndex = 0; cascadeIndex < length; ++cascadeIndex) {\r\n GetFullOffsetViewProjectionToRef(offset, viewMatrices[cascadeIndex], projectionMatrices[cascadeIndex], TempMat1);\r\n TempMat1.copyToArray(resultArray, cascadeIndex * 16);\r\n }\r\n return resultArray;\r\n}\r\n\r\nfunction OffsetWorldViewToRef(offset: IVector3Like, worldView: DeepImmutable<IMatrixLike>, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n // ( world * view ) * inverse ( view ) = world\r\n InvertMatrixToRef(view, TempMat1); // TempMat1 = inverseView\r\n MultiplyMatricesToRef(worldView, TempMat1, TempMat2); // TempMat2 = world, TempMat1 can be reused\r\n\r\n // ( offsetWorld * offsetView ) = offsetWorldView\r\n OffsetWorldToRef(offset, TempMat2, TempMat1); // TempMat1 = offsetWorld\r\n OffsetViewToRef(offset, view, TempMat2); // TempMat2 = offsetView\r\n MultiplyMatricesToRef(TempMat1, TempMat2, ref);\r\n\r\n return ref;\r\n}\r\n\r\nexport function GetFullOffsetViewProjectionToRef(\r\n offset: IVector3Like,\r\n viewMatrix: DeepImmutable<IMatrixLike>,\r\n projectionMatrix: DeepImmutable<IMatrixLike>,\r\n ref: IMatrixLike\r\n): DeepImmutable<IMatrixLike> {\r\n GetFullOffsetView(offset, viewMatrix, TempMat2);\r\n MultiplyMatricesToRef(TempMat2, projectionMatrix, ref);\r\n return ref;\r\n}\r\n\r\nfunction OffsetWorldViewProjectionToRef(\r\n offset: IVector3Like,\r\n worldViewProjection: DeepImmutable<IMatrixLike>,\r\n viewProjection: DeepImmutable<IMatrixLike>,\r\n view: DeepImmutable<IMatrixLike>,\r\n projection: DeepImmutable<IMatrixLike>,\r\n ref: IMatrixLike\r\n): DeepImmutable<IMatrixLike> {\r\n // ( world * view * projection ) * inverse(projection) * inverse(view) = world\r\n // ( world * view * projection ) * inverse (view * projection) = world\r\n InvertMatrixToRef(viewProjection, TempMat1); // TempMat1 = inverse (view * projection)\r\n MultiplyMatricesToRef(worldViewProjection, TempMat1, TempMat2); // TempMat2 = world, TempMat1 can be reused\r\n\r\n // ( offsetWorld * offsetViewProjection) = offsetWorldViewProjection\r\n OffsetWorldToRef(offset, TempMat2, TempMat1); // TempMat1 = offsetWorld\r\n OffsetViewProjectionToRef(offset, view, projection, TempMat2); // TempMat2 = offsetViewProjection\r\n MultiplyMatricesToRef(TempMat1, TempMat2, ref);\r\n\r\n return ref;\r\n}\r\n\r\nfunction GetOffsetMatrix(uniformName: string, mat: IMatrixLike): IMatrixLike {\r\n const scene = FloatingOriginCurrentScene.getScene();\r\n // Early out for scenes that don't have floatingOriginMode enabled\r\n // Effect.setMatrix will call pipelineContext.setMatrix. In WebGPU, this will in turn call ubo.updateMatrix. To avoid double offset, early out if mat is TempFinalMat\r\n if (!scene || TempFinalMat === mat) {\r\n return mat;\r\n }\r\n TempFinalMat.updateFlag = mat.updateFlag;\r\n const offset = scene.floatingOriginOffset;\r\n switch (uniformName) {\r\n case \"world\":\r\n return OffsetWorldToRef(offset, mat, TempFinalMat);\r\n case \"view\":\r\n return OffsetViewToRef(offset, mat, TempFinalMat);\r\n case \"worldView\":\r\n return OffsetWorldViewToRef(offset, mat, scene.getViewMatrix(), TempFinalMat);\r\n case \"viewProjection\":\r\n return OffsetViewProjectionToRef(offset, scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n case \"worldViewProjection\":\r\n return OffsetWorldViewProjectionToRef(offset, mat, scene.getTransformMatrix(), scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n default:\r\n // Node material blocks uniforms are formatted u_BlockName, with trailing numbers if there are multiple blocks of the same name\r\n // Check u_ first so that we can early out for non-node material uniforms\r\n if (uniformName.startsWith(\"u_\")) {\r\n if (uniformName.startsWith(\"u_WorldViewProjection\")) {\r\n return OffsetWorldViewProjectionToRef(offset, mat, scene.getTransformMatrix(), scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n }\r\n if (uniformName.startsWith(\"u_ViewProjection\")) {\r\n return OffsetViewProjectionToRef(offset, scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n }\r\n if (uniformName.startsWith(\"u_WorldView\")) {\r\n return OffsetWorldViewToRef(offset, mat, scene.getViewMatrix(), TempFinalMat);\r\n }\r\n if (uniformName.startsWith(\"u_World\")) {\r\n return OffsetWorldToRef(offset, mat, TempFinalMat);\r\n }\r\n if (uniformName.startsWith(\"u_View\")) {\r\n return OffsetViewToRef(offset, mat, TempFinalMat);\r\n }\r\n }\r\n return mat;\r\n }\r\n}\r\n\r\n// ---- Overriding the prototypes of effect and uniformBuffer's setMatrix functions ----\r\nconst UniformBufferInternal = UniformBuffer as any;\r\nconst EffectInternal = Effect as any;\r\nconst OriginalUpdateMatrixForUniform = UniformBufferInternal.prototype._updateMatrixForUniform;\r\nconst OriginalSetMatrix = Effect.prototype.setMatrix;\r\n\r\nexport function ResetMatrixFunctions() {\r\n Effect.prototype.setMatrix = OriginalSetMatrix;\r\n EffectInternal._setMatrixOverride = undefined;\r\n UniformBufferInternal.prototype._updateMatrixForUniform = OriginalUpdateMatrixForUniform;\r\n UniformBufferInternal.prototype._updateMatrixForUniformOverride = undefined;\r\n}\r\n\r\nexport function OverrideMatrixFunctions() {\r\n EffectInternal.prototype._setMatrixOverride = OriginalSetMatrix;\r\n EffectInternal.prototype.setMatrix = function (uniformName: string, matrix: IMatrixLike) {\r\n this._setMatrixOverride(uniformName, GetOffsetMatrix(uniformName, matrix));\r\n return this;\r\n };\r\n UniformBufferInternal.prototype._updateMatrixForUniformOverride = OriginalUpdateMatrixForUniform;\r\n UniformBufferInternal.prototype._updateMatrixForUniform = function (uniformName: string, matrix: IMatrixLike) {\r\n this._updateMatrixForUniformOverride(uniformName, GetOffsetMatrix(uniformName, matrix));\r\n };\r\n}\r\n"]}
|
|
@@ -13,6 +13,7 @@ import type { StorageBuffer } from "../Buffers/storageBuffer.js";
|
|
|
13
13
|
import { PushMaterial } from "./pushMaterial.js";
|
|
14
14
|
import type { ExternalTexture } from "./Textures/externalTexture.js";
|
|
15
15
|
import type { IColor3Like, IColor4Like, IVector2Like, IVector3Like, IVector4Like } from "../Maths/math.like.js";
|
|
16
|
+
import type { InternalTexture } from "./Textures/internalTexture.js";
|
|
16
17
|
/**
|
|
17
18
|
* Defines the options associated with the creation of a shader material.
|
|
18
19
|
*/
|
|
@@ -81,6 +82,7 @@ export declare class ShaderMaterial extends PushMaterial {
|
|
|
81
82
|
private _shaderPath;
|
|
82
83
|
private _options;
|
|
83
84
|
private _textures;
|
|
85
|
+
private _internalTextures;
|
|
84
86
|
private _textureArrays;
|
|
85
87
|
private _externalTextures;
|
|
86
88
|
private _floats;
|
|
@@ -172,6 +174,13 @@ export declare class ShaderMaterial extends PushMaterial {
|
|
|
172
174
|
* @returns the material itself allowing "fluent" like uniform updates
|
|
173
175
|
*/
|
|
174
176
|
setTexture(name: string, texture: BaseTexture): ShaderMaterial;
|
|
177
|
+
/**
|
|
178
|
+
* Set an internal texture in the shader.
|
|
179
|
+
* @param name Define the name of the uniform samplers as defined in the shader
|
|
180
|
+
* @param texture Define the texture to bind to this sampler
|
|
181
|
+
* @returns the material itself allowing "fluent" like uniform updates
|
|
182
|
+
*/
|
|
183
|
+
setInternalTexture(name: string, texture: InternalTexture): ShaderMaterial;
|
|
175
184
|
/**
|
|
176
185
|
* Remove a texture from the material.
|
|
177
186
|
* @param name Define the name of the texture to remove
|
|
@@ -10,7 +10,7 @@ import { PushMaterial } from "./pushMaterial.js";
|
|
|
10
10
|
import { EngineStore } from "../Engines/engineStore.js";
|
|
11
11
|
|
|
12
12
|
import { AddClipPlaneUniforms, BindClipPlane, PrepareStringDefinesForClipPlanes } from "./clipPlaneMaterialHelper.js";
|
|
13
|
-
import { BindBonesParameters, BindFogParameters, BindLogDepth, BindMorphTargetParameters, BindSceneUniformBuffer,
|
|
13
|
+
import { BindBonesParameters, BindFogParameters, BindLogDepth, BindMorphTargetParameters, BindSceneUniformBuffer, PrepareDefinesAndAttributesForMorphTargets, PushAttributesForInstances, } from "./materialHelper.functions.js";
|
|
14
14
|
const OnCreatedEffectParameters = { effect: null, subMesh: null };
|
|
15
15
|
/**
|
|
16
16
|
* The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
|
|
@@ -34,6 +34,7 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
34
34
|
constructor(name, scene, shaderPath, options = {}, storeEffectOnSubMeshes = true) {
|
|
35
35
|
super(name, scene, storeEffectOnSubMeshes);
|
|
36
36
|
this._textures = {};
|
|
37
|
+
this._internalTextures = {};
|
|
37
38
|
this._textureArrays = {};
|
|
38
39
|
this._externalTextures = {};
|
|
39
40
|
this._floats = {};
|
|
@@ -149,6 +150,19 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
149
150
|
this._textures[name] = texture;
|
|
150
151
|
return this;
|
|
151
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Set an internal texture in the shader.
|
|
155
|
+
* @param name Define the name of the uniform samplers as defined in the shader
|
|
156
|
+
* @param texture Define the texture to bind to this sampler
|
|
157
|
+
* @returns the material itself allowing "fluent" like uniform updates
|
|
158
|
+
*/
|
|
159
|
+
setInternalTexture(name, texture) {
|
|
160
|
+
if (this._options.samplers.indexOf(name) === -1) {
|
|
161
|
+
this._options.samplers.push(name);
|
|
162
|
+
}
|
|
163
|
+
this._internalTextures[name] = texture;
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
152
166
|
/**
|
|
153
167
|
* Remove a texture from the material.
|
|
154
168
|
* @param name Define the name of the texture to remove
|
|
@@ -626,8 +640,10 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
626
640
|
if (this._options.samplers.indexOf("bakedVertexAnimationTexture") === -1) {
|
|
627
641
|
this._options.samplers.push("bakedVertexAnimationTexture");
|
|
628
642
|
}
|
|
643
|
+
if (useInstances) {
|
|
644
|
+
attribs.push("bakedVertexAnimationSettingsInstanced");
|
|
645
|
+
}
|
|
629
646
|
}
|
|
630
|
-
PrepareAttributesForBakedVertexAnimation(attribs, mesh, defines);
|
|
631
647
|
}
|
|
632
648
|
// Textures
|
|
633
649
|
for (const name in this._textures) {
|
|
@@ -635,6 +651,11 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
635
651
|
return false;
|
|
636
652
|
}
|
|
637
653
|
}
|
|
654
|
+
for (const name in this._internalTextures) {
|
|
655
|
+
if (!this._internalTextures[name].isReady) {
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
638
659
|
// Alpha test
|
|
639
660
|
if (mesh && this.needAlphaTestingForMesh(mesh)) {
|
|
640
661
|
defines.push("#define ALPHATEST");
|
|
@@ -829,6 +850,9 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
829
850
|
for (name in this._textures) {
|
|
830
851
|
effect.setTexture(name, this._textures[name]);
|
|
831
852
|
}
|
|
853
|
+
for (name in this._internalTextures) {
|
|
854
|
+
effect._bindTexture(name, this._internalTextures[name]);
|
|
855
|
+
}
|
|
832
856
|
// Texture arrays
|
|
833
857
|
for (name in this._textureArrays) {
|
|
834
858
|
effect.setTextureArray(name, this._textureArrays[name]);
|
|
@@ -989,6 +1013,12 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
989
1013
|
return true;
|
|
990
1014
|
}
|
|
991
1015
|
}
|
|
1016
|
+
const internalTexture = texture.getInternalTexture();
|
|
1017
|
+
for (const name in this._internalTextures) {
|
|
1018
|
+
if (this._internalTextures[name] === internalTexture) {
|
|
1019
|
+
return true;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
992
1022
|
for (const name in this._textureArrays) {
|
|
993
1023
|
const array = this._textureArrays[name];
|
|
994
1024
|
for (let index = 0; index < array.length; index++) {
|
|
@@ -1027,6 +1057,9 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
1027
1057
|
for (const key in this._textures) {
|
|
1028
1058
|
result.setTexture(key, this._textures[key]);
|
|
1029
1059
|
}
|
|
1060
|
+
for (const key in this._internalTextures) {
|
|
1061
|
+
result.setInternalTexture(key, this._internalTextures[key]);
|
|
1062
|
+
}
|
|
1030
1063
|
// TextureArray
|
|
1031
1064
|
for (const key in this._textureArrays) {
|
|
1032
1065
|
result.setTextureArray(key, this._textureArrays[key]);
|
|
@@ -1141,6 +1174,9 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
1141
1174
|
for (name in this._textures) {
|
|
1142
1175
|
this._textures[name].dispose();
|
|
1143
1176
|
}
|
|
1177
|
+
for (name in this._internalTextures) {
|
|
1178
|
+
this._internalTextures[name].dispose();
|
|
1179
|
+
}
|
|
1144
1180
|
for (name in this._textureArrays) {
|
|
1145
1181
|
const array = this._textureArrays[name];
|
|
1146
1182
|
for (let index = 0; index < array.length; index++) {
|
|
@@ -1149,6 +1185,7 @@ export class ShaderMaterial extends PushMaterial {
|
|
|
1149
1185
|
}
|
|
1150
1186
|
}
|
|
1151
1187
|
this._textures = {};
|
|
1188
|
+
this._internalTextures = {};
|
|
1152
1189
|
super.dispose(forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
|
|
1153
1190
|
}
|
|
1154
1191
|
/**
|