@onerjs/core 8.56.3 → 9.0.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.core.js +36 -0
- package/Animations/animatable.core.js.map +1 -1
- package/Animations/animationGroup.pure.d.ts +61 -1
- package/Animations/animationGroup.pure.js +191 -2
- package/Animations/animationGroup.pure.js.map +1 -1
- package/Animations/index.d.ts +1 -0
- package/Animations/index.js +1 -0
- package/Animations/index.js.map +1 -1
- package/Animations/pure.d.ts +1 -0
- package/Animations/pure.js +1 -0
- package/Animations/pure.js.map +1 -1
- package/Animations/rootMotion.d.ts +560 -0
- package/Animations/rootMotion.js +1709 -0
- package/Animations/rootMotion.js.map +1 -0
- package/Animations/runtimeAnimation.d.ts +57 -0
- package/Animations/runtimeAnimation.js +127 -3
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Cameras/arcRotateCamera.pure.d.ts +2 -0
- package/Cameras/arcRotateCamera.pure.js +2 -0
- package/Cameras/arcRotateCamera.pure.js.map +1 -1
- package/Cameras/camera.pure.js +4 -0
- package/Cameras/camera.pure.js.map +1 -1
- package/Cameras/targetCamera.pure.d.ts +2 -0
- package/Cameras/targetCamera.pure.js +7 -1
- package/Cameras/targetCamera.pure.js.map +1 -1
- package/Collisions/gpuPicker.js +5 -5
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.query.pure.js +4 -2
- package/Engines/AbstractEngine/abstractEngine.query.pure.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.query.types.d.ts +11 -2
- package/Engines/AbstractEngine/abstractEngine.query.types.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.renderPass.pure.js +1 -0
- package/Engines/AbstractEngine/abstractEngine.renderPass.pure.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.pure.js +63 -0
- package/Engines/Extensions/engine.multiRender.pure.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.types.d.ts +13 -0
- package/Engines/Extensions/engine.multiRender.types.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.pure.js +2 -2
- package/Engines/Extensions/engine.prefilteredCubeTexture.pure.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.types.d.ts +2 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.types.js.map +1 -1
- package/Engines/Extensions/index.d.ts +1 -0
- package/Engines/Extensions/index.js +1 -0
- package/Engines/Extensions/index.js.map +1 -1
- package/Engines/Extensions/pure.d.ts +1 -1
- package/Engines/Extensions/pure.js +1 -1
- package/Engines/Extensions/pure.js.map +1 -1
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.js +88 -39
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.js.map +1 -1
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.types.d.ts +20 -2
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.types.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js +4 -0
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.types.d.ts +13 -0
- package/Engines/WebGPU/Extensions/engine.multiRender.types.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.pure.js +11 -3
- package/Engines/WebGPU/Extensions/engine.query.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/index.d.ts +1 -0
- package/Engines/WebGPU/Extensions/index.js +1 -0
- package/Engines/WebGPU/Extensions/index.js.map +1 -1
- package/Engines/WebGPU/Extensions/pure.d.ts +1 -1
- package/Engines/WebGPU/Extensions/pure.js +1 -1
- package/Engines/WebGPU/Extensions/pure.js.map +1 -1
- package/Engines/WebGPU/webgpuBundleList.d.ts +2 -0
- package/Engines/WebGPU/webgpuBundleList.js +4 -0
- package/Engines/WebGPU/webgpuBundleList.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +5 -2
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +3 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuSnapshotRendering.d.ts +4 -0
- package/Engines/WebGPU/webgpuSnapshotRendering.js +40 -7
- package/Engines/WebGPU/webgpuSnapshotRendering.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +2 -2
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +2 -0
- package/Engines/WebGPU/webgpuTextureManager.js +286 -13
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +2 -0
- package/Engines/abstractEngine.pure.js +7 -3
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/constants.d.ts +4 -0
- package/Engines/constants.js +4 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/thinEngine.pure.d.ts +14 -0
- package/Engines/thinEngine.pure.js +48 -12
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +1 -0
- package/Engines/thinNativeEngine.pure.js +7 -1
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +4 -0
- package/Engines/thinWebGPUEngine.js +10 -1
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +5 -2
- package/Engines/webgpuEngine.pure.js +48 -13
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js +2 -2
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.d.ts +11 -2
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js +1 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.pure.d.ts +9 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.pure.js +6 -8
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.d.ts +9 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js +34 -9
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js +4 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js +4 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.pure.js +19 -7
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.d.ts +20 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js +53 -10
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.d.ts +16 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js +64 -14
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.pure.js +64 -16
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.pure.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +4 -0
- package/FlowGraph/flowGraph.js +38 -7
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphBlock.js +3 -0
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphConnection.d.ts +7 -0
- package/FlowGraph/flowGraphConnection.js +7 -0
- package/FlowGraph/flowGraphConnection.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +2 -1
- package/FlowGraph/flowGraphContext.js +4 -3
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +15 -1
- package/FlowGraph/flowGraphCoordinator.js +47 -16
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphEventBlock.d.ts +5 -0
- package/FlowGraph/flowGraphEventBlock.js +7 -0
- package/FlowGraph/flowGraphEventBlock.js.map +1 -1
- package/FlowGraph/flowGraphHostResolver.d.ts +2 -1
- package/FlowGraph/flowGraphHostResolver.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +60 -2
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/serialization.d.ts +2 -0
- package/FlowGraph/serialization.js +10 -22
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +8 -0
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.d.ts +5 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.js +8 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.pure.d.ts +87 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.pure.js +295 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.pure.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/pure.d.ts +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/pure.js +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +4 -4
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.d.ts +5 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js +13 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/allBlocks.pure.js +2 -0
- package/FrameGraph/Node/Blocks/allBlocks.pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.pure.js +20 -1
- package/FrameGraph/Node/Blocks/inputBlock.pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/pure.d.ts +1 -0
- package/FrameGraph/Node/Blocks/pure.js +1 -0
- package/FrameGraph/Node/Blocks/pure.js.map +1 -1
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +4 -2
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +4 -2
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Tasks/Layers/selectionOutlineTask.js +1 -0
- package/FrameGraph/Tasks/Layers/selectionOutlineTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +5 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js +1 -0
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/meshBlendingTask.d.ts +69 -0
- package/FrameGraph/Tasks/PostProcesses/meshBlendingTask.js +223 -0
- package/FrameGraph/Tasks/PostProcesses/meshBlendingTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +25 -3
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +69 -33
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraphObjectList.d.ts +6 -1
- package/FrameGraph/frameGraphObjectList.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +3 -1
- package/FrameGraph/frameGraphRenderContext.js +5 -5
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/FrameGraph/pure.d.ts +1 -0
- package/FrameGraph/pure.js +1 -0
- package/FrameGraph/pure.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +4 -0
- package/Inputs/scene.inputManager.js +50 -8
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js +5 -5
- package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +5 -5
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +26 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +151 -47
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js +5 -5
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js +11 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.pure.js +17 -2
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +2 -2
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
- package/Materials/Node/nodeMaterial.pure.d.ts +4 -0
- package/Materials/Node/nodeMaterial.pure.js +4 -0
- package/Materials/Node/nodeMaterial.pure.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +25 -3
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.d.ts +2 -0
- package/Materials/PBR/pbrBaseMaterial.pure.d.ts +2 -0
- package/Materials/Textures/Procedurals/proceduralTexture.pure.d.ts +13 -14
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js +6 -6
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
- package/Materials/Textures/baseTexture.pure.js +3 -0
- package/Materials/Textures/baseTexture.pure.js.map +1 -1
- package/Materials/Textures/cubeTexture.pure.js +1 -1
- package/Materials/Textures/cubeTexture.pure.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +8 -1
- package/Materials/Textures/internalTexture.js +9 -2
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/rawTexture2DArray.functions.d.ts +3 -3
- package/Materials/Textures/rawTexture2DArray.functions.js.map +1 -1
- package/Materials/Textures/rawTexture3D.d.ts +1 -1
- package/Materials/Textures/rawTexture3D.js +1 -1
- package/Materials/Textures/rawTexture3D.js.map +1 -1
- package/Materials/Textures/textureHelper.functions.d.ts +14 -0
- package/Materials/Textures/textureHelper.functions.js +24 -0
- package/Materials/Textures/textureHelper.functions.js.map +1 -1
- package/Materials/ditheredTileFadeMaterialPlugin.d.ts +210 -0
- package/Materials/ditheredTileFadeMaterialPlugin.js +509 -0
- package/Materials/ditheredTileFadeMaterialPlugin.js.map +1 -0
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.d.ts +46 -1
- package/Materials/materialHelper.geometryrendering.js +105 -8
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/prepass.defines.d.ts +2 -0
- package/Materials/prepass.defines.js +2 -0
- package/Materials/prepass.defines.js.map +1 -1
- package/Materials/pure.d.ts +1 -0
- package/Materials/pure.js +1 -0
- package/Materials/pure.js.map +1 -1
- package/Materials/standardMaterial.pure.d.ts +2 -0
- package/Materials/standardMaterial.pure.js +6 -3
- package/Materials/standardMaterial.pure.js.map +1 -1
- package/Meshes/Builders/polygonBuilder.pure.d.ts +4 -0
- package/Meshes/Builders/polygonBuilder.pure.js +4 -1
- package/Meshes/Builders/polygonBuilder.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplatting.functions.d.ts +19 -0
- package/Meshes/GaussianSplatting/gaussianSplatting.functions.js +23 -0
- package/Meshes/GaussianSplatting/gaussianSplatting.functions.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +3 -14
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +20 -24
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +2 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +11 -4
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.d.ts +18 -0
- package/Meshes/abstractMesh.pure.js +22 -0
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/instancedMesh.pure.d.ts +5 -0
- package/Meshes/instancedMesh.pure.js +12 -0
- package/Meshes/instancedMesh.pure.js.map +1 -1
- package/Meshes/mesh.pure.js +23 -8
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/meshBlendingTag.d.ts +47 -0
- package/Meshes/meshBlendingTag.js +64 -0
- package/Meshes/meshBlendingTag.js.map +1 -0
- package/Meshes/polygonMesh.js +2 -2
- package/Meshes/polygonMesh.js.map +1 -1
- package/Meshes/pure.d.ts +1 -0
- package/Meshes/pure.js +1 -0
- package/Meshes/pure.js.map +1 -1
- package/Misc/fileTools.pure.js +21 -0
- package/Misc/fileTools.pure.js.map +1 -1
- package/Misc/snapshotRenderingHelper.js +2 -2
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +2 -0
- package/Particles/gpuParticleSystem.pure.js +89 -28
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Particles/thinParticleSystem.pure.d.ts +2 -0
- package/Particles/thinParticleSystem.pure.js +84 -19
- package/Particles/thinParticleSystem.pure.js.map +1 -1
- package/Particles/webgl2ParticleSystem.pure.d.ts +1 -0
- package/Particles/webgl2ParticleSystem.pure.js +12 -4
- package/Particles/webgl2ParticleSystem.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.pure.js +7 -0
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.pure.js.map +1 -1
- package/PostProcesses/index.d.ts +2 -0
- package/PostProcesses/index.js +2 -0
- package/PostProcesses/index.js.map +1 -1
- package/PostProcesses/meshBlendingBlueNoise.d.ts +15 -0
- package/PostProcesses/meshBlendingBlueNoise.js +77 -0
- package/PostProcesses/meshBlendingBlueNoise.js.map +1 -0
- package/PostProcesses/meshBlendingPostProcess.d.ts +131 -0
- package/PostProcesses/meshBlendingPostProcess.js +315 -0
- package/PostProcesses/meshBlendingPostProcess.js.map +1 -0
- package/PostProcesses/pure.d.ts +2 -0
- package/PostProcesses/pure.js +2 -0
- package/PostProcesses/pure.js.map +1 -1
- package/PostProcesses/thinMeshBlendingPostProcess.d.ts +339 -0
- package/PostProcesses/thinMeshBlendingPostProcess.js +771 -0
- package/PostProcesses/thinMeshBlendingPostProcess.js.map +1 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +6 -6
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +8 -8
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
- package/Rendering/boundingBoxRenderer.pure.js +2 -1
- package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
- package/Rendering/depthRenderer.pure.js +3 -4
- package/Rendering/depthRenderer.pure.js.map +1 -1
- package/Rendering/edgesRenderer.pure.d.ts +4 -2
- package/Rendering/edgesRenderer.pure.js +11 -2
- package/Rendering/edgesRenderer.pure.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +10 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.js +20 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +9 -3
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +14 -9
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.d.ts +38 -4
- package/Rendering/geometryBufferRenderer.pure.js +126 -17
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +7 -1
- package/Rendering/objectRenderer.js +45 -7
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.pure.js +6 -2
- package/Rendering/outlineRenderer.pure.js.map +1 -1
- package/Rendering/renderingManager.d.ts +1 -1
- package/Rendering/renderingManager.js +5 -4
- package/Rendering/renderingManager.js.map +1 -1
- package/Shaders/ShadersInclude/defaultFragmentAlpha.d.ts +5 -0
- package/Shaders/ShadersInclude/defaultFragmentAlpha.js +34 -0
- package/Shaders/ShadersInclude/defaultFragmentAlpha.js.map +1 -0
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +5 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/geometryRenderingFragment.d.ts +5 -0
- package/Shaders/ShadersInclude/geometryRenderingFragment.js +74 -0
- package/Shaders/ShadersInclude/geometryRenderingFragment.js.map +1 -0
- package/Shaders/ShadersInclude/mrtFragmentDeclaration.js +89 -0
- package/Shaders/ShadersInclude/mrtFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBlockPrePass.js +24 -17
- package/Shaders/ShadersInclude/openpbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js +27 -20
- package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js +6 -2
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/Shaders/ShadersInclude/prePassDeclaration.js +95 -2
- package/Shaders/ShadersInclude/prePassDeclaration.js.map +1 -1
- package/Shaders/default.fragment.js +31 -40
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/depthOfField.fragment.js +13 -9
- package/Shaders/depthOfField.fragment.js.map +1 -1
- package/Shaders/fluidRenderingParticleDepth.vertex.js +16 -1
- package/Shaders/fluidRenderingParticleDepth.vertex.js.map +1 -1
- package/Shaders/fluidRenderingParticleThickness.vertex.js +16 -1
- package/Shaders/fluidRenderingParticleThickness.vertex.js.map +1 -1
- package/Shaders/gaussianSplatting.fragment.js +63 -3
- package/Shaders/gaussianSplatting.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +80 -0
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/geometry.fragment.js +17 -11
- package/Shaders/geometry.fragment.js.map +1 -1
- package/Shaders/gpuRenderParticles.fragment.js +43 -1
- package/Shaders/gpuRenderParticles.fragment.js.map +1 -1
- package/Shaders/gpuRenderParticles.vertex.js +96 -16
- package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
- package/Shaders/meshBlending.fragment.d.ts +5 -0
- package/Shaders/meshBlending.fragment.js +519 -0
- package/Shaders/meshBlending.fragment.js.map +1 -0
- package/Shaders/particles.fragment.js +43 -1
- package/Shaders/particles.fragment.js.map +1 -1
- package/Shaders/particles.vertex.js +84 -3
- package/Shaders/particles.vertex.js.map +1 -1
- package/Shaders/sprites.fragment.js +52 -2
- package/Shaders/sprites.fragment.js.map +1 -1
- package/Shaders/sprites.vertex.js +62 -1
- package/Shaders/sprites.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/defaultFragmentAlpha.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/defaultFragmentAlpha.js +33 -0
- package/ShadersWGSL/ShadersInclude/defaultFragmentAlpha.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/geometryRenderingFragment.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/geometryRenderingFragment.js +76 -0
- package/ShadersWGSL/ShadersInclude/geometryRenderingFragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/meshBlendTagFragmentOutput.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/meshBlendTagFragmentOutput.js +18 -0
- package/ShadersWGSL/ShadersInclude/meshBlendTagFragmentOutput.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.js +11 -25
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +11 -25
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDebug.js +5 -1
- package/ShadersWGSL/ShadersInclude/pbrDebug.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassDeclaration.js +6 -1
- package/ShadersWGSL/ShadersInclude/prePassDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +17 -48
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js +15 -2
- package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js.map +1 -1
- package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js +15 -2
- package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js +63 -2
- package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +80 -0
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/geometry.fragment.js +37 -2
- package/ShadersWGSL/geometry.fragment.js.map +1 -1
- package/ShadersWGSL/gpuRenderParticles.fragment.js +47 -2
- package/ShadersWGSL/gpuRenderParticles.fragment.js.map +1 -1
- package/ShadersWGSL/gpuRenderParticles.vertex.js +110 -7
- package/ShadersWGSL/gpuRenderParticles.vertex.js.map +1 -1
- package/ShadersWGSL/meshBlending.fragment.d.ts +5 -0
- package/ShadersWGSL/meshBlending.fragment.js +576 -0
- package/ShadersWGSL/meshBlending.fragment.js.map +1 -0
- package/ShadersWGSL/openpbr.fragment.js +2 -1
- package/ShadersWGSL/openpbr.fragment.js.map +1 -1
- package/ShadersWGSL/particles.fragment.js +45 -1
- package/ShadersWGSL/particles.fragment.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +86 -4
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +2 -1
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/sprites.fragment.js +56 -2
- package/ShadersWGSL/sprites.fragment.js.map +1 -1
- package/ShadersWGSL/sprites.vertex.js +62 -1
- package/ShadersWGSL/sprites.vertex.js.map +1 -1
- package/Sprites/spriteManager.d.ts +13 -0
- package/Sprites/spriteManager.js +15 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +24 -1
- package/Sprites/spriteRenderer.js +368 -50
- package/Sprites/spriteRenderer.js.map +1 -1
- package/Sprites/thinSprite.d.ts +4 -0
- package/Sprites/thinSprite.js +4 -0
- package/Sprites/thinSprite.js.map +1 -1
- package/States/alphaCullingState.d.ts +3 -1
- package/States/alphaCullingState.js +18 -3
- package/States/alphaCullingState.js.map +1 -1
- package/XR/webXRDefaultExperience.d.ts +5 -1
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXREnterExitUI.d.ts +2 -1
- package/XR/webXREnterExitUI.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +23 -0
- package/scene.pure.js +35 -0
- package/scene.pure.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRDefaultExperience.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRDefaultExperience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAA2B,UAAU,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAEH,uCAAuC,EACvC,+BAA+B,GAClC,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAqC,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE7I,OAAO,EAAgC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAmC,oCAAoC,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AACzK,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAkC,MAAM,mCAAmC,CAAC;AACjI,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,6BAA6B;CA8EzC;AAED;;GAEG;AACH,MAAM,OAAO,sBAAsB;IA+B/B,gBAAuB,CAAC;IAExB;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAY,EAAE,UAAyC,EAAE;QACrF,uCAAuC,EAAE,CAAC;QAC1C,oCAAoC,EAAE,CAAC;QACvC,4BAA4B,EAAE,CAAC;QAC/B,yBAAyB,EAAE,CAAC;QAE5B,MAAM,MAAM,GAAG,IAAI,sBAAsB,EAAE,CAAC;QAC5C,KAAK,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE;YACnC,MAAM,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,uCAAuC;QACvC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC5B,MAAM,SAAS,GA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AC,OAAO,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { WebXRExperienceHelper } from \"./webXRExperienceHelper\";\r\nimport { type Scene } from \"../scene\";\r\nimport { type IWebXRInputOptions, WebXRInput } from \"./webXRInput\";\r\nimport {\r\n type IWebXRControllerPointerSelectionOptions,\r\n RegisterWebXRControllerPointerSelection,\r\n WebXRControllerPointerSelection,\r\n} from \"./features/WebXRControllerPointerSelection.pure\";\r\nimport { type IWebXRNearInteractionOptions, RegisterWebXRNearInteraction, WebXRNearInteraction } from \"./features/WebXRNearInteraction.pure\";\r\nimport { type WebXRRenderTarget } from \"./webXRTypes\";\r\nimport { type WebXREnterExitUIOptions, WebXREnterExitUI } from \"./webXREnterExitUI\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { type WebXRManagedOutputCanvasOptions } from \"./webXRManagedOutputCanvas\";\r\nimport { type IWebXRTeleportationOptions, RegisterWebXRControllerTeleportation, WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation.pure\";\r\nimport { RegisterWebXRHandTracking, WebXRHandTracking, type IWebXRHandTrackingOptions } from \"./features/WebXRHandTracking.pure\";\r\nimport { Logger } from \"../Misc/logger\";\r\n\r\n/**\r\n * Options for the default xr helper\r\n */\r\nexport class WebXRDefaultExperienceOptions {\r\n /**\r\n * Enable or disable default UI to enter XR\r\n */\r\n public disableDefaultUI?: boolean;\r\n /**\r\n * Should pointer selection not initialize.\r\n * Note that disabling pointer selection also disables teleportation.\r\n * Defaults to false.\r\n */\r\n public disablePointerSelection?: boolean;\r\n /**\r\n * Should teleportation not initialize. Defaults to false.\r\n */\r\n public disableTeleportation?: boolean;\r\n /**\r\n * Should nearInteraction not initialize. Defaults to false.\r\n */\r\n public disableNearInteraction?: boolean;\r\n\r\n /**\r\n * Should hand tracking be disabled. Defaults to false.\r\n */\r\n public disableHandTracking?: boolean;\r\n /**\r\n * Floor meshes that will be used for teleport\r\n */\r\n public floorMeshes?: Array<AbstractMesh>;\r\n /**\r\n * If set to true, the first frame will not be used to reset position\r\n * The first frame is mainly used when copying transformation from the old camera\r\n * Mainly used in AR\r\n */\r\n public ignoreNativeCameraTransformation?: boolean;\r\n /**\r\n * Optional configuration for the XR input object\r\n */\r\n public inputOptions?: Partial<IWebXRInputOptions>;\r\n /**\r\n * optional configuration for pointer selection\r\n */\r\n public pointerSelectionOptions?: Partial<IWebXRControllerPointerSelectionOptions>;\r\n /**\r\n * optional configuration for near interaction\r\n */\r\n public nearInteractionOptions?: Partial<IWebXRNearInteractionOptions>;\r\n\r\n /**\r\n * optional configuration for hand tracking\r\n */\r\n public handSupportOptions?: Partial<IWebXRHandTrackingOptions>;\r\n /**\r\n * optional configuration for teleportation\r\n */\r\n public teleportationOptions?: Partial<IWebXRTeleportationOptions>;\r\n /**\r\n * optional configuration for the output canvas\r\n */\r\n public outputCanvasOptions?: WebXRManagedOutputCanvasOptions;\r\n /**\r\n * optional UI options. This can be used among other to change session mode and reference space type\r\n */\r\n public uiOptions?: Partial<WebXREnterExitUIOptions>;\r\n /**\r\n * When loading teleportation and pointer select, use stable versions instead of latest.\r\n */\r\n public useStablePlugins?: boolean;\r\n\r\n /**\r\n * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes\r\n */\r\n public renderingGroupId?: number;\r\n\r\n /**\r\n * A list of optional features to init the session with\r\n * If set to true, all features we support will be added\r\n */\r\n public optionalFeatures?: boolean | string[];\r\n}\r\n\r\n/**\r\n * Default experience for webxr\r\n */\r\nexport class WebXRDefaultExperience {\r\n /**\r\n * Base experience\r\n */\r\n public baseExperience: WebXRExperienceHelper;\r\n /**\r\n * Enables ui for entering/exiting xr\r\n */\r\n public enterExitUI: WebXREnterExitUI;\r\n /**\r\n * Input experience extension\r\n */\r\n public input: WebXRInput;\r\n /**\r\n * Enables laser pointer and selection\r\n */\r\n public pointerSelection: WebXRControllerPointerSelection;\r\n /**\r\n * Default target xr should render to\r\n */\r\n public renderTarget: WebXRRenderTarget;\r\n /**\r\n * Enables teleportation\r\n */\r\n public teleportation: WebXRMotionControllerTeleportation;\r\n\r\n /**\r\n * Enables near interaction for hands/controllers\r\n */\r\n public nearInteraction: WebXRNearInteraction;\r\n\r\n private constructor() {}\r\n\r\n /**\r\n * Creates the default xr experience\r\n * @param scene scene\r\n * @param options options for basic configuration\r\n * @returns resulting WebXRDefaultExperience\r\n */\r\n public static async CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions = {}) {\r\n RegisterWebXRControllerPointerSelection();\r\n RegisterWebXRControllerTeleportation();\r\n RegisterWebXRNearInteraction();\r\n RegisterWebXRHandTracking();\r\n\r\n const result = new WebXRDefaultExperience();\r\n scene.onDisposeObservable.addOnce(() => {\r\n result.dispose();\r\n });\r\n // init the UI right after construction\r\n if (!options.disableDefaultUI) {\r\n const uiOptions: WebXREnterExitUIOptions = {\r\n renderTarget: result.renderTarget,\r\n ...(options.uiOptions || {}),\r\n };\r\n if (options.optionalFeatures) {\r\n if (typeof options.optionalFeatures === \"boolean\") {\r\n uiOptions.optionalFeatures = [\"hit-test\", \"anchors\", \"plane-detection\", \"hand-tracking\"];\r\n } else {\r\n uiOptions.optionalFeatures = options.optionalFeatures;\r\n }\r\n }\r\n result.enterExitUI = new WebXREnterExitUI(scene, uiOptions);\r\n }\r\n\r\n try {\r\n // Create base experience\r\n const xrHelper = await WebXRExperienceHelper.CreateAsync(scene);\r\n // eslint-disable-next-line require-atomic-updates\r\n result.baseExperience = xrHelper;\r\n\r\n if (options.ignoreNativeCameraTransformation) {\r\n // eslint-disable-next-line require-atomic-updates\r\n result.baseExperience.camera.compensateOnFirstFrame = false;\r\n }\r\n\r\n // Add controller support\r\n // eslint-disable-next-line require-atomic-updates\r\n result.input = new WebXRInput(xrHelper.sessionManager, xrHelper.camera, {\r\n controllerOptions: {\r\n renderingGroupId: options.renderingGroupId,\r\n },\r\n ...(options.inputOptions || {}),\r\n });\r\n\r\n if (!options.disablePointerSelection) {\r\n // Add default pointer selection\r\n const pointerSelectionOptions = {\r\n ...options.pointerSelectionOptions,\r\n xrInput: result.input,\r\n renderingGroupId: options.renderingGroupId,\r\n };\r\n\r\n result.pointerSelection = result.baseExperience.featuresManager.enableFeature(\r\n WebXRControllerPointerSelection.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRControllerPointerSelectionOptions>pointerSelectionOptions\r\n );\r\n\r\n if (!options.disableTeleportation) {\r\n // Add default teleportation, including rotation\r\n result.teleportation = result.baseExperience.featuresManager.enableFeature(\r\n WebXRMotionControllerTeleportation.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRTeleportationOptions>{\r\n floorMeshes: options.floorMeshes,\r\n xrInput: result.input,\r\n renderingGroupId: options.renderingGroupId,\r\n ...options.teleportationOptions,\r\n }\r\n );\r\n result.teleportation.setSelectionFeature(result.pointerSelection);\r\n }\r\n }\r\n\r\n if (!options.disableNearInteraction) {\r\n // Add default pointer selection\r\n result.nearInteraction = result.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, options.useStablePlugins ? \"stable\" : \"latest\", <\r\n IWebXRNearInteractionOptions\r\n >{\r\n xrInput: result.input,\r\n farInteractionFeature: result.pointerSelection,\r\n renderingGroupId: options.renderingGroupId,\r\n useUtilityLayer: true,\r\n enableNearInteractionOnAllControllers: true,\r\n ...options.nearInteractionOptions,\r\n });\r\n }\r\n\r\n if (!options.disableHandTracking) {\r\n // Add default hand tracking\r\n result.baseExperience.featuresManager.enableFeature(\r\n WebXRHandTracking.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRHandTrackingOptions>{\r\n xrInput: result.input,\r\n ...options.handSupportOptions,\r\n },\r\n undefined,\r\n false\r\n );\r\n }\r\n\r\n // Create the WebXR output target\r\n result.renderTarget = result.baseExperience.sessionManager.getWebXRRenderTarget(options.outputCanvasOptions);\r\n\r\n if (!options.disableDefaultUI) {\r\n // Create ui for entering/exiting xr\r\n await result.enterExitUI.setHelperAsync(result.baseExperience, result.renderTarget);\r\n }\r\n return result;\r\n } catch (error) {\r\n Logger.Error(\"Error initializing XR\");\r\n Logger.Error(error);\r\n return result;\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the experience helper\r\n */\r\n public dispose() {\r\n if (this.baseExperience) {\r\n this.baseExperience.dispose();\r\n }\r\n if (this.input) {\r\n this.input.dispose();\r\n }\r\n if (this.enterExitUI) {\r\n this.enterExitUI.dispose();\r\n }\r\n if (this.renderTarget) {\r\n this.renderTarget.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRDefaultExperience.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRDefaultExperience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAA2B,UAAU,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAEH,uCAAuC,EACvC,+BAA+B,GAClC,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAqC,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE7I,OAAO,EAAgC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAmC,oCAAoC,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AACzK,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAkC,MAAM,mCAAmC,CAAC;AACjI,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,6BAA6B;CAkFzC;AAED;;GAEG;AACH,MAAM,OAAO,sBAAsB;IA+B/B,gBAAuB,CAAC;IAExB;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAY,EAAE,UAAyC,EAAE;QACrF,u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KAAK,CAAC,CAAC;YACpB,OAAO,MAAM,CAAC;QAClB,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { WebXRExperienceHelper } from \"./webXRExperienceHelper\";\r\nimport { type Scene } from \"../scene\";\r\nimport { type IWebXRInputOptions, WebXRInput } from \"./webXRInput\";\r\nimport {\r\n type IWebXRControllerPointerSelectionOptions,\r\n RegisterWebXRControllerPointerSelection,\r\n WebXRControllerPointerSelection,\r\n} from \"./features/WebXRControllerPointerSelection.pure\";\r\nimport { type IWebXRNearInteractionOptions, RegisterWebXRNearInteraction, WebXRNearInteraction } from \"./features/WebXRNearInteraction.pure\";\r\nimport { type WebXRRenderTarget } from \"./webXRTypes\";\r\nimport { type WebXREnterExitUIOptions, WebXREnterExitUI } from \"./webXREnterExitUI\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { type WebXRManagedOutputCanvasOptions } from \"./webXRManagedOutputCanvas\";\r\nimport { type IWebXRTeleportationOptions, RegisterWebXRControllerTeleportation, WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation.pure\";\r\nimport { RegisterWebXRHandTracking, WebXRHandTracking, type IWebXRHandTrackingOptions } from \"./features/WebXRHandTracking.pure\";\r\nimport { Logger } from \"../Misc/logger\";\r\n\r\n/**\r\n * Options for the default xr helper\r\n */\r\nexport class WebXRDefaultExperienceOptions {\r\n /**\r\n * Enable or disable default UI to enter XR\r\n */\r\n public disableDefaultUI?: boolean;\r\n /**\r\n * Should pointer selection not initialize.\r\n * Note that disabling pointer selection also disables teleportation.\r\n * Defaults to false.\r\n */\r\n public disablePointerSelection?: boolean;\r\n /**\r\n * Should teleportation not initialize. Defaults to false.\r\n */\r\n public disableTeleportation?: boolean;\r\n /**\r\n * Should nearInteraction not initialize. Defaults to false.\r\n */\r\n public disableNearInteraction?: boolean;\r\n\r\n /**\r\n * Should hand tracking be disabled. Defaults to false.\r\n */\r\n public disableHandTracking?: boolean;\r\n /**\r\n * Floor meshes that will be used for teleport\r\n */\r\n public floorMeshes?: Array<AbstractMesh>;\r\n /**\r\n * If set to true, the first frame will not be used to reset position\r\n * The first frame is mainly used when copying transformation from the old camera\r\n * Mainly used in AR\r\n */\r\n public ignoreNativeCameraTransformation?: boolean;\r\n /**\r\n * Optional configuration for the XR input object\r\n */\r\n public inputOptions?: Partial<IWebXRInputOptions>;\r\n /**\r\n * optional configuration for pointer selection\r\n */\r\n public pointerSelectionOptions?: Partial<IWebXRControllerPointerSelectionOptions>;\r\n /**\r\n * optional configuration for near interaction\r\n */\r\n public nearInteractionOptions?: Partial<IWebXRNearInteractionOptions>;\r\n\r\n /**\r\n * optional configuration for hand tracking\r\n */\r\n public handSupportOptions?: Partial<IWebXRHandTrackingOptions>;\r\n /**\r\n * optional configuration for teleportation\r\n */\r\n public teleportationOptions?: Partial<IWebXRTeleportationOptions>;\r\n /**\r\n * optional configuration for the output canvas\r\n */\r\n public outputCanvasOptions?: WebXRManagedOutputCanvasOptions;\r\n /**\r\n * Options for the default enter/exit UI, including session mode and reference space type.\r\n * Set `onError` here to receive XR entry failures (including WebGPU session negotiation failures)\r\n * when the default button is used. The application can then notify the user or create a new\r\n * WebGL engine and scene; Babylon.js cannot switch an existing scene's rendering backend.\r\n * When `disableDefaultUI` is true, handle rejections from `baseExperience.enterXRAsync()` instead.\r\n */\r\n public uiOptions?: Partial<WebXREnterExitUIOptions>;\r\n /**\r\n * When loading teleportation and pointer select, use stable versions instead of latest.\r\n */\r\n public useStablePlugins?: boolean;\r\n\r\n /**\r\n * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes\r\n */\r\n public renderingGroupId?: number;\r\n\r\n /**\r\n * A list of optional features to init the session with\r\n * If set to true, all features we support will be added\r\n */\r\n public optionalFeatures?: boolean | string[];\r\n}\r\n\r\n/**\r\n * Default experience for webxr\r\n */\r\nexport class WebXRDefaultExperience {\r\n /**\r\n * Base experience\r\n */\r\n public baseExperience: WebXRExperienceHelper;\r\n /**\r\n * Enables ui for entering/exiting xr\r\n */\r\n public enterExitUI: WebXREnterExitUI;\r\n /**\r\n * Input experience extension\r\n */\r\n public input: WebXRInput;\r\n /**\r\n * Enables laser pointer and selection\r\n */\r\n public pointerSelection: WebXRControllerPointerSelection;\r\n /**\r\n * Default target xr should render to\r\n */\r\n public renderTarget: WebXRRenderTarget;\r\n /**\r\n * Enables teleportation\r\n */\r\n public teleportation: WebXRMotionControllerTeleportation;\r\n\r\n /**\r\n * Enables near interaction for hands/controllers\r\n */\r\n public nearInteraction: WebXRNearInteraction;\r\n\r\n private constructor() {}\r\n\r\n /**\r\n * Creates the default xr experience\r\n * @param scene scene\r\n * @param options options for basic configuration\r\n * @returns resulting WebXRDefaultExperience\r\n */\r\n public static async CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions = {}) {\r\n RegisterWebXRControllerPointerSelection();\r\n RegisterWebXRControllerTeleportation();\r\n RegisterWebXRNearInteraction();\r\n RegisterWebXRHandTracking();\r\n\r\n const result = new WebXRDefaultExperience();\r\n scene.onDisposeObservable.addOnce(() => {\r\n result.dispose();\r\n });\r\n // init the UI right after construction\r\n if (!options.disableDefaultUI) {\r\n const uiOptions: WebXREnterExitUIOptions = {\r\n renderTarget: result.renderTarget,\r\n ...(options.uiOptions || {}),\r\n };\r\n if (options.optionalFeatures) {\r\n if (typeof options.optionalFeatures === \"boolean\") {\r\n uiOptions.optionalFeatures = [\"hit-test\", \"anchors\", \"plane-detection\", \"hand-tracking\"];\r\n } else {\r\n uiOptions.optionalFeatures = options.optionalFeatures;\r\n }\r\n }\r\n result.enterExitUI = new WebXREnterExitUI(scene, uiOptions);\r\n }\r\n\r\n try {\r\n // Create base experience\r\n const xrHelper = await WebXRExperienceHelper.CreateAsync(scene);\r\n // eslint-disable-next-line require-atomic-updates\r\n result.baseExperience = xrHelper;\r\n\r\n if (options.ignoreNativeCameraTransformation) {\r\n // eslint-disable-next-line require-atomic-updates\r\n result.baseExperience.camera.compensateOnFirstFrame = false;\r\n }\r\n\r\n // Add controller support\r\n // eslint-disable-next-line require-atomic-updates\r\n result.input = new WebXRInput(xrHelper.sessionManager, xrHelper.camera, {\r\n controllerOptions: {\r\n renderingGroupId: options.renderingGroupId,\r\n },\r\n ...(options.inputOptions || {}),\r\n });\r\n\r\n if (!options.disablePointerSelection) {\r\n // Add default pointer selection\r\n const pointerSelectionOptions = {\r\n ...options.pointerSelectionOptions,\r\n xrInput: result.input,\r\n renderingGroupId: options.renderingGroupId,\r\n };\r\n\r\n result.pointerSelection = result.baseExperience.featuresManager.enableFeature(\r\n WebXRControllerPointerSelection.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRControllerPointerSelectionOptions>pointerSelectionOptions\r\n );\r\n\r\n if (!options.disableTeleportation) {\r\n // Add default teleportation, including rotation\r\n result.teleportation = result.baseExperience.featuresManager.enableFeature(\r\n WebXRMotionControllerTeleportation.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRTeleportationOptions>{\r\n floorMeshes: options.floorMeshes,\r\n xrInput: result.input,\r\n renderingGroupId: options.renderingGroupId,\r\n ...options.teleportationOptions,\r\n }\r\n );\r\n result.teleportation.setSelectionFeature(result.pointerSelection);\r\n }\r\n }\r\n\r\n if (!options.disableNearInteraction) {\r\n // Add default pointer selection\r\n result.nearInteraction = result.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, options.useStablePlugins ? \"stable\" : \"latest\", <\r\n IWebXRNearInteractionOptions\r\n >{\r\n xrInput: result.input,\r\n farInteractionFeature: result.pointerSelection,\r\n renderingGroupId: options.renderingGroupId,\r\n useUtilityLayer: true,\r\n enableNearInteractionOnAllControllers: true,\r\n ...options.nearInteractionOptions,\r\n });\r\n }\r\n\r\n if (!options.disableHandTracking) {\r\n // Add default hand tracking\r\n result.baseExperience.featuresManager.enableFeature(\r\n WebXRHandTracking.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRHandTrackingOptions>{\r\n xrInput: result.input,\r\n ...options.handSupportOptions,\r\n },\r\n undefined,\r\n false\r\n );\r\n }\r\n\r\n // Create the WebXR output target\r\n result.renderTarget = result.baseExperience.sessionManager.getWebXRRenderTarget(options.outputCanvasOptions);\r\n\r\n if (!options.disableDefaultUI) {\r\n // Create ui for entering/exiting xr\r\n await result.enterExitUI.setHelperAsync(result.baseExperience, result.renderTarget);\r\n }\r\n return result;\r\n } catch (error) {\r\n Logger.Error(\"Error initializing XR\");\r\n Logger.Error(error);\r\n return result;\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the experience helper\r\n */\r\n public dispose() {\r\n if (this.baseExperience) {\r\n this.baseExperience.dispose();\r\n }\r\n if (this.input) {\r\n this.input.dispose();\r\n }\r\n if (this.enterExitUI) {\r\n this.enterExitUI.dispose();\r\n }\r\n if (this.renderTarget) {\r\n this.renderTarget.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
package/XR/webXREnterExitUI.d.ts
CHANGED
|
@@ -69,7 +69,8 @@ export declare class WebXREnterExitUIOptions {
|
|
|
69
69
|
*/
|
|
70
70
|
ignoreSessionGrantedEvent?: boolean;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Called with the error from `enterXRAsync` when entering XR through the UI fails.
|
|
73
|
+
* The button still displays ERROR; the application decides whether to show a message or rebuild with WebGL.
|
|
73
74
|
*/
|
|
74
75
|
onError?: (error: any) => void;
|
|
75
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXREnterExitUI.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXREnterExitUI.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAC/B;;;;;OAKG;IACH;IACI,qBAAqB;IACd,OAAoB;IAC3B,+CAA+C;IACxC,WAA0B;IACjC,2BAA2B;IACpB,kBAAwC;QAJxC,YAAO,GAAP,OAAO,CAAa;QAEpB,gBAAW,GAAX,WAAW,CAAe;QAE1B,uBAAkB,GAAlB,kBAAkB,CAAsB;IAChD,CAAC;IAEJ;;;OAGG;IACH,6DAA6D;IACtD,MAAM,CAAC,YAA8C,IAAG,CAAC;CACnE;AAED;;GAEG;AACH,MAAM,OAAO,uBAAuB;CAyCnC;AACD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAmBzB;;;;;OAKG;IACH,YACY,MAAa;IACrB,+CAA+C;IACxC,OAAgC;QAF/B,WAAM,GAAN,MAAM,CAAO;QAEd,YAAO,GAAP,OAAO,CAAyB;QA3BnC,kBAAa,GAAqC,IAAI,CAAC;QACvD,aAAQ,GAAkC,EAAE,CAAC;QAQrD;;;;;;WAMG;QACI,kCAA6B,GAAG,IAAI,UAAU,EAAoC,CAAC;QAsJ1F,6DAA6D;QACrD,sBAAiB,GAAG,CAAC,GAA2B,EAAE,EAAE;YACxD,wCAAwC;YACxC,6GAA6G;YAE7G,mEAAmE;YACnE,iDAAiD;YACjD,qBAAqB;YACrB,yCAAyC;YACzC,iDAAiD;YACjD,iDAAiD;YACjD,2BAA2B;YAC3B,YAAY;YACZ,wBAAwB;YACxB,UAAU;YACV,SAAS;YAET,IAAI,IAAI,CAAC,OAAO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,CAAC,CAAC;IAC3E,CAAC;CACJ","sourcesContent":["import { type Nullable } from \"../types\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { type IDisposable, type Scene } from \"../scene\";\r\nimport { type WebXRExperienceHelper } from \"./webXRExperienceHelper\";\r\nimport { type WebXRRenderTarget, WebXRState } from \"./webXRTypes\";\r\nimport { Tools } from \"../Misc/tools.pure\";\r\n/**\r\n * Button which can be used to enter a different mode of XR\r\n */\r\nexport class WebXREnterExitUIButton {\r\n /**\r\n * Creates a WebXREnterExitUIButton\r\n * @param element button element\r\n * @param sessionMode XR initialization session mode\r\n * @param referenceSpaceType the type of reference space to be used\r\n */\r\n constructor(\r\n /** button element */\r\n public element: HTMLElement,\r\n /** XR initialization options for the button */\r\n public sessionMode: XRSessionMode,\r\n /** Reference space type */\r\n public referenceSpaceType: XRReferenceSpaceType\r\n ) {}\r\n\r\n /**\r\n * Extendable function which can be used to update the button's visuals when the state changes\r\n * @param activeButton the current active button in the UI\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public update(activeButton: Nullable<WebXREnterExitUIButton>) {}\r\n}\r\n\r\n/**\r\n * Options to create the webXR UI\r\n */\r\nexport class WebXREnterExitUIOptions {\r\n /**\r\n * User provided buttons to enable/disable WebXR. The system will provide default if not set\r\n */\r\n customButtons?: Array<WebXREnterExitUIButton>;\r\n /**\r\n * A reference space type to use when creating the default button.\r\n * Default is local-floor\r\n */\r\n referenceSpaceType?: XRReferenceSpaceType;\r\n /**\r\n * Context to enter xr with\r\n */\r\n renderTarget?: Nullable<WebXRRenderTarget>;\r\n /**\r\n * A session mode to use when creating the default button.\r\n * Default is immersive-vr\r\n */\r\n sessionMode?: XRSessionMode;\r\n\r\n /**\r\n * A list of optional features to init the session with\r\n */\r\n optionalFeatures?: string[];\r\n\r\n /**\r\n * A list of optional features to init the session with\r\n */\r\n requiredFeatures?: string[];\r\n\r\n /**\r\n * If set, the `sessiongranted` event will not be registered. `sessiongranted` is used to move seamlessly between WebXR experiences.\r\n * If set to true the user will be forced to press the \"enter XR\" button even if sessiongranted event was triggered.\r\n * If not set and a sessiongranted event was triggered, the XR session will start automatically.\r\n */\r\n ignoreSessionGrantedEvent?: boolean;\r\n\r\n /**\r\n * If defined, this function will be executed if the UI encounters an error when entering XR\r\n */\r\n onError?: (error: any) => void;\r\n}\r\n/**\r\n * UI to allow the user to enter/exit XR mode\r\n */\r\nexport class WebXREnterExitUI implements IDisposable {\r\n private _activeButton: Nullable<WebXREnterExitUIButton> = null;\r\n private _buttons: Array<WebXREnterExitUIButton> = [];\r\n private _helper: WebXRExperienceHelper;\r\n private _renderTarget?: WebXRRenderTarget;\r\n /**\r\n * The HTML Div Element to which buttons are added.\r\n */\r\n public readonly overlay: HTMLDivElement;\r\n\r\n /**\r\n * Fired every time the active button is changed.\r\n *\r\n * When xr is entered via a button that launches xr that button will be the callback parameter\r\n *\r\n * When exiting xr the callback parameter will be null)\r\n */\r\n public activeButtonChangedObservable = new Observable<Nullable<WebXREnterExitUIButton>>();\r\n\r\n /**\r\n * Construct a new EnterExit UI class\r\n *\r\n * @param _scene babylon scene object to use\r\n * @param options (read-only) version of the options passed to this UI\r\n */\r\n public constructor(\r\n private _scene: Scene,\r\n /** version of the options passed to this UI */\r\n public options: WebXREnterExitUIOptions\r\n ) {\r\n this.overlay = document.createElement(\"div\");\r\n this.overlay.classList.add(\"xr-button-overlay\");\r\n\r\n // prepare for session granted event\r\n if (!options.ignoreSessionGrantedEvent && (navigator as any).xr) {\r\n (navigator as any).xr.addEventListener(\"sessiongranted\", this._onSessionGranted);\r\n }\r\n\r\n // if served over HTTP, warn people.\r\n // Hopefully the browsers will catch up\r\n if (typeof window !== \"undefined\") {\r\n if (window.location && window.location.protocol === \"http:\" && window.location.hostname !== \"localhost\") {\r\n Tools.Warn(\"WebXR can only be served over HTTPS\");\r\n throw new Error(\"WebXR can only be served over HTTPS\");\r\n }\r\n }\r\n\r\n if (options.customButtons) {\r\n this._buttons = options.customButtons;\r\n } else {\r\n this.overlay.style.cssText = \"z-index:11;position: absolute; right: 20px;bottom: 50px;\";\r\n const sessionMode = options.sessionMode || \"immersive-vr\";\r\n const referenceSpaceType = options.referenceSpaceType || \"local-floor\";\r\n const url =\r\n typeof SVGSVGElement === \"undefined\"\r\n ? \"https://cdn.babylonjs.com/Assets/vrButton.png\"\r\n : \"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A\";\r\n let css =\r\n \".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(\" +\r\n url +\r\n \"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }\";\r\n css += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: \"EXIT\"} .xr-error::after { content: \"ERROR\"}';\r\n\r\n const style = document.createElement(\"style\");\r\n style.appendChild(document.createTextNode(css));\r\n document.getElementsByTagName(\"head\")[0].appendChild(style);\r\n const hmdBtn = document.createElement(\"button\");\r\n hmdBtn.className = \"babylonVRicon\";\r\n hmdBtn.title = `${sessionMode} - ${referenceSpaceType}`;\r\n this._buttons.push(new WebXREnterExitUIButton(hmdBtn, sessionMode, referenceSpaceType));\r\n this._buttons[this._buttons.length - 1].update = function (activeButton: WebXREnterExitUIButton) {\r\n this.element.style.display = activeButton === null || activeButton === this ? \"\" : \"none\";\r\n hmdBtn.className = \"babylonVRicon\" + (activeButton === this ? \" vrdisplaypresenting\" : \"\");\r\n };\r\n this._updateButtons(null);\r\n }\r\n\r\n const renderCanvas = _scene.getEngine().getInputElement();\r\n if (renderCanvas && renderCanvas.parentNode) {\r\n renderCanvas.parentNode.appendChild(this.overlay);\r\n _scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Set the helper to be used with this UI component.\r\n * The UI is bound to an experience helper. If not provided the UI can still be used but the events should be registered by the developer.\r\n *\r\n * @param helper the experience helper to attach\r\n * @param renderTarget an optional render target (in case it is created outside of the helper scope)\r\n * @returns a promise that resolves when the ui is ready\r\n */\r\n public async setHelperAsync(helper: WebXRExperienceHelper, renderTarget?: WebXRRenderTarget): Promise<void> {\r\n this._helper = helper;\r\n this._renderTarget = renderTarget;\r\n const supportedPromises = this._buttons.map(async (btn) => {\r\n return await helper.sessionManager.isSessionSupportedAsync(btn.sessionMode);\r\n });\r\n helper.onStateChangedObservable.add((state) => {\r\n if (state == WebXRState.NOT_IN_XR) {\r\n this._updateButtons(null);\r\n }\r\n });\r\n const results = await Promise.all(supportedPromises);\r\n for (let i = 0; i < results.length; i++) {\r\n const supported = results[i];\r\n if (supported) {\r\n this.overlay.appendChild(this._buttons[i].element);\r\n this._buttons[i].element.onclick = this._enterXRWithButtonIndexAsync.bind(this, i);\r\n } else {\r\n Tools.Warn(`Session mode \"${this._buttons[i].sessionMode}\" not supported in browser`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates UI to allow the user to enter/exit XR mode\r\n * @param scene the scene to add the ui to\r\n * @param helper the xr experience helper to enter/exit xr with\r\n * @param options options to configure the UI\r\n * @returns the created ui\r\n */\r\n public static async CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI> {\r\n const ui = new WebXREnterExitUI(scene, options);\r\n await ui.setHelperAsync(helper, options.renderTarget || undefined);\r\n return ui;\r\n }\r\n\r\n private async _enterXRWithButtonIndexAsync(idx: number = 0) {\r\n if (this._helper.state == WebXRState.IN_XR) {\r\n await this._helper.exitXRAsync();\r\n this._updateButtons(null);\r\n } else if (this._helper.state == WebXRState.NOT_IN_XR) {\r\n try {\r\n await this._helper.enterXRAsync(this._buttons[idx].sessionMode, this._buttons[idx].referenceSpaceType, this._renderTarget, {\r\n optionalFeatures: this.options.optionalFeatures,\r\n requiredFeatures: this.options.requiredFeatures,\r\n });\r\n this._updateButtons(this._buttons[idx]);\r\n } catch (e) {\r\n // make sure button is visible\r\n this._updateButtons(null);\r\n const element = this._buttons[idx].element;\r\n const prevTitle = element.title;\r\n element.title = \"Error entering XR session : \" + prevTitle;\r\n element.classList.add(\"xr-error\");\r\n if (this.options.onError) {\r\n this.options.onError(e);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the XR UI component\r\n */\r\n public dispose() {\r\n const renderCanvas = this._scene.getEngine().getInputElement();\r\n if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this.overlay)) {\r\n renderCanvas.parentNode.removeChild(this.overlay);\r\n }\r\n this.activeButtonChangedObservable.clear();\r\n (navigator as any).xr.removeEventListener(\"sessiongranted\", this._onSessionGranted);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _onSessionGranted = (evt: { session: XRSession }) => {\r\n // This section is for future reference.\r\n // As per specs, evt.session.mode should have the supported session mode, but no browser supports it for now.\r\n\r\n // // check if the session granted is the same as the one requested\r\n // const grantedMode = (evt.session as any).mode;\r\n // if (grantedMode) {\r\n // this._buttons.some((btn, idx) => {\r\n // if (btn.sessionMode === grantedMode) {\r\n // this._enterXRWithButtonIndex(idx);\r\n // return true;\r\n // }\r\n // return false;\r\n // });\r\n // } else\r\n\r\n if (this._helper) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._enterXRWithButtonIndexAsync(0);\r\n }\r\n };\r\n\r\n private _updateButtons(activeButton: Nullable<WebXREnterExitUIButton>) {\r\n this._activeButton = activeButton;\r\n for (const b of this._buttons) {\r\n b.update(this._activeButton);\r\n }\r\n this.activeButtonChangedObservable.notifyObservers(this._activeButton);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXREnterExitUI.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXREnterExitUI.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAC/B;;;;;OAKG;IACH;IACI,qBAAqB;IACd,OAAoB;IAC3B,+CAA+C;IACxC,WAA0B;IACjC,2BAA2B;IACpB,kBAAwC;QAJxC,YAAO,GAAP,OAAO,CAAa;QAEpB,gBAAW,GAAX,WAAW,CAAe;QAE1B,uBAAkB,GAAlB,kBAAkB,CAAsB;IAChD,CAAC;IAEJ;;;OAGG;IACH,6DAA6D;IACtD,MAAM,CAAC,YAA8C,IAAG,CAAC;CACnE;AAED;;GAEG;AACH,MAAM,OAAO,uBAAuB;CA0CnC;AACD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAmBzB;;;;;OAKG;IACH,YACY,MAAa;IACrB,+CAA+C;IACxC,OAAgC;QAF/B,WAAM,GAAN,MAAM,CAAO;QAEd,YAAO,GAAP,OAAO,CAAyB;QA3BnC,kBAAa,GAAqC,IAAI,CAAC;QACvD,aAAQ,GAAkC,EAAE,CAAC;QAQrD;;;;;;WAMG;QACI,kCAA6B,GAAG,IAAI,UAAU,EAAoC,CAAC;QAsJ1F,6DAA6D;QACrD,sBAAiB,GAAG,CAAC,GAA2B,EAAE,EAAE;YACxD,wCAAwC;YACxC,6GAA6G;YAE7G,mEAAmE;YACnE,iDAAiD;YACjD,qBAAqB;YACrB,yCAAyC;YACzC,iDAAiD;YACjD,iDAAiD;YACjD,2BAA2B;YAC3B,YAAY;YACZ,wBAAwB;YACxB,UAAU;YACV,SAAS;YAET,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,mEAAmE;gBACnE,IAAI,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["import { type Nullable } from \"../types\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { type IDisposable, type Scene } from \"../scene\";\r\nimport { type WebXRExperienceHelper } from \"./webXRExperienceHelper\";\r\nimport { type WebXRRenderTarget, WebXRState } from \"./webXRTypes\";\r\nimport { Tools } from \"../Misc/tools.pure\";\r\n/**\r\n * Button which can be used to enter a different mode of XR\r\n */\r\nexport class WebXREnterExitUIButton {\r\n /**\r\n * Creates a WebXREnterExitUIButton\r\n * @param element button element\r\n * @param sessionMode XR initialization session mode\r\n * @param referenceSpaceType the type of reference space to be used\r\n */\r\n constructor(\r\n /** button element */\r\n public element: HTMLElement,\r\n /** XR initialization options for the button */\r\n public sessionMode: XRSessionMode,\r\n /** Reference space type */\r\n public referenceSpaceType: XRReferenceSpaceType\r\n ) {}\r\n\r\n /**\r\n * Extendable function which can be used to update the button's visuals when the state changes\r\n * @param activeButton the current active button in the UI\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public update(activeButton: Nullable<WebXREnterExitUIButton>) {}\r\n}\r\n\r\n/**\r\n * Options to create the webXR UI\r\n */\r\nexport class WebXREnterExitUIOptions {\r\n /**\r\n * User provided buttons to enable/disable WebXR. The system will provide default if not set\r\n */\r\n customButtons?: Array<WebXREnterExitUIButton>;\r\n /**\r\n * A reference space type to use when creating the default button.\r\n * Default is local-floor\r\n */\r\n referenceSpaceType?: XRReferenceSpaceType;\r\n /**\r\n * Context to enter xr with\r\n */\r\n renderTarget?: Nullable<WebXRRenderTarget>;\r\n /**\r\n * A session mode to use when creating the default button.\r\n * Default is immersive-vr\r\n */\r\n sessionMode?: XRSessionMode;\r\n\r\n /**\r\n * A list of optional features to init the session with\r\n */\r\n optionalFeatures?: string[];\r\n\r\n /**\r\n * A list of optional features to init the session with\r\n */\r\n requiredFeatures?: string[];\r\n\r\n /**\r\n * If set, the `sessiongranted` event will not be registered. `sessiongranted` is used to move seamlessly between WebXR experiences.\r\n * If set to true the user will be forced to press the \"enter XR\" button even if sessiongranted event was triggered.\r\n * If not set and a sessiongranted event was triggered, the XR session will start automatically.\r\n */\r\n ignoreSessionGrantedEvent?: boolean;\r\n\r\n /**\r\n * Called with the error from `enterXRAsync` when entering XR through the UI fails.\r\n * The button still displays ERROR; the application decides whether to show a message or rebuild with WebGL.\r\n */\r\n onError?: (error: any) => void;\r\n}\r\n/**\r\n * UI to allow the user to enter/exit XR mode\r\n */\r\nexport class WebXREnterExitUI implements IDisposable {\r\n private _activeButton: Nullable<WebXREnterExitUIButton> = null;\r\n private _buttons: Array<WebXREnterExitUIButton> = [];\r\n private _helper: WebXRExperienceHelper;\r\n private _renderTarget?: WebXRRenderTarget;\r\n /**\r\n * The HTML Div Element to which buttons are added.\r\n */\r\n public readonly overlay: HTMLDivElement;\r\n\r\n /**\r\n * Fired every time the active button is changed.\r\n *\r\n * When xr is entered via a button that launches xr that button will be the callback parameter\r\n *\r\n * When exiting xr the callback parameter will be null)\r\n */\r\n public activeButtonChangedObservable = new Observable<Nullable<WebXREnterExitUIButton>>();\r\n\r\n /**\r\n * Construct a new EnterExit UI class\r\n *\r\n * @param _scene babylon scene object to use\r\n * @param options (read-only) version of the options passed to this UI\r\n */\r\n public constructor(\r\n private _scene: Scene,\r\n /** version of the options passed to this UI */\r\n public options: WebXREnterExitUIOptions\r\n ) {\r\n this.overlay = document.createElement(\"div\");\r\n this.overlay.classList.add(\"xr-button-overlay\");\r\n\r\n // prepare for session granted event\r\n if (!options.ignoreSessionGrantedEvent && (navigator as any).xr) {\r\n (navigator as any).xr.addEventListener(\"sessiongranted\", this._onSessionGranted);\r\n }\r\n\r\n // if served over HTTP, warn people.\r\n // Hopefully the browsers will catch up\r\n if (typeof window !== \"undefined\") {\r\n if (window.location && window.location.protocol === \"http:\" && window.location.hostname !== \"localhost\") {\r\n Tools.Warn(\"WebXR can only be served over HTTPS\");\r\n throw new Error(\"WebXR can only be served over HTTPS\");\r\n }\r\n }\r\n\r\n if (options.customButtons) {\r\n this._buttons = options.customButtons;\r\n } else {\r\n this.overlay.style.cssText = \"z-index:11;position: absolute; right: 20px;bottom: 50px;\";\r\n const sessionMode = options.sessionMode || \"immersive-vr\";\r\n const referenceSpaceType = options.referenceSpaceType || \"local-floor\";\r\n const url =\r\n typeof SVGSVGElement === \"undefined\"\r\n ? \"https://cdn.babylonjs.com/Assets/vrButton.png\"\r\n : \"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A\";\r\n let css =\r\n \".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(\" +\r\n url +\r\n \"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }\";\r\n css += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: \"EXIT\"} .xr-error::after { content: \"ERROR\"}';\r\n\r\n const style = document.createElement(\"style\");\r\n style.appendChild(document.createTextNode(css));\r\n document.getElementsByTagName(\"head\")[0].appendChild(style);\r\n const hmdBtn = document.createElement(\"button\");\r\n hmdBtn.className = \"babylonVRicon\";\r\n hmdBtn.title = `${sessionMode} - ${referenceSpaceType}`;\r\n this._buttons.push(new WebXREnterExitUIButton(hmdBtn, sessionMode, referenceSpaceType));\r\n this._buttons[this._buttons.length - 1].update = function (activeButton: WebXREnterExitUIButton) {\r\n this.element.style.display = activeButton === null || activeButton === this ? \"\" : \"none\";\r\n hmdBtn.className = \"babylonVRicon\" + (activeButton === this ? \" vrdisplaypresenting\" : \"\");\r\n };\r\n this._updateButtons(null);\r\n }\r\n\r\n const renderCanvas = _scene.getEngine().getInputElement();\r\n if (renderCanvas && renderCanvas.parentNode) {\r\n renderCanvas.parentNode.appendChild(this.overlay);\r\n _scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Set the helper to be used with this UI component.\r\n * The UI is bound to an experience helper. If not provided the UI can still be used but the events should be registered by the developer.\r\n *\r\n * @param helper the experience helper to attach\r\n * @param renderTarget an optional render target (in case it is created outside of the helper scope)\r\n * @returns a promise that resolves when the ui is ready\r\n */\r\n public async setHelperAsync(helper: WebXRExperienceHelper, renderTarget?: WebXRRenderTarget): Promise<void> {\r\n this._helper = helper;\r\n this._renderTarget = renderTarget;\r\n const supportedPromises = this._buttons.map(async (btn) => {\r\n return await helper.sessionManager.isSessionSupportedAsync(btn.sessionMode);\r\n });\r\n helper.onStateChangedObservable.add((state) => {\r\n if (state == WebXRState.NOT_IN_XR) {\r\n this._updateButtons(null);\r\n }\r\n });\r\n const results = await Promise.all(supportedPromises);\r\n for (let i = 0; i < results.length; i++) {\r\n const supported = results[i];\r\n if (supported) {\r\n this.overlay.appendChild(this._buttons[i].element);\r\n this._buttons[i].element.onclick = this._enterXRWithButtonIndexAsync.bind(this, i);\r\n } else {\r\n Tools.Warn(`Session mode \"${this._buttons[i].sessionMode}\" not supported in browser`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates UI to allow the user to enter/exit XR mode\r\n * @param scene the scene to add the ui to\r\n * @param helper the xr experience helper to enter/exit xr with\r\n * @param options options to configure the UI\r\n * @returns the created ui\r\n */\r\n public static async CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI> {\r\n const ui = new WebXREnterExitUI(scene, options);\r\n await ui.setHelperAsync(helper, options.renderTarget || undefined);\r\n return ui;\r\n }\r\n\r\n private async _enterXRWithButtonIndexAsync(idx: number = 0) {\r\n if (this._helper.state == WebXRState.IN_XR) {\r\n await this._helper.exitXRAsync();\r\n this._updateButtons(null);\r\n } else if (this._helper.state == WebXRState.NOT_IN_XR) {\r\n try {\r\n await this._helper.enterXRAsync(this._buttons[idx].sessionMode, this._buttons[idx].referenceSpaceType, this._renderTarget, {\r\n optionalFeatures: this.options.optionalFeatures,\r\n requiredFeatures: this.options.requiredFeatures,\r\n });\r\n this._updateButtons(this._buttons[idx]);\r\n } catch (e) {\r\n // make sure button is visible\r\n this._updateButtons(null);\r\n const element = this._buttons[idx].element;\r\n const prevTitle = element.title;\r\n element.title = \"Error entering XR session : \" + prevTitle;\r\n element.classList.add(\"xr-error\");\r\n if (this.options.onError) {\r\n this.options.onError(e);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the XR UI component\r\n */\r\n public dispose() {\r\n const renderCanvas = this._scene.getEngine().getInputElement();\r\n if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this.overlay)) {\r\n renderCanvas.parentNode.removeChild(this.overlay);\r\n }\r\n this.activeButtonChangedObservable.clear();\r\n (navigator as any).xr.removeEventListener(\"sessiongranted\", this._onSessionGranted);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _onSessionGranted = (evt: { session: XRSession }) => {\r\n // This section is for future reference.\r\n // As per specs, evt.session.mode should have the supported session mode, but no browser supports it for now.\r\n\r\n // // check if the session granted is the same as the one requested\r\n // const grantedMode = (evt.session as any).mode;\r\n // if (grantedMode) {\r\n // this._buttons.some((btn, idx) => {\r\n // if (btn.sessionMode === grantedMode) {\r\n // this._enterXRWithButtonIndex(idx);\r\n // return true;\r\n // }\r\n // return false;\r\n // });\r\n // } else\r\n\r\n if (this._helper) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._enterXRWithButtonIndexAsync(0);\r\n }\r\n };\r\n\r\n private _updateButtons(activeButton: Nullable<WebXREnterExitUIButton>) {\r\n this._activeButton = activeButton;\r\n for (const b of this._buttons) {\r\n b.update(this._activeButton);\r\n }\r\n this.activeButtonChangedObservable.notifyObservers(this._activeButton);\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
package/scene.pure.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ import { type SubMesh } from "./Meshes/subMesh.pure.js";
|
|
|
49
49
|
import { type Node } from "./node.js";
|
|
50
50
|
import { type Animation } from "./Animations/animation.pure.js";
|
|
51
51
|
import { type Animatable } from "./Animations/animatable.core.js";
|
|
52
|
+
import { type IRuntimeAnimationWrite } from "./Animations/runtimeAnimation.js";
|
|
52
53
|
import { type AbstractEngine } from "./Engines/abstractEngine.pure.js";
|
|
53
54
|
import { type FrameGraph } from "./FrameGraph/frameGraph.js";
|
|
54
55
|
import { type IAssetContainer } from "./IAssetContainer.js";
|
|
@@ -172,6 +173,14 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
|
|
|
172
173
|
readonly _isScene = true;
|
|
173
174
|
/** @internal */
|
|
174
175
|
_blockEntityCollection: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Executes a synchronous action without allowing it to weaken an existing entity-collection block.
|
|
178
|
+
* @param blockEntityCollection whether the action requires entity collection to be blocked
|
|
179
|
+
* @param action the action to execute
|
|
180
|
+
* @returns the action result
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
_executeWithBlockedEntityCollection<T>(blockEntityCollection: boolean, action: () => T): T;
|
|
175
184
|
/**
|
|
176
185
|
* Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
|
|
177
186
|
*/
|
|
@@ -1147,6 +1156,20 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
|
|
|
1147
1156
|
get renderingManager(): RenderingManager;
|
|
1148
1157
|
/** @internal */
|
|
1149
1158
|
_activeAnimatables: Animatable[];
|
|
1159
|
+
/**
|
|
1160
|
+
* @internal
|
|
1161
|
+
* The writes of the runtime animations since the last animation step's bindings were processed - between steps
|
|
1162
|
+
* and in the current or last step - in the order they were made: the first _animationWriteCount entries, the rest
|
|
1163
|
+
* being reused. What the animations wrote, kept whatever became of them since, for as long as the bindings they
|
|
1164
|
+
* registered are pending or just processed.
|
|
1165
|
+
*/
|
|
1166
|
+
_animationWrites: IRuntimeAnimationWrite[];
|
|
1167
|
+
/** @internal How many of _animationWrites are in use. */
|
|
1168
|
+
_animationWriteCount: number;
|
|
1169
|
+
/** @internal How many of them, at the front, the last animation step's bindings processed; the next step lets them go. */
|
|
1170
|
+
_animationStepWriteCount: number;
|
|
1171
|
+
/** @internal Whether the current or last animation step evaluated the active animatables, which none does while animations are disabled. */
|
|
1172
|
+
_animationStepEvaluated: boolean;
|
|
1150
1173
|
private _transformMatrix;
|
|
1151
1174
|
private _sceneUbo;
|
|
1152
1175
|
/** @internal */
|
package/scene.pure.js
CHANGED
|
@@ -68,6 +68,23 @@ export class Scene {
|
|
|
68
68
|
static CollisionCoordinatorFactory() {
|
|
69
69
|
throw _WarnImport("DefaultCollisionCoordinator");
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Executes a synchronous action without allowing it to weaken an existing entity-collection block.
|
|
73
|
+
* @param blockEntityCollection whether the action requires entity collection to be blocked
|
|
74
|
+
* @param action the action to execute
|
|
75
|
+
* @returns the action result
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
_executeWithBlockedEntityCollection(blockEntityCollection, action) {
|
|
79
|
+
const previousBlockEntityCollection = this._blockEntityCollection;
|
|
80
|
+
this._blockEntityCollection = previousBlockEntityCollection || blockEntityCollection;
|
|
81
|
+
try {
|
|
82
|
+
return action();
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
this._blockEntityCollection = previousBlockEntityCollection;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
71
88
|
/**
|
|
72
89
|
* Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
|
|
73
90
|
*/
|
|
@@ -1345,6 +1362,20 @@ export class Scene {
|
|
|
1345
1362
|
this._softwareSkinnedMeshes = new SmartArrayNoDuplicate(32);
|
|
1346
1363
|
/** @internal */
|
|
1347
1364
|
this._activeAnimatables = new Array();
|
|
1365
|
+
/**
|
|
1366
|
+
* @internal
|
|
1367
|
+
* The writes of the runtime animations since the last animation step's bindings were processed - between steps
|
|
1368
|
+
* and in the current or last step - in the order they were made: the first _animationWriteCount entries, the rest
|
|
1369
|
+
* being reused. What the animations wrote, kept whatever became of them since, for as long as the bindings they
|
|
1370
|
+
* registered are pending or just processed.
|
|
1371
|
+
*/
|
|
1372
|
+
this._animationWrites = new Array();
|
|
1373
|
+
/** @internal How many of _animationWrites are in use. */
|
|
1374
|
+
this._animationWriteCount = 0;
|
|
1375
|
+
/** @internal How many of them, at the front, the last animation step's bindings processed; the next step lets them go. */
|
|
1376
|
+
this._animationStepWriteCount = 0;
|
|
1377
|
+
/** @internal Whether the current or last animation step evaluated the active animatables, which none does while animations are disabled. */
|
|
1378
|
+
this._animationStepEvaluated = false;
|
|
1348
1379
|
this._transformMatrix = Matrix.Zero();
|
|
1349
1380
|
/**
|
|
1350
1381
|
* Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
|
|
@@ -4612,6 +4643,7 @@ export class Scene {
|
|
|
4612
4643
|
this._processSubCameras(this.activeCamera, !!this.activeCamera.outputRenderTarget);
|
|
4613
4644
|
}
|
|
4614
4645
|
}
|
|
4646
|
+
this._inputManager._updateMeshUnderPointer();
|
|
4615
4647
|
// Intersection checks
|
|
4616
4648
|
this._checkIntersections();
|
|
4617
4649
|
// Executes the after render stage actions.
|
|
@@ -4722,6 +4754,9 @@ export class Scene {
|
|
|
4722
4754
|
this._renderTargets.dispose();
|
|
4723
4755
|
this._materialsRenderTargets.dispose();
|
|
4724
4756
|
this._registeredForLateAnimationBindings.dispose();
|
|
4757
|
+
this._animationWrites.length = 0;
|
|
4758
|
+
this._animationWriteCount = 0;
|
|
4759
|
+
this._animationStepWriteCount = 0;
|
|
4725
4760
|
this._meshesForIntersections.dispose();
|
|
4726
4761
|
this._toBeDisposed.length = 0;
|
|
4727
4762
|
// Abort active requests
|