@babylonjs/core 7.2.2 → 7.2.3
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/abstractEngine.d.ts +1688 -0
- package/Engines/abstractEngine.js +1354 -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 +35 -591
- package/Engines/thinEngine.js +84 -1134
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +149 -109
- package/Engines/webgpuEngine.js +249 -161
- 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/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/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/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/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/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 -4
- 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/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
|
|
@@ -124,10 +60,6 @@ export class ThinEngine {
|
|
|
124
60
|
getCreationOptions() {
|
|
125
61
|
return this._creationOptions;
|
|
126
62
|
}
|
|
127
|
-
/** @internal */
|
|
128
|
-
get _shouldUseHighPrecisionShader() {
|
|
129
|
-
return !!(this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed);
|
|
130
|
-
}
|
|
131
63
|
/**
|
|
132
64
|
* Gets a boolean indicating that only power of 2 textures are supported
|
|
133
65
|
* Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
|
|
@@ -135,23 +67,6 @@ export class ThinEngine {
|
|
|
135
67
|
get needPOTTextures() {
|
|
136
68
|
return this._webGLVersion < 2 || this.forcePOTTextures;
|
|
137
69
|
}
|
|
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
70
|
get _supportsHardwareTextureRescaling() {
|
|
156
71
|
return false;
|
|
157
72
|
}
|
|
@@ -163,112 +78,12 @@ export class ThinEngine {
|
|
|
163
78
|
set framebufferDimensionsObject(dimensions) {
|
|
164
79
|
this._framebufferDimensionsObject = dimensions;
|
|
165
80
|
}
|
|
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
81
|
/**
|
|
242
82
|
* Creates a new snapshot at the next frame using the current snapshotRenderingMode
|
|
243
83
|
*/
|
|
244
84
|
snapshotRenderingReset() {
|
|
245
85
|
this.snapshotRendering = false;
|
|
246
86
|
}
|
|
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
87
|
/**
|
|
273
88
|
* Creates a new engine
|
|
274
89
|
* @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 +92,23 @@ export class ThinEngine {
|
|
|
277
92
|
* @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
|
|
278
93
|
*/
|
|
279
94
|
constructor(canvasOrContext, antialias, options, adaptToDeviceRatio) {
|
|
95
|
+
options = options || {};
|
|
96
|
+
super((antialias ?? options.antialias) || false, options, adaptToDeviceRatio);
|
|
280
97
|
/** @internal */
|
|
281
98
|
this._name = "WebGL";
|
|
282
|
-
this._isDisposed = false;
|
|
283
99
|
/**
|
|
284
100
|
* Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
|
|
285
101
|
*/
|
|
286
102
|
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
103
|
/** Gets or sets a boolean indicating if the engine should validate programs after compilation */
|
|
305
104
|
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
105
|
/**
|
|
316
106
|
* Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
|
|
317
107
|
*/
|
|
318
108
|
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
109
|
/** @internal */
|
|
329
110
|
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
111
|
this._vertexAttribArraysEnabled = [];
|
|
382
|
-
/** @internal */
|
|
383
|
-
this._currentRenderTarget = null;
|
|
384
112
|
this._uintIndicesCurrentlySet = false;
|
|
385
113
|
this._currentBoundBuffer = new Array();
|
|
386
114
|
/** @internal */
|
|
@@ -390,42 +118,11 @@ export class ThinEngine {
|
|
|
390
118
|
this._currentBufferPointers = new Array();
|
|
391
119
|
this._currentInstanceLocations = new Array();
|
|
392
120
|
this._currentInstanceBuffers = new Array();
|
|
393
|
-
/** @internal */
|
|
394
|
-
this._boundRenderFunction = () => this._renderLoop();
|
|
395
121
|
this._vaoRecordInProgress = false;
|
|
396
122
|
this._mustWipeVertexAttributes = false;
|
|
397
|
-
/** @internal */
|
|
398
|
-
this._frameHandler = 0;
|
|
399
123
|
this._nextFreeTextureSlots = new Array();
|
|
400
124
|
this._maxSimultaneousTextures = 0;
|
|
401
125
|
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
126
|
this._unpackFlipYCached = null;
|
|
430
127
|
/**
|
|
431
128
|
* In case you are sharing the context with other applications, it might
|
|
@@ -434,35 +131,11 @@ export class ThinEngine {
|
|
|
434
131
|
*/
|
|
435
132
|
this.enableUnpackFlipYCached = true;
|
|
436
133
|
this._boundUniforms = {};
|
|
437
|
-
this.startTime = PrecisionDate.Now;
|
|
438
|
-
let canvas = null;
|
|
439
|
-
options = options || {};
|
|
440
134
|
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
135
|
if (!canvasOrContext) {
|
|
464
136
|
return;
|
|
465
137
|
}
|
|
138
|
+
let canvas = null;
|
|
466
139
|
if (canvasOrContext.getContext) {
|
|
467
140
|
canvas = canvasOrContext;
|
|
468
141
|
this._renderingCanvas = canvas;
|
|
@@ -527,8 +200,6 @@ export class ThinEngine {
|
|
|
527
200
|
canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
|
|
528
201
|
options.powerPreference = options.powerPreference || "high-performance";
|
|
529
202
|
}
|
|
530
|
-
// Detect if we are running on a faulty buggy desktop OS.
|
|
531
|
-
this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
532
203
|
if (this._badDesktopOS) {
|
|
533
204
|
options.xrCompatible = false;
|
|
534
205
|
}
|
|
@@ -594,8 +265,6 @@ export class ThinEngine {
|
|
|
594
265
|
}
|
|
595
266
|
// Shader processor
|
|
596
267
|
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
268
|
// Starting with iOS 14, we can trust the browser
|
|
600
269
|
// let matches = navigator.userAgent.match(/Version\/(\d+)/);
|
|
601
270
|
// if (matches && matches.length === 2) {
|
|
@@ -610,81 +279,9 @@ export class ThinEngine {
|
|
|
610
279
|
this._renderingCanvas.setAttribute("data-engine", versionToLog);
|
|
611
280
|
}
|
|
612
281
|
}
|
|
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
282
|
_clearEmptyResources() {
|
|
633
283
|
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;
|
|
284
|
+
super._clearEmptyResources();
|
|
688
285
|
}
|
|
689
286
|
/**
|
|
690
287
|
* @internal
|
|
@@ -692,26 +289,6 @@ export class ThinEngine {
|
|
|
692
289
|
_getShaderProcessingContext(shaderLanguage) {
|
|
693
290
|
return null;
|
|
694
291
|
}
|
|
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
292
|
/**
|
|
716
293
|
* Gets a boolean indicating if all created effects are ready
|
|
717
294
|
* @returns true if all effects are ready
|
|
@@ -725,13 +302,6 @@ export class ThinEngine {
|
|
|
725
302
|
}
|
|
726
303
|
return true;
|
|
727
304
|
}
|
|
728
|
-
_rebuildBuffers() {
|
|
729
|
-
// Uniforms
|
|
730
|
-
for (const uniformBuffer of this._uniformBuffers) {
|
|
731
|
-
uniformBuffer._rebuildAfterContextLost();
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
_rebuildTextures() { }
|
|
735
305
|
_initGLContext() {
|
|
736
306
|
// Caps
|
|
737
307
|
this._caps = {
|
|
@@ -1023,12 +593,6 @@ export class ThinEngine {
|
|
|
1023
593
|
getClassName() {
|
|
1024
594
|
return "ThinEngine";
|
|
1025
595
|
}
|
|
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
596
|
/** @internal */
|
|
1033
597
|
_prepareWorkingCanvas() {
|
|
1034
598
|
if (this._workingCanvas) {
|
|
@@ -1040,18 +604,6 @@ export class ThinEngine {
|
|
|
1040
604
|
this._workingContext = context;
|
|
1041
605
|
}
|
|
1042
606
|
}
|
|
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
607
|
/**
|
|
1056
608
|
* Gets an object containing information about the current engine context
|
|
1057
609
|
* @returns an object containing the vendor, the renderer and the version of the current engine context
|
|
@@ -1070,131 +622,13 @@ export class ThinEngine {
|
|
|
1070
622
|
version: this._glVersion,
|
|
1071
623
|
};
|
|
1072
624
|
}
|
|
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());
|
|
625
|
+
/**Gets driver info if available */
|
|
626
|
+
extractDriverInfo() {
|
|
627
|
+
const glInfo = this.getGlInfo();
|
|
628
|
+
if (glInfo && glInfo.renderer) {
|
|
629
|
+
return glInfo.renderer;
|
|
1163
630
|
}
|
|
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;
|
|
1196
|
-
}
|
|
1197
|
-
return window;
|
|
631
|
+
return "";
|
|
1198
632
|
}
|
|
1199
633
|
/**
|
|
1200
634
|
* Gets the current render width
|
|
@@ -1218,27 +652,6 @@ export class ThinEngine {
|
|
|
1218
652
|
}
|
|
1219
653
|
return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight;
|
|
1220
654
|
}
|
|
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
655
|
/**
|
|
1243
656
|
* Clear the current render buffer or the current render target (if any is set up)
|
|
1244
657
|
* @param color defines the color to use
|
|
@@ -1313,90 +726,21 @@ export class ThinEngine {
|
|
|
1313
726
|
}
|
|
1314
727
|
}
|
|
1315
728
|
/**
|
|
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
|
|
729
|
+
* End the current frame
|
|
1335
730
|
*/
|
|
1336
731
|
endFrame() {
|
|
732
|
+
super.endFrame();
|
|
1337
733
|
// Force a flush in case we are using a bad OS.
|
|
1338
734
|
if (this._badOS) {
|
|
1339
735
|
this.flushFramebuffer();
|
|
1340
736
|
}
|
|
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
737
|
}
|
|
1381
738
|
/**
|
|
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
|
|
739
|
+
* Gets the performance monitor attached to this engine
|
|
740
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#engineinstrumentation
|
|
1387
741
|
*/
|
|
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;
|
|
742
|
+
get performanceMonitor() {
|
|
743
|
+
throw new Error("Not Supported by ThinEngine");
|
|
1400
744
|
}
|
|
1401
745
|
/**
|
|
1402
746
|
* Binds the frame buffer to the specified texture.
|
|
@@ -1498,50 +842,6 @@ export class ThinEngine {
|
|
|
1498
842
|
}
|
|
1499
843
|
this._stencilStateComposer.stencilMaterial = stencil;
|
|
1500
844
|
}
|
|
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
845
|
/**
|
|
1546
846
|
* @internal
|
|
1547
847
|
*/
|
|
@@ -2186,10 +1486,6 @@ export class ThinEngine {
|
|
|
2186
1486
|
return this._gl.TRIANGLES;
|
|
2187
1487
|
}
|
|
2188
1488
|
}
|
|
2189
|
-
/** @internal */
|
|
2190
|
-
_reportDrawCall() {
|
|
2191
|
-
// Will be implemented by children
|
|
2192
|
-
}
|
|
2193
1489
|
// Shaders
|
|
2194
1490
|
/**
|
|
2195
1491
|
* @internal
|
|
@@ -2213,49 +1509,6 @@ export class ThinEngine {
|
|
|
2213
1509
|
this._gl.deleteProgram(webGLPipelineContext.program);
|
|
2214
1510
|
}
|
|
2215
1511
|
}
|
|
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
1512
|
/**
|
|
2260
1513
|
* Create a new effect (used to store vertex/fragment shaders)
|
|
2261
1514
|
* @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
|
|
@@ -2538,7 +1791,7 @@ export class ThinEngine {
|
|
|
2538
1791
|
* @param effect defines the effect to activate
|
|
2539
1792
|
*/
|
|
2540
1793
|
enableEffect(effect) {
|
|
2541
|
-
effect = effect !== null &&
|
|
1794
|
+
effect = effect !== null && IsWrapper(effect) ? effect.effect : effect; // get only the effect, we don't need a Wrapper in the WebGL engine
|
|
2542
1795
|
if (!effect || effect === this._currentEffect) {
|
|
2543
1796
|
return;
|
|
2544
1797
|
}
|
|
@@ -2940,55 +2193,7 @@ export class ThinEngine {
|
|
|
2940
2193
|
this._gl.colorMask(enable, enable, enable, enable);
|
|
2941
2194
|
}
|
|
2942
2195
|
}
|
|
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
2196
|
// 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
2197
|
/**
|
|
2993
2198
|
* Force the entire cache to be cleared
|
|
2994
2199
|
* You should not have to use this function unless your engine needs to share the webGL context with another engine
|
|
@@ -3027,6 +2232,15 @@ export class ThinEngine {
|
|
|
3027
2232
|
this._cachedEffectForVertexBuffers = null;
|
|
3028
2233
|
this.bindIndexBuffer(null);
|
|
3029
2234
|
}
|
|
2235
|
+
setTextureFromPostProcess(channel, postProcess, name) {
|
|
2236
|
+
// Does nothing
|
|
2237
|
+
}
|
|
2238
|
+
setTextureFromPostProcessOutput(channel, postProcess, name) {
|
|
2239
|
+
// Does nothing
|
|
2240
|
+
}
|
|
2241
|
+
setDepthStencilTexture(channel, uniform, texture, name) {
|
|
2242
|
+
// Does nothing
|
|
2243
|
+
}
|
|
3030
2244
|
/**
|
|
3031
2245
|
* @internal
|
|
3032
2246
|
*/
|
|
@@ -3237,142 +2451,7 @@ export class ThinEngine {
|
|
|
3237
2451
|
*/
|
|
3238
2452
|
_getUseSRGBBuffer(useSRGBBuffer, noMipmap) {
|
|
3239
2453
|
// 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;
|
|
2454
|
+
return useSRGBBuffer && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || noMipmap);
|
|
3376
2455
|
}
|
|
3377
2456
|
/**
|
|
3378
2457
|
* Usually called from Texture.ts.
|
|
@@ -3470,20 +2549,6 @@ export class ThinEngine {
|
|
|
3470
2549
|
type: this._gl.UNSIGNED_BYTE,
|
|
3471
2550
|
};
|
|
3472
2551
|
}
|
|
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
2552
|
/**
|
|
3488
2553
|
* @internal
|
|
3489
2554
|
*/
|
|
@@ -3826,8 +2891,8 @@ export class ThinEngine {
|
|
|
3826
2891
|
}
|
|
3827
2892
|
_prepareWebGLTexture(texture, extension, scene, img, invertY, noMipmap, isCompressed, processFunction, samplingMode = 3) {
|
|
3828
2893
|
const maxTextureSize = this.getCaps().maxTextureSize;
|
|
3829
|
-
const potWidth = Math.min(maxTextureSize, this.needPOTTextures ?
|
|
3830
|
-
const potHeight = Math.min(maxTextureSize, this.needPOTTextures ?
|
|
2894
|
+
const potWidth = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.width, maxTextureSize) : img.width);
|
|
2895
|
+
const potHeight = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.height, maxTextureSize) : img.height);
|
|
3831
2896
|
const gl = this._gl;
|
|
3832
2897
|
if (!gl) {
|
|
3833
2898
|
return;
|
|
@@ -3926,15 +2991,6 @@ export class ThinEngine {
|
|
|
3926
2991
|
texture._irradianceTexture.dispose();
|
|
3927
2992
|
}
|
|
3928
2993
|
}
|
|
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
2994
|
_deleteTexture(texture) {
|
|
3939
2995
|
if (texture) {
|
|
3940
2996
|
this._gl.deleteTexture(texture);
|
|
@@ -4240,27 +3296,12 @@ export class ThinEngine {
|
|
|
4240
3296
|
* Dispose and release all associated resources
|
|
4241
3297
|
*/
|
|
4242
3298
|
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
|
-
}
|
|
3299
|
+
super.dispose();
|
|
4258
3300
|
if (this._dummyFramebuffer) {
|
|
4259
3301
|
this._gl.deleteFramebuffer(this._dummyFramebuffer);
|
|
4260
3302
|
}
|
|
4261
3303
|
// Release effects
|
|
4262
3304
|
this.releaseEffects();
|
|
4263
|
-
this.releaseComputeEffects?.();
|
|
4264
3305
|
// Unbind
|
|
4265
3306
|
this.unbindAllAttributes();
|
|
4266
3307
|
this._boundUniforms = {};
|
|
@@ -4271,22 +3312,12 @@ export class ThinEngine {
|
|
|
4271
3312
|
this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
|
|
4272
3313
|
this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
|
|
4273
3314
|
}
|
|
4274
|
-
window.removeEventListener("resize", this._checkForMobile);
|
|
4275
3315
|
}
|
|
4276
3316
|
}
|
|
4277
3317
|
this._workingCanvas = null;
|
|
4278
3318
|
this._workingContext = null;
|
|
4279
3319
|
this._currentBufferPointers.length = 0;
|
|
4280
|
-
this._renderingCanvas = null;
|
|
4281
3320
|
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
3321
|
if (this._creationOptions.loseContextOnDispose) {
|
|
4291
3322
|
this._gl.getExtension("WEBGL_lose_context")?.loseContext();
|
|
4292
3323
|
}
|
|
@@ -4640,31 +3671,6 @@ export class ThinEngine {
|
|
|
4640
3671
|
}
|
|
4641
3672
|
return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8;
|
|
4642
3673
|
}
|
|
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
3674
|
/**
|
|
4669
3675
|
* Reads pixels from the current frame buffer. Please note that this function can be slow
|
|
4670
3676
|
* @param x defines the x coordinate of the rectangle where pixels must be read
|
|
@@ -4685,6 +3691,15 @@ export class ThinEngine {
|
|
|
4685
3691
|
this._gl.readPixels(x, y, width, height, format, this._gl.UNSIGNED_BYTE, data);
|
|
4686
3692
|
return Promise.resolve(data);
|
|
4687
3693
|
}
|
|
3694
|
+
/**
|
|
3695
|
+
* Force the mipmap generation for the given render target texture
|
|
3696
|
+
* @param texture defines the render target texture to use
|
|
3697
|
+
* @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
|
|
3698
|
+
*/
|
|
3699
|
+
generateMipMapsForCubemap(texture, unbind) {
|
|
3700
|
+
// Does nothing
|
|
3701
|
+
// Child classes should implement this function
|
|
3702
|
+
}
|
|
4688
3703
|
/**
|
|
4689
3704
|
* Gets a Promise<boolean> indicating if the engine can be instantiated (ie. if a webGL context can be found)
|
|
4690
3705
|
*/
|
|
@@ -4709,7 +3724,7 @@ export class ThinEngine {
|
|
|
4709
3724
|
}
|
|
4710
3725
|
if (this._IsSupported === null) {
|
|
4711
3726
|
try {
|
|
4712
|
-
const tempcanvas =
|
|
3727
|
+
const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
|
|
4713
3728
|
const gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
|
|
4714
3729
|
this._IsSupported = gl != null && !!window.WebGLRenderingContext;
|
|
4715
3730
|
}
|
|
@@ -4725,7 +3740,7 @@ export class ThinEngine {
|
|
|
4725
3740
|
static get HasMajorPerformanceCaveat() {
|
|
4726
3741
|
if (this._HasMajorPerformanceCaveat === null) {
|
|
4727
3742
|
try {
|
|
4728
|
-
const tempcanvas =
|
|
3743
|
+
const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
|
|
4729
3744
|
const gl = tempcanvas.getContext("webgl", { failIfMajorPerformanceCaveat: true }) ||
|
|
4730
3745
|
tempcanvas.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: true });
|
|
4731
3746
|
this._HasMajorPerformanceCaveat = !gl;
|
|
@@ -4736,102 +3751,6 @@ export class ThinEngine {
|
|
|
4736
3751
|
}
|
|
4737
3752
|
return this._HasMajorPerformanceCaveat;
|
|
4738
3753
|
}
|
|
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
3754
|
}
|
|
4836
3755
|
ThinEngine._TempClearColorUint32 = new Uint32Array(4);
|
|
4837
3756
|
ThinEngine._TempClearColorInt32 = new Int32Array(4);
|
|
@@ -4852,8 +3771,6 @@ ThinEngine.ExceptionList = [
|
|
|
4852
3771
|
// mobile browsers using safari 15.4 on ios
|
|
4853
3772
|
{ key: ".*(15.4).*AppleWebKit.*Safari", capture: null, captureConstraint: null, targets: ["antialias", "maxMSAASamples"] },
|
|
4854
3773
|
];
|
|
4855
|
-
/** @internal */
|
|
4856
|
-
ThinEngine._TextureLoaders = [];
|
|
4857
3774
|
// Updatable statics so stick with vars here
|
|
4858
3775
|
/**
|
|
4859
3776
|
* Gets or sets the epsilon value used by collision engine
|
|
@@ -4862,4 +3779,37 @@ ThinEngine.CollisionsEpsilon = 0.001;
|
|
|
4862
3779
|
// Statics
|
|
4863
3780
|
ThinEngine._IsSupported = null;
|
|
4864
3781
|
ThinEngine._HasMajorPerformanceCaveat = null;
|
|
3782
|
+
/**
|
|
3783
|
+
* Find the next highest power of two.
|
|
3784
|
+
* @param x Number to start search from.
|
|
3785
|
+
* @returns Next highest power of two.
|
|
3786
|
+
*/
|
|
3787
|
+
ThinEngine.CeilingPOT = CeilingPOT;
|
|
3788
|
+
/**
|
|
3789
|
+
* Find the next lowest power of two.
|
|
3790
|
+
* @param x Number to start search from.
|
|
3791
|
+
* @returns Next lowest power of two.
|
|
3792
|
+
*/
|
|
3793
|
+
ThinEngine.FloorPOT = FloorPOT;
|
|
3794
|
+
/**
|
|
3795
|
+
* Find the nearest power of two.
|
|
3796
|
+
* @param x Number to start search from.
|
|
3797
|
+
* @returns Next nearest power of two.
|
|
3798
|
+
*/
|
|
3799
|
+
ThinEngine.NearestPOT = NearestPOT;
|
|
3800
|
+
/**
|
|
3801
|
+
* Get the closest exponent of two
|
|
3802
|
+
* @param value defines the value to approximate
|
|
3803
|
+
* @param max defines the maximum value to return
|
|
3804
|
+
* @param mode defines how to define the closest value
|
|
3805
|
+
* @returns closest exponent of two of the given value
|
|
3806
|
+
*/
|
|
3807
|
+
ThinEngine.GetExponentOfTwo = GetExponentOfTwo;
|
|
3808
|
+
/**
|
|
3809
|
+
* 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)
|
|
3810
|
+
* @param func - the function to be called
|
|
3811
|
+
* @param requester - the object that will request the next frame. Falls back to window.
|
|
3812
|
+
* @returns frame number
|
|
3813
|
+
*/
|
|
3814
|
+
ThinEngine.QueueNewFrame = QueueNewFrame;
|
|
4865
3815
|
//# sourceMappingURL=thinEngine.js.map
|