@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
package/Engines/thinEngine.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import { EngineStore } from "./engineStore.js";
|
|
3
|
-
import { Effect } from "../Materials/effect.js";
|
|
4
|
-
import { _WarnImport } from "../Misc/devTools.js";
|
|
5
|
-
import { Observable } from "../Misc/observable.js";
|
|
6
|
-
import { DepthCullingState } from "../States/depthCullingState.js";
|
|
7
|
-
import { StencilState } from "../States/stencilState.js";
|
|
8
|
-
import { AlphaState } from "../States/alphaCullingState.js";
|
|
9
|
-
|
|
10
|
-
import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture.js";
|
|
1
|
+
import { IsWrapper } from "../Materials/drawWrapper.functions.js";
|
|
11
2
|
import { Logger } from "../Misc/logger.js";
|
|
12
|
-
import {
|
|
3
|
+
import { IsWindowObjectExist } from "../Misc/domManagement.js";
|
|
13
4
|
import { WebGLShaderProcessor } from "./WebGL/webGLShaderProcessors.js";
|
|
14
5
|
import { WebGL2ShaderProcessor } from "./WebGL/webGL2ShaderProcessors.js";
|
|
15
6
|
import { WebGLDataBuffer } from "../Meshes/WebGL/webGLDataBuffer.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
7
|
+
import { CeilingPOT, FloorPOT, GetExponentOfTwo, NearestPOT } from "../Misc/tools.functions.js";
|
|
8
|
+
import { AbstractEngine, QueueNewFrame } from "./abstractEngine.js";
|
|
9
|
+
|
|
18
10
|
import { WebGLHardwareTexture } from "./WebGL/webGLHardwareTexture.js";
|
|
19
|
-
import { DrawWrapper } from "../Materials/drawWrapper.js";
|
|
20
|
-
import { StencilStateComposer } from "../States/stencilStateComposer.js";
|
|
21
11
|
import { ShaderLanguage } from "../Materials/shaderLanguage.js";
|
|
22
|
-
import {
|
|
12
|
+
import { WebGLPipelineContext } from "./WebGL/webGLPipelineContext.js";
|
|
13
|
+
import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture.js";
|
|
14
|
+
import { Effect } from "../Materials/effect.js";
|
|
15
|
+
import { _WarnImport } from "../Misc/devTools.js";
|
|
23
16
|
/**
|
|
24
17
|
* Keeps track of all the buffer info used in engine.
|
|
25
18
|
*/
|
|
@@ -28,30 +21,7 @@ class BufferPointer {
|
|
|
28
21
|
/**
|
|
29
22
|
* The base engine class (root of all engines)
|
|
30
23
|
*/
|
|
31
|
-
export class ThinEngine {
|
|
32
|
-
/**
|
|
33
|
-
* Returns the current npm package of the sdk
|
|
34
|
-
*/
|
|
35
|
-
// Not mixed with Version for tooling purpose.
|
|
36
|
-
static get NpmPackage() {
|
|
37
|
-
return "babylonjs@7.2.2";
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Returns the current version of the framework
|
|
41
|
-
*/
|
|
42
|
-
static get Version() {
|
|
43
|
-
return "7.2.2";
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Returns a string describing the current engine
|
|
47
|
-
*/
|
|
48
|
-
get description() {
|
|
49
|
-
let description = this.name + this.webGLVersion;
|
|
50
|
-
if (this._caps.parallelShaderCompile) {
|
|
51
|
-
description += " - Parallel shader compilation";
|
|
52
|
-
}
|
|
53
|
-
return description;
|
|
54
|
-
}
|
|
24
|
+
export class ThinEngine extends AbstractEngine {
|
|
55
25
|
/**
|
|
56
26
|
* Gets or sets the name of the engine
|
|
57
27
|
*/
|
|
@@ -67,9 +37,6 @@ export class ThinEngine {
|
|
|
67
37
|
get version() {
|
|
68
38
|
return this._webGLVersion;
|
|
69
39
|
}
|
|
70
|
-
get isDisposed() {
|
|
71
|
-
return this._isDisposed;
|
|
72
|
-
}
|
|
73
40
|
/**
|
|
74
41
|
* Gets or sets the relative url used to load shaders if using the engine in non-minified mode
|
|
75
42
|
*/
|
|
@@ -79,37 +46,6 @@ export class ThinEngine {
|
|
|
79
46
|
static set ShadersRepository(value) {
|
|
80
47
|
Effect.ShadersRepository = value;
|
|
81
48
|
}
|
|
82
|
-
/**
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
_getShaderProcessor(shaderLanguage) {
|
|
86
|
-
return this._shaderProcessor;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
|
|
90
|
-
* This can provide greater z depth for distant objects.
|
|
91
|
-
*/
|
|
92
|
-
get useReverseDepthBuffer() {
|
|
93
|
-
return this._useReverseDepthBuffer;
|
|
94
|
-
}
|
|
95
|
-
set useReverseDepthBuffer(useReverse) {
|
|
96
|
-
if (useReverse === this._useReverseDepthBuffer) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
this._useReverseDepthBuffer = useReverse;
|
|
100
|
-
if (useReverse) {
|
|
101
|
-
this._depthCullingState.depthFunc = 518;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
this._depthCullingState.depthFunc = 515;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Gets the current frame id
|
|
109
|
-
*/
|
|
110
|
-
get frameId() {
|
|
111
|
-
return this._frameId;
|
|
112
|
-
}
|
|
113
49
|
/**
|
|
114
50
|
* Gets a boolean indicating that the engine supports uniform buffers
|
|
115
51
|
* @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets
|
|
@@ -117,17 +53,6 @@ export class ThinEngine {
|
|
|
117
53
|
get supportsUniformBuffers() {
|
|
118
54
|
return this.webGLVersion > 1 && !this.disableUniformBuffers;
|
|
119
55
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Gets the options used for engine creation
|
|
122
|
-
* @returns EngineOptions object
|
|
123
|
-
*/
|
|
124
|
-
getCreationOptions() {
|
|
125
|
-
return this._creationOptions;
|
|
126
|
-
}
|
|
127
|
-
/** @internal */
|
|
128
|
-
get _shouldUseHighPrecisionShader() {
|
|
129
|
-
return !!(this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed);
|
|
130
|
-
}
|
|
131
56
|
/**
|
|
132
57
|
* Gets a boolean indicating that only power of 2 textures are supported
|
|
133
58
|
* Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
|
|
@@ -135,23 +60,6 @@ export class ThinEngine {
|
|
|
135
60
|
get needPOTTextures() {
|
|
136
61
|
return this._webGLVersion < 2 || this.forcePOTTextures;
|
|
137
62
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Gets the list of current active render loop functions
|
|
140
|
-
* @returns a read only array with the current render loop functions
|
|
141
|
-
*/
|
|
142
|
-
get activeRenderLoops() {
|
|
143
|
-
return this._activeRenderLoops;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
|
|
147
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#handling-webgl-context-lost
|
|
148
|
-
*/
|
|
149
|
-
get doNotHandleContextLost() {
|
|
150
|
-
return this._doNotHandleContextLost;
|
|
151
|
-
}
|
|
152
|
-
set doNotHandleContextLost(value) {
|
|
153
|
-
this._doNotHandleContextLost = value;
|
|
154
|
-
}
|
|
155
63
|
get _supportsHardwareTextureRescaling() {
|
|
156
64
|
return false;
|
|
157
65
|
}
|
|
@@ -163,112 +71,12 @@ export class ThinEngine {
|
|
|
163
71
|
set framebufferDimensionsObject(dimensions) {
|
|
164
72
|
this._framebufferDimensionsObject = dimensions;
|
|
165
73
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Gets the current viewport
|
|
168
|
-
*/
|
|
169
|
-
get currentViewport() {
|
|
170
|
-
return this._cachedViewport;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Gets the default empty texture
|
|
174
|
-
*/
|
|
175
|
-
get emptyTexture() {
|
|
176
|
-
if (!this._emptyTexture) {
|
|
177
|
-
this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, 5, false, false, 1);
|
|
178
|
-
}
|
|
179
|
-
return this._emptyTexture;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Gets the default empty 3D texture
|
|
183
|
-
*/
|
|
184
|
-
get emptyTexture3D() {
|
|
185
|
-
if (!this._emptyTexture3D) {
|
|
186
|
-
this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, 5, false, false, 1);
|
|
187
|
-
}
|
|
188
|
-
return this._emptyTexture3D;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Gets the default empty 2D array texture
|
|
192
|
-
*/
|
|
193
|
-
get emptyTexture2DArray() {
|
|
194
|
-
if (!this._emptyTexture2DArray) {
|
|
195
|
-
this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, 5, false, false, 1);
|
|
196
|
-
}
|
|
197
|
-
return this._emptyTexture2DArray;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Gets the default empty cube texture
|
|
201
|
-
*/
|
|
202
|
-
get emptyCubeTexture() {
|
|
203
|
-
if (!this._emptyCubeTexture) {
|
|
204
|
-
const faceData = new Uint8Array(4);
|
|
205
|
-
const cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
|
|
206
|
-
this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, 5, 0, false, false, 1);
|
|
207
|
-
}
|
|
208
|
-
return this._emptyCubeTexture;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Gets a boolean indicating if the engine runs in WebGPU or not.
|
|
212
|
-
*/
|
|
213
|
-
get isWebGPU() {
|
|
214
|
-
return this._isWebGPU;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Gets the shader platform name used by the effects.
|
|
218
|
-
*/
|
|
219
|
-
get shaderPlatformName() {
|
|
220
|
-
return this._shaderPlatformName;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Enables or disables the snapshot rendering mode
|
|
224
|
-
* Note that the WebGL engine does not support snapshot rendering so setting the value won't have any effect for this engine
|
|
225
|
-
*/
|
|
226
|
-
get snapshotRendering() {
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
set snapshotRendering(activate) {
|
|
230
|
-
// WebGL engine does not support snapshot rendering
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Gets or sets the snapshot rendering mode
|
|
234
|
-
*/
|
|
235
|
-
get snapshotRenderingMode() {
|
|
236
|
-
return this._snapshotRenderingMode;
|
|
237
|
-
}
|
|
238
|
-
set snapshotRenderingMode(mode) {
|
|
239
|
-
this._snapshotRenderingMode = mode;
|
|
240
|
-
}
|
|
241
74
|
/**
|
|
242
75
|
* Creates a new snapshot at the next frame using the current snapshotRenderingMode
|
|
243
76
|
*/
|
|
244
77
|
snapshotRenderingReset() {
|
|
245
78
|
this.snapshotRendering = false;
|
|
246
79
|
}
|
|
247
|
-
static _CreateCanvas(width, height) {
|
|
248
|
-
if (typeof document === "undefined") {
|
|
249
|
-
return new OffscreenCanvas(width, height);
|
|
250
|
-
}
|
|
251
|
-
const canvas = document.createElement("canvas");
|
|
252
|
-
canvas.width = width;
|
|
253
|
-
canvas.height = height;
|
|
254
|
-
return canvas;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Create a canvas. This method is overridden by other engines
|
|
258
|
-
* @param width width
|
|
259
|
-
* @param height height
|
|
260
|
-
* @returns ICanvas interface
|
|
261
|
-
*/
|
|
262
|
-
createCanvas(width, height) {
|
|
263
|
-
return ThinEngine._CreateCanvas(width, height);
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Create an image to use with canvas
|
|
267
|
-
* @returns IImage interface
|
|
268
|
-
*/
|
|
269
|
-
createCanvasImage() {
|
|
270
|
-
return document.createElement("img");
|
|
271
|
-
}
|
|
272
80
|
/**
|
|
273
81
|
* Creates a new engine
|
|
274
82
|
* @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which already used the WebGL context
|
|
@@ -277,110 +85,23 @@ export class ThinEngine {
|
|
|
277
85
|
* @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
|
|
278
86
|
*/
|
|
279
87
|
constructor(canvasOrContext, antialias, options, adaptToDeviceRatio) {
|
|
88
|
+
options = options || {};
|
|
89
|
+
super((antialias ?? options.antialias) || false, options, adaptToDeviceRatio);
|
|
280
90
|
/** @internal */
|
|
281
91
|
this._name = "WebGL";
|
|
282
|
-
this._isDisposed = false;
|
|
283
92
|
/**
|
|
284
93
|
* Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
|
|
285
94
|
*/
|
|
286
95
|
this.forcePOTTextures = false;
|
|
287
|
-
/**
|
|
288
|
-
* Gets a boolean indicating if the engine is currently rendering in fullscreen mode
|
|
289
|
-
*/
|
|
290
|
-
this.isFullscreen = false;
|
|
291
|
-
/**
|
|
292
|
-
* Gets or sets a boolean indicating if back faces must be culled. If false, front faces are culled instead (true by default)
|
|
293
|
-
* If non null, this takes precedence over the value from the material
|
|
294
|
-
*/
|
|
295
|
-
this.cullBackFaces = null;
|
|
296
|
-
/**
|
|
297
|
-
* Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foreground
|
|
298
|
-
*/
|
|
299
|
-
this.renderEvenInBackground = true;
|
|
300
|
-
/**
|
|
301
|
-
* Gets or sets a boolean indicating that cache can be kept between frames
|
|
302
|
-
*/
|
|
303
|
-
this.preventCacheWipeBetweenFrames = false;
|
|
304
96
|
/** Gets or sets a boolean indicating if the engine should validate programs after compilation */
|
|
305
97
|
this.validateShaderPrograms = false;
|
|
306
|
-
this._useReverseDepthBuffer = false;
|
|
307
|
-
/**
|
|
308
|
-
* Indicates if the z range in NDC space is 0..1 (value: true) or -1..1 (value: false)
|
|
309
|
-
*/
|
|
310
|
-
this.isNDCHalfZRange = false;
|
|
311
|
-
/**
|
|
312
|
-
* Indicates that the origin of the texture/framebuffer space is the bottom left corner. If false, the origin is top left
|
|
313
|
-
*/
|
|
314
|
-
this.hasOriginBottomLeft = true;
|
|
315
98
|
/**
|
|
316
99
|
* Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
|
|
317
100
|
*/
|
|
318
101
|
this.disableUniformBuffers = false;
|
|
319
|
-
/**
|
|
320
|
-
* An event triggered when the engine is disposed.
|
|
321
|
-
*/
|
|
322
|
-
this.onDisposeObservable = new Observable();
|
|
323
|
-
this._frameId = 0;
|
|
324
|
-
/** @internal */
|
|
325
|
-
this._uniformBuffers = new Array();
|
|
326
|
-
/** @internal */
|
|
327
|
-
this._storageBuffers = new Array();
|
|
328
102
|
/** @internal */
|
|
329
103
|
this._webGLVersion = 1.0;
|
|
330
|
-
this._windowIsBackground = false;
|
|
331
|
-
this._highPrecisionShadersAllowed = true;
|
|
332
|
-
/** @internal */
|
|
333
|
-
this._badOS = false;
|
|
334
|
-
/** @internal */
|
|
335
|
-
this._badDesktopOS = false;
|
|
336
|
-
this._activeRenderLoops = new Array();
|
|
337
|
-
// Lost context
|
|
338
|
-
/**
|
|
339
|
-
* Observable signaled when a context lost event is raised
|
|
340
|
-
*/
|
|
341
|
-
this.onContextLostObservable = new Observable();
|
|
342
|
-
/**
|
|
343
|
-
* Observable signaled when a context restored event is raised
|
|
344
|
-
*/
|
|
345
|
-
this.onContextRestoredObservable = new Observable();
|
|
346
|
-
this._contextWasLost = false;
|
|
347
|
-
/** @internal */
|
|
348
|
-
this._doNotHandleContextLost = false;
|
|
349
|
-
/**
|
|
350
|
-
* Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
|
|
351
|
-
*/
|
|
352
|
-
this.disableVertexArrayObjects = false;
|
|
353
|
-
// States
|
|
354
|
-
/** @internal */
|
|
355
|
-
this._colorWrite = true;
|
|
356
|
-
/** @internal */
|
|
357
|
-
this._colorWriteChanged = true;
|
|
358
|
-
/** @internal */
|
|
359
|
-
this._depthCullingState = new DepthCullingState();
|
|
360
|
-
/** @internal */
|
|
361
|
-
this._stencilStateComposer = new StencilStateComposer();
|
|
362
|
-
/** @internal */
|
|
363
|
-
this._stencilState = new StencilState();
|
|
364
|
-
/** @internal */
|
|
365
|
-
this._alphaState = new AlphaState();
|
|
366
|
-
/** @internal */
|
|
367
|
-
this._alphaMode = 1;
|
|
368
|
-
/** @internal */
|
|
369
|
-
this._alphaEquation = 0;
|
|
370
|
-
// Cache
|
|
371
|
-
/** @internal */
|
|
372
|
-
this._internalTexturesCache = new Array();
|
|
373
|
-
/** @internal */
|
|
374
|
-
this._renderTargetWrapperCache = new Array();
|
|
375
|
-
/** @internal */
|
|
376
|
-
this._activeChannel = 0;
|
|
377
|
-
this._currentTextureChannel = -1;
|
|
378
|
-
/** @internal */
|
|
379
|
-
this._boundTexturesCache = {};
|
|
380
|
-
this._compiledEffects = {};
|
|
381
104
|
this._vertexAttribArraysEnabled = [];
|
|
382
|
-
/** @internal */
|
|
383
|
-
this._currentRenderTarget = null;
|
|
384
105
|
this._uintIndicesCurrentlySet = false;
|
|
385
106
|
this._currentBoundBuffer = new Array();
|
|
386
107
|
/** @internal */
|
|
@@ -390,42 +111,11 @@ export class ThinEngine {
|
|
|
390
111
|
this._currentBufferPointers = new Array();
|
|
391
112
|
this._currentInstanceLocations = new Array();
|
|
392
113
|
this._currentInstanceBuffers = new Array();
|
|
393
|
-
/** @internal */
|
|
394
|
-
this._boundRenderFunction = () => this._renderLoop();
|
|
395
114
|
this._vaoRecordInProgress = false;
|
|
396
115
|
this._mustWipeVertexAttributes = false;
|
|
397
|
-
/** @internal */
|
|
398
|
-
this._frameHandler = 0;
|
|
399
116
|
this._nextFreeTextureSlots = new Array();
|
|
400
117
|
this._maxSimultaneousTextures = 0;
|
|
401
118
|
this._maxMSAASamplesOverride = null;
|
|
402
|
-
this._activeRequests = new Array();
|
|
403
|
-
/**
|
|
404
|
-
* If set to true zooming in and out in the browser will rescale the hardware-scaling correctly.
|
|
405
|
-
*/
|
|
406
|
-
this.adaptToDeviceRatio = false;
|
|
407
|
-
/** @internal */
|
|
408
|
-
this._lastDevicePixelRatio = 1.0;
|
|
409
|
-
/** @internal */
|
|
410
|
-
this._transformTextureUrl = null;
|
|
411
|
-
/**
|
|
412
|
-
* Gets information about the current host
|
|
413
|
-
*/
|
|
414
|
-
this.hostInformation = {
|
|
415
|
-
isMobile: false,
|
|
416
|
-
};
|
|
417
|
-
/**
|
|
418
|
-
* Defines whether the engine has been created with the premultipliedAlpha option on or not.
|
|
419
|
-
*/
|
|
420
|
-
this.premultipliedAlpha = true;
|
|
421
|
-
/**
|
|
422
|
-
* Observable event triggered before each texture is initialized
|
|
423
|
-
*/
|
|
424
|
-
this.onBeforeTextureInitObservable = new Observable();
|
|
425
|
-
/** @internal */
|
|
426
|
-
this._isWebGPU = false;
|
|
427
|
-
this._snapshotRenderingMode = 0;
|
|
428
|
-
this._viewportCached = { x: 0, y: 0, z: 0, w: 0 };
|
|
429
119
|
this._unpackFlipYCached = null;
|
|
430
120
|
/**
|
|
431
121
|
* In case you are sharing the context with other applications, it might
|
|
@@ -434,35 +124,10 @@ export class ThinEngine {
|
|
|
434
124
|
*/
|
|
435
125
|
this.enableUnpackFlipYCached = true;
|
|
436
126
|
this._boundUniforms = {};
|
|
437
|
-
this.startTime = PrecisionDate.Now;
|
|
438
|
-
let canvas = null;
|
|
439
|
-
options = options || {};
|
|
440
|
-
this._creationOptions = options;
|
|
441
|
-
// Save this off for use in resize().
|
|
442
|
-
this.adaptToDeviceRatio = adaptToDeviceRatio ?? false;
|
|
443
|
-
this._stencilStateComposer.stencilGlobal = this._stencilState;
|
|
444
|
-
PerformanceConfigurator.SetMatrixPrecision(!!options.useHighPrecisionMatrix);
|
|
445
|
-
options.antialias = antialias ?? options.antialias;
|
|
446
|
-
options.deterministicLockstep = options.deterministicLockstep ?? false;
|
|
447
|
-
options.lockstepMaxSteps = options.lockstepMaxSteps ?? 4;
|
|
448
|
-
options.timeStep = options.timeStep ?? 1 / 60;
|
|
449
|
-
options.audioEngine = options.audioEngine ?? true;
|
|
450
|
-
options.stencil = options.stencil ?? true;
|
|
451
|
-
this._audioContext = options.audioEngineOptions?.audioContext ?? null;
|
|
452
|
-
this._audioDestination = options.audioEngineOptions?.audioDestination ?? null;
|
|
453
|
-
this.premultipliedAlpha = options.premultipliedAlpha ?? true;
|
|
454
|
-
this.useExactSrgbConversions = options.useExactSrgbConversions ?? false;
|
|
455
|
-
this._doNotHandleContextLost = !!options.doNotHandleContextLost;
|
|
456
|
-
this._isStencilEnable = options.stencil ? true : false;
|
|
457
|
-
// Viewport
|
|
458
|
-
adaptToDeviceRatio = adaptToDeviceRatio || options.adaptToDeviceRatio || false;
|
|
459
|
-
const devicePixelRatio = IsWindowObjectExist() ? window.devicePixelRatio || 1.0 : 1.0;
|
|
460
|
-
const limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
|
|
461
|
-
this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
|
|
462
|
-
this._lastDevicePixelRatio = devicePixelRatio;
|
|
463
127
|
if (!canvasOrContext) {
|
|
464
128
|
return;
|
|
465
129
|
}
|
|
130
|
+
let canvas = null;
|
|
466
131
|
if (canvasOrContext.getContext) {
|
|
467
132
|
canvas = canvasOrContext;
|
|
468
133
|
this._renderingCanvas = canvas;
|
|
@@ -527,8 +192,6 @@ export class ThinEngine {
|
|
|
527
192
|
canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
|
|
528
193
|
options.powerPreference = options.powerPreference || "high-performance";
|
|
529
194
|
}
|
|
530
|
-
// Detect if we are running on a faulty buggy desktop OS.
|
|
531
|
-
this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
532
195
|
if (this._badDesktopOS) {
|
|
533
196
|
options.xrCompatible = false;
|
|
534
197
|
}
|
|
@@ -594,8 +257,6 @@ export class ThinEngine {
|
|
|
594
257
|
}
|
|
595
258
|
// Shader processor
|
|
596
259
|
this._shaderProcessor = this.webGLVersion > 1 ? new WebGL2ShaderProcessor() : new WebGLShaderProcessor();
|
|
597
|
-
// Detect if we are running on a faulty buggy OS.
|
|
598
|
-
this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
|
|
599
260
|
// Starting with iOS 14, we can trust the browser
|
|
600
261
|
// let matches = navigator.userAgent.match(/Version\/(\d+)/);
|
|
601
262
|
// if (matches && matches.length === 2) {
|
|
@@ -610,81 +271,9 @@ export class ThinEngine {
|
|
|
610
271
|
this._renderingCanvas.setAttribute("data-engine", versionToLog);
|
|
611
272
|
}
|
|
612
273
|
}
|
|
613
|
-
_setupMobileChecks() {
|
|
614
|
-
if (!(navigator && navigator.userAgent)) {
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
// Function to check if running on mobile device
|
|
618
|
-
this._checkForMobile = () => {
|
|
619
|
-
const currentUA = navigator.userAgent;
|
|
620
|
-
this.hostInformation.isMobile =
|
|
621
|
-
currentUA.indexOf("Mobile") !== -1 ||
|
|
622
|
-
// Needed for iOS 13+ detection on iPad (inspired by solution from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios)
|
|
623
|
-
(currentUA.indexOf("Mac") !== -1 && IsDocumentAvailable() && "ontouchend" in document);
|
|
624
|
-
};
|
|
625
|
-
// Set initial isMobile value
|
|
626
|
-
this._checkForMobile();
|
|
627
|
-
// Set up event listener to check when window is resized (used to get emulator activation to work properly)
|
|
628
|
-
if (IsWindowObjectExist()) {
|
|
629
|
-
window.addEventListener("resize", this._checkForMobile);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
274
|
_clearEmptyResources() {
|
|
633
275
|
this._dummyFramebuffer = null;
|
|
634
|
-
|
|
635
|
-
this._emptyCubeTexture = null;
|
|
636
|
-
this._emptyTexture3D = null;
|
|
637
|
-
this._emptyTexture2DArray = null;
|
|
638
|
-
}
|
|
639
|
-
_rebuildGraphicsResources() {
|
|
640
|
-
// Ensure webgl and engine states are matching
|
|
641
|
-
this.wipeCaches(true);
|
|
642
|
-
// Rebuild effects
|
|
643
|
-
this._rebuildEffects();
|
|
644
|
-
this._rebuildComputeEffects?.();
|
|
645
|
-
// Note:
|
|
646
|
-
// 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
|
|
647
|
-
// 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)
|
|
648
|
-
// Rebuild buffers
|
|
649
|
-
this._rebuildBuffers();
|
|
650
|
-
// Rebuild textures
|
|
651
|
-
this._rebuildInternalTextures();
|
|
652
|
-
// Rebuild textures
|
|
653
|
-
this._rebuildTextures();
|
|
654
|
-
// Rebuild textures
|
|
655
|
-
this._rebuildRenderTargetWrappers();
|
|
656
|
-
// Reset engine states after all the buffer/textures/... have been rebuilt
|
|
657
|
-
this.wipeCaches(true);
|
|
658
|
-
}
|
|
659
|
-
_flagContextRestored() {
|
|
660
|
-
Logger.Warn(this.name + " context successfully restored.");
|
|
661
|
-
this.onContextRestoredObservable.notifyObservers(this);
|
|
662
|
-
this._contextWasLost = false;
|
|
663
|
-
}
|
|
664
|
-
_restoreEngineAfterContextLost(initEngine) {
|
|
665
|
-
// Adding a timeout to avoid race condition at browser level
|
|
666
|
-
setTimeout(async () => {
|
|
667
|
-
this._clearEmptyResources();
|
|
668
|
-
const depthTest = this._depthCullingState.depthTest; // backup those values because the call to initEngine / wipeCaches will reset them
|
|
669
|
-
const depthFunc = this._depthCullingState.depthFunc;
|
|
670
|
-
const depthMask = this._depthCullingState.depthMask;
|
|
671
|
-
const stencilTest = this._stencilState.stencilTest;
|
|
672
|
-
// Rebuild context
|
|
673
|
-
await initEngine();
|
|
674
|
-
this._rebuildGraphicsResources();
|
|
675
|
-
this._depthCullingState.depthTest = depthTest;
|
|
676
|
-
this._depthCullingState.depthFunc = depthFunc;
|
|
677
|
-
this._depthCullingState.depthMask = depthMask;
|
|
678
|
-
this._stencilState.stencilTest = stencilTest;
|
|
679
|
-
this._flagContextRestored();
|
|
680
|
-
}, 0);
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Shared initialization across engines types.
|
|
684
|
-
* @param canvas The canvas associated with this instance of the engine.
|
|
685
|
-
*/
|
|
686
|
-
_sharedInit(canvas) {
|
|
687
|
-
this._renderingCanvas = canvas;
|
|
276
|
+
super._clearEmptyResources();
|
|
688
277
|
}
|
|
689
278
|
/**
|
|
690
279
|
* @internal
|
|
@@ -692,26 +281,6 @@ export class ThinEngine {
|
|
|
692
281
|
_getShaderProcessingContext(shaderLanguage) {
|
|
693
282
|
return null;
|
|
694
283
|
}
|
|
695
|
-
_rebuildInternalTextures() {
|
|
696
|
-
const currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
|
|
697
|
-
for (const internalTexture of currentState) {
|
|
698
|
-
internalTexture._rebuild();
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
_rebuildRenderTargetWrappers() {
|
|
702
|
-
const currentState = this._renderTargetWrapperCache.slice(); // Do a copy because the rebuild will add proxies
|
|
703
|
-
for (const renderTargetWrapper of currentState) {
|
|
704
|
-
renderTargetWrapper._rebuild();
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
_rebuildEffects() {
|
|
708
|
-
for (const key in this._compiledEffects) {
|
|
709
|
-
const effect = this._compiledEffects[key];
|
|
710
|
-
effect._pipelineContext = null; // because _prepareEffect will try to dispose this pipeline before recreating it and that would lead to webgl errors
|
|
711
|
-
effect._prepareEffect();
|
|
712
|
-
}
|
|
713
|
-
Effect.ResetCache();
|
|
714
|
-
}
|
|
715
284
|
/**
|
|
716
285
|
* Gets a boolean indicating if all created effects are ready
|
|
717
286
|
* @returns true if all effects are ready
|
|
@@ -725,13 +294,6 @@ export class ThinEngine {
|
|
|
725
294
|
}
|
|
726
295
|
return true;
|
|
727
296
|
}
|
|
728
|
-
_rebuildBuffers() {
|
|
729
|
-
// Uniforms
|
|
730
|
-
for (const uniformBuffer of this._uniformBuffers) {
|
|
731
|
-
uniformBuffer._rebuildAfterContextLost();
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
_rebuildTextures() { }
|
|
735
297
|
_initGLContext() {
|
|
736
298
|
// Caps
|
|
737
299
|
this._caps = {
|
|
@@ -1023,12 +585,6 @@ export class ThinEngine {
|
|
|
1023
585
|
getClassName() {
|
|
1024
586
|
return "ThinEngine";
|
|
1025
587
|
}
|
|
1026
|
-
/**
|
|
1027
|
-
* Returns true if the stencil buffer has been enabled through the creation option of the context.
|
|
1028
|
-
*/
|
|
1029
|
-
get isStencilEnable() {
|
|
1030
|
-
return this._isStencilEnable;
|
|
1031
|
-
}
|
|
1032
588
|
/** @internal */
|
|
1033
589
|
_prepareWorkingCanvas() {
|
|
1034
590
|
if (this._workingCanvas) {
|
|
@@ -1040,18 +596,6 @@ export class ThinEngine {
|
|
|
1040
596
|
this._workingContext = context;
|
|
1041
597
|
}
|
|
1042
598
|
}
|
|
1043
|
-
/**
|
|
1044
|
-
* Reset the texture cache to empty state
|
|
1045
|
-
*/
|
|
1046
|
-
resetTextureCache() {
|
|
1047
|
-
for (const key in this._boundTexturesCache) {
|
|
1048
|
-
if (!Object.prototype.hasOwnProperty.call(this._boundTexturesCache, key)) {
|
|
1049
|
-
continue;
|
|
1050
|
-
}
|
|
1051
|
-
this._boundTexturesCache[key] = null;
|
|
1052
|
-
}
|
|
1053
|
-
this._currentTextureChannel = -1;
|
|
1054
|
-
}
|
|
1055
599
|
/**
|
|
1056
600
|
* Gets an object containing information about the current engine context
|
|
1057
601
|
* @returns an object containing the vendor, the renderer and the version of the current engine context
|
|
@@ -1070,131 +614,13 @@ export class ThinEngine {
|
|
|
1070
614
|
version: this._glVersion,
|
|
1071
615
|
};
|
|
1072
616
|
}
|
|
1073
|
-
/**
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
*/
|
|
1079
|
-
setHardwareScalingLevel(level) {
|
|
1080
|
-
this._hardwareScalingLevel = level;
|
|
1081
|
-
this.resize();
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
* Gets the current hardware scaling level.
|
|
1085
|
-
* By default the hardware scaling level is computed from the window device ratio.
|
|
1086
|
-
* 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.
|
|
1087
|
-
* @returns a number indicating the current hardware scaling level
|
|
1088
|
-
*/
|
|
1089
|
-
getHardwareScalingLevel() {
|
|
1090
|
-
return this._hardwareScalingLevel;
|
|
1091
|
-
}
|
|
1092
|
-
/**
|
|
1093
|
-
* Gets the list of loaded textures
|
|
1094
|
-
* @returns an array containing all loaded textures
|
|
1095
|
-
*/
|
|
1096
|
-
getLoadedTexturesCache() {
|
|
1097
|
-
return this._internalTexturesCache;
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Gets the object containing all engine capabilities
|
|
1101
|
-
* @returns the EngineCapabilities object
|
|
1102
|
-
*/
|
|
1103
|
-
getCaps() {
|
|
1104
|
-
return this._caps;
|
|
1105
|
-
}
|
|
1106
|
-
/**
|
|
1107
|
-
* stop executing a render loop function and remove it from the execution array
|
|
1108
|
-
* @param renderFunction defines the function to be removed. If not provided all functions will be removed.
|
|
1109
|
-
*/
|
|
1110
|
-
stopRenderLoop(renderFunction) {
|
|
1111
|
-
if (!renderFunction) {
|
|
1112
|
-
this._activeRenderLoops.length = 0;
|
|
1113
|
-
this._cancelFrame();
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
const index = this._activeRenderLoops.indexOf(renderFunction);
|
|
1117
|
-
if (index >= 0) {
|
|
1118
|
-
this._activeRenderLoops.splice(index, 1);
|
|
1119
|
-
if (this._activeRenderLoops.length == 0) {
|
|
1120
|
-
this._cancelFrame();
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
_cancelFrame() {
|
|
1125
|
-
if (this._frameHandler !== 0) {
|
|
1126
|
-
const handlerToCancel = this._frameHandler;
|
|
1127
|
-
this._frameHandler = 0;
|
|
1128
|
-
if (!IsWindowObjectExist()) {
|
|
1129
|
-
if (typeof cancelAnimationFrame === "function") {
|
|
1130
|
-
return cancelAnimationFrame(handlerToCancel);
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
else {
|
|
1134
|
-
const { cancelAnimationFrame } = this.getHostWindow() || window;
|
|
1135
|
-
if (typeof cancelAnimationFrame === "function") {
|
|
1136
|
-
return cancelAnimationFrame(handlerToCancel);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
return clearTimeout(handlerToCancel);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
/** @internal */
|
|
1143
|
-
_renderLoop() {
|
|
1144
|
-
this._frameHandler = 0;
|
|
1145
|
-
if (!this._contextWasLost) {
|
|
1146
|
-
let shouldRender = true;
|
|
1147
|
-
if (this._isDisposed || (!this.renderEvenInBackground && this._windowIsBackground)) {
|
|
1148
|
-
shouldRender = false;
|
|
1149
|
-
}
|
|
1150
|
-
if (shouldRender) {
|
|
1151
|
-
// Start new frame
|
|
1152
|
-
this.beginFrame();
|
|
1153
|
-
for (let index = 0; index < this._activeRenderLoops.length; index++) {
|
|
1154
|
-
const renderFunction = this._activeRenderLoops[index];
|
|
1155
|
-
renderFunction();
|
|
1156
|
-
}
|
|
1157
|
-
// Present
|
|
1158
|
-
this.endFrame();
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
if (this._frameHandler === 0) {
|
|
1162
|
-
this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
/**
|
|
1166
|
-
* Gets the HTML canvas attached with the current webGL context
|
|
1167
|
-
* @returns a HTML canvas
|
|
1168
|
-
*/
|
|
1169
|
-
getRenderingCanvas() {
|
|
1170
|
-
return this._renderingCanvas;
|
|
1171
|
-
}
|
|
1172
|
-
/**
|
|
1173
|
-
* Gets the audio context specified in engine initialization options
|
|
1174
|
-
* @returns an Audio Context
|
|
1175
|
-
*/
|
|
1176
|
-
getAudioContext() {
|
|
1177
|
-
return this._audioContext;
|
|
1178
|
-
}
|
|
1179
|
-
/**
|
|
1180
|
-
* Gets the audio destination specified in engine initialization options
|
|
1181
|
-
* @returns an audio destination node
|
|
1182
|
-
*/
|
|
1183
|
-
getAudioDestination() {
|
|
1184
|
-
return this._audioDestination;
|
|
1185
|
-
}
|
|
1186
|
-
/**
|
|
1187
|
-
* Gets host window
|
|
1188
|
-
* @returns the host window object
|
|
1189
|
-
*/
|
|
1190
|
-
getHostWindow() {
|
|
1191
|
-
if (!IsWindowObjectExist()) {
|
|
1192
|
-
return null;
|
|
1193
|
-
}
|
|
1194
|
-
if (this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView) {
|
|
1195
|
-
return this._renderingCanvas.ownerDocument.defaultView;
|
|
617
|
+
/**Gets driver info if available */
|
|
618
|
+
extractDriverInfo() {
|
|
619
|
+
const glInfo = this.getGlInfo();
|
|
620
|
+
if (glInfo && glInfo.renderer) {
|
|
621
|
+
return glInfo.renderer;
|
|
1196
622
|
}
|
|
1197
|
-
return
|
|
623
|
+
return "";
|
|
1198
624
|
}
|
|
1199
625
|
/**
|
|
1200
626
|
* Gets the current render width
|
|
@@ -1218,27 +644,6 @@ export class ThinEngine {
|
|
|
1218
644
|
}
|
|
1219
645
|
return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight;
|
|
1220
646
|
}
|
|
1221
|
-
/**
|
|
1222
|
-
* Can be used to override the current requestAnimationFrame requester.
|
|
1223
|
-
* @internal
|
|
1224
|
-
*/
|
|
1225
|
-
_queueNewFrame(bindedRenderFunction, requester) {
|
|
1226
|
-
return ThinEngine.QueueNewFrame(bindedRenderFunction, requester);
|
|
1227
|
-
}
|
|
1228
|
-
/**
|
|
1229
|
-
* Register and execute a render loop. The engine can have more than one render function
|
|
1230
|
-
* @param renderFunction defines the function to continuously execute
|
|
1231
|
-
*/
|
|
1232
|
-
runRenderLoop(renderFunction) {
|
|
1233
|
-
if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
|
|
1234
|
-
return;
|
|
1235
|
-
}
|
|
1236
|
-
this._activeRenderLoops.push(renderFunction);
|
|
1237
|
-
// On the first added function, start the render loop.
|
|
1238
|
-
if (this._activeRenderLoops.length === 1 && this._frameHandler === 0) {
|
|
1239
|
-
this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
647
|
/**
|
|
1243
648
|
* Clear the current render buffer or the current render target (if any is set up)
|
|
1244
649
|
* @param color defines the color to use
|
|
@@ -1313,90 +718,21 @@ export class ThinEngine {
|
|
|
1313
718
|
}
|
|
1314
719
|
}
|
|
1315
720
|
/**
|
|
1316
|
-
*
|
|
1317
|
-
* @param viewport defines the viewport element to be used
|
|
1318
|
-
* @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
|
|
1319
|
-
* @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
|
|
1320
|
-
*/
|
|
1321
|
-
setViewport(viewport, requiredWidth, requiredHeight) {
|
|
1322
|
-
const width = requiredWidth || this.getRenderWidth();
|
|
1323
|
-
const height = requiredHeight || this.getRenderHeight();
|
|
1324
|
-
const x = viewport.x || 0;
|
|
1325
|
-
const y = viewport.y || 0;
|
|
1326
|
-
this._cachedViewport = viewport;
|
|
1327
|
-
this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
|
|
1328
|
-
}
|
|
1329
|
-
/**
|
|
1330
|
-
* Begin a new frame
|
|
1331
|
-
*/
|
|
1332
|
-
beginFrame() { }
|
|
1333
|
-
/**
|
|
1334
|
-
* Enf the current frame
|
|
721
|
+
* End the current frame
|
|
1335
722
|
*/
|
|
1336
723
|
endFrame() {
|
|
724
|
+
super.endFrame();
|
|
1337
725
|
// Force a flush in case we are using a bad OS.
|
|
1338
726
|
if (this._badOS) {
|
|
1339
727
|
this.flushFramebuffer();
|
|
1340
728
|
}
|
|
1341
|
-
this._frameId++;
|
|
1342
|
-
}
|
|
1343
|
-
/**
|
|
1344
|
-
* Resize the view according to the canvas' size
|
|
1345
|
-
* @param forceSetSize true to force setting the sizes of the underlying canvas
|
|
1346
|
-
*/
|
|
1347
|
-
resize(forceSetSize = false) {
|
|
1348
|
-
let width;
|
|
1349
|
-
let height;
|
|
1350
|
-
// Re-query hardware scaling level to handle zoomed-in resizing.
|
|
1351
|
-
if (this.adaptToDeviceRatio) {
|
|
1352
|
-
const devicePixelRatio = IsWindowObjectExist() ? window.devicePixelRatio || 1.0 : 1.0;
|
|
1353
|
-
const changeRatio = this._lastDevicePixelRatio / devicePixelRatio;
|
|
1354
|
-
this._lastDevicePixelRatio = devicePixelRatio;
|
|
1355
|
-
this._hardwareScalingLevel *= changeRatio;
|
|
1356
|
-
}
|
|
1357
|
-
if (IsWindowObjectExist() && IsDocumentAvailable()) {
|
|
1358
|
-
// make sure it is a Node object, and is a part of the document.
|
|
1359
|
-
if (this._renderingCanvas) {
|
|
1360
|
-
const boundingRect = this._renderingCanvas.getBoundingClientRect
|
|
1361
|
-
? this._renderingCanvas.getBoundingClientRect()
|
|
1362
|
-
: {
|
|
1363
|
-
// fallback to last solution in case the function doesn't exist
|
|
1364
|
-
width: this._renderingCanvas.width * this._hardwareScalingLevel,
|
|
1365
|
-
height: this._renderingCanvas.height * this._hardwareScalingLevel,
|
|
1366
|
-
};
|
|
1367
|
-
width = this._renderingCanvas.clientWidth || boundingRect.width || this._renderingCanvas.width || 100;
|
|
1368
|
-
height = this._renderingCanvas.clientHeight || boundingRect.height || this._renderingCanvas.height || 100;
|
|
1369
|
-
}
|
|
1370
|
-
else {
|
|
1371
|
-
width = window.innerWidth;
|
|
1372
|
-
height = window.innerHeight;
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
else {
|
|
1376
|
-
width = this._renderingCanvas ? this._renderingCanvas.width : 100;
|
|
1377
|
-
height = this._renderingCanvas ? this._renderingCanvas.height : 100;
|
|
1378
|
-
}
|
|
1379
|
-
this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel, forceSetSize);
|
|
1380
729
|
}
|
|
1381
730
|
/**
|
|
1382
|
-
*
|
|
1383
|
-
* @
|
|
1384
|
-
* @param height defines the new canvas' height
|
|
1385
|
-
* @param forceSetSize true to force setting the sizes of the underlying canvas
|
|
1386
|
-
* @returns true if the size was changed
|
|
731
|
+
* Gets the performance monitor attached to this engine
|
|
732
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#engineinstrumentation
|
|
1387
733
|
*/
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
return false;
|
|
1391
|
-
}
|
|
1392
|
-
width = width | 0;
|
|
1393
|
-
height = height | 0;
|
|
1394
|
-
if (!forceSetSize && this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
|
|
1395
|
-
return false;
|
|
1396
|
-
}
|
|
1397
|
-
this._renderingCanvas.width = width;
|
|
1398
|
-
this._renderingCanvas.height = height;
|
|
1399
|
-
return true;
|
|
734
|
+
get performanceMonitor() {
|
|
735
|
+
throw new Error("Not Supported by ThinEngine");
|
|
1400
736
|
}
|
|
1401
737
|
/**
|
|
1402
738
|
* Binds the frame buffer to the specified texture.
|
|
@@ -1498,50 +834,6 @@ export class ThinEngine {
|
|
|
1498
834
|
}
|
|
1499
835
|
this._stencilStateComposer.stencilMaterial = stencil;
|
|
1500
836
|
}
|
|
1501
|
-
/**
|
|
1502
|
-
* Gets a boolean indicating if depth testing is enabled
|
|
1503
|
-
* @returns the current state
|
|
1504
|
-
*/
|
|
1505
|
-
getDepthBuffer() {
|
|
1506
|
-
return this._depthCullingState.depthTest;
|
|
1507
|
-
}
|
|
1508
|
-
/**
|
|
1509
|
-
* Enable or disable depth buffering
|
|
1510
|
-
* @param enable defines the state to set
|
|
1511
|
-
*/
|
|
1512
|
-
setDepthBuffer(enable) {
|
|
1513
|
-
this._depthCullingState.depthTest = enable;
|
|
1514
|
-
}
|
|
1515
|
-
/**
|
|
1516
|
-
* Set the z offset Factor to apply to current rendering
|
|
1517
|
-
* @param value defines the offset to apply
|
|
1518
|
-
*/
|
|
1519
|
-
setZOffset(value) {
|
|
1520
|
-
this._depthCullingState.zOffset = this.useReverseDepthBuffer ? -value : value;
|
|
1521
|
-
}
|
|
1522
|
-
/**
|
|
1523
|
-
* Gets the current value of the zOffset Factor
|
|
1524
|
-
* @returns the current zOffset Factor state
|
|
1525
|
-
*/
|
|
1526
|
-
getZOffset() {
|
|
1527
|
-
const zOffset = this._depthCullingState.zOffset;
|
|
1528
|
-
return this.useReverseDepthBuffer ? -zOffset : zOffset;
|
|
1529
|
-
}
|
|
1530
|
-
/**
|
|
1531
|
-
* Set the z offset Units to apply to current rendering
|
|
1532
|
-
* @param value defines the offset to apply
|
|
1533
|
-
*/
|
|
1534
|
-
setZOffsetUnits(value) {
|
|
1535
|
-
this._depthCullingState.zOffsetUnits = this.useReverseDepthBuffer ? -value : value;
|
|
1536
|
-
}
|
|
1537
|
-
/**
|
|
1538
|
-
* Gets the current value of the zOffset Units
|
|
1539
|
-
* @returns the current zOffset Units state
|
|
1540
|
-
*/
|
|
1541
|
-
getZOffsetUnits() {
|
|
1542
|
-
const zOffsetUnits = this._depthCullingState.zOffsetUnits;
|
|
1543
|
-
return this.useReverseDepthBuffer ? -zOffsetUnits : zOffsetUnits;
|
|
1544
|
-
}
|
|
1545
837
|
/**
|
|
1546
838
|
* @internal
|
|
1547
839
|
*/
|
|
@@ -2186,10 +1478,6 @@ export class ThinEngine {
|
|
|
2186
1478
|
return this._gl.TRIANGLES;
|
|
2187
1479
|
}
|
|
2188
1480
|
}
|
|
2189
|
-
/** @internal */
|
|
2190
|
-
_reportDrawCall() {
|
|
2191
|
-
// Will be implemented by children
|
|
2192
|
-
}
|
|
2193
1481
|
// Shaders
|
|
2194
1482
|
/**
|
|
2195
1483
|
* @internal
|
|
@@ -2213,49 +1501,6 @@ export class ThinEngine {
|
|
|
2213
1501
|
this._gl.deleteProgram(webGLPipelineContext.program);
|
|
2214
1502
|
}
|
|
2215
1503
|
}
|
|
2216
|
-
/** @internal */
|
|
2217
|
-
_getGlobalDefines(defines) {
|
|
2218
|
-
if (defines) {
|
|
2219
|
-
if (this.isNDCHalfZRange) {
|
|
2220
|
-
defines["IS_NDC_HALF_ZRANGE"] = "";
|
|
2221
|
-
}
|
|
2222
|
-
else {
|
|
2223
|
-
delete defines["IS_NDC_HALF_ZRANGE"];
|
|
2224
|
-
}
|
|
2225
|
-
if (this.useReverseDepthBuffer) {
|
|
2226
|
-
defines["USE_REVERSE_DEPTHBUFFER"] = "";
|
|
2227
|
-
}
|
|
2228
|
-
else {
|
|
2229
|
-
delete defines["USE_REVERSE_DEPTHBUFFER"];
|
|
2230
|
-
}
|
|
2231
|
-
if (this.useExactSrgbConversions) {
|
|
2232
|
-
defines["USE_EXACT_SRGB_CONVERSIONS"] = "";
|
|
2233
|
-
}
|
|
2234
|
-
else {
|
|
2235
|
-
delete defines["USE_EXACT_SRGB_CONVERSIONS"];
|
|
2236
|
-
}
|
|
2237
|
-
return;
|
|
2238
|
-
}
|
|
2239
|
-
else {
|
|
2240
|
-
let s = "";
|
|
2241
|
-
if (this.isNDCHalfZRange) {
|
|
2242
|
-
s += "#define IS_NDC_HALF_ZRANGE";
|
|
2243
|
-
}
|
|
2244
|
-
if (this.useReverseDepthBuffer) {
|
|
2245
|
-
if (s) {
|
|
2246
|
-
s += "\n";
|
|
2247
|
-
}
|
|
2248
|
-
s += "#define USE_REVERSE_DEPTHBUFFER";
|
|
2249
|
-
}
|
|
2250
|
-
if (this.useExactSrgbConversions) {
|
|
2251
|
-
if (s) {
|
|
2252
|
-
s += "\n";
|
|
2253
|
-
}
|
|
2254
|
-
s += "#define USE_EXACT_SRGB_CONVERSIONS";
|
|
2255
|
-
}
|
|
2256
|
-
return s;
|
|
2257
|
-
}
|
|
2258
|
-
}
|
|
2259
1504
|
/**
|
|
2260
1505
|
* Create a new effect (used to store vertex/fragment shaders)
|
|
2261
1506
|
* @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
|
|
@@ -2286,7 +1531,7 @@ export class ThinEngine {
|
|
|
2286
1531
|
}
|
|
2287
1532
|
return compiledEffect;
|
|
2288
1533
|
}
|
|
2289
|
-
const effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters, name, shaderLanguage);
|
|
1534
|
+
const effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters, name, attributesNamesOrOptions.shaderLanguage ?? shaderLanguage);
|
|
2290
1535
|
this._compiledEffects[name] = effect;
|
|
2291
1536
|
return effect;
|
|
2292
1537
|
}
|
|
@@ -2538,7 +1783,7 @@ export class ThinEngine {
|
|
|
2538
1783
|
* @param effect defines the effect to activate
|
|
2539
1784
|
*/
|
|
2540
1785
|
enableEffect(effect) {
|
|
2541
|
-
effect = effect !== null &&
|
|
1786
|
+
effect = effect !== null && IsWrapper(effect) ? effect.effect : effect; // get only the effect, we don't need a Wrapper in the WebGL engine
|
|
2542
1787
|
if (!effect || effect === this._currentEffect) {
|
|
2543
1788
|
return;
|
|
2544
1789
|
}
|
|
@@ -2940,55 +2185,7 @@ export class ThinEngine {
|
|
|
2940
2185
|
this._gl.colorMask(enable, enable, enable, enable);
|
|
2941
2186
|
}
|
|
2942
2187
|
}
|
|
2943
|
-
/**
|
|
2944
|
-
* Enable or disable color writing
|
|
2945
|
-
* @param enable defines the state to set
|
|
2946
|
-
*/
|
|
2947
|
-
setColorWrite(enable) {
|
|
2948
|
-
if (enable !== this._colorWrite) {
|
|
2949
|
-
this._colorWriteChanged = true;
|
|
2950
|
-
this._colorWrite = enable;
|
|
2951
|
-
}
|
|
2952
|
-
}
|
|
2953
|
-
/**
|
|
2954
|
-
* Gets a boolean indicating if color writing is enabled
|
|
2955
|
-
* @returns the current color writing state
|
|
2956
|
-
*/
|
|
2957
|
-
getColorWrite() {
|
|
2958
|
-
return this._colorWrite;
|
|
2959
|
-
}
|
|
2960
|
-
/**
|
|
2961
|
-
* Gets the depth culling state manager
|
|
2962
|
-
*/
|
|
2963
|
-
get depthCullingState() {
|
|
2964
|
-
return this._depthCullingState;
|
|
2965
|
-
}
|
|
2966
|
-
/**
|
|
2967
|
-
* Gets the alpha state manager
|
|
2968
|
-
*/
|
|
2969
|
-
get alphaState() {
|
|
2970
|
-
return this._alphaState;
|
|
2971
|
-
}
|
|
2972
|
-
/**
|
|
2973
|
-
* Gets the stencil state manager
|
|
2974
|
-
*/
|
|
2975
|
-
get stencilState() {
|
|
2976
|
-
return this._stencilState;
|
|
2977
|
-
}
|
|
2978
|
-
/**
|
|
2979
|
-
* Gets the stencil state composer
|
|
2980
|
-
*/
|
|
2981
|
-
get stencilStateComposer() {
|
|
2982
|
-
return this._stencilStateComposer;
|
|
2983
|
-
}
|
|
2984
2188
|
// Textures
|
|
2985
|
-
/**
|
|
2986
|
-
* Clears the list of texture accessible through engine.
|
|
2987
|
-
* This can help preventing texture load conflict due to name collision.
|
|
2988
|
-
*/
|
|
2989
|
-
clearInternalTexturesCache() {
|
|
2990
|
-
this._internalTexturesCache.length = 0;
|
|
2991
|
-
}
|
|
2992
2189
|
/**
|
|
2993
2190
|
* Force the entire cache to be cleared
|
|
2994
2191
|
* You should not have to use this function unless your engine needs to share the webGL context with another engine
|
|
@@ -3027,6 +2224,15 @@ export class ThinEngine {
|
|
|
3027
2224
|
this._cachedEffectForVertexBuffers = null;
|
|
3028
2225
|
this.bindIndexBuffer(null);
|
|
3029
2226
|
}
|
|
2227
|
+
setTextureFromPostProcess(channel, postProcess, name) {
|
|
2228
|
+
// Does nothing
|
|
2229
|
+
}
|
|
2230
|
+
setTextureFromPostProcessOutput(channel, postProcess, name) {
|
|
2231
|
+
// Does nothing
|
|
2232
|
+
}
|
|
2233
|
+
setDepthStencilTexture(channel, uniform, texture, name) {
|
|
2234
|
+
// Does nothing
|
|
2235
|
+
}
|
|
3030
2236
|
/**
|
|
3031
2237
|
* @internal
|
|
3032
2238
|
*/
|
|
@@ -3237,142 +2443,7 @@ export class ThinEngine {
|
|
|
3237
2443
|
*/
|
|
3238
2444
|
_getUseSRGBBuffer(useSRGBBuffer, noMipmap) {
|
|
3239
2445
|
// Generating mipmaps for sRGB textures is not supported in WebGL1 so we must disable the support if mipmaps is enabled
|
|
3240
|
-
return useSRGBBuffer && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 ||
|
|
3241
|
-
}
|
|
3242
|
-
_createTextureBase(url, noMipmap, invertY, scene, samplingMode = 3, onLoad = null, onError = null, prepareTexture, prepareTextureProcessFunction, buffer = null, fallback = null, format = null, forcedExtension = null, mimeType, loaderOptions, useSRGBBuffer) {
|
|
3243
|
-
url = url || "";
|
|
3244
|
-
const fromData = url.substr(0, 5) === "data:";
|
|
3245
|
-
const fromBlob = url.substr(0, 5) === "blob:";
|
|
3246
|
-
const isBase64 = fromData && url.indexOf(";base64,") !== -1;
|
|
3247
|
-
const texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Url);
|
|
3248
|
-
if (texture !== fallback) {
|
|
3249
|
-
texture.label = url.substring(0, 60); // default label, can be overriden by the caller
|
|
3250
|
-
}
|
|
3251
|
-
const originalUrl = url;
|
|
3252
|
-
if (this._transformTextureUrl && !isBase64 && !fallback && !buffer) {
|
|
3253
|
-
url = this._transformTextureUrl(url);
|
|
3254
|
-
}
|
|
3255
|
-
if (originalUrl !== url) {
|
|
3256
|
-
texture._originalUrl = originalUrl;
|
|
3257
|
-
}
|
|
3258
|
-
// establish the file extension, if possible
|
|
3259
|
-
const lastDot = url.lastIndexOf(".");
|
|
3260
|
-
let extension = forcedExtension ? forcedExtension : lastDot > -1 ? url.substring(lastDot).toLowerCase() : "";
|
|
3261
|
-
let loader = null;
|
|
3262
|
-
// Remove query string
|
|
3263
|
-
const queryStringIndex = extension.indexOf("?");
|
|
3264
|
-
if (queryStringIndex > -1) {
|
|
3265
|
-
extension = extension.split("?")[0];
|
|
3266
|
-
}
|
|
3267
|
-
for (const availableLoader of ThinEngine._TextureLoaders) {
|
|
3268
|
-
if (availableLoader.canLoad(extension, mimeType)) {
|
|
3269
|
-
loader = availableLoader;
|
|
3270
|
-
break;
|
|
3271
|
-
}
|
|
3272
|
-
}
|
|
3273
|
-
if (scene) {
|
|
3274
|
-
scene.addPendingData(texture);
|
|
3275
|
-
}
|
|
3276
|
-
texture.url = url;
|
|
3277
|
-
texture.generateMipMaps = !noMipmap;
|
|
3278
|
-
texture.samplingMode = samplingMode;
|
|
3279
|
-
texture.invertY = invertY;
|
|
3280
|
-
texture._useSRGBBuffer = this._getUseSRGBBuffer(!!useSRGBBuffer, noMipmap);
|
|
3281
|
-
if (!this._doNotHandleContextLost) {
|
|
3282
|
-
// Keep a link to the buffer only if we plan to handle context lost
|
|
3283
|
-
texture._buffer = buffer;
|
|
3284
|
-
}
|
|
3285
|
-
let onLoadObserver = null;
|
|
3286
|
-
if (onLoad && !fallback) {
|
|
3287
|
-
onLoadObserver = texture.onLoadedObservable.add(onLoad);
|
|
3288
|
-
}
|
|
3289
|
-
if (!fallback) {
|
|
3290
|
-
this._internalTexturesCache.push(texture);
|
|
3291
|
-
}
|
|
3292
|
-
const onInternalError = (message, exception) => {
|
|
3293
|
-
if (scene) {
|
|
3294
|
-
scene.removePendingData(texture);
|
|
3295
|
-
}
|
|
3296
|
-
if (url === originalUrl) {
|
|
3297
|
-
if (onLoadObserver) {
|
|
3298
|
-
texture.onLoadedObservable.remove(onLoadObserver);
|
|
3299
|
-
}
|
|
3300
|
-
if (EngineStore.UseFallbackTexture && url !== EngineStore.FallbackTexture) {
|
|
3301
|
-
this._createTextureBase(EngineStore.FallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, onError, prepareTexture, prepareTextureProcessFunction, buffer, texture);
|
|
3302
|
-
}
|
|
3303
|
-
message = (message || "Unknown error") + (EngineStore.UseFallbackTexture ? " - Fallback texture was used" : "");
|
|
3304
|
-
texture.onErrorObservable.notifyObservers({ message, exception });
|
|
3305
|
-
if (onError) {
|
|
3306
|
-
onError(message, exception);
|
|
3307
|
-
}
|
|
3308
|
-
}
|
|
3309
|
-
else {
|
|
3310
|
-
// fall back to the original url if the transformed url fails to load
|
|
3311
|
-
Logger.Warn(`Failed to load ${url}, falling back to ${originalUrl}`);
|
|
3312
|
-
this._createTextureBase(originalUrl, noMipmap, texture.invertY, scene, samplingMode, onLoad, onError, prepareTexture, prepareTextureProcessFunction, buffer, texture, format, forcedExtension, mimeType, loaderOptions, useSRGBBuffer);
|
|
3313
|
-
}
|
|
3314
|
-
};
|
|
3315
|
-
// processing for non-image formats
|
|
3316
|
-
if (loader) {
|
|
3317
|
-
const callback = (data) => {
|
|
3318
|
-
loader.loadData(data, texture, (width, height, loadMipmap, isCompressed, done, loadFailed) => {
|
|
3319
|
-
if (loadFailed) {
|
|
3320
|
-
onInternalError("TextureLoader failed to load data");
|
|
3321
|
-
}
|
|
3322
|
-
else {
|
|
3323
|
-
prepareTexture(texture, extension, scene, { width, height }, texture.invertY, !loadMipmap, isCompressed, () => {
|
|
3324
|
-
done();
|
|
3325
|
-
return false;
|
|
3326
|
-
}, samplingMode);
|
|
3327
|
-
}
|
|
3328
|
-
}, loaderOptions);
|
|
3329
|
-
};
|
|
3330
|
-
if (!buffer) {
|
|
3331
|
-
this._loadFile(url, (data) => callback(new Uint8Array(data)), undefined, scene ? scene.offlineProvider : undefined, true, (request, exception) => {
|
|
3332
|
-
onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
|
|
3333
|
-
});
|
|
3334
|
-
}
|
|
3335
|
-
else {
|
|
3336
|
-
if (buffer instanceof ArrayBuffer) {
|
|
3337
|
-
callback(new Uint8Array(buffer));
|
|
3338
|
-
}
|
|
3339
|
-
else if (ArrayBuffer.isView(buffer)) {
|
|
3340
|
-
callback(buffer);
|
|
3341
|
-
}
|
|
3342
|
-
else {
|
|
3343
|
-
if (onError) {
|
|
3344
|
-
onError("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null);
|
|
3345
|
-
}
|
|
3346
|
-
}
|
|
3347
|
-
}
|
|
3348
|
-
}
|
|
3349
|
-
else {
|
|
3350
|
-
const onload = (img) => {
|
|
3351
|
-
if (fromBlob && !this._doNotHandleContextLost) {
|
|
3352
|
-
// We need to store the image if we need to rebuild the texture
|
|
3353
|
-
// in case of a webgl context lost
|
|
3354
|
-
texture._buffer = img;
|
|
3355
|
-
}
|
|
3356
|
-
prepareTexture(texture, extension, scene, img, texture.invertY, noMipmap, false, prepareTextureProcessFunction, samplingMode);
|
|
3357
|
-
};
|
|
3358
|
-
// According to the WebGL spec section 6.10, ImageBitmaps must be inverted on creation.
|
|
3359
|
-
// So, we pass imageOrientation to _FileToolsLoadImage() as it may create an ImageBitmap.
|
|
3360
|
-
if (!fromData || isBase64) {
|
|
3361
|
-
if (buffer && (typeof buffer.decoding === "string" || buffer.close)) {
|
|
3362
|
-
onload(buffer);
|
|
3363
|
-
}
|
|
3364
|
-
else {
|
|
3365
|
-
ThinEngine._FileToolsLoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null, mimeType, texture.invertY && this._features.needsInvertingBitmap ? { imageOrientation: "flipY" } : undefined);
|
|
3366
|
-
}
|
|
3367
|
-
}
|
|
3368
|
-
else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer) || buffer instanceof Blob) {
|
|
3369
|
-
ThinEngine._FileToolsLoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null, mimeType, texture.invertY && this._features.needsInvertingBitmap ? { imageOrientation: "flipY" } : undefined);
|
|
3370
|
-
}
|
|
3371
|
-
else if (buffer) {
|
|
3372
|
-
onload(buffer);
|
|
3373
|
-
}
|
|
3374
|
-
}
|
|
3375
|
-
return texture;
|
|
2446
|
+
return useSRGBBuffer && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || noMipmap);
|
|
3376
2447
|
}
|
|
3377
2448
|
/**
|
|
3378
2449
|
* Usually called from Texture.ts.
|
|
@@ -3470,20 +2541,6 @@ export class ThinEngine {
|
|
|
3470
2541
|
type: this._gl.UNSIGNED_BYTE,
|
|
3471
2542
|
};
|
|
3472
2543
|
}
|
|
3473
|
-
/**
|
|
3474
|
-
* Loads an image as an HTMLImageElement.
|
|
3475
|
-
* @param input url string, ArrayBuffer, or Blob to load
|
|
3476
|
-
* @param onLoad callback called when the image successfully loads
|
|
3477
|
-
* @param onError callback called when the image fails to load
|
|
3478
|
-
* @param offlineProvider offline provider for caching
|
|
3479
|
-
* @param mimeType optional mime type
|
|
3480
|
-
* @param imageBitmapOptions optional the options to use when creating an ImageBitmap
|
|
3481
|
-
* @returns the HTMLImageElement of the loaded image
|
|
3482
|
-
* @internal
|
|
3483
|
-
*/
|
|
3484
|
-
static _FileToolsLoadImage(input, onLoad, onError, offlineProvider, mimeType, imageBitmapOptions) {
|
|
3485
|
-
throw _WarnImport("FileTools");
|
|
3486
|
-
}
|
|
3487
2544
|
/**
|
|
3488
2545
|
* @internal
|
|
3489
2546
|
*/
|
|
@@ -3826,8 +2883,8 @@ export class ThinEngine {
|
|
|
3826
2883
|
}
|
|
3827
2884
|
_prepareWebGLTexture(texture, extension, scene, img, invertY, noMipmap, isCompressed, processFunction, samplingMode = 3) {
|
|
3828
2885
|
const maxTextureSize = this.getCaps().maxTextureSize;
|
|
3829
|
-
const potWidth = Math.min(maxTextureSize, this.needPOTTextures ?
|
|
3830
|
-
const potHeight = Math.min(maxTextureSize, this.needPOTTextures ?
|
|
2886
|
+
const potWidth = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.width, maxTextureSize) : img.width);
|
|
2887
|
+
const potHeight = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.height, maxTextureSize) : img.height);
|
|
3831
2888
|
const gl = this._gl;
|
|
3832
2889
|
if (!gl) {
|
|
3833
2890
|
return;
|
|
@@ -3926,15 +2983,6 @@ export class ThinEngine {
|
|
|
3926
2983
|
texture._irradianceTexture.dispose();
|
|
3927
2984
|
}
|
|
3928
2985
|
}
|
|
3929
|
-
/**
|
|
3930
|
-
* @internal
|
|
3931
|
-
*/
|
|
3932
|
-
_releaseRenderTargetWrapper(rtWrapper) {
|
|
3933
|
-
const index = this._renderTargetWrapperCache.indexOf(rtWrapper);
|
|
3934
|
-
if (index !== -1) {
|
|
3935
|
-
this._renderTargetWrapperCache.splice(index, 1);
|
|
3936
|
-
}
|
|
3937
|
-
}
|
|
3938
2986
|
_deleteTexture(texture) {
|
|
3939
2987
|
if (texture) {
|
|
3940
2988
|
this._gl.deleteTexture(texture);
|
|
@@ -4240,27 +3288,12 @@ export class ThinEngine {
|
|
|
4240
3288
|
* Dispose and release all associated resources
|
|
4241
3289
|
*/
|
|
4242
3290
|
dispose() {
|
|
4243
|
-
|
|
4244
|
-
this.stopRenderLoop();
|
|
4245
|
-
// Clear observables
|
|
4246
|
-
if (this.onBeforeTextureInitObservable) {
|
|
4247
|
-
this.onBeforeTextureInitObservable.clear();
|
|
4248
|
-
}
|
|
4249
|
-
// Empty texture
|
|
4250
|
-
if (this._emptyTexture) {
|
|
4251
|
-
this._releaseTexture(this._emptyTexture);
|
|
4252
|
-
this._emptyTexture = null;
|
|
4253
|
-
}
|
|
4254
|
-
if (this._emptyCubeTexture) {
|
|
4255
|
-
this._releaseTexture(this._emptyCubeTexture);
|
|
4256
|
-
this._emptyCubeTexture = null;
|
|
4257
|
-
}
|
|
3291
|
+
super.dispose();
|
|
4258
3292
|
if (this._dummyFramebuffer) {
|
|
4259
3293
|
this._gl.deleteFramebuffer(this._dummyFramebuffer);
|
|
4260
3294
|
}
|
|
4261
3295
|
// Release effects
|
|
4262
3296
|
this.releaseEffects();
|
|
4263
|
-
this.releaseComputeEffects?.();
|
|
4264
3297
|
// Unbind
|
|
4265
3298
|
this.unbindAllAttributes();
|
|
4266
3299
|
this._boundUniforms = {};
|
|
@@ -4271,22 +3304,12 @@ export class ThinEngine {
|
|
|
4271
3304
|
this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
|
|
4272
3305
|
this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
|
|
4273
3306
|
}
|
|
4274
|
-
window.removeEventListener("resize", this._checkForMobile);
|
|
4275
3307
|
}
|
|
4276
3308
|
}
|
|
4277
3309
|
this._workingCanvas = null;
|
|
4278
3310
|
this._workingContext = null;
|
|
4279
3311
|
this._currentBufferPointers.length = 0;
|
|
4280
|
-
this._renderingCanvas = null;
|
|
4281
3312
|
this._currentProgram = null;
|
|
4282
|
-
this._boundRenderFunction = null;
|
|
4283
|
-
Effect.ResetCache();
|
|
4284
|
-
// Abort active requests
|
|
4285
|
-
for (const request of this._activeRequests) {
|
|
4286
|
-
request.abort();
|
|
4287
|
-
}
|
|
4288
|
-
this.onDisposeObservable.notifyObservers(this);
|
|
4289
|
-
this.onDisposeObservable.clear();
|
|
4290
3313
|
if (this._creationOptions.loseContextOnDispose) {
|
|
4291
3314
|
this._gl.getExtension("WEBGL_lose_context")?.loseContext();
|
|
4292
3315
|
}
|
|
@@ -4640,31 +3663,6 @@ export class ThinEngine {
|
|
|
4640
3663
|
}
|
|
4641
3664
|
return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8;
|
|
4642
3665
|
}
|
|
4643
|
-
/**
|
|
4644
|
-
* @internal
|
|
4645
|
-
*/
|
|
4646
|
-
_loadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
|
|
4647
|
-
const request = ThinEngine._FileToolsLoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
|
|
4648
|
-
this._activeRequests.push(request);
|
|
4649
|
-
request.onCompleteObservable.add((request) => {
|
|
4650
|
-
this._activeRequests.splice(this._activeRequests.indexOf(request), 1);
|
|
4651
|
-
});
|
|
4652
|
-
return request;
|
|
4653
|
-
}
|
|
4654
|
-
/**
|
|
4655
|
-
* Loads a file from a url
|
|
4656
|
-
* @param url url to load
|
|
4657
|
-
* @param onSuccess callback called when the file successfully loads
|
|
4658
|
-
* @param onProgress callback called while file is loading (if the server supports this mode)
|
|
4659
|
-
* @param offlineProvider defines the offline provider for caching
|
|
4660
|
-
* @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
|
|
4661
|
-
* @param onError callback called when the file fails to load
|
|
4662
|
-
* @returns a file request object
|
|
4663
|
-
* @internal
|
|
4664
|
-
*/
|
|
4665
|
-
static _FileToolsLoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
|
|
4666
|
-
throw _WarnImport("FileTools");
|
|
4667
|
-
}
|
|
4668
3666
|
/**
|
|
4669
3667
|
* Reads pixels from the current frame buffer. Please note that this function can be slow
|
|
4670
3668
|
* @param x defines the x coordinate of the rectangle where pixels must be read
|
|
@@ -4685,6 +3683,15 @@ export class ThinEngine {
|
|
|
4685
3683
|
this._gl.readPixels(x, y, width, height, format, this._gl.UNSIGNED_BYTE, data);
|
|
4686
3684
|
return Promise.resolve(data);
|
|
4687
3685
|
}
|
|
3686
|
+
/**
|
|
3687
|
+
* Force the mipmap generation for the given render target texture
|
|
3688
|
+
* @param texture defines the render target texture to use
|
|
3689
|
+
* @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
|
|
3690
|
+
*/
|
|
3691
|
+
generateMipMapsForCubemap(texture, unbind) {
|
|
3692
|
+
// Does nothing
|
|
3693
|
+
// Child classes should implement this function
|
|
3694
|
+
}
|
|
4688
3695
|
/**
|
|
4689
3696
|
* Gets a Promise<boolean> indicating if the engine can be instantiated (ie. if a webGL context can be found)
|
|
4690
3697
|
*/
|
|
@@ -4709,7 +3716,7 @@ export class ThinEngine {
|
|
|
4709
3716
|
}
|
|
4710
3717
|
if (this._IsSupported === null) {
|
|
4711
3718
|
try {
|
|
4712
|
-
const tempcanvas =
|
|
3719
|
+
const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
|
|
4713
3720
|
const gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
|
|
4714
3721
|
this._IsSupported = gl != null && !!window.WebGLRenderingContext;
|
|
4715
3722
|
}
|
|
@@ -4725,7 +3732,7 @@ export class ThinEngine {
|
|
|
4725
3732
|
static get HasMajorPerformanceCaveat() {
|
|
4726
3733
|
if (this._HasMajorPerformanceCaveat === null) {
|
|
4727
3734
|
try {
|
|
4728
|
-
const tempcanvas =
|
|
3735
|
+
const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
|
|
4729
3736
|
const gl = tempcanvas.getContext("webgl", { failIfMajorPerformanceCaveat: true }) ||
|
|
4730
3737
|
tempcanvas.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: true });
|
|
4731
3738
|
this._HasMajorPerformanceCaveat = !gl;
|
|
@@ -4736,102 +3743,6 @@ export class ThinEngine {
|
|
|
4736
3743
|
}
|
|
4737
3744
|
return this._HasMajorPerformanceCaveat;
|
|
4738
3745
|
}
|
|
4739
|
-
/**
|
|
4740
|
-
* Find the next highest power of two.
|
|
4741
|
-
* @param x Number to start search from.
|
|
4742
|
-
* @returns Next highest power of two.
|
|
4743
|
-
*/
|
|
4744
|
-
static CeilingPOT(x) {
|
|
4745
|
-
x--;
|
|
4746
|
-
x |= x >> 1;
|
|
4747
|
-
x |= x >> 2;
|
|
4748
|
-
x |= x >> 4;
|
|
4749
|
-
x |= x >> 8;
|
|
4750
|
-
x |= x >> 16;
|
|
4751
|
-
x++;
|
|
4752
|
-
return x;
|
|
4753
|
-
}
|
|
4754
|
-
/**
|
|
4755
|
-
* Find the next lowest power of two.
|
|
4756
|
-
* @param x Number to start search from.
|
|
4757
|
-
* @returns Next lowest power of two.
|
|
4758
|
-
*/
|
|
4759
|
-
static FloorPOT(x) {
|
|
4760
|
-
x = x | (x >> 1);
|
|
4761
|
-
x = x | (x >> 2);
|
|
4762
|
-
x = x | (x >> 4);
|
|
4763
|
-
x = x | (x >> 8);
|
|
4764
|
-
x = x | (x >> 16);
|
|
4765
|
-
return x - (x >> 1);
|
|
4766
|
-
}
|
|
4767
|
-
/**
|
|
4768
|
-
* Find the nearest power of two.
|
|
4769
|
-
* @param x Number to start search from.
|
|
4770
|
-
* @returns Next nearest power of two.
|
|
4771
|
-
*/
|
|
4772
|
-
static NearestPOT(x) {
|
|
4773
|
-
const c = ThinEngine.CeilingPOT(x);
|
|
4774
|
-
const f = ThinEngine.FloorPOT(x);
|
|
4775
|
-
return c - x > x - f ? f : c;
|
|
4776
|
-
}
|
|
4777
|
-
/**
|
|
4778
|
-
* Get the closest exponent of two
|
|
4779
|
-
* @param value defines the value to approximate
|
|
4780
|
-
* @param max defines the maximum value to return
|
|
4781
|
-
* @param mode defines how to define the closest value
|
|
4782
|
-
* @returns closest exponent of two of the given value
|
|
4783
|
-
*/
|
|
4784
|
-
static GetExponentOfTwo(value, max, mode = 2) {
|
|
4785
|
-
let pot;
|
|
4786
|
-
switch (mode) {
|
|
4787
|
-
case 1:
|
|
4788
|
-
pot = ThinEngine.FloorPOT(value);
|
|
4789
|
-
break;
|
|
4790
|
-
case 2:
|
|
4791
|
-
pot = ThinEngine.NearestPOT(value);
|
|
4792
|
-
break;
|
|
4793
|
-
case 3:
|
|
4794
|
-
default:
|
|
4795
|
-
pot = ThinEngine.CeilingPOT(value);
|
|
4796
|
-
break;
|
|
4797
|
-
}
|
|
4798
|
-
return Math.min(pot, max);
|
|
4799
|
-
}
|
|
4800
|
-
/**
|
|
4801
|
-
* 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)
|
|
4802
|
-
* @param func - the function to be called
|
|
4803
|
-
* @param requester - the object that will request the next frame. Falls back to window.
|
|
4804
|
-
* @returns frame number
|
|
4805
|
-
*/
|
|
4806
|
-
static QueueNewFrame(func, requester) {
|
|
4807
|
-
// 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).
|
|
4808
|
-
// Also if the global `requestAnimationFrame`'s returnType is number, `requester.requestPostAnimationFrame` and `requester.requestAnimationFrame` types
|
|
4809
|
-
// are `any`.
|
|
4810
|
-
if (!IsWindowObjectExist()) {
|
|
4811
|
-
if (typeof requestAnimationFrame === "function") {
|
|
4812
|
-
return requestAnimationFrame(func);
|
|
4813
|
-
}
|
|
4814
|
-
}
|
|
4815
|
-
else {
|
|
4816
|
-
const { requestAnimationFrame } = requester || window;
|
|
4817
|
-
if (typeof requestAnimationFrame === "function") {
|
|
4818
|
-
return requestAnimationFrame(func);
|
|
4819
|
-
}
|
|
4820
|
-
}
|
|
4821
|
-
// fallback to the global `setTimeout`.
|
|
4822
|
-
// In most cases (aka in the browser), `window` is the global object, so instead of calling `window.setTimeout` we could call the global `setTimeout`.
|
|
4823
|
-
return setTimeout(func, 16);
|
|
4824
|
-
}
|
|
4825
|
-
/**
|
|
4826
|
-
* Gets host document
|
|
4827
|
-
* @returns the host document object
|
|
4828
|
-
*/
|
|
4829
|
-
getHostDocument() {
|
|
4830
|
-
if (this._renderingCanvas && this._renderingCanvas.ownerDocument) {
|
|
4831
|
-
return this._renderingCanvas.ownerDocument;
|
|
4832
|
-
}
|
|
4833
|
-
return IsDocumentAvailable() ? document : null;
|
|
4834
|
-
}
|
|
4835
3746
|
}
|
|
4836
3747
|
ThinEngine._TempClearColorUint32 = new Uint32Array(4);
|
|
4837
3748
|
ThinEngine._TempClearColorInt32 = new Int32Array(4);
|
|
@@ -4852,8 +3763,6 @@ ThinEngine.ExceptionList = [
|
|
|
4852
3763
|
// mobile browsers using safari 15.4 on ios
|
|
4853
3764
|
{ key: ".*(15.4).*AppleWebKit.*Safari", capture: null, captureConstraint: null, targets: ["antialias", "maxMSAASamples"] },
|
|
4854
3765
|
];
|
|
4855
|
-
/** @internal */
|
|
4856
|
-
ThinEngine._TextureLoaders = [];
|
|
4857
3766
|
// Updatable statics so stick with vars here
|
|
4858
3767
|
/**
|
|
4859
3768
|
* Gets or sets the epsilon value used by collision engine
|
|
@@ -4862,4 +3771,37 @@ ThinEngine.CollisionsEpsilon = 0.001;
|
|
|
4862
3771
|
// Statics
|
|
4863
3772
|
ThinEngine._IsSupported = null;
|
|
4864
3773
|
ThinEngine._HasMajorPerformanceCaveat = null;
|
|
3774
|
+
/**
|
|
3775
|
+
* Find the next highest power of two.
|
|
3776
|
+
* @param x Number to start search from.
|
|
3777
|
+
* @returns Next highest power of two.
|
|
3778
|
+
*/
|
|
3779
|
+
ThinEngine.CeilingPOT = CeilingPOT;
|
|
3780
|
+
/**
|
|
3781
|
+
* Find the next lowest power of two.
|
|
3782
|
+
* @param x Number to start search from.
|
|
3783
|
+
* @returns Next lowest power of two.
|
|
3784
|
+
*/
|
|
3785
|
+
ThinEngine.FloorPOT = FloorPOT;
|
|
3786
|
+
/**
|
|
3787
|
+
* Find the nearest power of two.
|
|
3788
|
+
* @param x Number to start search from.
|
|
3789
|
+
* @returns Next nearest power of two.
|
|
3790
|
+
*/
|
|
3791
|
+
ThinEngine.NearestPOT = NearestPOT;
|
|
3792
|
+
/**
|
|
3793
|
+
* Get the closest exponent of two
|
|
3794
|
+
* @param value defines the value to approximate
|
|
3795
|
+
* @param max defines the maximum value to return
|
|
3796
|
+
* @param mode defines how to define the closest value
|
|
3797
|
+
* @returns closest exponent of two of the given value
|
|
3798
|
+
*/
|
|
3799
|
+
ThinEngine.GetExponentOfTwo = GetExponentOfTwo;
|
|
3800
|
+
/**
|
|
3801
|
+
* 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)
|
|
3802
|
+
* @param func - the function to be called
|
|
3803
|
+
* @param requester - the object that will request the next frame. Falls back to window.
|
|
3804
|
+
* @returns frame number
|
|
3805
|
+
*/
|
|
3806
|
+
ThinEngine.QueueNewFrame = QueueNewFrame;
|
|
4865
3807
|
//# sourceMappingURL=thinEngine.js.map
|