@babylonjs/core 7.2.2 → 7.3.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/Animations/runtimeAnimation.d.ts +1 -0
- package/Animations/runtimeAnimation.js +12 -3
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioEngine.js +2 -2
- package/Audio/audioEngine.js.map +1 -1
- package/Bones/boneLookController.js +3 -0
- package/Bones/boneLookController.js.map +1 -1
- package/Buffers/buffer.d.ts +5 -5
- package/Buffers/buffer.js.map +1 -1
- package/Buffers/storageBuffer.d.ts +2 -2
- package/Buffers/storageBuffer.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
- package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
- package/Compute/computeEffect.d.ts +3 -3
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.d.ts +10 -2
- package/Compute/computeShader.js +53 -35
- package/Compute/computeShader.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.d.ts +2 -2
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/internalDeviceSourceManager.d.ts +4 -4
- package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.d.ts +2 -2
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.alpha.d.ts +10 -0
- package/Engines/AbstractEngine/abstractEngine.alpha.js +29 -0
- package/Engines/AbstractEngine/abstractEngine.alpha.js.map +1 -0
- package/Engines/AbstractEngine/abstractEngine.cubeTexture.d.ts +17 -0
- package/Engines/AbstractEngine/abstractEngine.cubeTexture.js +138 -0
- package/Engines/AbstractEngine/abstractEngine.cubeTexture.js.map +1 -0
- package/Engines/AbstractEngine/abstractEngine.dom.d.ts +61 -0
- package/Engines/AbstractEngine/abstractEngine.dom.js +27 -0
- package/Engines/AbstractEngine/abstractEngine.dom.js.map +1 -0
- package/Engines/AbstractEngine/abstractEngine.loadingScreen.d.ts +30 -0
- package/Engines/AbstractEngine/abstractEngine.loadingScreen.js +48 -0
- package/Engines/AbstractEngine/abstractEngine.loadingScreen.js.map +1 -0
- package/Engines/AbstractEngine/abstractEngine.query.d.ts +122 -0
- package/Engines/AbstractEngine/abstractEngine.query.js +175 -0
- package/Engines/AbstractEngine/abstractEngine.query.js.map +1 -0
- package/Engines/AbstractEngine/abstractEngine.renderPass.d.ts +26 -0
- package/Engines/AbstractEngine/abstractEngine.renderPass.js +29 -0
- package/Engines/AbstractEngine/abstractEngine.renderPass.js.map +1 -0
- package/Engines/AbstractEngine/abstractEngine.states.d.ts +162 -0
- package/Engines/AbstractEngine/abstractEngine.states.js +105 -0
- package/Engines/AbstractEngine/abstractEngine.states.js.map +1 -0
- package/Engines/AbstractEngine/abstractEngine.texture.d.ts +16 -0
- package/Engines/AbstractEngine/abstractEngine.texture.js +11 -0
- package/Engines/AbstractEngine/abstractEngine.texture.js.map +1 -0
- package/Engines/AbstractEngine/index.d.ts +8 -0
- package/Engines/AbstractEngine/index.js +10 -0
- package/Engines/AbstractEngine/index.js.map +1 -0
- package/Engines/Extensions/engine.alpha.d.ts +0 -24
- package/Engines/Extensions/engine.alpha.js +0 -35
- package/Engines/Extensions/engine.alpha.js.map +1 -1
- package/Engines/Extensions/engine.computeShader.d.ts +15 -2
- package/Engines/Extensions/engine.computeShader.js +5 -1
- package/Engines/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/Extensions/engine.cubeTexture.d.ts +0 -8
- package/Engines/Extensions/engine.cubeTexture.js +2 -135
- package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/Extensions/engine.debugging.d.ts +2 -2
- package/Engines/Extensions/engine.debugging.js +5 -5
- package/Engines/Extensions/engine.debugging.js.map +1 -1
- package/Engines/Extensions/engine.dynamicTexture.js +3 -2
- package/Engines/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/Extensions/engine.multiview.js.map +1 -1
- package/Engines/Extensions/engine.query.d.ts +5 -120
- package/Engines/Extensions/engine.query.js +14 -150
- package/Engines/Extensions/engine.query.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +0 -9
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +3 -2
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Processors/iShaderProcessor.d.ts +2 -2
- package/Engines/Processors/iShaderProcessor.js.map +1 -1
- package/Engines/Processors/shaderProcessor.d.ts +3 -3
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js +12 -9
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGL/webGLShaderProcessors.d.ts +2 -2
- package/Engines/WebGL/webGLShaderProcessors.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.alpha.d.ts +35 -0
- package/Engines/WebGPU/Extensions/engine.alpha.js +4 -4
- package/Engines/WebGPU/Extensions/engine.alpha.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.d.ts +9 -0
- package/Engines/WebGPU/Extensions/engine.computeShader.js +13 -2
- package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.d.ts +78 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.d.ts +27 -1
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +3 -3
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.externalTexture.d.ts +16 -0
- package/Engines/WebGPU/Extensions/engine.externalTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +55 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.d.ts +1 -1
- package/Engines/WebGPU/Extensions/engine.query.js +1 -0
- package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.d.ts +185 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.readTexture.d.ts +10 -1
- package/Engines/WebGPU/Extensions/engine.readTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.d.ts +38 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.d.ts +13 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.storageBuffer.d.ts +38 -1
- package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.textureSampler.d.ts +10 -0
- package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.d.ts +14 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.d.ts +2 -2
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +2 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +2 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/abstractEngine.d.ts +1695 -0
- package/Engines/abstractEngine.js +1362 -0
- package/Engines/abstractEngine.js.map +1 -0
- package/Engines/engine.common.d.ts +39 -0
- package/Engines/engine.common.js +226 -0
- package/Engines/engine.common.js.map +1 -0
- package/Engines/engine.d.ts +40 -447
- package/Engines/engine.js +64 -810
- package/Engines/engine.js.map +1 -1
- package/Engines/engineFactory.d.ts +2 -2
- package/Engines/engineFactory.js.map +1 -1
- package/Engines/engineStore.d.ts +4 -4
- package/Engines/engineStore.js.map +1 -1
- package/Engines/index.d.ts +3 -0
- package/Engines/index.js +3 -0
- package/Engines/index.js.map +1 -1
- package/Engines/nativeEngine.d.ts +1 -1
- package/Engines/nativeEngine.js +2 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +2 -2
- package/Engines/nullEngine.js +2 -3
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +3 -3
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +34 -597
- package/Engines/thinEngine.js +85 -1143
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +147 -109
- package/Engines/webgpuEngine.js +249 -162
- package/Engines/webgpuEngine.js.map +1 -1
- package/Instrumentation/engineInstrumentation.d.ts +5 -4
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Layers/effectLayer.d.ts +2 -2
- package/Layers/effectLayer.js +3 -3
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/effectLayerSceneComponent.js.map +1 -1
- package/Layers/glowLayer.js +3 -3
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js +3 -3
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/layerSceneComponent.js.map +1 -1
- package/Loading/loadingScreen.js +2 -2
- package/Loading/loadingScreen.js.map +1 -1
- package/Loading/sceneLoader.d.ts +3 -3
- package/Loading/sceneLoader.js +1 -1
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +6 -6
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +2 -3
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +5 -5
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js +4 -4
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +4 -4
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +8 -7
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +9 -5
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +4 -2
- package/Materials/Node/Blocks/Dual/textureBlock.js +43 -21
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +3 -3
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/derivativeBlock.js +9 -2
- package/Materials/Node/Blocks/Fragment/derivativeBlock.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/fragmentOutputBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +16 -8
- 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 +2 -2
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +3 -3
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +4 -4
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +3 -3
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +4 -4
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/twirlBlock.js +9 -9
- package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.d.ts +6 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +36 -12
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +3 -3
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +9 -9
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +21 -21
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +6 -6
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +5 -0
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock.js +2 -2
- package/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleRampGradientBlock.js +3 -3
- package/Materials/Node/Blocks/Particle/particleRampGradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.js +2 -2
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +5 -5
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +12 -12
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +7 -7
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js +10 -3
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/addBlock.js +2 -1
- package/Materials/Node/Blocks/addBlock.js.map +1 -1
- package/Materials/Node/Blocks/arcTan2Block.js +3 -1
- package/Materials/Node/Blocks/arcTan2Block.js.map +1 -1
- package/Materials/Node/Blocks/clampBlock.js +1 -1
- package/Materials/Node/Blocks/clampBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js +1 -1
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +9 -7
- 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 +18 -12
- 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 +48 -53
- package/Materials/Node/Blocks/curveBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js +1 -1
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/desaturateBlock.js +5 -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 +2 -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 -7
- package/Materials/Node/Blocks/gradientBlock.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 +1 -1
- 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 +2 -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 +1 -1
- 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 +1 -1
- package/Materials/Node/Blocks/remapBlock.js.map +1 -1
- package/Materials/Node/Blocks/replaceColorBlock.js +1 -1
- 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 +1 -1
- package/Materials/Node/Blocks/simplexPerlin3DBlock.js.map +1 -1
- package/Materials/Node/Blocks/smoothStepBlock.js +3 -2
- 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 +2 -1
- package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
- package/Materials/Node/Blocks/transformBlock.js +18 -10
- package/Materials/Node/Blocks/transformBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js +2 -2
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js +30 -27
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorSplitterBlock.js +9 -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 +19 -8
- package/Materials/Node/Blocks/voronoiNoiseBlock.js.map +1 -1
- package/Materials/Node/Blocks/waveBlock.js +3 -3
- package/Materials/Node/Blocks/waveBlock.js.map +1 -1
- package/Materials/Node/Blocks/worleyNoise3DBlock.js +3 -3
- package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +9 -3
- package/Materials/Node/nodeMaterial.js +29 -4
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.d.ts +0 -1
- package/Materials/Node/nodeMaterialBlock.js +6 -6
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +4 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +12 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +35 -3
- package/Materials/Node/nodeMaterialBuildState.js +169 -16
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +18 -4
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +60 -9
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.d.ts +2 -2
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/Loaders/basisTextureLoader.js +2 -2
- package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
- package/Materials/Textures/MultiviewRenderTarget.d.ts +1 -0
- package/Materials/Textures/MultiviewRenderTarget.js +1 -0
- package/Materials/Textures/MultiviewRenderTarget.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +3 -3
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/colorGradingTexture.d.ts +2 -2
- package/Materials/Textures/colorGradingTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.d.ts +3 -2
- package/Materials/Textures/cubeTexture.js +1 -0
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.d.ts +2 -2
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.d.ts +2 -2
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +3 -3
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/rawTexture.d.ts +10 -10
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +4 -4
- package/Materials/Textures/renderTargetTexture.js +4 -4
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.d.ts +2 -2
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/thinTexture.d.ts +3 -3
- package/Materials/Textures/thinTexture.js +1 -1
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Materials/drawWrapper.d.ts +2 -3
- package/Materials/drawWrapper.functions.d.ts +8 -0
- package/Materials/drawWrapper.functions.js +9 -0
- package/Materials/drawWrapper.functions.js.map +1 -0
- package/Materials/drawWrapper.js +0 -3
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.d.ts +4 -5
- package/Materials/effect.js.map +1 -1
- package/Materials/effectRenderer.d.ts +4 -4
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +15 -1
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -2
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +4 -4
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginManager.d.ts +2 -2
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/meshDebugPluginMaterial.js +1 -1
- package/Materials/meshDebugPluginMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +2 -2
- package/Materials/uniformBuffer.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +6 -0
- package/Meshes/Builders/greasedLineBuilder.js +15 -8
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.js +4 -3
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +2 -2
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/geometry.d.ts +2 -2
- package/Meshes/geometry.js +3 -2
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +3 -3
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/subMesh.d.ts +2 -2
- package/Meshes/subMesh.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +2 -2
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/dds.d.ts +3 -2
- package/Misc/dds.js +2 -1
- package/Misc/dds.js.map +1 -1
- package/Misc/dumpTools.d.ts +2 -2
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/fileTools.js +3 -3
- package/Misc/fileTools.js.map +1 -1
- package/Misc/filesInput.d.ts +2 -2
- package/Misc/filesInput.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +8 -2
- package/Misc/khronosTextureContainer2.js +3 -2
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/minMaxReducer.d.ts +2 -2
- package/Misc/minMaxReducer.js.map +1 -1
- package/Misc/screenshotTools.d.ts +6 -6
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.d.ts +7 -7
- package/Misc/tools.functions.d.ts +26 -0
- package/Misc/tools.functions.js +62 -0
- package/Misc/tools.functions.js.map +1 -1
- package/Misc/tools.js.map +1 -1
- package/Misc/videoRecorder.d.ts +3 -3
- package/Misc/videoRecorder.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +2 -2
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/computeShaderParticleSystem.d.ts +2 -2
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +3 -3
- package/Particles/gpuParticleSystem.js +2 -2
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particle.js +1 -1
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.d.ts +3 -3
- package/Particles/particleSystem.js +3 -3
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/particleSystemComponent.d.ts +2 -2
- package/Particles/particleSystemComponent.js +2 -2
- package/Particles/particleSystemComponent.js.map +1 -1
- package/Particles/subEmitter.d.ts +3 -3
- package/Particles/subEmitter.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +2 -2
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/v2/physicsBody.js +3 -3
- package/Physics/v2/physicsBody.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.d.ts +2 -2
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.d.ts +2 -2
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/blackAndWhitePostProcess.d.ts +2 -2
- package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/bloomMergePostProcess.d.ts +2 -2
- package/PostProcesses/bloomMergePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +2 -2
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/chromaticAberrationPostProcess.d.ts +2 -2
- package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.d.ts +2 -2
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.d.ts +2 -2
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/convolutionPostProcess.d.ts +2 -2
- package/PostProcesses/convolutionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.d.ts +2 -2
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldEffect.js +1 -1
- package/PostProcesses/depthOfFieldEffect.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.d.ts +2 -2
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/displayPassPostProcess.d.ts +2 -2
- package/PostProcesses/displayPassPostProcess.js.map +1 -1
- package/PostProcesses/extractHighlightsPostProcess.d.ts +2 -2
- package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/filterPostProcess.d.ts +2 -2
- package/PostProcesses/filterPostProcess.js.map +1 -1
- package/PostProcesses/fxaaPostProcess.d.ts +2 -2
- package/PostProcesses/fxaaPostProcess.js +2 -2
- package/PostProcesses/fxaaPostProcess.js.map +1 -1
- package/PostProcesses/grainPostProcess.d.ts +2 -2
- package/PostProcesses/grainPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.d.ts +2 -2
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.d.ts +2 -2
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/passPostProcess.d.ts +3 -3
- package/PostProcesses/passPostProcess.js +2 -2
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +4 -5
- package/PostProcesses/postProcess.js +3 -3
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/refractionPostProcess.d.ts +2 -2
- package/PostProcesses/refractionPostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.d.ts +2 -2
- package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.d.ts +2 -2
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.d.ts +2 -2
- package/PostProcesses/sharpenPostProcess.js.map +1 -1
- package/PostProcesses/subSurfaceScatteringPostProcess.d.ts +2 -2
- package/PostProcesses/subSurfaceScatteringPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +2 -2
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.d.ts +2 -2
- package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +2 -2
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.d.ts +2 -2
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTextures.d.ts +2 -2
- package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +24 -18
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +19 -3
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +4 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/pbr.fragment.js +7 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/fresnelFunction.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/fresnelFunction.js +13 -0
- package/ShadersWGSL/ShadersInclude/fresnelFunction.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +68 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -0
- package/Sprites/spriteRenderer.d.ts +2 -2
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRImageTracking.js.map +1 -1
- package/XR/features/WebXRLayers.d.ts +2 -2
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.d.ts +1 -1
- package/XR/features/WebXRRawCameraAccess.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.js +1 -3
- package/XR/features/WebXRSpaceWarp.js.map +1 -1
- package/XR/features/WebXRWalkingLocomotion.js.map +1 -1
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/XR/webXRManagedOutputCanvas.d.ts +2 -2
- package/XR/webXRManagedOutputCanvas.js.map +1 -1
- package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
- package/XR/webXRSessionManager.js.map +1 -1
- package/assetContainer.js.map +1 -1
- package/node.d.ts +2 -2
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +3 -3
- package/scene.js.map +1 -1
|
@@ -0,0 +1,1362 @@
|
|
|
1
|
+
import { EngineStore } from "./engineStore.js";
|
|
2
|
+
import { Logger } from "../Misc/logger.js";
|
|
3
|
+
import { Effect } from "../Materials/effect.js";
|
|
4
|
+
import { PerformanceConfigurator } from "./performanceConfigurator.js";
|
|
5
|
+
import { PrecisionDate } from "../Misc/precisionDate.js";
|
|
6
|
+
import { DepthCullingState } from "../States/depthCullingState.js";
|
|
7
|
+
import { StencilStateComposer } from "../States/stencilStateComposer.js";
|
|
8
|
+
import { StencilState } from "../States/stencilState.js";
|
|
9
|
+
import { AlphaState } from "../States/alphaCullingState.js";
|
|
10
|
+
import { _WarnImport } from "../Misc/devTools.js";
|
|
11
|
+
import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture.js";
|
|
12
|
+
import { IsDocumentAvailable, IsNavigatorAvailable, IsWindowObjectExist } from "../Misc/domManagement.js";
|
|
13
|
+
|
|
14
|
+
import { Observable } from "../Misc/observable.js";
|
|
15
|
+
/**
|
|
16
|
+
* Queue a new function into the requested animation frame pool (ie. this function will be executed by the browser (or the javascript engine) for the next frame)
|
|
17
|
+
* @param func - the function to be called
|
|
18
|
+
* @param requester - the object that will request the next frame. Falls back to window.
|
|
19
|
+
* @returns frame number
|
|
20
|
+
*/
|
|
21
|
+
export function QueueNewFrame(func, requester) {
|
|
22
|
+
// Note that there is kind of a typing issue here, as `setTimeout` might return something else than a number (NodeJs returns a NodeJS.Timeout object).
|
|
23
|
+
// Also if the global `requestAnimationFrame`'s returnType is number, `requester.requestPostAnimationFrame` and `requester.requestAnimationFrame` types
|
|
24
|
+
// are `any`.
|
|
25
|
+
if (!IsWindowObjectExist()) {
|
|
26
|
+
if (typeof requestAnimationFrame === "function") {
|
|
27
|
+
return requestAnimationFrame(func);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const { requestAnimationFrame } = requester || window;
|
|
32
|
+
if (typeof requestAnimationFrame === "function") {
|
|
33
|
+
return requestAnimationFrame(func);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// fallback to the global `setTimeout`.
|
|
37
|
+
// In most cases (aka in the browser), `window` is the global object, so instead of calling `window.setTimeout` we could call the global `setTimeout`.
|
|
38
|
+
return setTimeout(func, 16);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The parent class for specialized engines (WebGL, WebGPU)
|
|
42
|
+
*/
|
|
43
|
+
export class AbstractEngine {
|
|
44
|
+
/**
|
|
45
|
+
* Gets the current frame id
|
|
46
|
+
*/
|
|
47
|
+
get frameId() {
|
|
48
|
+
return this._frameId;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets a boolean indicating if the engine runs in WebGPU or not.
|
|
52
|
+
*/
|
|
53
|
+
get isWebGPU() {
|
|
54
|
+
return this._isWebGPU;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
_getShaderProcessor(shaderLanguage) {
|
|
60
|
+
return this._shaderProcessor;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Gets the shader platform name used by the effects.
|
|
64
|
+
*/
|
|
65
|
+
get shaderPlatformName() {
|
|
66
|
+
return this._shaderPlatformName;
|
|
67
|
+
}
|
|
68
|
+
_clearEmptyResources() {
|
|
69
|
+
this._emptyTexture = null;
|
|
70
|
+
this._emptyCubeTexture = null;
|
|
71
|
+
this._emptyTexture3D = null;
|
|
72
|
+
this._emptyTexture2DArray = null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
|
|
76
|
+
* This can provide greater z depth for distant objects.
|
|
77
|
+
*/
|
|
78
|
+
get useReverseDepthBuffer() {
|
|
79
|
+
return this._useReverseDepthBuffer;
|
|
80
|
+
}
|
|
81
|
+
set useReverseDepthBuffer(useReverse) {
|
|
82
|
+
if (useReverse === this._useReverseDepthBuffer) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this._useReverseDepthBuffer = useReverse;
|
|
86
|
+
if (useReverse) {
|
|
87
|
+
this._depthCullingState.depthFunc = 518;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this._depthCullingState.depthFunc = 515;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Enable or disable color writing
|
|
95
|
+
* @param enable defines the state to set
|
|
96
|
+
*/
|
|
97
|
+
setColorWrite(enable) {
|
|
98
|
+
if (enable !== this._colorWrite) {
|
|
99
|
+
this._colorWriteChanged = true;
|
|
100
|
+
this._colorWrite = enable;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gets a boolean indicating if color writing is enabled
|
|
105
|
+
* @returns the current color writing state
|
|
106
|
+
*/
|
|
107
|
+
getColorWrite() {
|
|
108
|
+
return this._colorWrite;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets the depth culling state manager
|
|
112
|
+
*/
|
|
113
|
+
get depthCullingState() {
|
|
114
|
+
return this._depthCullingState;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets the alpha state manager
|
|
118
|
+
*/
|
|
119
|
+
get alphaState() {
|
|
120
|
+
return this._alphaState;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Gets the stencil state manager
|
|
124
|
+
*/
|
|
125
|
+
get stencilState() {
|
|
126
|
+
return this._stencilState;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets the stencil state composer
|
|
130
|
+
*/
|
|
131
|
+
get stencilStateComposer() {
|
|
132
|
+
return this._stencilStateComposer;
|
|
133
|
+
}
|
|
134
|
+
/** @internal */
|
|
135
|
+
_getGlobalDefines(defines) {
|
|
136
|
+
if (defines) {
|
|
137
|
+
if (this.isNDCHalfZRange) {
|
|
138
|
+
defines["IS_NDC_HALF_ZRANGE"] = "";
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
delete defines["IS_NDC_HALF_ZRANGE"];
|
|
142
|
+
}
|
|
143
|
+
if (this.useReverseDepthBuffer) {
|
|
144
|
+
defines["USE_REVERSE_DEPTHBUFFER"] = "";
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
delete defines["USE_REVERSE_DEPTHBUFFER"];
|
|
148
|
+
}
|
|
149
|
+
if (this.useExactSrgbConversions) {
|
|
150
|
+
defines["USE_EXACT_SRGB_CONVERSIONS"] = "";
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
delete defines["USE_EXACT_SRGB_CONVERSIONS"];
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
let s = "";
|
|
159
|
+
if (this.isNDCHalfZRange) {
|
|
160
|
+
s += "#define IS_NDC_HALF_ZRANGE";
|
|
161
|
+
}
|
|
162
|
+
if (this.useReverseDepthBuffer) {
|
|
163
|
+
if (s) {
|
|
164
|
+
s += "\n";
|
|
165
|
+
}
|
|
166
|
+
s += "#define USE_REVERSE_DEPTHBUFFER";
|
|
167
|
+
}
|
|
168
|
+
if (this.useExactSrgbConversions) {
|
|
169
|
+
if (s) {
|
|
170
|
+
s += "\n";
|
|
171
|
+
}
|
|
172
|
+
s += "#define USE_EXACT_SRGB_CONVERSIONS";
|
|
173
|
+
}
|
|
174
|
+
return s;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
_rebuildInternalTextures() {
|
|
178
|
+
const currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
|
|
179
|
+
for (const internalTexture of currentState) {
|
|
180
|
+
internalTexture._rebuild();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
_rebuildRenderTargetWrappers() {
|
|
184
|
+
const currentState = this._renderTargetWrapperCache.slice(); // Do a copy because the rebuild will add proxies
|
|
185
|
+
for (const renderTargetWrapper of currentState) {
|
|
186
|
+
renderTargetWrapper._rebuild();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
_rebuildEffects() {
|
|
190
|
+
for (const key in this._compiledEffects) {
|
|
191
|
+
const effect = this._compiledEffects[key];
|
|
192
|
+
effect._pipelineContext = null; // because _prepareEffect will try to dispose this pipeline before recreating it and that would lead to webgl errors
|
|
193
|
+
effect._prepareEffect();
|
|
194
|
+
}
|
|
195
|
+
Effect.ResetCache();
|
|
196
|
+
}
|
|
197
|
+
_rebuildGraphicsResources() {
|
|
198
|
+
// Ensure webgl and engine states are matching
|
|
199
|
+
this.wipeCaches(true);
|
|
200
|
+
// Rebuild effects
|
|
201
|
+
this._rebuildEffects();
|
|
202
|
+
this._rebuildComputeEffects?.();
|
|
203
|
+
// Note:
|
|
204
|
+
// The call to _rebuildBuffers must be made before the call to _rebuildInternalTextures because in the process of _rebuildBuffers the buffers used by the post process managers will be rebuilt
|
|
205
|
+
// and we may need to use the post process manager of the scene during _rebuildInternalTextures (in WebGL1, non-POT textures are rescaled using a post process + post process manager of the scene)
|
|
206
|
+
// Rebuild buffers
|
|
207
|
+
this._rebuildBuffers();
|
|
208
|
+
// Rebuild textures
|
|
209
|
+
this._rebuildInternalTextures();
|
|
210
|
+
// Rebuild textures
|
|
211
|
+
this._rebuildTextures();
|
|
212
|
+
// Rebuild textures
|
|
213
|
+
this._rebuildRenderTargetWrappers();
|
|
214
|
+
// Reset engine states after all the buffer/textures/... have been rebuilt
|
|
215
|
+
this.wipeCaches(true);
|
|
216
|
+
}
|
|
217
|
+
_flagContextRestored() {
|
|
218
|
+
Logger.Warn(this.name + " context successfully restored.");
|
|
219
|
+
this.onContextRestoredObservable.notifyObservers(this);
|
|
220
|
+
this._contextWasLost = false;
|
|
221
|
+
}
|
|
222
|
+
_restoreEngineAfterContextLost(initEngine) {
|
|
223
|
+
// Adding a timeout to avoid race condition at browser level
|
|
224
|
+
setTimeout(async () => {
|
|
225
|
+
this._clearEmptyResources();
|
|
226
|
+
const depthTest = this._depthCullingState.depthTest; // backup those values because the call to initEngine / wipeCaches will reset them
|
|
227
|
+
const depthFunc = this._depthCullingState.depthFunc;
|
|
228
|
+
const depthMask = this._depthCullingState.depthMask;
|
|
229
|
+
const stencilTest = this._stencilState.stencilTest;
|
|
230
|
+
// Rebuild context
|
|
231
|
+
await initEngine();
|
|
232
|
+
this._rebuildGraphicsResources();
|
|
233
|
+
this._depthCullingState.depthTest = depthTest;
|
|
234
|
+
this._depthCullingState.depthFunc = depthFunc;
|
|
235
|
+
this._depthCullingState.depthMask = depthMask;
|
|
236
|
+
this._stencilState.stencilTest = stencilTest;
|
|
237
|
+
this._flagContextRestored();
|
|
238
|
+
}, 0);
|
|
239
|
+
}
|
|
240
|
+
/** Gets a boolean indicating if the engine was disposed */
|
|
241
|
+
get isDisposed() {
|
|
242
|
+
return this._isDisposed;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Enables or disables the snapshot rendering mode
|
|
246
|
+
* Note that the WebGL engine does not support snapshot rendering so setting the value won't have any effect for this engine
|
|
247
|
+
*/
|
|
248
|
+
get snapshotRendering() {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
set snapshotRendering(activate) {
|
|
252
|
+
// Do nothing
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Gets or sets the snapshot rendering mode
|
|
256
|
+
*/
|
|
257
|
+
get snapshotRenderingMode() {
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
set snapshotRenderingMode(mode) { }
|
|
261
|
+
/**
|
|
262
|
+
* Returns the string "AbstractEngine"
|
|
263
|
+
* @returns "AbstractEngine"
|
|
264
|
+
*/
|
|
265
|
+
getClassName() {
|
|
266
|
+
return "AbstractEngine";
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Gets the default empty texture
|
|
270
|
+
*/
|
|
271
|
+
get emptyTexture() {
|
|
272
|
+
if (!this._emptyTexture) {
|
|
273
|
+
this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, 5, false, false, 1);
|
|
274
|
+
}
|
|
275
|
+
return this._emptyTexture;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Gets the default empty 3D texture
|
|
279
|
+
*/
|
|
280
|
+
get emptyTexture3D() {
|
|
281
|
+
if (!this._emptyTexture3D) {
|
|
282
|
+
this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, 5, false, false, 1);
|
|
283
|
+
}
|
|
284
|
+
return this._emptyTexture3D;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Gets the default empty 2D array texture
|
|
288
|
+
*/
|
|
289
|
+
get emptyTexture2DArray() {
|
|
290
|
+
if (!this._emptyTexture2DArray) {
|
|
291
|
+
this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, 5, false, false, 1);
|
|
292
|
+
}
|
|
293
|
+
return this._emptyTexture2DArray;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Gets the default empty cube texture
|
|
297
|
+
*/
|
|
298
|
+
get emptyCubeTexture() {
|
|
299
|
+
if (!this._emptyCubeTexture) {
|
|
300
|
+
const faceData = new Uint8Array(4);
|
|
301
|
+
const cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
|
|
302
|
+
this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, 5, 0, false, false, 1);
|
|
303
|
+
}
|
|
304
|
+
return this._emptyCubeTexture;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Gets the list of current active render loop functions
|
|
308
|
+
* @returns a read only array with the current render loop functions
|
|
309
|
+
*/
|
|
310
|
+
get activeRenderLoops() {
|
|
311
|
+
return this._activeRenderLoops;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* stop executing a render loop function and remove it from the execution array
|
|
315
|
+
* @param renderFunction defines the function to be removed. If not provided all functions will be removed.
|
|
316
|
+
*/
|
|
317
|
+
stopRenderLoop(renderFunction) {
|
|
318
|
+
if (!renderFunction) {
|
|
319
|
+
this._activeRenderLoops.length = 0;
|
|
320
|
+
this._cancelFrame();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const index = this._activeRenderLoops.indexOf(renderFunction);
|
|
324
|
+
if (index >= 0) {
|
|
325
|
+
this._activeRenderLoops.splice(index, 1);
|
|
326
|
+
if (this._activeRenderLoops.length == 0) {
|
|
327
|
+
this._cancelFrame();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
_cancelFrame() {
|
|
332
|
+
if (this._frameHandler !== 0) {
|
|
333
|
+
const handlerToCancel = this._frameHandler;
|
|
334
|
+
this._frameHandler = 0;
|
|
335
|
+
if (!IsWindowObjectExist()) {
|
|
336
|
+
if (typeof cancelAnimationFrame === "function") {
|
|
337
|
+
return cancelAnimationFrame(handlerToCancel);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
const { cancelAnimationFrame } = this.getHostWindow() || window;
|
|
342
|
+
if (typeof cancelAnimationFrame === "function") {
|
|
343
|
+
return cancelAnimationFrame(handlerToCancel);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return clearTimeout(handlerToCancel);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Begin a new frame
|
|
351
|
+
*/
|
|
352
|
+
beginFrame() {
|
|
353
|
+
this.onBeginFrameObservable.notifyObservers(this);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* End the current frame
|
|
357
|
+
*/
|
|
358
|
+
endFrame() {
|
|
359
|
+
this._frameId++;
|
|
360
|
+
this.onEndFrameObservable.notifyObservers(this);
|
|
361
|
+
}
|
|
362
|
+
/** @internal */
|
|
363
|
+
_renderLoop() {
|
|
364
|
+
this._frameHandler = 0;
|
|
365
|
+
if (!this._contextWasLost) {
|
|
366
|
+
let shouldRender = true;
|
|
367
|
+
if (this._isDisposed || (!this.renderEvenInBackground && this._windowIsBackground)) {
|
|
368
|
+
shouldRender = false;
|
|
369
|
+
}
|
|
370
|
+
if (shouldRender) {
|
|
371
|
+
// Start new frame
|
|
372
|
+
this.beginFrame();
|
|
373
|
+
for (let index = 0; index < this._activeRenderLoops.length; index++) {
|
|
374
|
+
const renderFunction = this._activeRenderLoops[index];
|
|
375
|
+
renderFunction();
|
|
376
|
+
}
|
|
377
|
+
// Present
|
|
378
|
+
this.endFrame();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (this._frameHandler === 0) {
|
|
382
|
+
this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Can be used to override the current requestAnimationFrame requester.
|
|
387
|
+
* @internal
|
|
388
|
+
*/
|
|
389
|
+
_queueNewFrame(bindedRenderFunction, requester) {
|
|
390
|
+
return QueueNewFrame(bindedRenderFunction, requester);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Register and execute a render loop. The engine can have more than one render function
|
|
394
|
+
* @param renderFunction defines the function to continuously execute
|
|
395
|
+
*/
|
|
396
|
+
runRenderLoop(renderFunction) {
|
|
397
|
+
if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
this._activeRenderLoops.push(renderFunction);
|
|
401
|
+
// On the first added function, start the render loop.
|
|
402
|
+
if (this._activeRenderLoops.length === 1 && this._frameHandler === 0) {
|
|
403
|
+
this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Gets a boolean indicating if depth testing is enabled
|
|
408
|
+
* @returns the current state
|
|
409
|
+
*/
|
|
410
|
+
getDepthBuffer() {
|
|
411
|
+
return this._depthCullingState.depthTest;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Enable or disable depth buffering
|
|
415
|
+
* @param enable defines the state to set
|
|
416
|
+
*/
|
|
417
|
+
setDepthBuffer(enable) {
|
|
418
|
+
this._depthCullingState.depthTest = enable;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Set the z offset Factor to apply to current rendering
|
|
422
|
+
* @param value defines the offset to apply
|
|
423
|
+
*/
|
|
424
|
+
setZOffset(value) {
|
|
425
|
+
this._depthCullingState.zOffset = this.useReverseDepthBuffer ? -value : value;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Gets the current value of the zOffset Factor
|
|
429
|
+
* @returns the current zOffset Factor state
|
|
430
|
+
*/
|
|
431
|
+
getZOffset() {
|
|
432
|
+
const zOffset = this._depthCullingState.zOffset;
|
|
433
|
+
return this.useReverseDepthBuffer ? -zOffset : zOffset;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Set the z offset Units to apply to current rendering
|
|
437
|
+
* @param value defines the offset to apply
|
|
438
|
+
*/
|
|
439
|
+
setZOffsetUnits(value) {
|
|
440
|
+
this._depthCullingState.zOffsetUnits = this.useReverseDepthBuffer ? -value : value;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Gets the current value of the zOffset Units
|
|
444
|
+
* @returns the current zOffset Units state
|
|
445
|
+
*/
|
|
446
|
+
getZOffsetUnits() {
|
|
447
|
+
const zOffsetUnits = this._depthCullingState.zOffsetUnits;
|
|
448
|
+
return this.useReverseDepthBuffer ? -zOffsetUnits : zOffsetUnits;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Gets host window
|
|
452
|
+
* @returns the host window object
|
|
453
|
+
*/
|
|
454
|
+
getHostWindow() {
|
|
455
|
+
if (!IsWindowObjectExist()) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
if (this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView) {
|
|
459
|
+
return this._renderingCanvas.ownerDocument.defaultView;
|
|
460
|
+
}
|
|
461
|
+
return window;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* (WebGPU only) True (default) to be in compatibility mode, meaning rendering all existing scenes without artifacts (same rendering than WebGL).
|
|
465
|
+
* Setting the property to false will improve performances but may not work in some scenes if some precautions are not taken.
|
|
466
|
+
* See https://doc.babylonjs.com/setup/support/webGPU/webGPUOptimization/webGPUNonCompatibilityMode for more details
|
|
467
|
+
*/
|
|
468
|
+
get compatibilityMode() {
|
|
469
|
+
return this._compatibilityMode;
|
|
470
|
+
}
|
|
471
|
+
set compatibilityMode(mode) {
|
|
472
|
+
// not supported in WebGL
|
|
473
|
+
this._compatibilityMode = true;
|
|
474
|
+
}
|
|
475
|
+
_rebuildTextures() {
|
|
476
|
+
for (const scene of this.scenes) {
|
|
477
|
+
scene._rebuildTextures();
|
|
478
|
+
}
|
|
479
|
+
for (const scene of this._virtualScenes) {
|
|
480
|
+
scene._rebuildTextures();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* @internal
|
|
485
|
+
*/
|
|
486
|
+
_releaseRenderTargetWrapper(rtWrapper) {
|
|
487
|
+
const index = this._renderTargetWrapperCache.indexOf(rtWrapper);
|
|
488
|
+
if (index !== -1) {
|
|
489
|
+
this._renderTargetWrapperCache.splice(index, 1);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Gets the current viewport
|
|
494
|
+
*/
|
|
495
|
+
get currentViewport() {
|
|
496
|
+
return this._cachedViewport;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Set the WebGL's viewport
|
|
500
|
+
* @param viewport defines the viewport element to be used
|
|
501
|
+
* @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
|
|
502
|
+
* @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
|
|
503
|
+
*/
|
|
504
|
+
setViewport(viewport, requiredWidth, requiredHeight) {
|
|
505
|
+
const width = requiredWidth || this.getRenderWidth();
|
|
506
|
+
const height = requiredHeight || this.getRenderHeight();
|
|
507
|
+
const x = viewport.x || 0;
|
|
508
|
+
const y = viewport.y || 0;
|
|
509
|
+
this._cachedViewport = viewport;
|
|
510
|
+
this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Create an image to use with canvas
|
|
514
|
+
* @returns IImage interface
|
|
515
|
+
*/
|
|
516
|
+
createCanvasImage() {
|
|
517
|
+
return document.createElement("img");
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Returns a string describing the current engine
|
|
521
|
+
*/
|
|
522
|
+
get description() {
|
|
523
|
+
let description = this.name + this.version;
|
|
524
|
+
if (this._caps.parallelShaderCompile) {
|
|
525
|
+
description += " - Parallel shader compilation";
|
|
526
|
+
}
|
|
527
|
+
return description;
|
|
528
|
+
}
|
|
529
|
+
_createTextureBase(url, noMipmap, invertY, scene, samplingMode = 3, onLoad = null, onError = null, prepareTexture, prepareTextureProcessFunction, buffer = null, fallback = null, format = null, forcedExtension = null, mimeType, loaderOptions, useSRGBBuffer) {
|
|
530
|
+
url = url || "";
|
|
531
|
+
const fromData = url.substr(0, 5) === "data:";
|
|
532
|
+
const fromBlob = url.substr(0, 5) === "blob:";
|
|
533
|
+
const isBase64 = fromData && url.indexOf(";base64,") !== -1;
|
|
534
|
+
const texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Url);
|
|
535
|
+
if (texture !== fallback) {
|
|
536
|
+
texture.label = url.substring(0, 60); // default label, can be overriden by the caller
|
|
537
|
+
}
|
|
538
|
+
const originalUrl = url;
|
|
539
|
+
if (this._transformTextureUrl && !isBase64 && !fallback && !buffer) {
|
|
540
|
+
url = this._transformTextureUrl(url);
|
|
541
|
+
}
|
|
542
|
+
if (originalUrl !== url) {
|
|
543
|
+
texture._originalUrl = originalUrl;
|
|
544
|
+
}
|
|
545
|
+
// establish the file extension, if possible
|
|
546
|
+
const lastDot = url.lastIndexOf(".");
|
|
547
|
+
let extension = forcedExtension ? forcedExtension : lastDot > -1 ? url.substring(lastDot).toLowerCase() : "";
|
|
548
|
+
let loader = null;
|
|
549
|
+
// Remove query string
|
|
550
|
+
const queryStringIndex = extension.indexOf("?");
|
|
551
|
+
if (queryStringIndex > -1) {
|
|
552
|
+
extension = extension.split("?")[0];
|
|
553
|
+
}
|
|
554
|
+
for (const availableLoader of AbstractEngine._TextureLoaders) {
|
|
555
|
+
if (availableLoader.canLoad(extension, mimeType)) {
|
|
556
|
+
loader = availableLoader;
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (scene) {
|
|
561
|
+
scene.addPendingData(texture);
|
|
562
|
+
}
|
|
563
|
+
texture.url = url;
|
|
564
|
+
texture.generateMipMaps = !noMipmap;
|
|
565
|
+
texture.samplingMode = samplingMode;
|
|
566
|
+
texture.invertY = invertY;
|
|
567
|
+
texture._useSRGBBuffer = this._getUseSRGBBuffer(!!useSRGBBuffer, noMipmap);
|
|
568
|
+
if (!this._doNotHandleContextLost) {
|
|
569
|
+
// Keep a link to the buffer only if we plan to handle context lost
|
|
570
|
+
texture._buffer = buffer;
|
|
571
|
+
}
|
|
572
|
+
let onLoadObserver = null;
|
|
573
|
+
if (onLoad && !fallback) {
|
|
574
|
+
onLoadObserver = texture.onLoadedObservable.add(onLoad);
|
|
575
|
+
}
|
|
576
|
+
if (!fallback) {
|
|
577
|
+
this._internalTexturesCache.push(texture);
|
|
578
|
+
}
|
|
579
|
+
const onInternalError = (message, exception) => {
|
|
580
|
+
if (scene) {
|
|
581
|
+
scene.removePendingData(texture);
|
|
582
|
+
}
|
|
583
|
+
if (url === originalUrl) {
|
|
584
|
+
if (onLoadObserver) {
|
|
585
|
+
texture.onLoadedObservable.remove(onLoadObserver);
|
|
586
|
+
}
|
|
587
|
+
if (EngineStore.UseFallbackTexture && url !== EngineStore.FallbackTexture) {
|
|
588
|
+
this._createTextureBase(EngineStore.FallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, onError, prepareTexture, prepareTextureProcessFunction, buffer, texture);
|
|
589
|
+
}
|
|
590
|
+
message = (message || "Unknown error") + (EngineStore.UseFallbackTexture ? " - Fallback texture was used" : "");
|
|
591
|
+
texture.onErrorObservable.notifyObservers({ message, exception });
|
|
592
|
+
if (onError) {
|
|
593
|
+
onError(message, exception);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
// fall back to the original url if the transformed url fails to load
|
|
598
|
+
Logger.Warn(`Failed to load ${url}, falling back to ${originalUrl}`);
|
|
599
|
+
this._createTextureBase(originalUrl, noMipmap, texture.invertY, scene, samplingMode, onLoad, onError, prepareTexture, prepareTextureProcessFunction, buffer, texture, format, forcedExtension, mimeType, loaderOptions, useSRGBBuffer);
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
// processing for non-image formats
|
|
603
|
+
if (loader) {
|
|
604
|
+
const callback = (data) => {
|
|
605
|
+
loader.loadData(data, texture, (width, height, loadMipmap, isCompressed, done, loadFailed) => {
|
|
606
|
+
if (loadFailed) {
|
|
607
|
+
onInternalError("TextureLoader failed to load data");
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
prepareTexture(texture, extension, scene, { width, height }, texture.invertY, !loadMipmap, isCompressed, () => {
|
|
611
|
+
done();
|
|
612
|
+
return false;
|
|
613
|
+
}, samplingMode);
|
|
614
|
+
}
|
|
615
|
+
}, loaderOptions);
|
|
616
|
+
};
|
|
617
|
+
if (!buffer) {
|
|
618
|
+
this._loadFile(url, (data) => callback(new Uint8Array(data)), undefined, scene ? scene.offlineProvider : undefined, true, (request, exception) => {
|
|
619
|
+
onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
if (buffer instanceof ArrayBuffer) {
|
|
624
|
+
callback(new Uint8Array(buffer));
|
|
625
|
+
}
|
|
626
|
+
else if (ArrayBuffer.isView(buffer)) {
|
|
627
|
+
callback(buffer);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
if (onError) {
|
|
631
|
+
onError("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
const onload = (img) => {
|
|
638
|
+
if (fromBlob && !this._doNotHandleContextLost) {
|
|
639
|
+
// We need to store the image if we need to rebuild the texture
|
|
640
|
+
// in case of a webgl context lost
|
|
641
|
+
texture._buffer = img;
|
|
642
|
+
}
|
|
643
|
+
prepareTexture(texture, extension, scene, img, texture.invertY, noMipmap, false, prepareTextureProcessFunction, samplingMode);
|
|
644
|
+
};
|
|
645
|
+
// According to the WebGL spec section 6.10, ImageBitmaps must be inverted on creation.
|
|
646
|
+
// So, we pass imageOrientation to _FileToolsLoadImage() as it may create an ImageBitmap.
|
|
647
|
+
if (!fromData || isBase64) {
|
|
648
|
+
if (buffer && (typeof buffer.decoding === "string" || buffer.close)) {
|
|
649
|
+
onload(buffer);
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
AbstractEngine._FileToolsLoadImage(url || "", onload, onInternalError, scene ? scene.offlineProvider : null, mimeType, texture.invertY && this._features.needsInvertingBitmap ? { imageOrientation: "flipY" } : undefined);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer) || buffer instanceof Blob) {
|
|
656
|
+
AbstractEngine._FileToolsLoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null, mimeType, texture.invertY && this._features.needsInvertingBitmap ? { imageOrientation: "flipY" } : undefined);
|
|
657
|
+
}
|
|
658
|
+
else if (buffer) {
|
|
659
|
+
onload(buffer);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return texture;
|
|
663
|
+
}
|
|
664
|
+
_rebuildBuffers() {
|
|
665
|
+
// Uniforms
|
|
666
|
+
for (const uniformBuffer of this._uniformBuffers) {
|
|
667
|
+
uniformBuffer._rebuildAfterContextLost();
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
/** @internal */
|
|
671
|
+
get _shouldUseHighPrecisionShader() {
|
|
672
|
+
return !!(this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Gets host document
|
|
676
|
+
* @returns the host document object
|
|
677
|
+
*/
|
|
678
|
+
getHostDocument() {
|
|
679
|
+
if (this._renderingCanvas && this._renderingCanvas.ownerDocument) {
|
|
680
|
+
return this._renderingCanvas.ownerDocument;
|
|
681
|
+
}
|
|
682
|
+
return IsDocumentAvailable() ? document : null;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Gets the list of loaded textures
|
|
686
|
+
* @returns an array containing all loaded textures
|
|
687
|
+
*/
|
|
688
|
+
getLoadedTexturesCache() {
|
|
689
|
+
return this._internalTexturesCache;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Clears the list of texture accessible through engine.
|
|
693
|
+
* This can help preventing texture load conflict due to name collision.
|
|
694
|
+
*/
|
|
695
|
+
clearInternalTexturesCache() {
|
|
696
|
+
this._internalTexturesCache.length = 0;
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Gets the object containing all engine capabilities
|
|
700
|
+
* @returns the EngineCapabilities object
|
|
701
|
+
*/
|
|
702
|
+
getCaps() {
|
|
703
|
+
return this._caps;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Reset the texture cache to empty state
|
|
707
|
+
*/
|
|
708
|
+
resetTextureCache() {
|
|
709
|
+
for (const key in this._boundTexturesCache) {
|
|
710
|
+
if (!Object.prototype.hasOwnProperty.call(this._boundTexturesCache, key)) {
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
this._boundTexturesCache[key] = null;
|
|
714
|
+
}
|
|
715
|
+
this._currentTextureChannel = -1;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Gets or sets the name of the engine
|
|
719
|
+
*/
|
|
720
|
+
get name() {
|
|
721
|
+
return this._name;
|
|
722
|
+
}
|
|
723
|
+
set name(value) {
|
|
724
|
+
this._name = value;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Returns the current npm package of the sdk
|
|
728
|
+
*/
|
|
729
|
+
// Not mixed with Version for tooling purpose.
|
|
730
|
+
static get NpmPackage() {
|
|
731
|
+
return "babylonjs@7.3.0";
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Returns the current version of the framework
|
|
735
|
+
*/
|
|
736
|
+
static get Version() {
|
|
737
|
+
return "7.3.0";
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Gets the HTML canvas attached with the current webGL context
|
|
741
|
+
* @returns a HTML canvas
|
|
742
|
+
*/
|
|
743
|
+
getRenderingCanvas() {
|
|
744
|
+
return this._renderingCanvas;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Gets the audio context specified in engine initialization options
|
|
748
|
+
* @returns an Audio Context
|
|
749
|
+
*/
|
|
750
|
+
getAudioContext() {
|
|
751
|
+
return this._audioContext;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Gets the audio destination specified in engine initialization options
|
|
755
|
+
* @returns an audio destination node
|
|
756
|
+
*/
|
|
757
|
+
getAudioDestination() {
|
|
758
|
+
return this._audioDestination;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Defines the hardware scaling level.
|
|
762
|
+
* By default the hardware scaling level is computed from the window device ratio.
|
|
763
|
+
* if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
|
|
764
|
+
* @param level defines the level to use
|
|
765
|
+
*/
|
|
766
|
+
setHardwareScalingLevel(level) {
|
|
767
|
+
this._hardwareScalingLevel = level;
|
|
768
|
+
this.resize();
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Gets the current hardware scaling level.
|
|
772
|
+
* By default the hardware scaling level is computed from the window device ratio.
|
|
773
|
+
* if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
|
|
774
|
+
* @returns a number indicating the current hardware scaling level
|
|
775
|
+
*/
|
|
776
|
+
getHardwareScalingLevel() {
|
|
777
|
+
return this._hardwareScalingLevel;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
|
|
781
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#handling-webgl-context-lost
|
|
782
|
+
*/
|
|
783
|
+
get doNotHandleContextLost() {
|
|
784
|
+
return this._doNotHandleContextLost;
|
|
785
|
+
}
|
|
786
|
+
set doNotHandleContextLost(value) {
|
|
787
|
+
this._doNotHandleContextLost = value;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Returns true if the stencil buffer has been enabled through the creation option of the context.
|
|
791
|
+
*/
|
|
792
|
+
get isStencilEnable() {
|
|
793
|
+
return this._isStencilEnable;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Gets the options used for engine creation
|
|
797
|
+
* @returns EngineOptions object
|
|
798
|
+
*/
|
|
799
|
+
getCreationOptions() {
|
|
800
|
+
return this._creationOptions;
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Creates a new engine
|
|
804
|
+
* @param antialias defines enable antialiasing (default: false)
|
|
805
|
+
* @param options defines further options to be sent to the creation context
|
|
806
|
+
* @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
|
|
807
|
+
*/
|
|
808
|
+
constructor(antialias, options, adaptToDeviceRatio) {
|
|
809
|
+
// States
|
|
810
|
+
/** @internal */
|
|
811
|
+
this._colorWrite = true;
|
|
812
|
+
/** @internal */
|
|
813
|
+
this._colorWriteChanged = true;
|
|
814
|
+
/** @internal */
|
|
815
|
+
this._depthCullingState = new DepthCullingState();
|
|
816
|
+
/** @internal */
|
|
817
|
+
this._stencilStateComposer = new StencilStateComposer();
|
|
818
|
+
/** @internal */
|
|
819
|
+
this._stencilState = new StencilState();
|
|
820
|
+
/** @internal */
|
|
821
|
+
this._alphaState = new AlphaState();
|
|
822
|
+
/** @internal */
|
|
823
|
+
this._alphaMode = 1;
|
|
824
|
+
/** @internal */
|
|
825
|
+
this._alphaEquation = 0;
|
|
826
|
+
/** @internal */
|
|
827
|
+
this._badOS = false;
|
|
828
|
+
/** @internal */
|
|
829
|
+
this._badDesktopOS = false;
|
|
830
|
+
this._compatibilityMode = true;
|
|
831
|
+
/** @internal */
|
|
832
|
+
this._internalTexturesCache = new Array();
|
|
833
|
+
this._activeRequests = new Array();
|
|
834
|
+
/** @internal */
|
|
835
|
+
this._currentRenderTarget = null;
|
|
836
|
+
/** @internal */
|
|
837
|
+
this._boundTexturesCache = {};
|
|
838
|
+
/** @internal */
|
|
839
|
+
this._activeChannel = 0;
|
|
840
|
+
/** @internal */
|
|
841
|
+
this._currentTextureChannel = -1;
|
|
842
|
+
/** @internal */
|
|
843
|
+
this._viewportCached = { x: 0, y: 0, z: 0, w: 0 };
|
|
844
|
+
/** @internal */
|
|
845
|
+
this._isWebGPU = false;
|
|
846
|
+
/**
|
|
847
|
+
* Observable event triggered each time the canvas loses focus
|
|
848
|
+
*/
|
|
849
|
+
this.onCanvasBlurObservable = new Observable();
|
|
850
|
+
/**
|
|
851
|
+
* Observable event triggered each time the canvas gains focus
|
|
852
|
+
*/
|
|
853
|
+
this.onCanvasFocusObservable = new Observable();
|
|
854
|
+
/**
|
|
855
|
+
* Event raised when a new scene is created
|
|
856
|
+
*/
|
|
857
|
+
this.onNewSceneAddedObservable = new Observable();
|
|
858
|
+
/**
|
|
859
|
+
* Observable event triggered each time the rendering canvas is resized
|
|
860
|
+
*/
|
|
861
|
+
this.onResizeObservable = new Observable();
|
|
862
|
+
/**
|
|
863
|
+
* Observable event triggered each time the canvas receives pointerout event
|
|
864
|
+
*/
|
|
865
|
+
this.onCanvasPointerOutObservable = new Observable();
|
|
866
|
+
/**
|
|
867
|
+
* Turn this value on if you want to pause FPS computation when in background
|
|
868
|
+
*/
|
|
869
|
+
this.disablePerformanceMonitorInBackground = false;
|
|
870
|
+
/**
|
|
871
|
+
* Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
|
|
872
|
+
*/
|
|
873
|
+
this.disableVertexArrayObjects = false;
|
|
874
|
+
/** @internal */
|
|
875
|
+
this._frameId = 0;
|
|
876
|
+
/**
|
|
877
|
+
* Gets information about the current host
|
|
878
|
+
*/
|
|
879
|
+
this.hostInformation = {
|
|
880
|
+
isMobile: false,
|
|
881
|
+
};
|
|
882
|
+
/**
|
|
883
|
+
* Gets a boolean indicating if the engine is currently rendering in fullscreen mode
|
|
884
|
+
*/
|
|
885
|
+
this.isFullscreen = false;
|
|
886
|
+
/**
|
|
887
|
+
* Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
|
|
888
|
+
**/
|
|
889
|
+
this.enableOfflineSupport = false;
|
|
890
|
+
/**
|
|
891
|
+
* Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
|
|
892
|
+
**/
|
|
893
|
+
this.disableManifestCheck = false;
|
|
894
|
+
/**
|
|
895
|
+
* Gets or sets a boolean to enable/disable the context menu (right-click) from appearing on the main canvas
|
|
896
|
+
*/
|
|
897
|
+
this.disableContextMenu = true;
|
|
898
|
+
/**
|
|
899
|
+
* Gets or sets the current render pass id
|
|
900
|
+
*/
|
|
901
|
+
this.currentRenderPassId = 0;
|
|
902
|
+
/**
|
|
903
|
+
* Gets a boolean indicating if the pointer is currently locked
|
|
904
|
+
*/
|
|
905
|
+
this.isPointerLock = false;
|
|
906
|
+
/**
|
|
907
|
+
* Gets the list of created postprocesses
|
|
908
|
+
*/
|
|
909
|
+
this.postProcesses = [];
|
|
910
|
+
/** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
|
|
911
|
+
this.canvasTabIndex = 1;
|
|
912
|
+
/** @internal */
|
|
913
|
+
this._contextWasLost = false;
|
|
914
|
+
this._useReverseDepthBuffer = false;
|
|
915
|
+
/**
|
|
916
|
+
* Indicates if the z range in NDC space is 0..1 (value: true) or -1..1 (value: false)
|
|
917
|
+
*/
|
|
918
|
+
this.isNDCHalfZRange = false;
|
|
919
|
+
/**
|
|
920
|
+
* Indicates that the origin of the texture/framebuffer space is the bottom left corner. If false, the origin is top left
|
|
921
|
+
*/
|
|
922
|
+
this.hasOriginBottomLeft = true;
|
|
923
|
+
/** @internal */
|
|
924
|
+
this._renderTargetWrapperCache = new Array();
|
|
925
|
+
/** @internal */
|
|
926
|
+
this._compiledEffects = {};
|
|
927
|
+
/** @internal */
|
|
928
|
+
this._isDisposed = false;
|
|
929
|
+
/**
|
|
930
|
+
* Gets the list of created scenes
|
|
931
|
+
*/
|
|
932
|
+
this.scenes = [];
|
|
933
|
+
/** @internal */
|
|
934
|
+
this._virtualScenes = new Array();
|
|
935
|
+
/**
|
|
936
|
+
* Observable event triggered before each texture is initialized
|
|
937
|
+
*/
|
|
938
|
+
this.onBeforeTextureInitObservable = new Observable();
|
|
939
|
+
/**
|
|
940
|
+
* Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foreground
|
|
941
|
+
*/
|
|
942
|
+
this.renderEvenInBackground = true;
|
|
943
|
+
/**
|
|
944
|
+
* Gets or sets a boolean indicating that cache can be kept between frames
|
|
945
|
+
*/
|
|
946
|
+
this.preventCacheWipeBetweenFrames = false;
|
|
947
|
+
/** @internal */
|
|
948
|
+
this._frameHandler = 0;
|
|
949
|
+
/** @internal */
|
|
950
|
+
this._activeRenderLoops = new Array();
|
|
951
|
+
/** @internal */
|
|
952
|
+
this._windowIsBackground = false;
|
|
953
|
+
/** @internal */
|
|
954
|
+
this._boundRenderFunction = () => this._renderLoop();
|
|
955
|
+
/**
|
|
956
|
+
* Observable raised when the engine is about to compile a shader
|
|
957
|
+
*/
|
|
958
|
+
this.onBeforeShaderCompilationObservable = new Observable();
|
|
959
|
+
/**
|
|
960
|
+
* Observable raised when the engine has just compiled a shader
|
|
961
|
+
*/
|
|
962
|
+
this.onAfterShaderCompilationObservable = new Observable();
|
|
963
|
+
/**
|
|
964
|
+
* Observable raised when the engine begins a new frame
|
|
965
|
+
*/
|
|
966
|
+
this.onBeginFrameObservable = new Observable();
|
|
967
|
+
/**
|
|
968
|
+
* Observable raised when the engine ends the current frame
|
|
969
|
+
*/
|
|
970
|
+
this.onEndFrameObservable = new Observable();
|
|
971
|
+
/** @internal */
|
|
972
|
+
this._transformTextureUrl = null;
|
|
973
|
+
/** @internal */
|
|
974
|
+
this._uniformBuffers = new Array();
|
|
975
|
+
/** @internal */
|
|
976
|
+
this._storageBuffers = new Array();
|
|
977
|
+
this._highPrecisionShadersAllowed = true;
|
|
978
|
+
// Lost context
|
|
979
|
+
/**
|
|
980
|
+
* Observable signaled when a context lost event is raised
|
|
981
|
+
*/
|
|
982
|
+
this.onContextLostObservable = new Observable();
|
|
983
|
+
/**
|
|
984
|
+
* Observable signaled when a context restored event is raised
|
|
985
|
+
*/
|
|
986
|
+
this.onContextRestoredObservable = new Observable();
|
|
987
|
+
/** @internal */
|
|
988
|
+
this._name = "";
|
|
989
|
+
/**
|
|
990
|
+
* Defines whether the engine has been created with the premultipliedAlpha option on or not.
|
|
991
|
+
*/
|
|
992
|
+
this.premultipliedAlpha = true;
|
|
993
|
+
/**
|
|
994
|
+
* If set to true zooming in and out in the browser will rescale the hardware-scaling correctly.
|
|
995
|
+
*/
|
|
996
|
+
this.adaptToDeviceRatio = false;
|
|
997
|
+
/** @internal */
|
|
998
|
+
this._lastDevicePixelRatio = 1.0;
|
|
999
|
+
/** @internal */
|
|
1000
|
+
this._doNotHandleContextLost = false;
|
|
1001
|
+
/**
|
|
1002
|
+
* Gets or sets a boolean indicating if back faces must be culled. If false, front faces are culled instead (true by default)
|
|
1003
|
+
* If non null, this takes precedence over the value from the material
|
|
1004
|
+
*/
|
|
1005
|
+
this.cullBackFaces = null;
|
|
1006
|
+
/** @internal */
|
|
1007
|
+
this._renderPassNames = ["main"];
|
|
1008
|
+
// FPS
|
|
1009
|
+
this._fps = 60;
|
|
1010
|
+
this._deltaTime = 0;
|
|
1011
|
+
// Deterministic lockstepMaxSteps
|
|
1012
|
+
/** @internal */
|
|
1013
|
+
this._deterministicLockstep = false;
|
|
1014
|
+
/** @internal */
|
|
1015
|
+
this._lockstepMaxSteps = 4;
|
|
1016
|
+
/** @internal */
|
|
1017
|
+
this._timeStep = 1 / 60;
|
|
1018
|
+
/**
|
|
1019
|
+
* An event triggered when the engine is disposed.
|
|
1020
|
+
*/
|
|
1021
|
+
this.onDisposeObservable = new Observable();
|
|
1022
|
+
EngineStore.Instances.push(this);
|
|
1023
|
+
this.startTime = PrecisionDate.Now;
|
|
1024
|
+
this._stencilStateComposer.stencilGlobal = this._stencilState;
|
|
1025
|
+
PerformanceConfigurator.SetMatrixPrecision(!!options.useHighPrecisionMatrix);
|
|
1026
|
+
if (IsNavigatorAvailable() && navigator.userAgent) {
|
|
1027
|
+
// Detect if we are running on a faulty buggy OS.
|
|
1028
|
+
this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
|
|
1029
|
+
// Detect if we are running on a faulty buggy desktop OS.
|
|
1030
|
+
this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1031
|
+
}
|
|
1032
|
+
// Save this off for use in resize().
|
|
1033
|
+
this.adaptToDeviceRatio = adaptToDeviceRatio ?? false;
|
|
1034
|
+
options.antialias = antialias ?? options.antialias;
|
|
1035
|
+
options.deterministicLockstep = options.deterministicLockstep ?? false;
|
|
1036
|
+
options.lockstepMaxSteps = options.lockstepMaxSteps ?? 4;
|
|
1037
|
+
options.timeStep = options.timeStep ?? 1 / 60;
|
|
1038
|
+
options.audioEngine = options.audioEngine ?? true;
|
|
1039
|
+
options.stencil = options.stencil ?? true;
|
|
1040
|
+
this._audioContext = options.audioEngineOptions?.audioContext ?? null;
|
|
1041
|
+
this._audioDestination = options.audioEngineOptions?.audioDestination ?? null;
|
|
1042
|
+
this.premultipliedAlpha = options.premultipliedAlpha ?? true;
|
|
1043
|
+
this._doNotHandleContextLost = !!options.doNotHandleContextLost;
|
|
1044
|
+
this._isStencilEnable = options.stencil ? true : false;
|
|
1045
|
+
this.useExactSrgbConversions = options.useExactSrgbConversions ?? false;
|
|
1046
|
+
const devicePixelRatio = IsWindowObjectExist() ? window.devicePixelRatio || 1.0 : 1.0;
|
|
1047
|
+
const limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
|
|
1048
|
+
// Viewport
|
|
1049
|
+
adaptToDeviceRatio = adaptToDeviceRatio || options.adaptToDeviceRatio || false;
|
|
1050
|
+
this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
|
|
1051
|
+
this._lastDevicePixelRatio = devicePixelRatio;
|
|
1052
|
+
this._creationOptions = options;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Resize the view according to the canvas' size
|
|
1056
|
+
* @param forceSetSize true to force setting the sizes of the underlying canvas
|
|
1057
|
+
*/
|
|
1058
|
+
resize(forceSetSize = false) {
|
|
1059
|
+
let width;
|
|
1060
|
+
let height;
|
|
1061
|
+
// Re-query hardware scaling level to handle zoomed-in resizing.
|
|
1062
|
+
if (this.adaptToDeviceRatio) {
|
|
1063
|
+
const devicePixelRatio = IsWindowObjectExist() ? window.devicePixelRatio || 1.0 : 1.0;
|
|
1064
|
+
const changeRatio = this._lastDevicePixelRatio / devicePixelRatio;
|
|
1065
|
+
this._lastDevicePixelRatio = devicePixelRatio;
|
|
1066
|
+
this._hardwareScalingLevel *= changeRatio;
|
|
1067
|
+
}
|
|
1068
|
+
if (IsWindowObjectExist() && IsDocumentAvailable()) {
|
|
1069
|
+
// make sure it is a Node object, and is a part of the document.
|
|
1070
|
+
if (this._renderingCanvas) {
|
|
1071
|
+
const boundingRect = this._renderingCanvas.getBoundingClientRect
|
|
1072
|
+
? this._renderingCanvas.getBoundingClientRect()
|
|
1073
|
+
: {
|
|
1074
|
+
// fallback to last solution in case the function doesn't exist
|
|
1075
|
+
width: this._renderingCanvas.width * this._hardwareScalingLevel,
|
|
1076
|
+
height: this._renderingCanvas.height * this._hardwareScalingLevel,
|
|
1077
|
+
};
|
|
1078
|
+
width = this._renderingCanvas.clientWidth || boundingRect.width || this._renderingCanvas.width || 100;
|
|
1079
|
+
height = this._renderingCanvas.clientHeight || boundingRect.height || this._renderingCanvas.height || 100;
|
|
1080
|
+
}
|
|
1081
|
+
else {
|
|
1082
|
+
width = window.innerWidth;
|
|
1083
|
+
height = window.innerHeight;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
else {
|
|
1087
|
+
width = this._renderingCanvas ? this._renderingCanvas.width : 100;
|
|
1088
|
+
height = this._renderingCanvas ? this._renderingCanvas.height : 100;
|
|
1089
|
+
}
|
|
1090
|
+
this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel, forceSetSize);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Force a specific size of the canvas
|
|
1094
|
+
* @param width defines the new canvas' width
|
|
1095
|
+
* @param height defines the new canvas' height
|
|
1096
|
+
* @param forceSetSize true to force setting the sizes of the underlying canvas
|
|
1097
|
+
* @returns true if the size was changed
|
|
1098
|
+
*/
|
|
1099
|
+
setSize(width, height, forceSetSize = false) {
|
|
1100
|
+
if (!this._renderingCanvas) {
|
|
1101
|
+
return false;
|
|
1102
|
+
}
|
|
1103
|
+
width = width | 0;
|
|
1104
|
+
height = height | 0;
|
|
1105
|
+
if (!forceSetSize && this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
|
|
1106
|
+
return false;
|
|
1107
|
+
}
|
|
1108
|
+
this._renderingCanvas.width = width;
|
|
1109
|
+
this._renderingCanvas.height = height;
|
|
1110
|
+
return true;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Shared initialization across engines types.
|
|
1114
|
+
* @param canvas The canvas associated with this instance of the engine.
|
|
1115
|
+
*/
|
|
1116
|
+
_sharedInit(canvas) {
|
|
1117
|
+
this._renderingCanvas = canvas;
|
|
1118
|
+
}
|
|
1119
|
+
_setupMobileChecks() {
|
|
1120
|
+
if (!(navigator && navigator.userAgent)) {
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
// Function to check if running on mobile device
|
|
1124
|
+
this._checkForMobile = () => {
|
|
1125
|
+
const currentUA = navigator.userAgent;
|
|
1126
|
+
this.hostInformation.isMobile =
|
|
1127
|
+
currentUA.indexOf("Mobile") !== -1 ||
|
|
1128
|
+
// Needed for iOS 13+ detection on iPad (inspired by solution from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios)
|
|
1129
|
+
(currentUA.indexOf("Mac") !== -1 && IsDocumentAvailable() && "ontouchend" in document);
|
|
1130
|
+
};
|
|
1131
|
+
// Set initial isMobile value
|
|
1132
|
+
this._checkForMobile();
|
|
1133
|
+
// Set up event listener to check when window is resized (used to get emulator activation to work properly)
|
|
1134
|
+
if (IsWindowObjectExist()) {
|
|
1135
|
+
window.addEventListener("resize", this._checkForMobile);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* creates and returns a new video element
|
|
1140
|
+
* @param constraints video constraints
|
|
1141
|
+
* @returns video element
|
|
1142
|
+
*/
|
|
1143
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1144
|
+
createVideoElement(constraints) {
|
|
1145
|
+
return document.createElement("video");
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* @internal
|
|
1149
|
+
*/
|
|
1150
|
+
_reportDrawCall(numDrawCalls = 1) {
|
|
1151
|
+
this._drawCalls?.addCount(numDrawCalls, false);
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Gets the current framerate
|
|
1155
|
+
* @returns a number representing the framerate
|
|
1156
|
+
*/
|
|
1157
|
+
getFps() {
|
|
1158
|
+
return this._fps;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Gets the time spent between current and previous frame
|
|
1162
|
+
* @returns a number representing the delta time in ms
|
|
1163
|
+
*/
|
|
1164
|
+
getDeltaTime() {
|
|
1165
|
+
return this._deltaTime;
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Gets a boolean indicating that the engine is running in deterministic lock step mode
|
|
1169
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#deterministic-lockstep
|
|
1170
|
+
* @returns true if engine is in deterministic lock step mode
|
|
1171
|
+
*/
|
|
1172
|
+
isDeterministicLockStep() {
|
|
1173
|
+
return this._deterministicLockstep;
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Gets the max steps when engine is running in deterministic lock step
|
|
1177
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#deterministic-lockstep
|
|
1178
|
+
* @returns the max steps
|
|
1179
|
+
*/
|
|
1180
|
+
getLockstepMaxSteps() {
|
|
1181
|
+
return this._lockstepMaxSteps;
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Returns the time in ms between steps when using deterministic lock step.
|
|
1185
|
+
* @returns time step in (ms)
|
|
1186
|
+
*/
|
|
1187
|
+
getTimeStep() {
|
|
1188
|
+
return this._timeStep * 1000;
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Engine abstraction for loading and creating an image bitmap from a given source string.
|
|
1192
|
+
* @param imageSource source to load the image from.
|
|
1193
|
+
* @param options An object that sets options for the image's extraction.
|
|
1194
|
+
*/
|
|
1195
|
+
_createImageBitmapFromSource(imageSource, options) {
|
|
1196
|
+
throw new Error("createImageBitmapFromSource is not implemented");
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Engine abstraction for createImageBitmap
|
|
1200
|
+
* @param image source for image
|
|
1201
|
+
* @param options An object that sets options for the image's extraction.
|
|
1202
|
+
* @returns ImageBitmap
|
|
1203
|
+
*/
|
|
1204
|
+
createImageBitmap(image, options) {
|
|
1205
|
+
return createImageBitmap(image, options);
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Resize an image and returns the image data as an uint8array
|
|
1209
|
+
* @param image image to resize
|
|
1210
|
+
* @param bufferWidth destination buffer width
|
|
1211
|
+
* @param bufferHeight destination buffer height
|
|
1212
|
+
*/
|
|
1213
|
+
resizeImageBitmap(image, bufferWidth, bufferHeight) {
|
|
1214
|
+
throw new Error("resizeImageBitmap is not implemented");
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Get Font size information
|
|
1218
|
+
* @param font font name
|
|
1219
|
+
*/
|
|
1220
|
+
getFontOffset(font) {
|
|
1221
|
+
throw new Error("getFontOffset is not implemented");
|
|
1222
|
+
}
|
|
1223
|
+
static _CreateCanvas(width, height) {
|
|
1224
|
+
if (typeof document === "undefined") {
|
|
1225
|
+
return new OffscreenCanvas(width, height);
|
|
1226
|
+
}
|
|
1227
|
+
const canvas = document.createElement("canvas");
|
|
1228
|
+
canvas.width = width;
|
|
1229
|
+
canvas.height = height;
|
|
1230
|
+
return canvas;
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Create a canvas. This method is overridden by other engines
|
|
1234
|
+
* @param width width
|
|
1235
|
+
* @param height height
|
|
1236
|
+
* @returns ICanvas interface
|
|
1237
|
+
*/
|
|
1238
|
+
createCanvas(width, height) {
|
|
1239
|
+
return AbstractEngine._CreateCanvas(width, height);
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Loads an image as an HTMLImageElement.
|
|
1243
|
+
* @param input url string, ArrayBuffer, or Blob to load
|
|
1244
|
+
* @param onLoad callback called when the image successfully loads
|
|
1245
|
+
* @param onError callback called when the image fails to load
|
|
1246
|
+
* @param offlineProvider offline provider for caching
|
|
1247
|
+
* @param mimeType optional mime type
|
|
1248
|
+
* @param imageBitmapOptions optional the options to use when creating an ImageBitmap
|
|
1249
|
+
* @returns the HTMLImageElement of the loaded image
|
|
1250
|
+
* @internal
|
|
1251
|
+
*/
|
|
1252
|
+
static _FileToolsLoadImage(input, onLoad, onError, offlineProvider, mimeType, imageBitmapOptions) {
|
|
1253
|
+
throw _WarnImport("FileTools");
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Loads a file from a url
|
|
1257
|
+
* @param url url to load
|
|
1258
|
+
* @param onSuccess callback called when the file successfully loads
|
|
1259
|
+
* @param onProgress callback called while file is loading (if the server supports this mode)
|
|
1260
|
+
* @param offlineProvider defines the offline provider for caching
|
|
1261
|
+
* @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
|
|
1262
|
+
* @param onError callback called when the file fails to load
|
|
1263
|
+
* @returns a file request object
|
|
1264
|
+
* @internal
|
|
1265
|
+
*/
|
|
1266
|
+
static _FileToolsLoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
|
|
1267
|
+
throw _WarnImport("FileTools");
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* @internal
|
|
1271
|
+
*/
|
|
1272
|
+
_loadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
|
|
1273
|
+
const request = AbstractEngine._FileToolsLoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
|
|
1274
|
+
this._activeRequests.push(request);
|
|
1275
|
+
request.onCompleteObservable.add((request) => {
|
|
1276
|
+
this._activeRequests.splice(this._activeRequests.indexOf(request), 1);
|
|
1277
|
+
});
|
|
1278
|
+
return request;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Dispose and release all associated resources
|
|
1282
|
+
*/
|
|
1283
|
+
dispose() {
|
|
1284
|
+
this.hideLoadingUI();
|
|
1285
|
+
this._isDisposed = true;
|
|
1286
|
+
this.stopRenderLoop();
|
|
1287
|
+
// Empty texture
|
|
1288
|
+
if (this._emptyTexture) {
|
|
1289
|
+
this._releaseTexture(this._emptyTexture);
|
|
1290
|
+
this._emptyTexture = null;
|
|
1291
|
+
}
|
|
1292
|
+
if (this._emptyCubeTexture) {
|
|
1293
|
+
this._releaseTexture(this._emptyCubeTexture);
|
|
1294
|
+
this._emptyCubeTexture = null;
|
|
1295
|
+
}
|
|
1296
|
+
this._renderingCanvas = null;
|
|
1297
|
+
// Clear observables
|
|
1298
|
+
if (this.onBeforeTextureInitObservable) {
|
|
1299
|
+
this.onBeforeTextureInitObservable.clear();
|
|
1300
|
+
}
|
|
1301
|
+
// Release postProcesses
|
|
1302
|
+
while (this.postProcesses.length) {
|
|
1303
|
+
this.postProcesses[0].dispose();
|
|
1304
|
+
}
|
|
1305
|
+
// Release scenes
|
|
1306
|
+
while (this.scenes.length) {
|
|
1307
|
+
this.scenes[0].dispose();
|
|
1308
|
+
}
|
|
1309
|
+
while (this._virtualScenes.length) {
|
|
1310
|
+
this._virtualScenes[0].dispose();
|
|
1311
|
+
}
|
|
1312
|
+
// Release effects
|
|
1313
|
+
this.releaseComputeEffects?.();
|
|
1314
|
+
Effect.ResetCache();
|
|
1315
|
+
// Abort active requests
|
|
1316
|
+
for (const request of this._activeRequests) {
|
|
1317
|
+
request.abort();
|
|
1318
|
+
}
|
|
1319
|
+
this._boundRenderFunction = null;
|
|
1320
|
+
this.onDisposeObservable.notifyObservers(this);
|
|
1321
|
+
this.onDisposeObservable.clear();
|
|
1322
|
+
this.onResizeObservable.clear();
|
|
1323
|
+
this.onCanvasBlurObservable.clear();
|
|
1324
|
+
this.onCanvasFocusObservable.clear();
|
|
1325
|
+
this.onCanvasPointerOutObservable.clear();
|
|
1326
|
+
this.onNewSceneAddedObservable.clear();
|
|
1327
|
+
if (IsWindowObjectExist()) {
|
|
1328
|
+
window.removeEventListener("resize", this._checkForMobile);
|
|
1329
|
+
}
|
|
1330
|
+
// Remove from Instances
|
|
1331
|
+
const index = EngineStore.Instances.indexOf(this);
|
|
1332
|
+
if (index >= 0) {
|
|
1333
|
+
EngineStore.Instances.splice(index, 1);
|
|
1334
|
+
}
|
|
1335
|
+
// no more engines left in the engine store? Notify!
|
|
1336
|
+
if (!EngineStore.Instances.length) {
|
|
1337
|
+
EngineStore.OnEnginesDisposedObservable.notifyObservers(this);
|
|
1338
|
+
}
|
|
1339
|
+
// Observables
|
|
1340
|
+
this.onBeginFrameObservable.clear();
|
|
1341
|
+
this.onEndFrameObservable.clear();
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Method called to create the default loading screen.
|
|
1345
|
+
* This can be overridden in your own app.
|
|
1346
|
+
* @param canvas The rendering canvas element
|
|
1347
|
+
*/
|
|
1348
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1349
|
+
static DefaultLoadingScreenFactory(canvas) {
|
|
1350
|
+
throw _WarnImport("LoadingScreen");
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
/** @internal */
|
|
1354
|
+
AbstractEngine._TextureLoaders = [];
|
|
1355
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1356
|
+
/** @internal */
|
|
1357
|
+
AbstractEngine._RenderPassIdCounter = 0;
|
|
1358
|
+
/**
|
|
1359
|
+
* Method called to create the default rescale post process on each engine.
|
|
1360
|
+
*/
|
|
1361
|
+
AbstractEngine._RescalePostProcessFactory = null;
|
|
1362
|
+
//# sourceMappingURL=abstractEngine.js.map
|