@babylonjs/core 5.27.0 → 5.28.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/animatable.js +2 -1
- package/Animations/animatable.js.map +1 -1
- package/Animations/runtimeAnimation.js +1 -1
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioSceneComponent.js +2 -1
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Audio/sound.js +70 -45
- package/Audio/sound.js.map +1 -1
- package/Audio/soundTrack.js +12 -6
- package/Audio/soundTrack.js.map +1 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js +2 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
- package/Behaviors/Meshes/followBehavior.js +2 -1
- package/Behaviors/Meshes/followBehavior.js.map +1 -1
- package/Behaviors/Meshes/handConstraintBehavior.js +6 -6
- package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
- package/Bones/bone.js +2 -1
- package/Bones/bone.js.map +1 -1
- package/Bones/skeleton.js +3 -2
- package/Bones/skeleton.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.js +2 -2
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +5 -3
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js +2 -2
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +2 -2
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/arcRotateCamera.js +2 -1
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.js +6 -4
- package/Cameras/camera.js.map +1 -1
- package/Compute/computeEffect.js +8 -5
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.js +12 -11
- package/Compute/computeShader.js.map +1 -1
- package/Culling/Octrees/octreeSceneComponent.js +2 -1
- package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
- package/Culling/boundingBox.js +3 -2
- package/Culling/boundingBox.js.map +1 -1
- package/Culling/ray.js +2 -1
- package/Culling/ray.js.map +1 -1
- package/Debug/directionalLightFrustumViewer.js +9 -7
- package/Debug/directionalLightFrustumViewer.js.map +1 -1
- package/Debug/rayHelper.js +2 -1
- package/Debug/rayHelper.js.map +1 -1
- package/Debug/skeletonViewer.js +29 -24
- package/Debug/skeletonViewer.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.js +5 -3
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/internalDeviceSourceManager.js +2 -1
- package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +12 -9
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.rawTexture.js +4 -4
- package/Engines/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/Extensions/engine.readTexture.js +3 -2
- package/Engines/Extensions/engine.readTexture.js.map +1 -1
- package/Engines/Extensions/engine.views.js +2 -1
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +11 -6
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +2 -1
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +2 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.js +4 -2
- package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -4
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.storageBuffer.js +3 -2
- package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.textureSampler.js +2 -1
- package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.js +2 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheBindGroups.js +7 -6
- package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +18 -14
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +4 -3
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuClearQuad.js +3 -2
- package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
- package/Engines/WebGPU/webgpuComputePipelineContext.js +2 -1
- package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuDepthCullingState.js +2 -2
- package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.js +2 -1
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +4 -3
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuMaterialContext.js +5 -4
- package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js +5 -3
- package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuPipelineContext.js +4 -2
- package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.js +4 -2
- package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuSnapshotRendering.js +3 -2
- package/Engines/WebGPU/webgpuSnapshotRendering.js.map +1 -1
- package/Engines/WebGPU/webgpuStencilStateComposer.js +2 -1
- package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +40 -38
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/engine.d.ts +898 -273
- package/Engines/engine.js +5 -3
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.js +7 -5
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +7 -0
- package/Engines/nullEngine.js +42 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.js +14 -9
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.js +25 -16
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +87 -61
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gamepads/gamepadManager.js +1 -1
- package/Gamepads/gamepadManager.js.map +1 -1
- package/Gizmos/axisDragGizmo.js +4 -2
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js +6 -4
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/gizmo.js +21 -6
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.js +3 -2
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/planeDragGizmo.js +4 -2
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js +4 -2
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Helpers/videoDome.js +2 -1
- package/Helpers/videoDome.js.map +1 -1
- package/Layers/effectLayer.js +5 -3
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.js +4 -3
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js +2 -1
- package/Layers/highlightLayer.js.map +1 -1
- package/LensFlares/lensFlareSystem.js +2 -1
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +25 -21
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +13 -8
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +2 -1
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Loading/sceneLoader.d.ts +1 -1
- package/Loading/sceneLoader.js +3 -3
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +2 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +2 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +10 -6
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +3 -2
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +2 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +2 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +2 -1
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +26 -24
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js +3 -3
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +48 -44
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +2 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js +13 -13
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +27 -26
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +2 -2
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +6 -6
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js +3 -2
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +5 -4
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js +4 -3
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js +5 -4
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +7 -6
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.js +4 -3
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialDecorator.js +1 -1
- package/Materials/Node/nodeMaterialDecorator.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +25 -19
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js +9 -6
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.js +7 -4
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.js +7 -4
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/Textures/Loaders/envTextureLoader.js +2 -2
- package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
- package/Materials/Textures/Packer/packer.js +14 -13
- package/Materials/Textures/Packer/packer.js.map +1 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.d.ts +2 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/noiseProceduralTexture.js +2 -1
- package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +7 -4
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +5 -4
- package/Materials/Textures/baseTexture.js +1 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.js +8 -4
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js +4 -2
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.js +4 -2
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +6 -3
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.js +6 -4
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/rawTexture.js +1 -1
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +26 -15
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js +16 -13
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/thinRenderTargetTexture.js +4 -2
- package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
- package/Materials/Textures/thinTexture.d.ts +3 -3
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.js +3 -3
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/drawWrapper.js +4 -2
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.js +15 -10
- package/Materials/effect.js.map +1 -1
- package/Materials/material.d.ts +14 -0
- package/Materials/material.detailMapConfiguration.js +2 -1
- package/Materials/material.detailMapConfiguration.js.map +1 -1
- package/Materials/material.js +35 -3
- package/Materials/material.js.map +1 -1
- package/Materials/materialDefines.js +6 -5
- package/Materials/materialDefines.js.map +1 -1
- package/Materials/materialHelper.js +1 -1
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/materialPluginManager.js +3 -2
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/multiMaterial.js +2 -1
- package/Materials/multiMaterial.js.map +1 -1
- package/Materials/shaderMaterial.js +12 -9
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/shadowDepthWrapper.js +13 -8
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Materials/standardMaterial.js +12 -10
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.js +1 -1
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +7 -6
- package/Maths/math.vector.js +10 -8
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/groundBuilder.js +1 -1
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/abstractMesh.js +8 -5
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg.js +2 -1
- package/Meshes/csg.js.map +1 -1
- package/Meshes/instancedMesh.js +2 -1
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +1 -1
- package/Meshes/mesh.js +23 -13
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.js +4 -3
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/subMesh.js +14 -8
- package/Meshes/subMesh.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +18 -12
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Meshes/transformNode.d.ts +7 -1
- package/Meshes/transformNode.js +15 -4
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +2 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +12 -8
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js +3 -2
- package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
- package/Misc/arrayTools.js +1 -1
- package/Misc/arrayTools.js.map +1 -1
- package/Misc/assetsManager.d.ts +22 -4
- package/Misc/assetsManager.js +20 -8
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/computePressure.js +9 -6
- package/Misc/computePressure.js.map +1 -1
- package/Misc/dataStorage.js +1 -1
- package/Misc/dataStorage.js.map +1 -1
- package/Misc/dds.js +1 -1
- package/Misc/dds.js.map +1 -1
- package/Misc/environmentTextureTools.js +3 -2
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/fileTools.js +31 -8
- package/Misc/fileTools.js.map +1 -1
- package/Misc/logger.js +2 -1
- package/Misc/logger.js.map +1 -1
- package/Misc/minMaxReducer.js +3 -2
- package/Misc/minMaxReducer.js.map +1 -1
- package/Misc/sceneRecorder.js +1 -1
- package/Misc/sceneRecorder.js.map +1 -1
- package/Misc/textureTools.js +3 -3
- package/Misc/textureTools.js.map +1 -1
- package/Misc/timer.js +5 -3
- package/Misc/timer.js.map +1 -1
- package/Misc/tools.js +4 -4
- package/Misc/tools.js.map +1 -1
- package/Misc/trajectoryClassifier.js +3 -3
- package/Misc/trajectoryClassifier.js.map +1 -1
- package/Particles/EmitterTypes/meshParticleEmitter.js +2 -1
- package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
- package/Particles/computeShaderParticleSystem.js +6 -3
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.js +13 -8
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.js +22 -14
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/particleSystemComponent.js +2 -1
- package/Particles/particleSystemComponent.js.map +1 -1
- package/Particles/pointsCloudSystem.js +7 -4
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Particles/solidParticleSystem.js +2 -2
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/webgl2ParticleSystem.js +2 -1
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +5 -4
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.d.ts +4 -2
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.js +8 -5
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/postProcessManager.js +6 -4
- package/PostProcesses/postProcessManager.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +7 -4
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +1 -1
- package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
- package/Probes/reflectionProbe.js +4 -2
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/boundingBoxRenderer.js +3 -2
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Rendering/depthPeelingRenderer.d.ts +12 -0
- package/Rendering/depthPeelingRenderer.js +30 -6
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthPeelingSceneComponent.js +4 -2
- package/Rendering/depthPeelingSceneComponent.js.map +1 -1
- package/Rendering/depthRenderer.js +10 -6
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.js +11 -8
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +2 -2
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Rendering/prePassRenderer.js +4 -2
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +3 -3
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/Shaders/pbr.fragment.js +4 -1
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Sprites/spriteManager.js +2 -1
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.js +2 -1
- package/Sprites/spriteRenderer.js.map +1 -1
- package/States/stencilStateComposer.js +4 -2
- package/States/stencilStateComposer.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js +2 -1
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRControllerMovement.js +7 -6
- package/XR/features/WebXRControllerMovement.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js +6 -4
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js +2 -1
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRHandTracking.d.ts +3 -3
- package/XR/features/WebXRHandTracking.js +126 -118
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRHitTest.js.map +1 -1
- package/XR/features/WebXRLayers.js +1 -1
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js +7 -4
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRMeshDetector.js +2 -1
- package/XR/features/WebXRMeshDetector.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js +7 -4
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.js +2 -1
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/XR/native/nativeXRFrame.js +2 -1
- package/XR/native/nativeXRFrame.js.map +1 -1
- package/XR/webXRCamera.js +2 -1
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRExperienceHelper.js +7 -5
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/XR/webXRInput.js.map +1 -1
- package/XR/webXRInputSource.js +2 -1
- package/XR/webXRInputSource.js.map +1 -1
- package/XR/webXRManagedOutputCanvas.js +0 -1
- package/XR/webXRManagedOutputCanvas.js.map +1 -1
- package/XR/webXRSessionManager.js +27 -14
- package/XR/webXRSessionManager.js.map +1 -1
- package/XR/webXRWebGLLayer.js +3 -0
- package/XR/webXRWebGLLayer.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +17 -11
- package/scene.js.map +1 -1
|
@@ -80,6 +80,7 @@ export class WebXRSessionManager {
|
|
|
80
80
|
* This should be called explicitly by the dev, if required.
|
|
81
81
|
*/
|
|
82
82
|
dispose() {
|
|
83
|
+
var _a;
|
|
83
84
|
// disposing without leaving XR? Exit XR first
|
|
84
85
|
if (this.inXRSession) {
|
|
85
86
|
this.exitXRAsync();
|
|
@@ -88,7 +89,7 @@ export class WebXRSessionManager {
|
|
|
88
89
|
this.onXRSessionEnded.clear();
|
|
89
90
|
this.onXRReferenceSpaceChanged.clear();
|
|
90
91
|
this.onXRSessionInit.clear();
|
|
91
|
-
this._engine
|
|
92
|
+
(_a = this._engine) === null || _a === void 0 ? void 0 : _a.onDisposeObservable.remove(this._onEngineDisposedObserver);
|
|
92
93
|
this._engine = null;
|
|
93
94
|
}
|
|
94
95
|
/**
|
|
@@ -112,7 +113,8 @@ export class WebXRSessionManager {
|
|
|
112
113
|
* @returns whether the operation was successful
|
|
113
114
|
*/
|
|
114
115
|
trySetViewportForView(viewport, view) {
|
|
115
|
-
|
|
116
|
+
var _a;
|
|
117
|
+
return ((_a = this._baseLayerRTTProvider) === null || _a === void 0 ? void 0 : _a.trySetViewportForView(viewport, view)) || false;
|
|
116
118
|
}
|
|
117
119
|
/**
|
|
118
120
|
* Gets the correct render target texture to be rendered this frame for this eye
|
|
@@ -120,7 +122,8 @@ export class WebXRSessionManager {
|
|
|
120
122
|
* @returns the render target for the specified eye or null if not available
|
|
121
123
|
*/
|
|
122
124
|
getRenderTargetTextureForEye(eye) {
|
|
123
|
-
|
|
125
|
+
var _a;
|
|
126
|
+
return ((_a = this._baseLayerRTTProvider) === null || _a === void 0 ? void 0 : _a.getRenderTargetTextureForEye(eye)) || null;
|
|
124
127
|
}
|
|
125
128
|
/**
|
|
126
129
|
* Gets the correct render target texture to be rendered this frame for this view
|
|
@@ -128,7 +131,8 @@ export class WebXRSessionManager {
|
|
|
128
131
|
* @returns the render target for the specified view or null if not available
|
|
129
132
|
*/
|
|
130
133
|
getRenderTargetTextureForView(view) {
|
|
131
|
-
|
|
134
|
+
var _a;
|
|
135
|
+
return ((_a = this._baseLayerRTTProvider) === null || _a === void 0 ? void 0 : _a.getRenderTargetTextureForView(view)) || null;
|
|
132
136
|
}
|
|
133
137
|
/**
|
|
134
138
|
* Creates a WebXRRenderTarget object for the XR session
|
|
@@ -173,6 +177,7 @@ export class WebXRSessionManager {
|
|
|
173
177
|
this.inXRSession = true;
|
|
174
178
|
// handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
|
|
175
179
|
this.session.addEventListener("end", () => {
|
|
180
|
+
var _a;
|
|
176
181
|
this.inXRSession = false;
|
|
177
182
|
// Notify frame observers
|
|
178
183
|
this.onXRSessionEnded.notifyObservers(null);
|
|
@@ -188,7 +193,7 @@ export class WebXRSessionManager {
|
|
|
188
193
|
// Dispose render target textures.
|
|
189
194
|
// Only dispose on native because we can't destroy opaque textures on browser.
|
|
190
195
|
if (this.isNative) {
|
|
191
|
-
this._baseLayerRTTProvider
|
|
196
|
+
(_a = this._baseLayerRTTProvider) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
192
197
|
}
|
|
193
198
|
this._baseLayerRTTProvider = null;
|
|
194
199
|
this._baseLayerWrapper = null;
|
|
@@ -214,6 +219,7 @@ export class WebXRSessionManager {
|
|
|
214
219
|
* Starts rendering to the xr layer
|
|
215
220
|
*/
|
|
216
221
|
runXRRenderLoop() {
|
|
222
|
+
var _a;
|
|
217
223
|
if (!this.inXRSession || !this._engine) {
|
|
218
224
|
return;
|
|
219
225
|
}
|
|
@@ -221,6 +227,7 @@ export class WebXRSessionManager {
|
|
|
221
227
|
this._engine.customAnimationFrameRequester = {
|
|
222
228
|
requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session),
|
|
223
229
|
renderFunction: (timestamp, xrFrame) => {
|
|
230
|
+
var _a;
|
|
224
231
|
if (!this.inXRSession || !this._engine) {
|
|
225
232
|
return;
|
|
226
233
|
}
|
|
@@ -229,7 +236,7 @@ export class WebXRSessionManager {
|
|
|
229
236
|
this.currentTimestamp = timestamp;
|
|
230
237
|
if (xrFrame) {
|
|
231
238
|
this.inXRFrameLoop = true;
|
|
232
|
-
this._engine.framebufferDimensionsObject = this._baseLayerRTTProvider
|
|
239
|
+
this._engine.framebufferDimensionsObject = ((_a = this._baseLayerRTTProvider) === null || _a === void 0 ? void 0 : _a.getFramebufferDimensions()) || null;
|
|
233
240
|
this.onXRFrameObservable.notifyObservers(xrFrame);
|
|
234
241
|
this._engine._renderLoop();
|
|
235
242
|
this._engine.framebufferDimensionsObject = null;
|
|
@@ -237,7 +244,7 @@ export class WebXRSessionManager {
|
|
|
237
244
|
}
|
|
238
245
|
},
|
|
239
246
|
};
|
|
240
|
-
this._engine.framebufferDimensionsObject = this._baseLayerRTTProvider
|
|
247
|
+
this._engine.framebufferDimensionsObject = ((_a = this._baseLayerRTTProvider) === null || _a === void 0 ? void 0 : _a.getFramebufferDimensions()) || null;
|
|
241
248
|
// Stop window's animation frame and trigger sessions animation frame
|
|
242
249
|
if (typeof window !== "undefined" && window.cancelAnimationFrame) {
|
|
243
250
|
window.cancelAnimationFrame(this._engine._frameHandler);
|
|
@@ -293,11 +300,12 @@ export class WebXRSessionManager {
|
|
|
293
300
|
* @internal
|
|
294
301
|
*/
|
|
295
302
|
_setBaseLayerWrapper(baseLayerWrapper) {
|
|
303
|
+
var _a, _b;
|
|
296
304
|
if (this.isNative) {
|
|
297
|
-
this._baseLayerRTTProvider
|
|
305
|
+
(_a = this._baseLayerRTTProvider) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
298
306
|
}
|
|
299
307
|
this._baseLayerWrapper = baseLayerWrapper;
|
|
300
|
-
this._baseLayerRTTProvider = this._baseLayerWrapper
|
|
308
|
+
this._baseLayerRTTProvider = ((_b = this._baseLayerWrapper) === null || _b === void 0 ? void 0 : _b.createRenderTargetTextureProvider(this)) || null;
|
|
301
309
|
}
|
|
302
310
|
/**
|
|
303
311
|
* Updates the render state of the session
|
|
@@ -340,19 +348,22 @@ export class WebXRSessionManager {
|
|
|
340
348
|
* Returns true if Babylon.js is using the BabylonNative backend, otherwise false
|
|
341
349
|
*/
|
|
342
350
|
get isNative() {
|
|
343
|
-
|
|
351
|
+
var _a;
|
|
352
|
+
return (_a = this._xrNavigator.xr.native) !== null && _a !== void 0 ? _a : false;
|
|
344
353
|
}
|
|
345
354
|
/**
|
|
346
355
|
* The current frame rate as reported by the device
|
|
347
356
|
*/
|
|
348
357
|
get currentFrameRate() {
|
|
349
|
-
|
|
358
|
+
var _a;
|
|
359
|
+
return (_a = this.session) === null || _a === void 0 ? void 0 : _a.frameRate;
|
|
350
360
|
}
|
|
351
361
|
/**
|
|
352
362
|
* A list of supported frame rates (only available in-session!
|
|
353
363
|
*/
|
|
354
364
|
get supportedFrameRates() {
|
|
355
|
-
|
|
365
|
+
var _a;
|
|
366
|
+
return (_a = this.session) === null || _a === void 0 ? void 0 : _a.supportedFrameRates;
|
|
356
367
|
}
|
|
357
368
|
/**
|
|
358
369
|
* Set the framerate of the session.
|
|
@@ -379,14 +390,16 @@ export class WebXRSessionManager {
|
|
|
379
390
|
* Check if fixed foveation is supported on this device
|
|
380
391
|
*/
|
|
381
392
|
get isFixedFoveationSupported() {
|
|
382
|
-
|
|
393
|
+
var _a;
|
|
394
|
+
return ((_a = this._baseLayerWrapper) === null || _a === void 0 ? void 0 : _a.isFixedFoveationSupported) || false;
|
|
383
395
|
}
|
|
384
396
|
/**
|
|
385
397
|
* Get the fixed foveation currently set, as specified by the webxr specs
|
|
386
398
|
* If this returns null, then fixed foveation is not supported
|
|
387
399
|
*/
|
|
388
400
|
get fixedFoveation() {
|
|
389
|
-
|
|
401
|
+
var _a;
|
|
402
|
+
return ((_a = this._baseLayerWrapper) === null || _a === void 0 ? void 0 : _a.fixedFoveation) || null;
|
|
390
403
|
}
|
|
391
404
|
/**
|
|
392
405
|
* Set the fixed foveation to the specified value, as specified by the webxr specs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRSessionManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRSessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKhD,OAAO,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAKvG,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG3D;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IA2D5B;;;OAGG;IACH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AAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACxB,IAAI,CAAC,iBAAiB,CAAC,cAAc,GAAG,GAAG,CAAC;SAC/C;IACL,CAAC;CACJ","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { WebXRRenderTarget } from \"./webXRTypes\";\r\nimport { WebXRManagedOutputCanvas, WebXRManagedOutputCanvasOptions } from \"./webXRManagedOutputCanvas\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { IWebXRRenderTargetTextureProvider, WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\r\nimport type { Viewport } from \"../Maths/math.viewport\";\r\nimport type { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\nimport { NativeXRLayerWrapper, NativeXRRenderTarget } from \"./native/nativeXRRenderTarget\";\r\nimport { WebXRWebGLLayerWrapper } from \"./webXRWebGLLayer\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\n\r\n/**\r\n * Manages an XRSession to work with Babylon's engine\r\n * @see https://doc.babylonjs.com/how_to/webxr_session_manager\r\n */\r\nexport class WebXRSessionManager implements IDisposable, IWebXRRenderTargetTextureProvider {\r\n private _engine: Nullable<Engine>;\r\n private _referenceSpace: XRReferenceSpace;\r\n private _baseLayerWrapper: Nullable<WebXRLayerWrapper>;\r\n private _baseLayerRTTProvider: Nullable<WebXRLayerRenderTargetTextureProvider>;\r\n private _xrNavigator: any;\r\n private _sessionMode: XRSessionMode;\r\n private _onEngineDisposedObserver: Nullable<Observer<ThinEngine>>;\r\n\r\n /**\r\n * The base reference space from which the session started. good if you want to reset your\r\n * reference space\r\n */\r\n public baseReferenceSpace: XRReferenceSpace;\r\n /**\r\n * Current XR frame\r\n */\r\n public currentFrame: Nullable<XRFrame>;\r\n /** WebXR timestamp updated every frame */\r\n public currentTimestamp: number = -1;\r\n /**\r\n * Used just in case of a failure to initialize an immersive session.\r\n * The viewer reference space is compensated using this height, creating a kind of \"viewer-floor\" reference space\r\n */\r\n public defaultHeightCompensation = 1.7;\r\n /**\r\n * Fires every time a new xrFrame arrives which can be used to update the camera\r\n */\r\n public onXRFrameObservable: Observable<XRFrame> = new Observable<XRFrame>();\r\n /**\r\n * Fires when the reference space changed\r\n */\r\n public onXRReferenceSpaceChanged: Observable<XRReferenceSpace> = new Observable();\r\n /**\r\n * Fires when the xr session is ended either by the device or manually done\r\n */\r\n public onXRSessionEnded: Observable<any> = new Observable<any>();\r\n /**\r\n * Fires when the xr session is initialized: right after requestSession was called and returned with a successful result\r\n */\r\n public onXRSessionInit: Observable<XRSession> = new Observable<XRSession>();\r\n /**\r\n * Underlying xr session\r\n */\r\n public session: XRSession;\r\n /**\r\n * The viewer (head position) reference space. This can be used to get the XR world coordinates\r\n * or get the offset the player is currently at.\r\n */\r\n public viewerReferenceSpace: XRReferenceSpace;\r\n /**\r\n * Are we currently in the XR loop?\r\n */\r\n public inXRFrameLoop: boolean = false;\r\n /**\r\n * Are we in an XR session?\r\n */\r\n public inXRSession: boolean = false;\r\n\r\n /**\r\n * Constructs a WebXRSessionManager, this must be initialized within a user action before usage\r\n * @param scene The scene which the session should be created for\r\n */\r\n constructor(\r\n /** The scene which the session should be created for */\r\n public scene: Scene\r\n ) {\r\n this._engine = scene.getEngine();\r\n this._onEngineDisposedObserver = this._engine.onDisposeObservable.addOnce(() => {\r\n this._engine = null;\r\n });\r\n scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * The current reference space used in this session. This reference space can constantly change!\r\n * It is mainly used to offset the camera's position.\r\n */\r\n public get referenceSpace(): XRReferenceSpace {\r\n return this._referenceSpace;\r\n }\r\n\r\n /**\r\n * Set a new reference space and triggers the observable\r\n */\r\n public set referenceSpace(newReferenceSpace: XRReferenceSpace) {\r\n this._referenceSpace = newReferenceSpace;\r\n this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace);\r\n }\r\n\r\n /**\r\n * The mode for the managed XR session\r\n */\r\n public get sessionMode(): XRSessionMode {\r\n return this._sessionMode;\r\n }\r\n\r\n /**\r\n * Disposes of the session manager\r\n * This should be called explicitly by the dev, if required.\r\n */\r\n public dispose() {\r\n // disposing without leaving XR? Exit XR first\r\n if (this.inXRSession) {\r\n this.exitXRAsync();\r\n }\r\n this.onXRFrameObservable.clear();\r\n this.onXRSessionEnded.clear();\r\n this.onXRReferenceSpaceChanged.clear();\r\n this.onXRSessionInit.clear();\r\n this._engine?.onDisposeObservable.remove(this._onEngineDisposedObserver);\r\n this._engine = null;\r\n }\r\n\r\n /**\r\n * Stops the xrSession and restores the render loop\r\n * @returns Promise which resolves after it exits XR\r\n */\r\n public exitXRAsync() {\r\n if (this.session && this.inXRSession) {\r\n this.inXRSession = false;\r\n return this.session.end().catch(() => {\r\n Logger.Warn(\"Could not end XR session.\");\r\n });\r\n }\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Attempts to set the framebuffer-size-normalized viewport to be rendered this frame for this view.\r\n * In the event of a failure, the supplied viewport is not updated.\r\n * @param viewport the viewport to which the view will be rendered\r\n * @param view the view for which to set the viewport\r\n * @returns whether the operation was successful\r\n */\r\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\r\n return this._baseLayerRTTProvider?.trySetViewportForView(viewport, view) || false;\r\n }\r\n\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this eye\r\n * @param eye the eye for which to get the render target\r\n * @returns the render target for the specified eye or null if not available\r\n */\r\n public getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture> {\r\n return this._baseLayerRTTProvider?.getRenderTargetTextureForEye(eye) || null;\r\n }\r\n\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this view\r\n * @param view the view for which to get the render target\r\n * @returns the render target for the specified view or null if not available\r\n */\r\n public getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture> {\r\n return this._baseLayerRTTProvider?.getRenderTargetTextureForView(view) || null;\r\n }\r\n\r\n /**\r\n * Creates a WebXRRenderTarget object for the XR session\r\n * @param options optional options to provide when creating a new render target\r\n * @returns a WebXR render target to which the session can render\r\n */\r\n public getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget {\r\n const engine = this.scene.getEngine();\r\n if (this._xrNavigator.xr.native) {\r\n return new NativeXRRenderTarget(this);\r\n } else {\r\n options = options || WebXRManagedOutputCanvasOptions.GetDefaults(engine);\r\n options.canvasElement = options.canvasElement || engine.getRenderingCanvas() || undefined;\r\n return new WebXRManagedOutputCanvas(this, options);\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the manager\r\n * After initialization enterXR can be called to start an XR session\r\n * @returns Promise which resolves after it is initialized\r\n */\r\n public initializeAsync(): Promise<void> {\r\n // Check if the browser supports webXR\r\n this._xrNavigator = navigator;\r\n if (!this._xrNavigator.xr) {\r\n return Promise.reject(\"WebXR not available\");\r\n }\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Initializes an xr session\r\n * @param xrSessionMode mode to initialize\r\n * @param xrSessionInit defines optional and required values to pass to the session builder\r\n * @returns a promise which will resolve once the session has been initialized\r\n */\r\n public initializeSessionAsync(xrSessionMode: XRSessionMode = \"immersive-vr\", xrSessionInit: XRSessionInit = {}): Promise<XRSession> {\r\n return this._xrNavigator.xr.requestSession(xrSessionMode, xrSessionInit).then((session: XRSession) => {\r\n this.session = session;\r\n this._sessionMode = xrSessionMode;\r\n this.onXRSessionInit.notifyObservers(session);\r\n this.inXRSession = true;\r\n\r\n // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)\r\n this.session.addEventListener(\r\n \"end\",\r\n () => {\r\n this.inXRSession = false;\r\n\r\n // Notify frame observers\r\n this.onXRSessionEnded.notifyObservers(null);\r\n\r\n if (this._engine) {\r\n // make sure dimensions object is restored\r\n this._engine.framebufferDimensionsObject = null;\r\n\r\n // Restore frame buffer to avoid clear on xr framebuffer after session end\r\n this._engine.restoreDefaultFramebuffer();\r\n\r\n // Need to restart render loop as after the session is ended the last request for new frame will never call callback\r\n this._engine.customAnimationFrameRequester = null;\r\n this._engine._renderLoop();\r\n }\r\n\r\n // Dispose render target textures.\r\n // Only dispose on native because we can't destroy opaque textures on browser.\r\n if (this.isNative) {\r\n this._baseLayerRTTProvider?.dispose();\r\n }\r\n this._baseLayerRTTProvider = null;\r\n this._baseLayerWrapper = null;\r\n },\r\n { once: true }\r\n );\r\n\r\n return this.session;\r\n });\r\n }\r\n\r\n /**\r\n * Checks if a session would be supported for the creation options specified\r\n * @param sessionMode session mode to check if supported eg. immersive-vr\r\n * @returns A Promise that resolves to true if supported and false if not\r\n */\r\n public isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean> {\r\n return WebXRSessionManager.IsSessionSupportedAsync(sessionMode);\r\n }\r\n\r\n /**\r\n * Resets the reference space to the one started the session\r\n */\r\n public resetReferenceSpace() {\r\n this.referenceSpace = this.baseReferenceSpace;\r\n }\r\n\r\n /**\r\n * Starts rendering to the xr layer\r\n */\r\n public runXRRenderLoop() {\r\n if (!this.inXRSession || !this._engine) {\r\n return;\r\n }\r\n\r\n // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information\r\n this._engine.customAnimationFrameRequester = {\r\n requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session),\r\n renderFunction: (timestamp: number, xrFrame: Nullable<XRFrame>) => {\r\n if (!this.inXRSession || !this._engine) {\r\n return;\r\n }\r\n // Store the XR frame and timestamp in the session manager\r\n this.currentFrame = xrFrame;\r\n this.currentTimestamp = timestamp;\r\n if (xrFrame) {\r\n this.inXRFrameLoop = true;\r\n this._engine.framebufferDimensionsObject = this._baseLayerRTTProvider?.getFramebufferDimensions() || null;\r\n this.onXRFrameObservable.notifyObservers(xrFrame);\r\n this._engine._renderLoop();\r\n this._engine.framebufferDimensionsObject = null;\r\n this.inXRFrameLoop = false;\r\n }\r\n },\r\n };\r\n\r\n this._engine.framebufferDimensionsObject = this._baseLayerRTTProvider?.getFramebufferDimensions() || null;\r\n\r\n // Stop window's animation frame and trigger sessions animation frame\r\n if (typeof window !== \"undefined\" && window.cancelAnimationFrame) {\r\n window.cancelAnimationFrame(this._engine._frameHandler);\r\n }\r\n this._engine._renderLoop();\r\n }\r\n\r\n /**\r\n * Sets the reference space on the xr session\r\n * @param referenceSpaceType space to set\r\n * @returns a promise that will resolve once the reference space has been set\r\n */\r\n public setReferenceSpaceTypeAsync(referenceSpaceType: XRReferenceSpaceType = \"local-floor\"): Promise<XRReferenceSpace> {\r\n return this.session\r\n .requestReferenceSpace(referenceSpaceType)\r\n .then(\r\n (referenceSpace) => {\r\n return referenceSpace as XRReferenceSpace;\r\n },\r\n (rejectionReason) => {\r\n Logger.Error(\"XR.requestReferenceSpace failed for the following reason: \");\r\n Logger.Error(rejectionReason);\r\n Logger.Log('Defaulting to universally-supported \"viewer\" reference space type.');\r\n\r\n return this.session.requestReferenceSpace(\"viewer\").then(\r\n (referenceSpace) => {\r\n const heightCompensation = new XRRigidTransform({ x: 0, y: -this.defaultHeightCompensation, z: 0 });\r\n return (referenceSpace as XRReferenceSpace).getOffsetReferenceSpace(heightCompensation);\r\n },\r\n (rejectionReason) => {\r\n Logger.Error(rejectionReason);\r\n throw 'XR initialization failed: required \"viewer\" reference space type not supported.';\r\n }\r\n );\r\n }\r\n )\r\n .then((referenceSpace) => {\r\n // create viewer reference space before setting the first reference space\r\n return this.session.requestReferenceSpace(\"viewer\").then((viewerReferenceSpace) => {\r\n this.viewerReferenceSpace = viewerReferenceSpace as XRReferenceSpace;\r\n return referenceSpace;\r\n });\r\n })\r\n .then((referenceSpace) => {\r\n // initialize the base and offset (currently the same)\r\n this.referenceSpace = this.baseReferenceSpace = referenceSpace;\r\n return this.referenceSpace;\r\n });\r\n }\r\n\r\n /**\r\n * Updates the render state of the session.\r\n * Note that this is deprecated in favor of WebXRSessionManager.updateRenderState().\r\n * @param state state to set\r\n * @returns a promise that resolves once the render state has been updated\r\n * @deprecated\r\n */\r\n public updateRenderStateAsync(state: XRRenderState): Promise<void> {\r\n return Promise.resolve(this.session.updateRenderState(state));\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setBaseLayerWrapper(baseLayerWrapper: Nullable<WebXRLayerWrapper>): void {\r\n if (this.isNative) {\r\n this._baseLayerRTTProvider?.dispose();\r\n }\r\n this._baseLayerWrapper = baseLayerWrapper;\r\n this._baseLayerRTTProvider = this._baseLayerWrapper?.createRenderTargetTextureProvider(this) || null;\r\n }\r\n\r\n /**\r\n * Updates the render state of the session\r\n * @param state state to set\r\n */\r\n public updateRenderState(state: XRRenderStateInit): void {\r\n if (state.baseLayer) {\r\n this._setBaseLayerWrapper(this.isNative ? new NativeXRLayerWrapper(state.baseLayer) : new WebXRWebGLLayerWrapper(state.baseLayer));\r\n }\r\n\r\n this.session.updateRenderState(state);\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser\r\n * @param sessionMode defines the session to test\r\n * @returns a promise with boolean as final value\r\n */\r\n public static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean> {\r\n if (!(navigator as any).xr) {\r\n return Promise.resolve(false);\r\n }\r\n // When the specs are final, remove supportsSession!\r\n const functionToUse = (navigator as any).xr.isSessionSupported || (navigator as any).xr.supportsSession;\r\n if (!functionToUse) {\r\n return Promise.resolve(false);\r\n } else {\r\n return functionToUse\r\n .call((navigator as any).xr, sessionMode)\r\n .then((result: boolean) => {\r\n const returnValue = typeof result === \"undefined\" ? true : result;\r\n return Promise.resolve(returnValue);\r\n })\r\n .catch((e: any) => {\r\n Logger.Warn(e);\r\n return Promise.resolve(false);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if Babylon.js is using the BabylonNative backend, otherwise false\r\n */\r\n public get isNative(): boolean {\r\n return this._xrNavigator.xr.native ?? false;\r\n }\r\n\r\n /**\r\n * The current frame rate as reported by the device\r\n */\r\n public get currentFrameRate(): number | undefined {\r\n return this.session?.frameRate;\r\n }\r\n\r\n /**\r\n * A list of supported frame rates (only available in-session!\r\n */\r\n public get supportedFrameRates(): Float32Array | undefined {\r\n return this.session?.supportedFrameRates;\r\n }\r\n\r\n /**\r\n * Set the framerate of the session.\r\n * @param rate the new framerate. This value needs to be in the supportedFrameRates array\r\n * @returns a promise that resolves once the framerate has been set\r\n */\r\n public updateTargetFrameRate(rate: number): Promise<void> {\r\n return this.session.updateTargetFrameRate(rate);\r\n }\r\n\r\n /**\r\n * Run a callback in the xr render loop\r\n * @param callback the callback to call when in XR Frame\r\n * @param ignoreIfNotInSession if no session is currently running, run it first thing on the next session\r\n */\r\n public runInXRFrame(callback: () => void, ignoreIfNotInSession = true): void {\r\n if (this.inXRFrameLoop) {\r\n callback();\r\n } else if (this.inXRSession || !ignoreIfNotInSession) {\r\n this.onXRFrameObservable.addOnce(callback);\r\n }\r\n }\r\n\r\n /**\r\n * Check if fixed foveation is supported on this device\r\n */\r\n public get isFixedFoveationSupported(): boolean {\r\n return this._baseLayerWrapper?.isFixedFoveationSupported || false;\r\n }\r\n\r\n /**\r\n * Get the fixed foveation currently set, as specified by the webxr specs\r\n * If this returns null, then fixed foveation is not supported\r\n */\r\n public get fixedFoveation(): Nullable<number> {\r\n return this._baseLayerWrapper?.fixedFoveation || null;\r\n }\r\n\r\n /**\r\n * Set the fixed foveation to the specified value, as specified by the webxr specs\r\n * This value will be normalized to be between 0 and 1, 1 being max foveation, 0 being no foveation\r\n */\r\n public set fixedFoveation(value: Nullable<number>) {\r\n const val = Math.max(0, Math.min(1, value || 0));\r\n if (this._baseLayerWrapper) {\r\n this._baseLayerWrapper.fixedFoveation = val;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRSessionManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRSessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKhD,OAAO,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAKvG,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG3D;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IA2D5B;;;OAGG;IACH;IACI,wDAAwD;IACjD,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QA/CvB,0CAA0C;QACnC,qBAAgB,GAAW,CAAC,CAAC,CAAC;QACrC;;;WAGG;QACI,8BAAyB,GAAG,GAAG,CAAC;QACvC;;WAEG;QACI,wBAAmB,GAAwB,IAAI,UAAU,EAAW,CAAC;QAC5E;;WAEG;QACI,8BAAyB,GAAiC,IAAI,UAAU,EAAE,CAAC;QAClF;;WAEG;QACI,qBAAgB,GAAoB,IAAI,UAAU,EAAO,CAAC;QACjE;;WAEG;QACI,oBAAe,GAA0B,IAAI,UAAU,EAAa,CAAC;QAU5E;;WAEG;QACI,kBAAa,GAAY,KAAK,CAAC;QACtC;;WAEG;QACI,gBAAW,GAAY,KAAK,CAAC;QAUhC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE;YAC3E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE;YACnC,IAAI,CAAC,OAAO,EAAE,C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AIG;IACI,YAAY,CAAC,QAAoB,EAAE,oBAAoB,GAAG,IAAI;QACjE,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,QAAQ,EAAE,CAAC;SACd;aAAM,IAAI,IAAI,CAAC,WAAW,IAAI,CAAC,oBAAoB,EAAE;YAClD,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SAC9C;IACL,CAAC;IAED;;OAEG;IACH,IAAW,yBAAyB;;QAChC,OAAO,CAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,yBAAyB,KAAI,KAAK,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;;QACrB,OAAO,CAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,cAAc,KAAI,IAAI,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc,CAAC,KAAuB;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACxB,IAAI,CAAC,iBAAiB,CAAC,cAAc,GAAG,GAAG,CAAC;SAC/C;IACL,CAAC;CACJ","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { WebXRRenderTarget } from \"./webXRTypes\";\r\nimport { WebXRManagedOutputCanvas, WebXRManagedOutputCanvasOptions } from \"./webXRManagedOutputCanvas\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { IWebXRRenderTargetTextureProvider, WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\r\nimport type { Viewport } from \"../Maths/math.viewport\";\r\nimport type { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\nimport { NativeXRLayerWrapper, NativeXRRenderTarget } from \"./native/nativeXRRenderTarget\";\r\nimport { WebXRWebGLLayerWrapper } from \"./webXRWebGLLayer\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\n\r\n/**\r\n * Manages an XRSession to work with Babylon's engine\r\n * @see https://doc.babylonjs.com/how_to/webxr_session_manager\r\n */\r\nexport class WebXRSessionManager implements IDisposable, IWebXRRenderTargetTextureProvider {\r\n private _engine: Nullable<Engine>;\r\n private _referenceSpace: XRReferenceSpace;\r\n private _baseLayerWrapper: Nullable<WebXRLayerWrapper>;\r\n private _baseLayerRTTProvider: Nullable<WebXRLayerRenderTargetTextureProvider>;\r\n private _xrNavigator: any;\r\n private _sessionMode: XRSessionMode;\r\n private _onEngineDisposedObserver: Nullable<Observer<ThinEngine>>;\r\n\r\n /**\r\n * The base reference space from which the session started. good if you want to reset your\r\n * reference space\r\n */\r\n public baseReferenceSpace: XRReferenceSpace;\r\n /**\r\n * Current XR frame\r\n */\r\n public currentFrame: Nullable<XRFrame>;\r\n /** WebXR timestamp updated every frame */\r\n public currentTimestamp: number = -1;\r\n /**\r\n * Used just in case of a failure to initialize an immersive session.\r\n * The viewer reference space is compensated using this height, creating a kind of \"viewer-floor\" reference space\r\n */\r\n public defaultHeightCompensation = 1.7;\r\n /**\r\n * Fires every time a new xrFrame arrives which can be used to update the camera\r\n */\r\n public onXRFrameObservable: Observable<XRFrame> = new Observable<XRFrame>();\r\n /**\r\n * Fires when the reference space changed\r\n */\r\n public onXRReferenceSpaceChanged: Observable<XRReferenceSpace> = new Observable();\r\n /**\r\n * Fires when the xr session is ended either by the device or manually done\r\n */\r\n public onXRSessionEnded: Observable<any> = new Observable<any>();\r\n /**\r\n * Fires when the xr session is initialized: right after requestSession was called and returned with a successful result\r\n */\r\n public onXRSessionInit: Observable<XRSession> = new Observable<XRSession>();\r\n /**\r\n * Underlying xr session\r\n */\r\n public session: XRSession;\r\n /**\r\n * The viewer (head position) reference space. This can be used to get the XR world coordinates\r\n * or get the offset the player is currently at.\r\n */\r\n public viewerReferenceSpace: XRReferenceSpace;\r\n /**\r\n * Are we currently in the XR loop?\r\n */\r\n public inXRFrameLoop: boolean = false;\r\n /**\r\n * Are we in an XR session?\r\n */\r\n public inXRSession: boolean = false;\r\n\r\n /**\r\n * Constructs a WebXRSessionManager, this must be initialized within a user action before usage\r\n * @param scene The scene which the session should be created for\r\n */\r\n constructor(\r\n /** The scene which the session should be created for */\r\n public scene: Scene\r\n ) {\r\n this._engine = scene.getEngine();\r\n this._onEngineDisposedObserver = this._engine.onDisposeObservable.addOnce(() => {\r\n this._engine = null;\r\n });\r\n scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * The current reference space used in this session. This reference space can constantly change!\r\n * It is mainly used to offset the camera's position.\r\n */\r\n public get referenceSpace(): XRReferenceSpace {\r\n return this._referenceSpace;\r\n }\r\n\r\n /**\r\n * Set a new reference space and triggers the observable\r\n */\r\n public set referenceSpace(newReferenceSpace: XRReferenceSpace) {\r\n this._referenceSpace = newReferenceSpace;\r\n this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace);\r\n }\r\n\r\n /**\r\n * The mode for the managed XR session\r\n */\r\n public get sessionMode(): XRSessionMode {\r\n return this._sessionMode;\r\n }\r\n\r\n /**\r\n * Disposes of the session manager\r\n * This should be called explicitly by the dev, if required.\r\n */\r\n public dispose() {\r\n // disposing without leaving XR? Exit XR first\r\n if (this.inXRSession) {\r\n this.exitXRAsync();\r\n }\r\n this.onXRFrameObservable.clear();\r\n this.onXRSessionEnded.clear();\r\n this.onXRReferenceSpaceChanged.clear();\r\n this.onXRSessionInit.clear();\r\n this._engine?.onDisposeObservable.remove(this._onEngineDisposedObserver);\r\n this._engine = null;\r\n }\r\n\r\n /**\r\n * Stops the xrSession and restores the render loop\r\n * @returns Promise which resolves after it exits XR\r\n */\r\n public exitXRAsync() {\r\n if (this.session && this.inXRSession) {\r\n this.inXRSession = false;\r\n return this.session.end().catch(() => {\r\n Logger.Warn(\"Could not end XR session.\");\r\n });\r\n }\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Attempts to set the framebuffer-size-normalized viewport to be rendered this frame for this view.\r\n * In the event of a failure, the supplied viewport is not updated.\r\n * @param viewport the viewport to which the view will be rendered\r\n * @param view the view for which to set the viewport\r\n * @returns whether the operation was successful\r\n */\r\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\r\n return this._baseLayerRTTProvider?.trySetViewportForView(viewport, view) || false;\r\n }\r\n\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this eye\r\n * @param eye the eye for which to get the render target\r\n * @returns the render target for the specified eye or null if not available\r\n */\r\n public getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture> {\r\n return this._baseLayerRTTProvider?.getRenderTargetTextureForEye(eye) || null;\r\n }\r\n\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this view\r\n * @param view the view for which to get the render target\r\n * @returns the render target for the specified view or null if not available\r\n */\r\n public getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture> {\r\n return this._baseLayerRTTProvider?.getRenderTargetTextureForView(view) || null;\r\n }\r\n\r\n /**\r\n * Creates a WebXRRenderTarget object for the XR session\r\n * @param options optional options to provide when creating a new render target\r\n * @returns a WebXR render target to which the session can render\r\n */\r\n public getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget {\r\n const engine = this.scene.getEngine();\r\n if (this._xrNavigator.xr.native) {\r\n return new NativeXRRenderTarget(this);\r\n } else {\r\n options = options || WebXRManagedOutputCanvasOptions.GetDefaults(engine);\r\n options.canvasElement = options.canvasElement || engine.getRenderingCanvas() || undefined;\r\n return new WebXRManagedOutputCanvas(this, options);\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the manager\r\n * After initialization enterXR can be called to start an XR session\r\n * @returns Promise which resolves after it is initialized\r\n */\r\n public initializeAsync(): Promise<void> {\r\n // Check if the browser supports webXR\r\n this._xrNavigator = navigator;\r\n if (!this._xrNavigator.xr) {\r\n return Promise.reject(\"WebXR not available\");\r\n }\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Initializes an xr session\r\n * @param xrSessionMode mode to initialize\r\n * @param xrSessionInit defines optional and required values to pass to the session builder\r\n * @returns a promise which will resolve once the session has been initialized\r\n */\r\n public initializeSessionAsync(xrSessionMode: XRSessionMode = \"immersive-vr\", xrSessionInit: XRSessionInit = {}): Promise<XRSession> {\r\n return this._xrNavigator.xr.requestSession(xrSessionMode, xrSessionInit).then((session: XRSession) => {\r\n this.session = session;\r\n this._sessionMode = xrSessionMode;\r\n this.onXRSessionInit.notifyObservers(session);\r\n this.inXRSession = true;\r\n\r\n // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)\r\n this.session.addEventListener(\r\n \"end\",\r\n () => {\r\n this.inXRSession = false;\r\n\r\n // Notify frame observers\r\n this.onXRSessionEnded.notifyObservers(null);\r\n\r\n if (this._engine) {\r\n // make sure dimensions object is restored\r\n this._engine.framebufferDimensionsObject = null;\r\n\r\n // Restore frame buffer to avoid clear on xr framebuffer after session end\r\n this._engine.restoreDefaultFramebuffer();\r\n\r\n // Need to restart render loop as after the session is ended the last request for new frame will never call callback\r\n this._engine.customAnimationFrameRequester = null;\r\n this._engine._renderLoop();\r\n }\r\n\r\n // Dispose render target textures.\r\n // Only dispose on native because we can't destroy opaque textures on browser.\r\n if (this.isNative) {\r\n this._baseLayerRTTProvider?.dispose();\r\n }\r\n this._baseLayerRTTProvider = null;\r\n this._baseLayerWrapper = null;\r\n },\r\n { once: true }\r\n );\r\n\r\n return this.session;\r\n });\r\n }\r\n\r\n /**\r\n * Checks if a session would be supported for the creation options specified\r\n * @param sessionMode session mode to check if supported eg. immersive-vr\r\n * @returns A Promise that resolves to true if supported and false if not\r\n */\r\n public isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean> {\r\n return WebXRSessionManager.IsSessionSupportedAsync(sessionMode);\r\n }\r\n\r\n /**\r\n * Resets the reference space to the one started the session\r\n */\r\n public resetReferenceSpace() {\r\n this.referenceSpace = this.baseReferenceSpace;\r\n }\r\n\r\n /**\r\n * Starts rendering to the xr layer\r\n */\r\n public runXRRenderLoop() {\r\n if (!this.inXRSession || !this._engine) {\r\n return;\r\n }\r\n\r\n // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information\r\n this._engine.customAnimationFrameRequester = {\r\n requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session),\r\n renderFunction: (timestamp: number, xrFrame: Nullable<XRFrame>) => {\r\n if (!this.inXRSession || !this._engine) {\r\n return;\r\n }\r\n // Store the XR frame and timestamp in the session manager\r\n this.currentFrame = xrFrame;\r\n this.currentTimestamp = timestamp;\r\n if (xrFrame) {\r\n this.inXRFrameLoop = true;\r\n this._engine.framebufferDimensionsObject = this._baseLayerRTTProvider?.getFramebufferDimensions() || null;\r\n this.onXRFrameObservable.notifyObservers(xrFrame);\r\n this._engine._renderLoop();\r\n this._engine.framebufferDimensionsObject = null;\r\n this.inXRFrameLoop = false;\r\n }\r\n },\r\n };\r\n\r\n this._engine.framebufferDimensionsObject = this._baseLayerRTTProvider?.getFramebufferDimensions() || null;\r\n\r\n // Stop window's animation frame and trigger sessions animation frame\r\n if (typeof window !== \"undefined\" && window.cancelAnimationFrame) {\r\n window.cancelAnimationFrame(this._engine._frameHandler);\r\n }\r\n this._engine._renderLoop();\r\n }\r\n\r\n /**\r\n * Sets the reference space on the xr session\r\n * @param referenceSpaceType space to set\r\n * @returns a promise that will resolve once the reference space has been set\r\n */\r\n public setReferenceSpaceTypeAsync(referenceSpaceType: XRReferenceSpaceType = \"local-floor\"): Promise<XRReferenceSpace> {\r\n return this.session\r\n .requestReferenceSpace(referenceSpaceType)\r\n .then(\r\n (referenceSpace) => {\r\n return referenceSpace as XRReferenceSpace;\r\n },\r\n (rejectionReason) => {\r\n Logger.Error(\"XR.requestReferenceSpace failed for the following reason: \");\r\n Logger.Error(rejectionReason);\r\n Logger.Log('Defaulting to universally-supported \"viewer\" reference space type.');\r\n\r\n return this.session.requestReferenceSpace(\"viewer\").then(\r\n (referenceSpace) => {\r\n const heightCompensation = new XRRigidTransform({ x: 0, y: -this.defaultHeightCompensation, z: 0 });\r\n return (referenceSpace as XRReferenceSpace).getOffsetReferenceSpace(heightCompensation);\r\n },\r\n (rejectionReason) => {\r\n Logger.Error(rejectionReason);\r\n throw 'XR initialization failed: required \"viewer\" reference space type not supported.';\r\n }\r\n );\r\n }\r\n )\r\n .then((referenceSpace) => {\r\n // create viewer reference space before setting the first reference space\r\n return this.session.requestReferenceSpace(\"viewer\").then((viewerReferenceSpace) => {\r\n this.viewerReferenceSpace = viewerReferenceSpace as XRReferenceSpace;\r\n return referenceSpace;\r\n });\r\n })\r\n .then((referenceSpace) => {\r\n // initialize the base and offset (currently the same)\r\n this.referenceSpace = this.baseReferenceSpace = referenceSpace;\r\n return this.referenceSpace;\r\n });\r\n }\r\n\r\n /**\r\n * Updates the render state of the session.\r\n * Note that this is deprecated in favor of WebXRSessionManager.updateRenderState().\r\n * @param state state to set\r\n * @returns a promise that resolves once the render state has been updated\r\n * @deprecated\r\n */\r\n public updateRenderStateAsync(state: XRRenderState): Promise<void> {\r\n return Promise.resolve(this.session.updateRenderState(state));\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setBaseLayerWrapper(baseLayerWrapper: Nullable<WebXRLayerWrapper>): void {\r\n if (this.isNative) {\r\n this._baseLayerRTTProvider?.dispose();\r\n }\r\n this._baseLayerWrapper = baseLayerWrapper;\r\n this._baseLayerRTTProvider = this._baseLayerWrapper?.createRenderTargetTextureProvider(this) || null;\r\n }\r\n\r\n /**\r\n * Updates the render state of the session\r\n * @param state state to set\r\n */\r\n public updateRenderState(state: XRRenderStateInit): void {\r\n if (state.baseLayer) {\r\n this._setBaseLayerWrapper(this.isNative ? new NativeXRLayerWrapper(state.baseLayer) : new WebXRWebGLLayerWrapper(state.baseLayer));\r\n }\r\n\r\n this.session.updateRenderState(state);\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser\r\n * @param sessionMode defines the session to test\r\n * @returns a promise with boolean as final value\r\n */\r\n public static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean> {\r\n if (!(navigator as any).xr) {\r\n return Promise.resolve(false);\r\n }\r\n // When the specs are final, remove supportsSession!\r\n const functionToUse = (navigator as any).xr.isSessionSupported || (navigator as any).xr.supportsSession;\r\n if (!functionToUse) {\r\n return Promise.resolve(false);\r\n } else {\r\n return functionToUse\r\n .call((navigator as any).xr, sessionMode)\r\n .then((result: boolean) => {\r\n const returnValue = typeof result === \"undefined\" ? true : result;\r\n return Promise.resolve(returnValue);\r\n })\r\n .catch((e: any) => {\r\n Logger.Warn(e);\r\n return Promise.resolve(false);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if Babylon.js is using the BabylonNative backend, otherwise false\r\n */\r\n public get isNative(): boolean {\r\n return this._xrNavigator.xr.native ?? false;\r\n }\r\n\r\n /**\r\n * The current frame rate as reported by the device\r\n */\r\n public get currentFrameRate(): number | undefined {\r\n return this.session?.frameRate;\r\n }\r\n\r\n /**\r\n * A list of supported frame rates (only available in-session!\r\n */\r\n public get supportedFrameRates(): Float32Array | undefined {\r\n return this.session?.supportedFrameRates;\r\n }\r\n\r\n /**\r\n * Set the framerate of the session.\r\n * @param rate the new framerate. This value needs to be in the supportedFrameRates array\r\n * @returns a promise that resolves once the framerate has been set\r\n */\r\n public updateTargetFrameRate(rate: number): Promise<void> {\r\n return this.session.updateTargetFrameRate(rate);\r\n }\r\n\r\n /**\r\n * Run a callback in the xr render loop\r\n * @param callback the callback to call when in XR Frame\r\n * @param ignoreIfNotInSession if no session is currently running, run it first thing on the next session\r\n */\r\n public runInXRFrame(callback: () => void, ignoreIfNotInSession = true): void {\r\n if (this.inXRFrameLoop) {\r\n callback();\r\n } else if (this.inXRSession || !ignoreIfNotInSession) {\r\n this.onXRFrameObservable.addOnce(callback);\r\n }\r\n }\r\n\r\n /**\r\n * Check if fixed foveation is supported on this device\r\n */\r\n public get isFixedFoveationSupported(): boolean {\r\n return this._baseLayerWrapper?.isFixedFoveationSupported || false;\r\n }\r\n\r\n /**\r\n * Get the fixed foveation currently set, as specified by the webxr specs\r\n * If this returns null, then fixed foveation is not supported\r\n */\r\n public get fixedFoveation(): Nullable<number> {\r\n return this._baseLayerWrapper?.fixedFoveation || null;\r\n }\r\n\r\n /**\r\n * Set the fixed foveation to the specified value, as specified by the webxr specs\r\n * This value will be normalized to be between 0 and 1, 1 being max foveation, 0 being no foveation\r\n */\r\n public set fixedFoveation(value: Nullable<number>) {\r\n const val = Math.max(0, Math.min(1, value || 0));\r\n if (this._baseLayerWrapper) {\r\n this._baseLayerWrapper.fixedFoveation = val;\r\n }\r\n }\r\n}\r\n"]}
|
package/XR/webXRWebGLLayer.js
CHANGED
|
@@ -30,6 +30,9 @@ export class WebXRWebGLLayerRenderTargetTextureProvider extends WebXRLayerRender
|
|
|
30
30
|
}
|
|
31
31
|
trySetViewportForView(viewport, view) {
|
|
32
32
|
const xrViewport = this._layer.getViewport(view);
|
|
33
|
+
if (!xrViewport) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
33
36
|
const framebufferWidth = this._framebufferDimensions.framebufferWidth;
|
|
34
37
|
const framebufferHeight = this._framebufferDimensions.framebufferHeight;
|
|
35
38
|
viewport.x = xrViewport.x / framebufferWidth;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRWebGLLayer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRWebGLLayer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAE3F;;;GAGG;AACH,MAAM,O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U,CAAC,MAAM,GAAG,iBAAiB,CAAC;QACxD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,6DAA6D;IACtD,4BAA4B,CAAC,GAAU;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAClD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QAE5C,IACI,CAAC,IAAI,CAAC,IAAI;YACV,UAAU,KAAK,IAAI,CAAC,sBAAsB,CAAC,gBAAgB;YAC3D,WAAW,KAAK,IAAI,CAAC,sBAAsB,CAAC,iBAAiB;YAC7D,WAAW,KAAK,IAAI,CAAC,YAAY,EACnC;YACE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,0BAA0B,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;YAClF,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,GAAG,UAAU,CAAC;YAC1D,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,GAAG,WAAW,CAAC;YAC5D,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;SACnC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEM,6BAA6B,CAAC,IAAY;QAC7C,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["import type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Viewport } from \"../Maths/math.viewport\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\nimport { WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\r\n\r\n/**\r\n * Wraps xr webgl layers.\r\n * @internal\r\n */\r\nexport class WebXRWebGLLayerWrapper extends WebXRLayerWrapper {\r\n /**\r\n * @param layer is the layer to be wrapped.\r\n * @returns a new WebXRLayerWrapper wrapping the provided XRWebGLLayer.\r\n */\r\n constructor(public readonly layer: XRWebGLLayer) {\r\n super(\r\n () => layer.framebufferWidth,\r\n () => layer.framebufferHeight,\r\n layer,\r\n \"XRWebGLLayer\",\r\n (sessionManager) => new WebXRWebGLLayerRenderTargetTextureProvider(sessionManager.scene, this)\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRWebGLLayer.\r\n * @internal\r\n */\r\nexport class WebXRWebGLLayerRenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {\r\n // The dimensions will always be defined in this class.\r\n protected _framebufferDimensions: { framebufferWidth: number; framebufferHeight: number };\r\n private _rtt: Nullable<RenderTargetTexture>;\r\n private _framebuffer: WebGLFramebuffer;\r\n private _layer: XRWebGLLayer;\r\n\r\n constructor(scene: Scene, public readonly layerWrapper: WebXRWebGLLayerWrapper) {\r\n super(scene, layerWrapper);\r\n this._layer = layerWrapper.layer;\r\n this._framebufferDimensions = {\r\n framebufferWidth: this._layer.framebufferWidth,\r\n framebufferHeight: this._layer.framebufferHeight,\r\n };\r\n }\r\n\r\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\r\n const xrViewport = this._layer.getViewport(view);\r\n const framebufferWidth = this._framebufferDimensions.framebufferWidth;\r\n const framebufferHeight = this._framebufferDimensions.framebufferHeight;\r\n viewport.x = xrViewport.x / framebufferWidth;\r\n viewport.y = xrViewport.y / framebufferHeight;\r\n viewport.width = xrViewport.width / framebufferWidth;\r\n viewport.height = xrViewport.height / framebufferHeight;\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture> {\r\n const layerWidth = this._layer.framebufferWidth;\r\n const layerHeight = this._layer.framebufferHeight;\r\n const framebuffer = this._layer.framebuffer;\r\n\r\n if (\r\n !this._rtt ||\r\n layerWidth !== this._framebufferDimensions.framebufferWidth ||\r\n layerHeight !== this._framebufferDimensions.framebufferHeight ||\r\n framebuffer !== this._framebuffer\r\n ) {\r\n this._rtt = this._createRenderTargetTexture(layerWidth, layerHeight, framebuffer);\r\n this._framebufferDimensions.framebufferWidth = layerWidth;\r\n this._framebufferDimensions.framebufferHeight = layerHeight;\r\n this._framebuffer = framebuffer;\r\n }\r\n\r\n return this._rtt;\r\n }\r\n\r\n public getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture> {\r\n return this.getRenderTargetTextureForEye(view.eye);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRWebGLLayer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRWebGLLayer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAE3F;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IACzD;;;OAGG;IACH,YAA4B,KAAmB;QAC3C,KAAK,CACD,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAC5B,GAAG,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAC7B,KAAK,EACL,cAAc,EACd,CAAC,cAAc,EAAE,EAAE,CAAC,IAAI,0CAA0C,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CACjG,CAAC;QAPsB,UAAK,GAAL,KAAK,CAAc;IAQ/C,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,0CAA2C,SAAQ,qCAAqC;IAOjG,YAAY,KAAY,EAAkB,YAAoC;QAC1E,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QADW,iBAAY,GAAZ,YAAY,CAAwB;QAE1E,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,sBAAsB,GAAG;YAC1B,gBAA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EAAE,WAAW,CAAC,CAAC;YAClF,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,GAAG,UAAU,CAAC;YAC1D,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,GAAG,WAAW,CAAC;YAC5D,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;SACnC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEM,6BAA6B,CAAC,IAAY;QAC7C,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["import type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Viewport } from \"../Maths/math.viewport\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\nimport { WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\r\n\r\n/**\r\n * Wraps xr webgl layers.\r\n * @internal\r\n */\r\nexport class WebXRWebGLLayerWrapper extends WebXRLayerWrapper {\r\n /**\r\n * @param layer is the layer to be wrapped.\r\n * @returns a new WebXRLayerWrapper wrapping the provided XRWebGLLayer.\r\n */\r\n constructor(public readonly layer: XRWebGLLayer) {\r\n super(\r\n () => layer.framebufferWidth,\r\n () => layer.framebufferHeight,\r\n layer,\r\n \"XRWebGLLayer\",\r\n (sessionManager) => new WebXRWebGLLayerRenderTargetTextureProvider(sessionManager.scene, this)\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRWebGLLayer.\r\n * @internal\r\n */\r\nexport class WebXRWebGLLayerRenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {\r\n // The dimensions will always be defined in this class.\r\n protected _framebufferDimensions: { framebufferWidth: number; framebufferHeight: number };\r\n private _rtt: Nullable<RenderTargetTexture>;\r\n private _framebuffer: WebGLFramebuffer;\r\n private _layer: XRWebGLLayer;\r\n\r\n constructor(scene: Scene, public readonly layerWrapper: WebXRWebGLLayerWrapper) {\r\n super(scene, layerWrapper);\r\n this._layer = layerWrapper.layer;\r\n this._framebufferDimensions = {\r\n framebufferWidth: this._layer.framebufferWidth,\r\n framebufferHeight: this._layer.framebufferHeight,\r\n };\r\n }\r\n\r\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\r\n const xrViewport = this._layer.getViewport(view);\r\n if (!xrViewport) {\r\n return false;\r\n }\r\n const framebufferWidth = this._framebufferDimensions.framebufferWidth;\r\n const framebufferHeight = this._framebufferDimensions.framebufferHeight;\r\n viewport.x = xrViewport.x / framebufferWidth;\r\n viewport.y = xrViewport.y / framebufferHeight;\r\n viewport.width = xrViewport.width / framebufferWidth;\r\n viewport.height = xrViewport.height / framebufferHeight;\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture> {\r\n const layerWidth = this._layer.framebufferWidth;\r\n const layerHeight = this._layer.framebufferHeight;\r\n const framebuffer = this._layer.framebuffer;\r\n\r\n if (\r\n !this._rtt ||\r\n layerWidth !== this._framebufferDimensions.framebufferWidth ||\r\n layerHeight !== this._framebufferDimensions.framebufferHeight ||\r\n framebuffer !== this._framebuffer\r\n ) {\r\n this._rtt = this._createRenderTargetTexture(layerWidth, layerHeight, framebuffer);\r\n this._framebufferDimensions.framebufferWidth = layerWidth;\r\n this._framebufferDimensions.framebufferHeight = layerHeight;\r\n this._framebuffer = framebuffer;\r\n }\r\n\r\n return this._rtt;\r\n }\r\n\r\n public getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture> {\r\n return this.getRenderTargetTextureForEye(view.eye);\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
package/scene.js
CHANGED
|
@@ -951,11 +951,12 @@ export class Scene extends AbstractScene {
|
|
|
951
951
|
* @returns the computed eye position
|
|
952
952
|
*/
|
|
953
953
|
bindEyePosition(effect, variableName = "vEyePosition", isVector3 = false) {
|
|
954
|
+
var _a;
|
|
954
955
|
const eyePosition = this._forcedViewPosition
|
|
955
956
|
? this._forcedViewPosition
|
|
956
957
|
: this._mirroredCameraPosition
|
|
957
958
|
? this._mirroredCameraPosition
|
|
958
|
-
: this.activeCamera.globalPosition
|
|
959
|
+
: (_a = this.activeCamera.globalPosition) !== null && _a !== void 0 ? _a : this.activeCamera.devicePosition;
|
|
959
960
|
const invertNormal = this.useRightHandedSystem === (this._mirroredCameraPosition != null);
|
|
960
961
|
TmpVectors.Vector4[0].set(eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
|
|
961
962
|
if (effect) {
|
|
@@ -1788,7 +1789,7 @@ export class Scene extends AbstractScene {
|
|
|
1788
1789
|
* @returns a new ubo
|
|
1789
1790
|
*/
|
|
1790
1791
|
createSceneUniformBuffer(name) {
|
|
1791
|
-
const sceneUbo = new UniformBuffer(this._engine, undefined, false, name
|
|
1792
|
+
const sceneUbo = new UniformBuffer(this._engine, undefined, false, name !== null && name !== void 0 ? name : "scene");
|
|
1792
1793
|
sceneUbo.addUniform("viewProjection", 16);
|
|
1793
1794
|
sceneUbo.addUniform("view", 16);
|
|
1794
1795
|
sceneUbo.addUniform("projection", 16);
|
|
@@ -3107,9 +3108,10 @@ export class Scene extends AbstractScene {
|
|
|
3107
3108
|
this.onBeforeRenderObservable.addOnce(() => container.dispose());
|
|
3108
3109
|
}
|
|
3109
3110
|
_evaluateActiveMeshes() {
|
|
3111
|
+
var _a;
|
|
3110
3112
|
if (this._engine.snapshotRendering && this._engine.snapshotRenderingMode === 1) {
|
|
3111
3113
|
if (this._activeMeshes.length > 0) {
|
|
3112
|
-
this.activeCamera
|
|
3114
|
+
(_a = this.activeCamera) === null || _a === void 0 ? void 0 : _a._activeMeshes.reset();
|
|
3113
3115
|
this._activeMeshes.reset();
|
|
3114
3116
|
this._renderingManager.reset();
|
|
3115
3117
|
this._processedMaterials.reset();
|
|
@@ -3311,6 +3313,7 @@ export class Scene extends AbstractScene {
|
|
|
3311
3313
|
* @internal
|
|
3312
3314
|
*/
|
|
3313
3315
|
_renderForCamera(camera, rigParent, bindFrameBuffer = true) {
|
|
3316
|
+
var _a, _b, _c;
|
|
3314
3317
|
if (camera && camera._skipRendering) {
|
|
3315
3318
|
return;
|
|
3316
3319
|
}
|
|
@@ -3385,7 +3388,7 @@ export class Scene extends AbstractScene {
|
|
|
3385
3388
|
}
|
|
3386
3389
|
this._intermediateRendering = false;
|
|
3387
3390
|
}
|
|
3388
|
-
this._engine.currentRenderPassId = camera.outputRenderTarget
|
|
3391
|
+
this._engine.currentRenderPassId = (_c = (_b = (_a = camera.outputRenderTarget) === null || _a === void 0 ? void 0 : _a.renderPassId) !== null && _b !== void 0 ? _b : camera.renderPassId) !== null && _c !== void 0 ? _c : 0;
|
|
3389
3392
|
// Restore framebuffer after rendering to targets
|
|
3390
3393
|
if (needRebind && !this.prePass) {
|
|
3391
3394
|
this._bindFrameBuffer(this._activeCamera, false);
|
|
@@ -3544,10 +3547,11 @@ export class Scene extends AbstractScene {
|
|
|
3544
3547
|
}
|
|
3545
3548
|
}
|
|
3546
3549
|
_checkCameraRenderTarget(camera) {
|
|
3547
|
-
|
|
3550
|
+
var _a;
|
|
3551
|
+
if ((camera === null || camera === void 0 ? void 0 : camera.outputRenderTarget) && !(camera === null || camera === void 0 ? void 0 : camera.isRigCamera)) {
|
|
3548
3552
|
camera.outputRenderTarget._cleared = false;
|
|
3549
3553
|
}
|
|
3550
|
-
if (camera
|
|
3554
|
+
if ((_a = camera === null || camera === void 0 ? void 0 : camera.rigCameras) === null || _a === void 0 ? void 0 : _a.length) {
|
|
3551
3555
|
for (let i = 0; i < camera.rigCameras.length; ++i) {
|
|
3552
3556
|
const rtt = camera.rigCameras[i].outputRenderTarget;
|
|
3553
3557
|
if (rtt) {
|
|
@@ -3574,6 +3578,7 @@ export class Scene extends AbstractScene {
|
|
|
3574
3578
|
* @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
|
|
3575
3579
|
*/
|
|
3576
3580
|
render(updateCameras = true, ignoreAnimations = false) {
|
|
3581
|
+
var _a, _b, _c;
|
|
3577
3582
|
if (this.isDisposed) {
|
|
3578
3583
|
return;
|
|
3579
3584
|
}
|
|
@@ -3583,7 +3588,7 @@ export class Scene extends AbstractScene {
|
|
|
3583
3588
|
this._frameId++;
|
|
3584
3589
|
this._defaultFrameBufferCleared = false;
|
|
3585
3590
|
this._checkCameraRenderTarget(this.activeCamera);
|
|
3586
|
-
if (this.activeCameras
|
|
3591
|
+
if ((_a = this.activeCameras) === null || _a === void 0 ? void 0 : _a.length) {
|
|
3587
3592
|
this.activeCameras.forEach(this._checkCameraRenderTarget);
|
|
3588
3593
|
}
|
|
3589
3594
|
// Register components that have been associated lately to the scene.
|
|
@@ -3636,7 +3641,7 @@ export class Scene extends AbstractScene {
|
|
|
3636
3641
|
const engine = this.getEngine();
|
|
3637
3642
|
// Customs render targets
|
|
3638
3643
|
this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
|
|
3639
|
-
const currentActiveCamera = this.activeCameras
|
|
3644
|
+
const currentActiveCamera = ((_b = this.activeCameras) === null || _b === void 0 ? void 0 : _b.length) ? this.activeCameras[0] : this.activeCamera;
|
|
3640
3645
|
if (this.renderTargetsEnabled) {
|
|
3641
3646
|
Tools.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
|
|
3642
3647
|
this._intermediateRendering = true;
|
|
@@ -3659,7 +3664,7 @@ export class Scene extends AbstractScene {
|
|
|
3659
3664
|
this._intermediateRendering = false;
|
|
3660
3665
|
this._renderId++;
|
|
3661
3666
|
}
|
|
3662
|
-
this._engine.currentRenderPassId = currentActiveCamera
|
|
3667
|
+
this._engine.currentRenderPassId = (_c = currentActiveCamera === null || currentActiveCamera === void 0 ? void 0 : currentActiveCamera.renderPassId) !== null && _c !== void 0 ? _c : 0;
|
|
3663
3668
|
// Restore back buffer
|
|
3664
3669
|
this.activeCamera = currentActiveCamera;
|
|
3665
3670
|
if (this._activeCamera && this._activeCamera.cameraRigMode !== 22 && !this.prePass) {
|
|
@@ -3741,6 +3746,7 @@ export class Scene extends AbstractScene {
|
|
|
3741
3746
|
* Releases all held resources
|
|
3742
3747
|
*/
|
|
3743
3748
|
dispose() {
|
|
3749
|
+
var _a;
|
|
3744
3750
|
if (this.isDisposed) {
|
|
3745
3751
|
return;
|
|
3746
3752
|
}
|
|
@@ -3847,7 +3853,7 @@ export class Scene extends AbstractScene {
|
|
|
3847
3853
|
this.onKeyboardObservable.clear();
|
|
3848
3854
|
this.onActiveCameraChanged.clear();
|
|
3849
3855
|
this.onComputePressureChanged.clear();
|
|
3850
|
-
this._computePressureObserver
|
|
3856
|
+
(_a = this._computePressureObserver) === null || _a === void 0 ? void 0 : _a.unobserve("cpu");
|
|
3851
3857
|
this._computePressureObserver = undefined;
|
|
3852
3858
|
this.detachControl();
|
|
3853
3859
|
// Detach cameras
|
|
@@ -3912,7 +3918,7 @@ export class Scene extends AbstractScene {
|
|
|
3912
3918
|
}
|
|
3913
3919
|
_disposeList(items, callback) {
|
|
3914
3920
|
const itemsCopy = items.slice(0);
|
|
3915
|
-
callback = callback
|
|
3921
|
+
callback = callback !== null && callback !== void 0 ? callback : ((item) => item.dispose());
|
|
3916
3922
|
for (const item of itemsCopy) {
|
|
3917
3923
|
callback(item);
|
|
3918
3924
|
}
|