@onerjs/core 8.55.8 → 8.55.9
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/animation.pure.js +2 -2
- package/Animations/animation.pure.js.map +1 -1
- package/Animations/runtimeAnimation.js +4 -0
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
- package/Behaviors/Meshes/followBehavior.js +1 -0
- package/Behaviors/Meshes/followBehavior.js.map +1 -1
- package/Behaviors/Meshes/surfaceMagnetismBehavior.js +1 -0
- package/Behaviors/Meshes/surfaceMagnetismBehavior.js.map +1 -1
- package/Cameras/Inputs/followCameraMouseWheelInput.js +2 -2
- package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/followCameraPointersInput.d.ts +15 -0
- package/Cameras/Inputs/followCameraPointersInput.js +18 -3
- package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js +1 -1
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicUniversalCamera.pure.js +1 -1
- package/Cameras/Stereoscopic/stereoscopicUniversalCamera.pure.js.map +1 -1
- package/Cameras/arcRotateCamera.pure.js +1 -1
- package/Cameras/arcRotateCamera.pure.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +1 -0
- package/Collisions/gpuPicker.js +5 -4
- package/Collisions/gpuPicker.js.map +1 -1
- package/Culling/Helper/boundingInfoHelper.js +1 -1
- package/Culling/Helper/boundingInfoHelper.js.map +1 -1
- package/Culling/boundingSphere.js +7 -4
- package/Culling/boundingSphere.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.pure.js +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.pure.js.map +1 -1
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.js +48 -6
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/abstractEngine.pure.js +2 -2
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/engine.d.ts +10 -1
- package/Engines/thinNativeEngine.pure.d.ts +6 -1
- package/Engines/thinNativeEngine.pure.js +29 -2
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.d.ts +3 -63
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.js +5 -71
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.pure.d.ts +71 -0
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.pure.js +86 -0
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Data/pure.d.ts +1 -0
- package/FlowGraph/Blocks/Data/pure.js +1 -0
- package/FlowGraph/Blocks/Data/pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.d.ts +3 -37
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.js +5 -39
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.pure.d.ts +45 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.pure.js +54 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.d.ts +3 -17
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.js +5 -22
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.pure.d.ts +25 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.pure.js +37 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Event/pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/pure.js +2 -0
- package/FlowGraph/Blocks/Event/pure.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.d.ts +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +198 -172
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FrameGraph/frameGraph.js +10 -1
- package/FrameGraph/frameGraph.js.map +1 -1
- package/Gamepads/gamepadManager.d.ts +1 -0
- package/Gamepads/gamepadManager.js +5 -2
- package/Gamepads/gamepadManager.js.map +1 -1
- package/Gizmos/scaleGizmo.js +1 -0
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Lights/IES/iesLoader.js +6 -8
- package/Lights/IES/iesLoader.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.js +4 -6
- package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +2 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/light.js +3 -5
- package/Lights/light.js.map +1 -1
- package/Lights/spotLight.pure.js +1 -1
- package/Lights/spotLight.pure.js.map +1 -1
- package/Materials/Background/backgroundMaterial.pure.d.ts +1 -1
- package/Materials/Background/backgroundMaterial.pure.js +3 -12
- package/Materials/Background/backgroundMaterial.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +2 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.pure.js +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.pure.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.d.ts +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js +3 -12
- package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.pure.d.ts +1 -1
- package/Materials/PBR/pbrBaseMaterial.pure.js +3 -12
- package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.pure.js +1 -1
- package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
- package/Materials/material.pure.js +2 -2
- package/Materials/material.pure.js.map +1 -1
- package/Materials/standardMaterial.pure.d.ts +1 -1
- package/Materials/standardMaterial.pure.js +4 -13
- package/Materials/standardMaterial.pure.js.map +1 -1
- package/Maths/math.path.js +1 -1
- package/Maths/math.path.js.map +1 -1
- package/Maths/math.polar.js +1 -1
- package/Maths/math.polar.js.map +1 -1
- package/Maths/math.vector.pure.js +4 -3
- package/Maths/math.vector.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +72 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +164 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +2 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +36 -18
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.d.ts +5 -4
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js +25 -8
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +3 -3
- package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js +2 -2
- package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js.map +1 -1
- package/Meshes/Node/Blocks/mappingBlock.pure.js +2 -2
- package/Meshes/Node/Blocks/mappingBlock.pure.js.map +1 -1
- package/Meshes/csg.js +5 -5
- package/Meshes/csg.js.map +1 -1
- package/Meshes/groundMesh.pure.js +1 -1
- package/Meshes/groundMesh.pure.js.map +1 -1
- package/Meshes/mesh.pure.js +2 -2
- package/Meshes/mesh.pure.js.map +1 -1
- package/Misc/deepMerger.js +1 -1
- package/Misc/deepMerger.js.map +1 -1
- package/Misc/dumpTools.pure.js +1 -1
- package/Misc/dumpTools.pure.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/pure.d.ts +1 -0
- package/Misc/pure.js +1 -0
- package/Misc/pure.js.map +1 -1
- package/Misc/shaderImportLoader.d.ts +25 -0
- package/Misc/shaderImportLoader.js +54 -0
- package/Misc/shaderImportLoader.js.map +1 -0
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/Node/Blocks/particleClampBlock.pure.d.ts +0 -1
- package/Particles/Node/Blocks/particleClampBlock.pure.js +1 -6
- package/Particles/Node/Blocks/particleClampBlock.pure.js.map +1 -1
- package/Particles/Node/Blocks/particleMathBlock.pure.js +1 -1
- package/Particles/Node/Blocks/particleMathBlock.pure.js.map +1 -1
- package/Particles/Node/Blocks/particleNLerpBlock.pure.js +8 -3
- package/Particles/Node/Blocks/particleNLerpBlock.pure.js.map +1 -1
- package/Particles/Node/Blocks/particleSmoothStepBlock.pure.js +3 -2
- package/Particles/Node/Blocks/particleSmoothStepBlock.pure.js.map +1 -1
- package/Particles/Node/Blocks/particleStepBlock.pure.js +3 -2
- package/Particles/Node/Blocks/particleStepBlock.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js.map +1 -1
- package/PostProcesses/depthOfFieldEffect.js +1 -1
- package/PostProcesses/depthOfFieldEffect.js.map +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.pure.js +1 -1
- package/PostProcesses/sharpenPostProcess.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.d.ts +12 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +15 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +14 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +122 -6
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +7 -0
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +17 -0
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/boundingBoxRenderer.pure.js +3 -3
- package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
- package/Rendering/outlineRenderer.pure.js +1 -0
- package/Rendering/outlineRenderer.pure.js.map +1 -1
- package/Rendering/subSurfaceConfiguration.js +1 -1
- package/Rendering/subSurfaceConfiguration.js.map +1 -1
- package/Rendering/subSurfaceSceneComponent.pure.d.ts +1 -1
- package/Rendering/subSurfaceSceneComponent.pure.js +1 -1
- package/Rendering/subSurfaceSceneComponent.pure.js.map +1 -1
- package/Rendering/utilityLayerRenderer.js +1 -1
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/Shaders/gaussianSplattingVoxel.fragment.js +4 -10
- package/Shaders/gaussianSplattingVoxel.fragment.js.map +1 -1
- package/Shaders/iblCombineVoxelGrids.fragment.js +1 -1
- package/Shaders/iblCombineVoxelGrids.fragment.js.map +1 -1
- package/Shaders/iblShadowVoxelTracing.fragment.js +24 -7
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/iblVoxelOpacityAtomicMax.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/iblVoxelOpacityAtomicMax.js +13 -0
- package/ShadersWGSL/ShadersInclude/iblVoxelOpacityAtomicMax.js.map +1 -0
- package/ShadersWGSL/gaussianSplattingVoxel.fragment.js +15 -9
- package/ShadersWGSL/gaussianSplattingVoxel.fragment.js.map +1 -1
- package/ShadersWGSL/iblCombineVoxelGrids.fragment.js +1 -1
- package/ShadersWGSL/iblCombineVoxelGrids.fragment.js.map +1 -1
- package/ShadersWGSL/iblCopyVoxelBufferToGrid.compute.d.ts +5 -0
- package/ShadersWGSL/iblCopyVoxelBufferToGrid.compute.js +14 -0
- package/ShadersWGSL/iblCopyVoxelBufferToGrid.compute.js.map +1 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +24 -7
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.fragment.js +26 -6
- package/ShadersWGSL/iblVoxelGrid.fragment.js.map +1 -1
- package/SmartAssets/smartAssetManager.pure.js +1 -1
- package/SmartAssets/smartAssetManager.pure.js.map +1 -1
- package/Sprites/thinSprite.js +1 -1
- package/Sprites/thinSprite.js.map +1 -1
- package/XR/features/Layers/WebXRCompositionLayer.d.ts +130 -12
- package/XR/features/Layers/WebXRCompositionLayer.js +192 -3
- package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
- package/XR/features/Layers/WebXRFallbackLayer.d.ts +84 -0
- package/XR/features/Layers/WebXRFallbackLayer.js +137 -0
- package/XR/features/Layers/WebXRFallbackLayer.js.map +1 -0
- package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +4 -4
- package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.pure.d.ts +45 -0
- package/XR/features/WebXRAnchorSystem.pure.js +153 -13
- package/XR/features/WebXRAnchorSystem.pure.js.map +1 -1
- package/XR/features/WebXRLayers.pure.d.ts +171 -8
- package/XR/features/WebXRLayers.pure.js +500 -98
- package/XR/features/WebXRLayers.pure.js.map +1 -1
- package/XR/features/WebXRLayersFallback.d.ts +5 -0
- package/XR/features/WebXRLayersFallback.js +8 -0
- package/XR/features/WebXRLayersFallback.js.map +1 -0
- package/XR/features/WebXRLayersFallback.pure.d.ts +6 -0
- package/XR/features/WebXRLayersFallback.pure.js +44 -0
- package/XR/features/WebXRLayersFallback.pure.js.map +1 -0
- package/XR/features/WebXRLightEstimation.pure.d.ts +3 -4
- package/XR/features/WebXRLightEstimation.pure.js +22 -21
- package/XR/features/WebXRLightEstimation.pure.js.map +1 -1
- package/XR/features/WebXRMeshDetector.pure.d.ts +5 -0
- package/XR/features/WebXRMeshDetector.pure.js +1 -0
- package/XR/features/WebXRMeshDetector.pure.js.map +1 -1
- package/XR/features/WebXRNearInteraction.pure.js +3 -3
- package/XR/features/WebXRNearInteraction.pure.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.pure.d.ts +9 -5
- package/XR/features/WebXRPlaneDetector.pure.js +12 -8
- package/XR/features/WebXRPlaneDetector.pure.js.map +1 -1
- package/XR/features/pure.d.ts +1 -0
- package/XR/features/pure.js +1 -0
- package/XR/features/pure.js.map +1 -1
- package/XR/webXRCamera.d.ts +2 -0
- package/XR/webXRCamera.js +8 -2
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRLayerWrapper.d.ts +19 -5
- package/XR/webXRLayerWrapper.js +9 -0
- package/XR/webXRLayerWrapper.js.map +1 -1
- package/XR/webXRRenderTargetTextureProvider.d.ts +4 -4
- package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
- package/XR/webXRWebGLRenderTargetTextureProvider.d.ts +2 -1
- package/XR/webXRWebGLRenderTargetTextureProvider.js.map +1 -1
- package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +3 -3
- package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +5 -0
- package/scene.pure.js +25 -0
- package/scene.pure.js.map +1 -1
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { Observable } from "../../../Misc/observable.js";
|
|
2
2
|
import { WebXRLayerWrapper } from "../../webXRLayerWrapper.js";
|
|
3
|
+
import { WebXRLayerRenderTargetTextureProvider } from "../../webXRRenderTargetTextureProvider.js";
|
|
3
4
|
import { WebXRWebGLRenderTargetTextureProvider } from "../../webXRWebGLRenderTargetTextureProvider.js";
|
|
5
|
+
import { Quaternion, Vector3 } from "../../../Maths/math.vector.pure.js";
|
|
4
6
|
/**
|
|
5
|
-
* Wraps
|
|
6
|
-
* @
|
|
7
|
+
* Wraps an XR composition layer and creates its Babylon render target provider.
|
|
8
|
+
* @typeParam LayerT the concrete WebXR composition layer type
|
|
7
9
|
*/
|
|
8
10
|
export class WebXRCompositionLayerWrapper extends WebXRLayerWrapper {
|
|
9
|
-
constructor(getWidth, getHeight, layer, layerType,
|
|
11
|
+
constructor(getWidth, getHeight, layer, layerType,
|
|
12
|
+
/**
|
|
13
|
+
* Whether the layer renders both views into a texture array.
|
|
14
|
+
*/
|
|
15
|
+
isMultiview, createRTTProvider, _originalInternalTexture = null, _destroyLayerOnDispose = false,
|
|
16
|
+
/**
|
|
17
|
+
* Whether the layer can only be rendered when its native `needsRedraw` flag is set.
|
|
18
|
+
*/
|
|
19
|
+
isStatic = false) {
|
|
10
20
|
super(getWidth, getHeight, layer, layerType, createRTTProvider);
|
|
11
21
|
this.getWidth = getWidth;
|
|
12
22
|
this.getHeight = getHeight;
|
|
@@ -15,6 +25,185 @@ export class WebXRCompositionLayerWrapper extends WebXRLayerWrapper {
|
|
|
15
25
|
this.isMultiview = isMultiview;
|
|
16
26
|
this.createRTTProvider = createRTTProvider;
|
|
17
27
|
this._originalInternalTexture = _originalInternalTexture;
|
|
28
|
+
this._destroyLayerOnDispose = _destroyLayerOnDispose;
|
|
29
|
+
this.isStatic = isStatic;
|
|
30
|
+
/**
|
|
31
|
+
* Whether this layer receives its content directly from an HTML media element.
|
|
32
|
+
*/
|
|
33
|
+
this.isMediaLayer = false;
|
|
34
|
+
/**
|
|
35
|
+
* Whether Babylon should acquire subimages and expose render target textures for this layer.
|
|
36
|
+
*/
|
|
37
|
+
this.usesRenderTargetProvider = true;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Disposes the Babylon render-target resources and destroys the native layer when this wrapper owns it.
|
|
41
|
+
*/
|
|
42
|
+
dispose() {
|
|
43
|
+
super.dispose();
|
|
44
|
+
if (this._destroyLayerOnDispose) {
|
|
45
|
+
this.layer.destroy();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Wraps a positionable XR composition layer and synchronizes it with a Babylon transform node.
|
|
51
|
+
* The node's scaling does not affect the physical dimensions of the layer.
|
|
52
|
+
* @typeParam LayerT the concrete positionable WebXR layer type
|
|
53
|
+
*/
|
|
54
|
+
export class WebXRSpatialLayerWrapper extends WebXRCompositionLayerWrapper {
|
|
55
|
+
constructor(getWidth, getHeight, layer, layerType, isMultiview, isStatic,
|
|
56
|
+
/**
|
|
57
|
+
* Whether the layer should follow changes to the session manager's reference space.
|
|
58
|
+
*/
|
|
59
|
+
usesSessionReferenceSpace, createRTTProvider,
|
|
60
|
+
/**
|
|
61
|
+
* The Babylon node whose world position and rotation are applied to the native layer.
|
|
62
|
+
*/
|
|
63
|
+
transformNode, _ownsTransformNode) {
|
|
64
|
+
super(getWidth, getHeight, layer, layerType, isMultiview, createRTTProvider, null, true, isStatic);
|
|
65
|
+
this.usesSessionReferenceSpace = usesSessionReferenceSpace;
|
|
66
|
+
this.transformNode = transformNode;
|
|
67
|
+
this._ownsTransformNode = _ownsTransformNode;
|
|
68
|
+
this._currentPosition = new Vector3();
|
|
69
|
+
this._currentRotation = new Quaternion();
|
|
70
|
+
this._lastPosition = new Vector3(Number.NaN, Number.NaN, Number.NaN);
|
|
71
|
+
this._lastRotation = new Quaternion(Number.NaN, Number.NaN, Number.NaN, Number.NaN);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Synchronizes the native layer with the current world transform of the Babylon node.
|
|
75
|
+
* @param useRightHandedSystem whether the Babylon scene uses right-handed coordinates
|
|
76
|
+
* @param worldScalingFactor the number of Babylon scene units represented by one meter
|
|
77
|
+
*/
|
|
78
|
+
updateFromTransformNode(useRightHandedSystem, worldScalingFactor) {
|
|
79
|
+
this.transformNode.computeWorldMatrix(true).decompose(undefined, this._currentRotation, this._currentPosition);
|
|
80
|
+
this._currentPosition.scaleInPlace(1 / worldScalingFactor);
|
|
81
|
+
if (!useRightHandedSystem) {
|
|
82
|
+
this._currentPosition.z *= -1;
|
|
83
|
+
this._currentRotation.z *= -1;
|
|
84
|
+
this._currentRotation.w *= -1;
|
|
85
|
+
}
|
|
86
|
+
if (this._currentPosition.equals(this._lastPosition) && this._currentRotation.equals(this._lastRotation)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this._lastPosition.copyFrom(this._currentPosition);
|
|
90
|
+
this._lastRotation.copyFrom(this._currentRotation);
|
|
91
|
+
const orientation = {
|
|
92
|
+
x: this._currentRotation.x,
|
|
93
|
+
y: this._currentRotation.y,
|
|
94
|
+
z: this._currentRotation.z,
|
|
95
|
+
w: this._currentRotation.w,
|
|
96
|
+
};
|
|
97
|
+
if (this.layerType === "XRCubeLayer") {
|
|
98
|
+
this.layer.orientation =
|
|
99
|
+
typeof DOMPointReadOnly === "undefined" ? orientation : new DOMPointReadOnly(orientation.x, orientation.y, orientation.z, orientation.w);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.layer.transform = new XRRigidTransform({
|
|
103
|
+
x: this._currentPosition.x,
|
|
104
|
+
y: this._currentPosition.y,
|
|
105
|
+
z: this._currentPosition.z,
|
|
106
|
+
}, orientation);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Disposes the native layer wrapper and its Babylon transform node when the node was created by Babylon.
|
|
111
|
+
*/
|
|
112
|
+
dispose() {
|
|
113
|
+
super.dispose();
|
|
114
|
+
if (this._ownsTransformNode) {
|
|
115
|
+
this.transformNode.dispose();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Wraps an XRMediaBinding layer.
|
|
121
|
+
* @typeParam LayerT the concrete media layer type
|
|
122
|
+
*/
|
|
123
|
+
export class WebXRMediaLayerWrapper extends WebXRSpatialLayerWrapper {
|
|
124
|
+
/**
|
|
125
|
+
* Creates a wrapper for a media-backed spatial layer.
|
|
126
|
+
* @param getWidth returns the current video width
|
|
127
|
+
* @param getHeight returns the current video height
|
|
128
|
+
* @param layer the native media composition layer
|
|
129
|
+
* @param layerType the concrete spatial layer type
|
|
130
|
+
* @param transformNode the Babylon transform synchronized with the native layer
|
|
131
|
+
* @param ownsTransformNode whether the wrapper should dispose the transform node
|
|
132
|
+
* @param usesSessionReferenceSpace whether the layer should follow session reference-space changes
|
|
133
|
+
*/
|
|
134
|
+
constructor(getWidth, getHeight, layer, layerType, transformNode, ownsTransformNode, usesSessionReferenceSpace) {
|
|
135
|
+
super(getWidth, getHeight, layer, layerType, false, false, usesSessionReferenceSpace, (sessionManager) => new WebXRNoRenderTargetTextureProvider(sessionManager, this), transformNode, ownsTransformNode);
|
|
136
|
+
/**
|
|
137
|
+
* Media layers receive their contents directly from the user agent.
|
|
138
|
+
*/
|
|
139
|
+
this.isMediaLayer = true;
|
|
140
|
+
/**
|
|
141
|
+
* Media layers are populated directly by the user agent.
|
|
142
|
+
*/
|
|
143
|
+
this.usesRenderTargetProvider = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Wraps a native cube layer and exposes its raw subimage.
|
|
148
|
+
* Cube layers require six face uploads or render passes and therefore do not use Babylon's 2D composition-layer render target provider.
|
|
149
|
+
*/
|
|
150
|
+
export class WebXRCubeLayerWrapper extends WebXRSpatialLayerWrapper {
|
|
151
|
+
constructor(getWidth, getHeight, layer, isStatic, usesSessionReferenceSpace, _binding, transformNode, ownsTransformNode) {
|
|
152
|
+
super(getWidth, getHeight, layer, "XRCubeLayer", false, isStatic, usesSessionReferenceSpace, (sessionManager) => new WebXRNoRenderTargetTextureProvider(sessionManager, this), transformNode, ownsTransformNode);
|
|
153
|
+
this._binding = _binding;
|
|
154
|
+
/**
|
|
155
|
+
* Cube layers are populated through raw cubemap or array-layer access.
|
|
156
|
+
*/
|
|
157
|
+
this.usesRenderTargetProvider = false;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Gets the compositor-owned cube subimage for the current frame.
|
|
161
|
+
* WebGL callers must populate all six cubemap faces. WebGPU callers must render to six consecutive array layers beginning at the descriptor's base array layer.
|
|
162
|
+
* @param frame the current XR frame
|
|
163
|
+
* @param eye the eye to retrieve for stereo cube layers
|
|
164
|
+
* @returns the raw WebGL or WebGPU cube subimage
|
|
165
|
+
*/
|
|
166
|
+
getSubImage(frame, eye) {
|
|
167
|
+
return this._binding.getSubImage(this.layer, frame, eye);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Composition layers that are populated outside Babylon do not expose render targets.
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
class WebXRNoRenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {
|
|
175
|
+
/**
|
|
176
|
+
* Creates a no-render-target provider.
|
|
177
|
+
* @param sessionManager the current XR session manager
|
|
178
|
+
* @param layerWrapper the composition layer wrapper
|
|
179
|
+
*/
|
|
180
|
+
constructor(sessionManager, layerWrapper) {
|
|
181
|
+
super(sessionManager.scene, layerWrapper);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Media layers do not expose a viewport.
|
|
185
|
+
* @param _viewport unused viewport
|
|
186
|
+
* @param _view unused XR view
|
|
187
|
+
* @returns always `false`
|
|
188
|
+
*/
|
|
189
|
+
trySetViewportForView(_viewport, _view) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Media layers do not expose render target textures.
|
|
194
|
+
* @param _eye unused XR eye
|
|
195
|
+
* @returns always `null`
|
|
196
|
+
*/
|
|
197
|
+
getRenderTargetTextureForEye(_eye) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Media layers do not expose render target textures.
|
|
202
|
+
* @param _view unused XR view
|
|
203
|
+
* @returns always `null`
|
|
204
|
+
*/
|
|
205
|
+
getRenderTargetTextureForView(_view) {
|
|
206
|
+
return null;
|
|
18
207
|
}
|
|
19
208
|
}
|
|
20
209
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXRCompositionLayer.js","sourceRoot":"","sources":["../../../../../../dev/core/src/XR/features/Layers/WebXRCompositionLayer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAuB,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnF,OAAO,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAC;AAItG;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,iBAAiB;IAC/D,YACoB,QAAsB,EACtB,SAAuB,EACd,KAAyB,EACzB,SAAyB,EAClC,WAAoB,EAC7B,iBAAmG,EACnG,2BAAsD,IAAI;QAEjE,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;QARhD,aAAQ,GAAR,QAAQ,CAAc;QACtB,cAAS,GAAT,SAAS,CAAc;QACd,UAAK,GAAL,KAAK,CAAoB;QACzB,cAAS,GAA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,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IACM,6BAA6B,CAAC,IAAa;QAC9C,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxD,CAAC;IAES,uBAAuB,CAAC,QAAkB,EAAE,QAAyB;QAC3E,MAAM,YAAY,GAAG,QAAQ,CAAC,iBAAiB,IAAI,QAAQ,CAAC,YAAY,CAAC;QACzE,MAAM,aAAa,GAAG,QAAQ,CAAC,kBAAkB,IAAI,QAAQ,CAAC,aAAa,CAAC;QAC5E,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC;QACrC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,YAAY,CAAC;QACzC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,aAAa,CAAC;QAC1C,QAAQ,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC;QACjD,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,aAAa,CAAC;IACxD,CAAC;IAEM,qBAAqB,CAAC,QAAkB,EAAE,IAAY;QACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxF,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import { type InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport { type RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport { type Viewport } from \"core/Maths/math.viewport\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { type WebXRLayerType, WebXRLayerWrapper } from \"core/XR/webXRLayerWrapper\";\r\nimport { type WebXRLayerRenderTargetTextureProvider } from \"core/XR/webXRRenderTargetTextureProvider\";\r\nimport { WebXRWebGLRenderTargetTextureProvider } from \"core/XR/webXRWebGLRenderTargetTextureProvider\";\r\nimport { type WebXRSessionManager } from \"core/XR/webXRSessionManager\";\r\nimport { type Nullable } from \"core/types\";\r\n\r\n/**\r\n * Wraps xr composition layers.\r\n * @internal\r\n */\r\nexport class WebXRCompositionLayerWrapper extends WebXRLayerWrapper {\r\n constructor(\r\n public override getWidth: () => number,\r\n public override getHeight: () => number,\r\n public override readonly layer: XRCompositionLayer,\r\n public override readonly layerType: WebXRLayerType,\r\n public readonly isMultiview: boolean,\r\n public createRTTProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider,\r\n public _originalInternalTexture: Nullable<InternalTexture> = null\r\n ) {\r\n super(getWidth, getHeight, layer, layerType, createRTTProvider);\r\n }\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRCompositionLayer.\r\n * @internal\r\n */\r\nexport class WebXRCompositionLayerRenderTargetTextureProvider extends WebXRWebGLRenderTargetTextureProvider {\r\n protected _lastSubImages = new Map<XREye, XRWebGLSubImage>();\r\n private _compositionLayer: XRCompositionLayer;\r\n /**\r\n * Fires every time a new render target texture is created (either for eye, for view, or for the entire frame)\r\n */\r\n public onRenderTargetTextureCreatedObservable = new Observable<{ texture: RenderTargetTexture; eye?: XREye }>();\r\n\r\n constructor(\r\n protected readonly _xrSessionManager: WebXRSessionManager,\r\n protected readonly _xrWebGLBinding: XRWebGLBinding,\r\n public override readonly layerWrapper: WebXRCompositionLayerWrapper\r\n ) {\r\n super(_xrSessionManager.scene, layerWrapper);\r\n this._compositionLayer = layerWrapper.layer;\r\n }\r\n\r\n protected _getRenderTargetForSubImage(subImage: XRWebGLSubImage, eye: XREye = \"none\") {\r\n const lastSubImage = this._lastSubImages.get(eye);\r\n const eyeIndex = eye == \"right\" ? 1 : 0;\r\n\r\n const colorTextureWidth = subImage.colorTextureWidth ?? subImage.textureWidth;\r\n const colorTextureHeight = subImage.colorTextureHeight ?? subImage.textureHeight;\r\n\r\n if (!this._renderTargetTextures[eyeIndex] || lastSubImage?.textureWidth !== colorTextureWidth || lastSubImage?.textureHeight !== colorTextureHeight) {\r\n let depthStencilTexture;\r\n const depthStencilTextureWidth = subImage.depthStencilTextureWidth ?? colorTextureWidth;\r\n const depthStencilTextureHeight = subImage.depthStencilTextureHeight ?? colorTextureHeight;\r\n if (colorTextureWidth === depthStencilTextureWidth || colorTextureHeight === depthStencilTextureHeight) {\r\n depthStencilTexture = subImage.depthStencilTexture;\r\n }\r\n\r\n this._renderTargetTextures[eyeIndex] = this._createRenderTargetTexture(\r\n colorTextureWidth,\r\n colorTextureHeight,\r\n null,\r\n subImage.colorTexture,\r\n depthStencilTexture,\r\n this.layerWrapper.isMultiview\r\n );\r\n\r\n this._framebufferDimensions = {\r\n framebufferWidth: colorTextureWidth,\r\n framebufferHeight: colorTextureHeight,\r\n };\r\n this.onRenderTargetTextureCreatedObservable.notifyObservers({ texture: this._renderTargetTextures[eyeIndex], eye });\r\n }\r\n\r\n this._lastSubImages.set(eye, subImage);\r\n return this._renderTargetTextures[eyeIndex];\r\n }\r\n private _getSubImageForEye(eye?: XREye): Nullable<XRWebGLSubImage> {\r\n const currentFrame = this._xrSessionManager.currentFrame;\r\n if (currentFrame) {\r\n return this._xrWebGLBinding.getSubImage(this._compositionLayer, currentFrame, eye);\r\n }\r\n return null;\r\n }\r\n public getRenderTargetTextureForEye(eye?: XREye): Nullable<RenderTargetTexture> {\r\n const subImage = this._getSubImageForEye(eye);\r\n if (subImage) {\r\n return this._getRenderTargetForSubImage(subImage, eye);\r\n }\r\n return null;\r\n }\r\n public getRenderTargetTextureForView(view?: XRView): Nullable<RenderTargetTexture> {\r\n return this.getRenderTargetTextureForEye(view?.eye);\r\n }\r\n\r\n protected _setViewportForSubImage(viewport: Viewport, subImage: XRWebGLSubImage) {\r\n const textureWidth = subImage.colorTextureWidth ?? subImage.textureWidth;\r\n const textureHeight = subImage.colorTextureHeight ?? subImage.textureHeight;\r\n const xrViewport = subImage.viewport;\r\n viewport.x = xrViewport.x / textureWidth;\r\n viewport.y = xrViewport.y / textureHeight;\r\n viewport.width = xrViewport.width / textureWidth;\r\n viewport.height = xrViewport.height / textureHeight;\r\n }\r\n\r\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\r\n const subImage = this._lastSubImages.get(view.eye) || this._getSubImageForEye(view.eye);\r\n if (subImage) {\r\n this._setViewportForSubImage(viewport, subImage);\r\n return true;\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebXRCompositionLayer.js","sourceRoot":"","sources":["../../../../../../dev/core/src/XR/features/Layers/WebXRCompositionLayer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAuB,iBAAiB,EAA4D,MAAM,2BAA2B,CAAC;AAC7I,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC;AACjG,OAAO,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAC;AAGtG,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAUlE;;;GAGG;AACH,MAAM,OAAO,4BAGX,SAAQ,iBAA6B;IAWnC,YACoB,QAAsB,EACtB,SAAuB,EACd,KAAa,EACb,SAAqB;IAC9C;;OAEG;IACa,WAAoB,EAC7B,iBAA+G,EAC/G,2BAAsD,IAAI,EAChD,yBAAyB,KAAK;IAC/C;;OAEG;IACa,WAAW,KAAK;QAEhC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;QAhBhD,aAAQ,GAAR,QAAQ,CAAc;QACtB,cAAS,GAAT,SAAS,CAAc;QACd,UAAK,GAAL,KAAK,CA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,CAAC,kBAAkB,IAAI,QAAQ,CAAC,aAAa,CAAC;QAC5E,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC;QACrC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,YAAY,CAAC;QACzC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,aAAa,CAAC;QAC1C,QAAQ,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC;QACjD,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,aAAa,CAAC;IACxD,CAAC;IAEM,qBAAqB,CAAC,QAAkB,EAAE,IAAY;QACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxF,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import { type InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport { type RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport { type Viewport } from \"core/Maths/math.viewport\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { type WebXRLayerType, WebXRLayerWrapper, type WebXRSpatialLayerType, type WebXRSupportedLayerType } from \"core/XR/webXRLayerWrapper\";\r\nimport { WebXRLayerRenderTargetTextureProvider } from \"core/XR/webXRRenderTargetTextureProvider\";\r\nimport { WebXRWebGLRenderTargetTextureProvider } from \"core/XR/webXRWebGLRenderTargetTextureProvider\";\r\nimport { type WebXRSessionManager } from \"core/XR/webXRSessionManager\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { Quaternion, Vector3 } from \"core/Maths/math.vector.pure\";\r\nimport { type TransformNode } from \"core/Meshes/transformNode.pure\";\r\n\r\n/**\r\n * The non-projection composition layers that can be positioned in an XR space.\r\n */\r\nexport type WebXRSpatialLayer = XRQuadLayer | XRCylinderLayer | XREquirectLayer | XRCubeLayer;\r\n\r\nexport type { WebXRSpatialLayerType } from \"core/XR/webXRLayerWrapper\";\r\n\r\n/**\r\n * Wraps an XR composition layer and creates its Babylon render target provider.\r\n * @typeParam LayerT the concrete WebXR composition layer type\r\n */\r\nexport class WebXRCompositionLayerWrapper<\r\n LayerT extends XRCompositionLayer = XRCompositionLayer,\r\n LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType,\r\n> extends WebXRLayerWrapper<LayerTypeT> {\r\n /**\r\n * Whether this layer receives its content directly from an HTML media element.\r\n */\r\n public readonly isMediaLayer: boolean = false;\r\n\r\n /**\r\n * Whether Babylon should acquire subimages and expose render target textures for this layer.\r\n */\r\n public readonly usesRenderTargetProvider: boolean = true;\r\n\r\n constructor(\r\n public override getWidth: () => number,\r\n public override getHeight: () => number,\r\n public override readonly layer: LayerT,\r\n public override readonly layerType: LayerTypeT,\r\n /**\r\n * Whether the layer renders both views into a texture array.\r\n */\r\n public readonly isMultiview: boolean,\r\n public createRTTProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider<LayerTypeT>,\r\n public _originalInternalTexture: Nullable<InternalTexture> = null,\r\n private readonly _destroyLayerOnDispose = false,\r\n /**\r\n * Whether the layer can only be rendered when its native `needsRedraw` flag is set.\r\n */\r\n public readonly isStatic = false\r\n ) {\r\n super(getWidth, getHeight, layer, layerType, createRTTProvider);\r\n }\r\n\r\n /**\r\n * Disposes the Babylon render-target resources and destroys the native layer when this wrapper owns it.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n if (this._destroyLayerOnDispose) {\r\n this.layer.destroy();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Wraps a positionable XR composition layer and synchronizes it with a Babylon transform node.\r\n * The node's scaling does not affect the physical dimensions of the layer.\r\n * @typeParam LayerT the concrete positionable WebXR layer type\r\n */\r\nexport class WebXRSpatialLayerWrapper<\r\n LayerT extends WebXRSpatialLayer = WebXRSpatialLayer,\r\n LayerTypeT extends WebXRSpatialLayerType = WebXRSpatialLayerType,\r\n> extends WebXRCompositionLayerWrapper<LayerT, LayerTypeT> {\r\n private readonly _currentPosition = new Vector3();\r\n private readonly _currentRotation = new Quaternion();\r\n private readonly _lastPosition = new Vector3(Number.NaN, Number.NaN, Number.NaN);\r\n private readonly _lastRotation = new Quaternion(Number.NaN, Number.NaN, Number.NaN, Number.NaN);\r\n\r\n constructor(\r\n getWidth: () => number,\r\n getHeight: () => number,\r\n layer: LayerT,\r\n layerType: LayerTypeT,\r\n isMultiview: boolean,\r\n isStatic: boolean,\r\n /**\r\n * Whether the layer should follow changes to the session manager's reference space.\r\n */\r\n public readonly usesSessionReferenceSpace: boolean,\r\n createRTTProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider<LayerTypeT>,\r\n /**\r\n * The Babylon node whose world position and rotation are applied to the native layer.\r\n */\r\n public readonly transformNode: TransformNode,\r\n private readonly _ownsTransformNode: boolean\r\n ) {\r\n super(getWidth, getHeight, layer, layerType, isMultiview, createRTTProvider, null, true, isStatic);\r\n }\r\n\r\n /**\r\n * Synchronizes the native layer with the current world transform of the Babylon node.\r\n * @param useRightHandedSystem whether the Babylon scene uses right-handed coordinates\r\n * @param worldScalingFactor the number of Babylon scene units represented by one meter\r\n */\r\n public updateFromTransformNode(useRightHandedSystem: boolean, worldScalingFactor: number): void {\r\n this.transformNode.computeWorldMatrix(true).decompose(undefined, this._currentRotation, this._currentPosition);\r\n this._currentPosition.scaleInPlace(1 / worldScalingFactor);\r\n\r\n if (!useRightHandedSystem) {\r\n this._currentPosition.z *= -1;\r\n this._currentRotation.z *= -1;\r\n this._currentRotation.w *= -1;\r\n }\r\n\r\n if (this._currentPosition.equals(this._lastPosition) && this._currentRotation.equals(this._lastRotation)) {\r\n return;\r\n }\r\n\r\n this._lastPosition.copyFrom(this._currentPosition);\r\n this._lastRotation.copyFrom(this._currentRotation);\r\n\r\n const orientation = {\r\n x: this._currentRotation.x,\r\n y: this._currentRotation.y,\r\n z: this._currentRotation.z,\r\n w: this._currentRotation.w,\r\n };\r\n if (this.layerType === \"XRCubeLayer\") {\r\n (this.layer as XRCubeLayer).orientation =\r\n typeof DOMPointReadOnly === \"undefined\" ? (orientation as DOMPointReadOnly) : new DOMPointReadOnly(orientation.x, orientation.y, orientation.z, orientation.w);\r\n } else {\r\n (this.layer as XRQuadLayer | XRCylinderLayer | XREquirectLayer).transform = new XRRigidTransform(\r\n {\r\n x: this._currentPosition.x,\r\n y: this._currentPosition.y,\r\n z: this._currentPosition.z,\r\n },\r\n orientation\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the native layer wrapper and its Babylon transform node when the node was created by Babylon.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n if (this._ownsTransformNode) {\r\n this.transformNode.dispose();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Wraps an XRMediaBinding layer.\r\n * @typeParam LayerT the concrete media layer type\r\n */\r\nexport class WebXRMediaLayerWrapper<\r\n LayerT extends Exclude<WebXRSpatialLayer, XRCubeLayer> = Exclude<WebXRSpatialLayer, XRCubeLayer>,\r\n LayerTypeT extends Exclude<WebXRSpatialLayerType, \"XRCubeLayer\"> = Exclude<WebXRSpatialLayerType, \"XRCubeLayer\">,\r\n> extends WebXRSpatialLayerWrapper<LayerT, LayerTypeT> {\r\n /**\r\n * Media layers receive their contents directly from the user agent.\r\n */\r\n public override readonly isMediaLayer: boolean = true;\r\n /**\r\n * Media layers are populated directly by the user agent.\r\n */\r\n public override readonly usesRenderTargetProvider: boolean = false;\r\n\r\n /**\r\n * Creates a wrapper for a media-backed spatial layer.\r\n * @param getWidth returns the current video width\r\n * @param getHeight returns the current video height\r\n * @param layer the native media composition layer\r\n * @param layerType the concrete spatial layer type\r\n * @param transformNode the Babylon transform synchronized with the native layer\r\n * @param ownsTransformNode whether the wrapper should dispose the transform node\r\n * @param usesSessionReferenceSpace whether the layer should follow session reference-space changes\r\n */\r\n constructor(\r\n getWidth: () => number,\r\n getHeight: () => number,\r\n layer: LayerT,\r\n layerType: LayerTypeT,\r\n transformNode: TransformNode,\r\n ownsTransformNode: boolean,\r\n usesSessionReferenceSpace: boolean\r\n ) {\r\n super(\r\n getWidth,\r\n getHeight,\r\n layer,\r\n layerType,\r\n false,\r\n false,\r\n usesSessionReferenceSpace,\r\n (sessionManager) => new WebXRNoRenderTargetTextureProvider(sessionManager, this),\r\n transformNode,\r\n ownsTransformNode\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Wraps a native cube layer and exposes its raw subimage.\r\n * Cube layers require six face uploads or render passes and therefore do not use Babylon's 2D composition-layer render target provider.\r\n */\r\nexport class WebXRCubeLayerWrapper extends WebXRSpatialLayerWrapper<XRCubeLayer, \"XRCubeLayer\"> {\r\n /**\r\n * Cube layers are populated through raw cubemap or array-layer access.\r\n */\r\n public override readonly usesRenderTargetProvider: boolean = false;\r\n\r\n constructor(\r\n getWidth: () => number,\r\n getHeight: () => number,\r\n layer: XRCubeLayer,\r\n isStatic: boolean,\r\n usesSessionReferenceSpace: boolean,\r\n private readonly _binding: XRWebGLBinding | XRGPUBinding,\r\n transformNode: TransformNode,\r\n ownsTransformNode: boolean\r\n ) {\r\n super(\r\n getWidth,\r\n getHeight,\r\n layer,\r\n \"XRCubeLayer\",\r\n false,\r\n isStatic,\r\n usesSessionReferenceSpace,\r\n (sessionManager) => new WebXRNoRenderTargetTextureProvider(sessionManager, this),\r\n transformNode,\r\n ownsTransformNode\r\n );\r\n }\r\n\r\n /**\r\n * Gets the compositor-owned cube subimage for the current frame.\r\n * WebGL callers must populate all six cubemap faces. WebGPU callers must render to six consecutive array layers beginning at the descriptor's base array layer.\r\n * @param frame the current XR frame\r\n * @param eye the eye to retrieve for stereo cube layers\r\n * @returns the raw WebGL or WebGPU cube subimage\r\n */\r\n public getSubImage(frame: XRFrame, eye?: XREye): XRWebGLSubImage | XRGPUSubImage {\r\n return this._binding.getSubImage(this.layer, frame, eye);\r\n }\r\n}\r\n\r\n/**\r\n * Composition layers that are populated outside Babylon do not expose render targets.\r\n * @internal\r\n */\r\nclass WebXRNoRenderTargetTextureProvider<LayerTypeT extends WebXRSupportedLayerType> extends WebXRLayerRenderTargetTextureProvider<LayerTypeT> {\r\n /**\r\n * Creates a no-render-target provider.\r\n * @param sessionManager the current XR session manager\r\n * @param layerWrapper the composition layer wrapper\r\n */\r\n constructor(sessionManager: WebXRSessionManager, layerWrapper: WebXRCompositionLayerWrapper<XRCompositionLayer, LayerTypeT>) {\r\n super(sessionManager.scene, layerWrapper);\r\n }\r\n\r\n /**\r\n * Media layers do not expose a viewport.\r\n * @param _viewport unused viewport\r\n * @param _view unused XR view\r\n * @returns always `false`\r\n */\r\n public trySetViewportForView(_viewport: Viewport, _view: XRView): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Media layers do not expose render target textures.\r\n * @param _eye unused XR eye\r\n * @returns always `null`\r\n */\r\n public getRenderTargetTextureForEye(_eye: XREye): Nullable<RenderTargetTexture> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Media layers do not expose render target textures.\r\n * @param _view unused XR view\r\n * @returns always `null`\r\n */\r\n public getRenderTargetTextureForView(_view: XRView): Nullable<RenderTargetTexture> {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRCompositionLayer.\r\n * @internal\r\n */\r\nexport class WebXRCompositionLayerRenderTargetTextureProvider<\r\n LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType,\r\n> extends WebXRWebGLRenderTargetTextureProvider<LayerTypeT> {\r\n protected _lastSubImages = new Map<XREye, XRWebGLSubImage>();\r\n private _compositionLayer: XRCompositionLayer;\r\n /**\r\n * Fires every time a new render target texture is created (either for eye, for view, or for the entire frame)\r\n */\r\n public onRenderTargetTextureCreatedObservable = new Observable<{ texture: RenderTargetTexture; eye?: XREye }>();\r\n\r\n constructor(\r\n protected readonly _xrSessionManager: WebXRSessionManager,\r\n protected readonly _xrWebGLBinding: XRWebGLBinding,\r\n public override readonly layerWrapper: WebXRCompositionLayerWrapper<XRCompositionLayer, LayerTypeT>\r\n ) {\r\n super(_xrSessionManager.scene, layerWrapper);\r\n this._compositionLayer = layerWrapper.layer;\r\n }\r\n\r\n protected _getRenderTargetForSubImage(subImage: XRWebGLSubImage, eye: XREye = \"none\") {\r\n const lastSubImage = this._lastSubImages.get(eye);\r\n const eyeIndex = eye == \"right\" ? 1 : 0;\r\n\r\n const colorTextureWidth = subImage.colorTextureWidth ?? subImage.textureWidth;\r\n const colorTextureHeight = subImage.colorTextureHeight ?? subImage.textureHeight;\r\n\r\n if (!this._renderTargetTextures[eyeIndex] || lastSubImage?.textureWidth !== colorTextureWidth || lastSubImage?.textureHeight !== colorTextureHeight) {\r\n let depthStencilTexture;\r\n const depthStencilTextureWidth = subImage.depthStencilTextureWidth ?? colorTextureWidth;\r\n const depthStencilTextureHeight = subImage.depthStencilTextureHeight ?? colorTextureHeight;\r\n if (colorTextureWidth === depthStencilTextureWidth || colorTextureHeight === depthStencilTextureHeight) {\r\n depthStencilTexture = subImage.depthStencilTexture;\r\n }\r\n\r\n this._renderTargetTextures[eyeIndex] = this._createRenderTargetTexture(\r\n colorTextureWidth,\r\n colorTextureHeight,\r\n null,\r\n subImage.colorTexture,\r\n depthStencilTexture,\r\n this.layerWrapper.isMultiview\r\n );\r\n\r\n this._framebufferDimensions = {\r\n framebufferWidth: colorTextureWidth,\r\n framebufferHeight: colorTextureHeight,\r\n };\r\n this.onRenderTargetTextureCreatedObservable.notifyObservers({ texture: this._renderTargetTextures[eyeIndex], eye });\r\n }\r\n\r\n this._lastSubImages.set(eye, subImage);\r\n return this._renderTargetTextures[eyeIndex];\r\n }\r\n private _getSubImageForEye(eye?: XREye): Nullable<XRWebGLSubImage> {\r\n const currentFrame = this._xrSessionManager.currentFrame;\r\n if (currentFrame) {\r\n return this._xrWebGLBinding.getSubImage(this._compositionLayer, currentFrame, eye);\r\n }\r\n return null;\r\n }\r\n public getRenderTargetTextureForEye(eye?: XREye): Nullable<RenderTargetTexture> {\r\n const subImage = this._getSubImageForEye(eye);\r\n if (subImage) {\r\n return this._getRenderTargetForSubImage(subImage, eye);\r\n }\r\n return null;\r\n }\r\n public getRenderTargetTextureForView(view?: XRView): Nullable<RenderTargetTexture> {\r\n return this.getRenderTargetTextureForEye(view?.eye);\r\n }\r\n\r\n protected _setViewportForSubImage(viewport: Viewport, subImage: XRWebGLSubImage) {\r\n const textureWidth = subImage.colorTextureWidth ?? subImage.textureWidth;\r\n const textureHeight = subImage.colorTextureHeight ?? subImage.textureHeight;\r\n const xrViewport = subImage.viewport;\r\n viewport.x = xrViewport.x / textureWidth;\r\n viewport.y = xrViewport.y / textureHeight;\r\n viewport.width = xrViewport.width / textureWidth;\r\n viewport.height = xrViewport.height / textureHeight;\r\n }\r\n\r\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\r\n const subImage = this._lastSubImages.get(view.eye) || this._getSubImageForEye(view.eye);\r\n if (subImage) {\r\n this._setViewportForSubImage(viewport, subImage);\r\n return true;\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type BaseTexture } from "../../../Materials/Textures/baseTexture.js";
|
|
2
|
+
import { Mesh } from "../../../Meshes/mesh.pure.js";
|
|
3
|
+
import { type TransformNode } from "../../../Meshes/transformNode.pure.js";
|
|
4
|
+
import { type Scene } from "../../../scene.js";
|
|
5
|
+
import { type WebXRSpatialLayerType } from "./WebXRCompositionLayer.js";
|
|
6
|
+
/**
|
|
7
|
+
* Physical dimensions used to approximate a native composition layer with a Babylon mesh.
|
|
8
|
+
*/
|
|
9
|
+
export interface IWebXRFallbackLayerDimensions {
|
|
10
|
+
/** The quad width in meters. */
|
|
11
|
+
width?: number;
|
|
12
|
+
/** The quad height in meters. */
|
|
13
|
+
height?: number;
|
|
14
|
+
/** The cylinder or sphere radius in meters. */
|
|
15
|
+
radius?: number;
|
|
16
|
+
/** The cylinder central angle in radians. */
|
|
17
|
+
centralAngle?: number;
|
|
18
|
+
/** The cylinder width-to-height aspect ratio. */
|
|
19
|
+
aspectRatio?: number;
|
|
20
|
+
/** The equirectangular horizontal angle in radians. */
|
|
21
|
+
centralHorizontalAngle?: number;
|
|
22
|
+
/** The equirectangular upper vertical angle in radians. */
|
|
23
|
+
upperVerticalAngle?: number;
|
|
24
|
+
/** The equirectangular lower vertical angle in radians. */
|
|
25
|
+
lowerVerticalAngle?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wraps a mesh used when a requested native WebXR composition layer is unavailable.
|
|
29
|
+
*/
|
|
30
|
+
export declare class WebXRFallbackLayerWrapper {
|
|
31
|
+
/**
|
|
32
|
+
* The requested WebXR composition layer type.
|
|
33
|
+
*/
|
|
34
|
+
readonly layerType: WebXRSpatialLayerType;
|
|
35
|
+
/**
|
|
36
|
+
* The Babylon node whose world position and rotation control the fallback mesh.
|
|
37
|
+
*/
|
|
38
|
+
readonly transformNode: TransformNode;
|
|
39
|
+
private readonly _ownsTransformNode;
|
|
40
|
+
private readonly _currentPosition;
|
|
41
|
+
private readonly _currentRotation;
|
|
42
|
+
private readonly _meshRotationOffset;
|
|
43
|
+
private readonly _material;
|
|
44
|
+
private readonly _ownsTexture;
|
|
45
|
+
/**
|
|
46
|
+
* The native layer is always `null` for a fallback wrapper.
|
|
47
|
+
*/
|
|
48
|
+
readonly layer: null;
|
|
49
|
+
/**
|
|
50
|
+
* Whether this wrapper is backed by a native WebXR composition layer.
|
|
51
|
+
*/
|
|
52
|
+
readonly isNative = false;
|
|
53
|
+
/**
|
|
54
|
+
* The Babylon mesh that approximates the requested composition layer.
|
|
55
|
+
*/
|
|
56
|
+
readonly mesh: Mesh;
|
|
57
|
+
/**
|
|
58
|
+
* The texture displayed by the fallback mesh.
|
|
59
|
+
*/
|
|
60
|
+
readonly texture: BaseTexture;
|
|
61
|
+
constructor(scene: Scene,
|
|
62
|
+
/**
|
|
63
|
+
* The requested WebXR composition layer type.
|
|
64
|
+
*/
|
|
65
|
+
layerType: WebXRSpatialLayerType,
|
|
66
|
+
/**
|
|
67
|
+
* The texture displayed by the fallback mesh.
|
|
68
|
+
*/
|
|
69
|
+
texture: BaseTexture,
|
|
70
|
+
/**
|
|
71
|
+
* The Babylon node whose world position and rotation control the fallback mesh.
|
|
72
|
+
*/
|
|
73
|
+
transformNode: TransformNode, _ownsTransformNode: boolean, ownsTexture: boolean, dimensions: IWebXRFallbackLayerDimensions, worldScalingFactor: number);
|
|
74
|
+
private _createMesh;
|
|
75
|
+
/**
|
|
76
|
+
* Copies the transform node's world position and rotation to the fallback mesh without applying the node's scaling.
|
|
77
|
+
* @param worldScalingFactor the number of Babylon scene units represented by one meter
|
|
78
|
+
*/
|
|
79
|
+
updateFromTransformNode(worldScalingFactor?: number): void;
|
|
80
|
+
/**
|
|
81
|
+
* Disposes the fallback mesh, material, and any resources owned by this wrapper.
|
|
82
|
+
*/
|
|
83
|
+
dispose(): void;
|
|
84
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { StandardMaterial } from "../../../Materials/standardMaterial.pure.js";
|
|
2
|
+
import { Quaternion, Vector3 } from "../../../Maths/math.vector.pure.js";
|
|
3
|
+
import { Color3 } from "../../../Maths/math.color.pure.js";
|
|
4
|
+
import { Mesh } from "../../../Meshes/mesh.pure.js";
|
|
5
|
+
import { CreateBox } from "../../../Meshes/Builders/boxBuilder.pure.js";
|
|
6
|
+
import { CreateCylinder } from "../../../Meshes/Builders/cylinderBuilder.pure.js";
|
|
7
|
+
import { CreatePlane } from "../../../Meshes/Builders/planeBuilder.pure.js";
|
|
8
|
+
import { CreateSphere } from "../../../Meshes/Builders/sphereBuilder.pure.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a mesh used when a requested native WebXR composition layer is unavailable.
|
|
12
|
+
*/
|
|
13
|
+
export class WebXRFallbackLayerWrapper {
|
|
14
|
+
constructor(scene,
|
|
15
|
+
/**
|
|
16
|
+
* The requested WebXR composition layer type.
|
|
17
|
+
*/
|
|
18
|
+
layerType,
|
|
19
|
+
/**
|
|
20
|
+
* The texture displayed by the fallback mesh.
|
|
21
|
+
*/
|
|
22
|
+
texture,
|
|
23
|
+
/**
|
|
24
|
+
* The Babylon node whose world position and rotation control the fallback mesh.
|
|
25
|
+
*/
|
|
26
|
+
transformNode, _ownsTransformNode, ownsTexture, dimensions, worldScalingFactor) {
|
|
27
|
+
this.layerType = layerType;
|
|
28
|
+
this.transformNode = transformNode;
|
|
29
|
+
this._ownsTransformNode = _ownsTransformNode;
|
|
30
|
+
this._currentPosition = new Vector3();
|
|
31
|
+
this._currentRotation = new Quaternion();
|
|
32
|
+
this._meshRotationOffset = new Quaternion();
|
|
33
|
+
/**
|
|
34
|
+
* The native layer is always `null` for a fallback wrapper.
|
|
35
|
+
*/
|
|
36
|
+
this.layer = null;
|
|
37
|
+
/**
|
|
38
|
+
* Whether this wrapper is backed by a native WebXR composition layer.
|
|
39
|
+
*/
|
|
40
|
+
this.isNative = false;
|
|
41
|
+
if (layerType === "XRCubeLayer") {
|
|
42
|
+
const clonedTexture = texture.clone();
|
|
43
|
+
if (clonedTexture) {
|
|
44
|
+
texture = clonedTexture;
|
|
45
|
+
texture.coordinatesMode = 5;
|
|
46
|
+
ownsTexture = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
this.texture = texture;
|
|
50
|
+
this._ownsTexture = ownsTexture;
|
|
51
|
+
this.mesh = this._createMesh(scene, dimensions);
|
|
52
|
+
this.mesh.isPickable = false;
|
|
53
|
+
this.mesh.rotationQuaternion = new Quaternion();
|
|
54
|
+
this._material = new StandardMaterial(`WebXR ${layerType} fallback material`, scene);
|
|
55
|
+
this._material.disableLighting = true;
|
|
56
|
+
this._material.emissiveColor = Color3.Black();
|
|
57
|
+
this._material.backFaceCulling = layerType === "XRQuadLayer";
|
|
58
|
+
if (layerType === "XRCubeLayer" && this.texture.isCube) {
|
|
59
|
+
this._material.reflectionTexture = this.texture;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this._material.emissiveTexture = this.texture;
|
|
63
|
+
this._material.opacityTexture = this.texture;
|
|
64
|
+
}
|
|
65
|
+
this.mesh.material = this._material;
|
|
66
|
+
this.updateFromTransformNode(worldScalingFactor);
|
|
67
|
+
}
|
|
68
|
+
_createMesh(scene, dimensions) {
|
|
69
|
+
switch (this.layerType) {
|
|
70
|
+
case "XRQuadLayer":
|
|
71
|
+
return CreatePlane(`WebXR ${this.layerType} fallback`, {
|
|
72
|
+
width: dimensions.width ?? 1,
|
|
73
|
+
height: dimensions.height ?? 1,
|
|
74
|
+
}, scene);
|
|
75
|
+
case "XRCylinderLayer": {
|
|
76
|
+
const radius = dimensions.radius ?? 2;
|
|
77
|
+
const centralAngle = dimensions.centralAngle ?? Math.PI / 4;
|
|
78
|
+
const aspectRatio = dimensions.aspectRatio ?? 2;
|
|
79
|
+
Quaternion.RotationAxisToRef(Vector3.UpReadOnly, (Math.PI - centralAngle) / 2, this._meshRotationOffset);
|
|
80
|
+
return CreateCylinder(`WebXR ${this.layerType} fallback`, {
|
|
81
|
+
diameter: radius * 2,
|
|
82
|
+
height: (radius * centralAngle) / aspectRatio,
|
|
83
|
+
arc: centralAngle / (Math.PI * 2),
|
|
84
|
+
cap: Mesh.NO_CAP,
|
|
85
|
+
sideOrientation: Mesh.BACKSIDE,
|
|
86
|
+
}, scene);
|
|
87
|
+
}
|
|
88
|
+
case "XREquirectLayer": {
|
|
89
|
+
const radius = dimensions.radius && Number.isFinite(dimensions.radius) ? dimensions.radius : 1000;
|
|
90
|
+
const centralHorizontalAngle = dimensions.centralHorizontalAngle ?? Math.PI * 2;
|
|
91
|
+
const upperVerticalAngle = dimensions.upperVerticalAngle ?? Math.PI / 2;
|
|
92
|
+
const lowerVerticalAngle = dimensions.lowerVerticalAngle ?? -Math.PI / 2;
|
|
93
|
+
Quaternion.RotationYawPitchRollToRef((Math.PI - centralHorizontalAngle) / 2, upperVerticalAngle - Math.PI / 2, 0, this._meshRotationOffset);
|
|
94
|
+
return CreateSphere(`WebXR ${this.layerType} fallback`, {
|
|
95
|
+
diameter: radius * 2,
|
|
96
|
+
arc: centralHorizontalAngle / (Math.PI * 2),
|
|
97
|
+
slice: (upperVerticalAngle - lowerVerticalAngle) / Math.PI,
|
|
98
|
+
sideOrientation: Mesh.BACKSIDE,
|
|
99
|
+
}, scene);
|
|
100
|
+
}
|
|
101
|
+
case "XRCubeLayer":
|
|
102
|
+
return CreateBox(`WebXR ${this.layerType} fallback`, {
|
|
103
|
+
size: 1000,
|
|
104
|
+
sideOrientation: Mesh.BACKSIDE,
|
|
105
|
+
}, scene);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Copies the transform node's world position and rotation to the fallback mesh without applying the node's scaling.
|
|
110
|
+
* @param worldScalingFactor the number of Babylon scene units represented by one meter
|
|
111
|
+
*/
|
|
112
|
+
updateFromTransformNode(worldScalingFactor = 1) {
|
|
113
|
+
this.transformNode.computeWorldMatrix(true).decompose(undefined, this._currentRotation, this._currentPosition);
|
|
114
|
+
if (this.layerType === "XRCubeLayer") {
|
|
115
|
+
this.mesh.position.setAll(0);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.mesh.position.copyFrom(this._currentPosition);
|
|
119
|
+
}
|
|
120
|
+
this._currentRotation.multiplyToRef(this._meshRotationOffset, this.mesh.rotationQuaternion);
|
|
121
|
+
this.mesh.scaling.setAll(worldScalingFactor);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Disposes the fallback mesh, material, and any resources owned by this wrapper.
|
|
125
|
+
*/
|
|
126
|
+
dispose() {
|
|
127
|
+
this.mesh.dispose(false, false);
|
|
128
|
+
this._material.dispose();
|
|
129
|
+
if (this._ownsTexture) {
|
|
130
|
+
this.texture.dispose();
|
|
131
|
+
}
|
|
132
|
+
if (this._ownsTransformNode) {
|
|
133
|
+
this.transformNode.dispose();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=WebXRFallbackLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebXRFallbackLayer.js","sourceRoot":"","sources":["../../../../../../dev/core/src/XR/features/Layers/WebXRFallbackLayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAGvE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAyBnD;;GAEG;AACH,MAAM,OAAO,yBAAyB;IA2BlC,YACI,KAAY;IACZ;;OAEG;IACa,SAAgC;IAChD;;OAEG;IACH,OAAoB;IACpB;;OAEG;IACa,aAA4B,EAC3B,kBAA2B,EAC5C,WAAoB,EACpB,UAAyC,EACzC,kBAA0B;QAZV,cAAS,GAAT,SAAS,CAAuB;QAQhC,kBAAa,GAAb,aAAa,CAAe;QAC3B,uBAAkB,GAAlB,kBAAkB,CAAS;QAxC/B,qBAAgB,GAAG,IAAI,OAAO,EAAE,CAAC;QACjC,qBAAgB,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,wBAAmB,GAAG,IAAI,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,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC/G,IAAI,IAAI,CAAC,SAAS,KAAK,aAAa,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,kBAAmB,CAAC,CAAC;QAC7F,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QACjC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\nimport { StandardMaterial } from \"core/Materials/standardMaterial.pure\";\nimport { Quaternion, Vector3 } from \"core/Maths/math.vector.pure\";\nimport { Color3 } from \"core/Maths/math.color.pure\";\nimport { Mesh } from \"core/Meshes/mesh.pure\";\nimport { CreateBox } from \"core/Meshes/Builders/boxBuilder.pure\";\nimport { CreateCylinder } from \"core/Meshes/Builders/cylinderBuilder.pure\";\nimport { CreatePlane } from \"core/Meshes/Builders/planeBuilder.pure\";\nimport { CreateSphere } from \"core/Meshes/Builders/sphereBuilder.pure\";\nimport { type TransformNode } from \"core/Meshes/transformNode.pure\";\nimport { type Scene } from \"core/scene\";\nimport { Constants } from \"core/Engines/constants\";\nimport { type WebXRSpatialLayerType } from \"./WebXRCompositionLayer\";\n\n/**\n * Physical dimensions used to approximate a native composition layer with a Babylon mesh.\n */\nexport interface IWebXRFallbackLayerDimensions {\n /** The quad width in meters. */\n width?: number;\n /** The quad height in meters. */\n height?: number;\n /** The cylinder or sphere radius in meters. */\n radius?: number;\n /** The cylinder central angle in radians. */\n centralAngle?: number;\n /** The cylinder width-to-height aspect ratio. */\n aspectRatio?: number;\n /** The equirectangular horizontal angle in radians. */\n centralHorizontalAngle?: number;\n /** The equirectangular upper vertical angle in radians. */\n upperVerticalAngle?: number;\n /** The equirectangular lower vertical angle in radians. */\n lowerVerticalAngle?: number;\n}\n\n/**\n * Wraps a mesh used when a requested native WebXR composition layer is unavailable.\n */\nexport class WebXRFallbackLayerWrapper {\n private readonly _currentPosition = new Vector3();\n private readonly _currentRotation = new Quaternion();\n private readonly _meshRotationOffset = new Quaternion();\n private readonly _material: StandardMaterial;\n private readonly _ownsTexture: boolean;\n\n /**\n * The native layer is always `null` for a fallback wrapper.\n */\n public readonly layer = null;\n\n /**\n * Whether this wrapper is backed by a native WebXR composition layer.\n */\n public readonly isNative = false;\n\n /**\n * The Babylon mesh that approximates the requested composition layer.\n */\n public readonly mesh: Mesh;\n\n /**\n * The texture displayed by the fallback mesh.\n */\n public readonly texture: BaseTexture;\n\n constructor(\n scene: Scene,\n /**\n * The requested WebXR composition layer type.\n */\n public readonly layerType: WebXRSpatialLayerType,\n /**\n * The texture displayed by the fallback mesh.\n */\n texture: BaseTexture,\n /**\n * The Babylon node whose world position and rotation control the fallback mesh.\n */\n public readonly transformNode: TransformNode,\n private readonly _ownsTransformNode: boolean,\n ownsTexture: boolean,\n dimensions: IWebXRFallbackLayerDimensions,\n worldScalingFactor: number\n ) {\n if (layerType === \"XRCubeLayer\") {\n const clonedTexture = texture.clone();\n if (clonedTexture) {\n texture = clonedTexture;\n texture.coordinatesMode = Constants.TEXTURE_SKYBOX_MODE;\n ownsTexture = true;\n }\n }\n this.texture = texture;\n this._ownsTexture = ownsTexture;\n this.mesh = this._createMesh(scene, dimensions);\n this.mesh.isPickable = false;\n this.mesh.rotationQuaternion = new Quaternion();\n this._material = new StandardMaterial(`WebXR ${layerType} fallback material`, scene);\n this._material.disableLighting = true;\n this._material.emissiveColor = Color3.Black();\n this._material.backFaceCulling = layerType === \"XRQuadLayer\";\n if (layerType === \"XRCubeLayer\" && this.texture.isCube) {\n this._material.reflectionTexture = this.texture;\n } else {\n this._material.emissiveTexture = this.texture;\n this._material.opacityTexture = this.texture;\n }\n this.mesh.material = this._material;\n this.updateFromTransformNode(worldScalingFactor);\n }\n\n private _createMesh(scene: Scene, dimensions: IWebXRFallbackLayerDimensions): Mesh {\n switch (this.layerType) {\n case \"XRQuadLayer\":\n return CreatePlane(\n `WebXR ${this.layerType} fallback`,\n {\n width: dimensions.width ?? 1,\n height: dimensions.height ?? 1,\n },\n scene\n );\n case \"XRCylinderLayer\": {\n const radius = dimensions.radius ?? 2;\n const centralAngle = dimensions.centralAngle ?? Math.PI / 4;\n const aspectRatio = dimensions.aspectRatio ?? 2;\n Quaternion.RotationAxisToRef(Vector3.UpReadOnly, (Math.PI - centralAngle) / 2, this._meshRotationOffset);\n return CreateCylinder(\n `WebXR ${this.layerType} fallback`,\n {\n diameter: radius * 2,\n height: (radius * centralAngle) / aspectRatio,\n arc: centralAngle / (Math.PI * 2),\n cap: Mesh.NO_CAP,\n sideOrientation: Mesh.BACKSIDE,\n },\n scene\n );\n }\n case \"XREquirectLayer\": {\n const radius = dimensions.radius && Number.isFinite(dimensions.radius) ? dimensions.radius : 1000;\n const centralHorizontalAngle = dimensions.centralHorizontalAngle ?? Math.PI * 2;\n const upperVerticalAngle = dimensions.upperVerticalAngle ?? Math.PI / 2;\n const lowerVerticalAngle = dimensions.lowerVerticalAngle ?? -Math.PI / 2;\n Quaternion.RotationYawPitchRollToRef((Math.PI - centralHorizontalAngle) / 2, upperVerticalAngle - Math.PI / 2, 0, this._meshRotationOffset);\n return CreateSphere(\n `WebXR ${this.layerType} fallback`,\n {\n diameter: radius * 2,\n arc: centralHorizontalAngle / (Math.PI * 2),\n slice: (upperVerticalAngle - lowerVerticalAngle) / Math.PI,\n sideOrientation: Mesh.BACKSIDE,\n },\n scene\n );\n }\n case \"XRCubeLayer\":\n return CreateBox(\n `WebXR ${this.layerType} fallback`,\n {\n size: 1000,\n sideOrientation: Mesh.BACKSIDE,\n },\n scene\n );\n }\n }\n\n /**\n * Copies the transform node's world position and rotation to the fallback mesh without applying the node's scaling.\n * @param worldScalingFactor the number of Babylon scene units represented by one meter\n */\n public updateFromTransformNode(worldScalingFactor = 1): void {\n this.transformNode.computeWorldMatrix(true).decompose(undefined, this._currentRotation, this._currentPosition);\n if (this.layerType === \"XRCubeLayer\") {\n this.mesh.position.setAll(0);\n } else {\n this.mesh.position.copyFrom(this._currentPosition);\n }\n this._currentRotation.multiplyToRef(this._meshRotationOffset, this.mesh.rotationQuaternion!);\n this.mesh.scaling.setAll(worldScalingFactor);\n }\n\n /**\n * Disposes the fallback mesh, material, and any resources owned by this wrapper.\n */\n public dispose(): void {\n this.mesh.dispose(false, false);\n this._material.dispose();\n if (this._ownsTexture) {\n this.texture.dispose();\n }\n if (this._ownsTransformNode) {\n this.transformNode.dispose();\n }\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { type RenderTargetTexture } from "../../../Materials/Textures/renderTarg
|
|
|
2
2
|
import { type Viewport } from "../../../Maths/math.viewport.js";
|
|
3
3
|
import { Observable } from "../../../Misc/observable.js";
|
|
4
4
|
import { type WebXRLayerRenderTargetTexture } from "../../webXRLayerRenderTargetTexture.js";
|
|
5
|
-
import { type WebXRLayerType } from "../../webXRLayerWrapper.js";
|
|
5
|
+
import { type WebXRLayerType, type WebXRSupportedLayerType } from "../../webXRLayerWrapper.js";
|
|
6
6
|
import { type WebXRLayerRenderTargetTextureProvider } from "../../webXRRenderTargetTextureProvider.js";
|
|
7
7
|
import { WebXRWebGPURenderTargetTextureProvider } from "../../webXRWebGPURenderTargetTextureProvider.js";
|
|
8
8
|
import { type WebXRSessionManager } from "../../webXRSessionManager.js";
|
|
@@ -22,9 +22,9 @@ export declare class WebXRWebGPUCompositionLayerWrapper extends WebXRComposition
|
|
|
22
22
|
* {@link XRGPUSubImage} GPUTextures instead of WebGL textures.
|
|
23
23
|
* @internal
|
|
24
24
|
*/
|
|
25
|
-
export declare class WebXRWebGPUCompositionLayerRenderTargetTextureProvider extends WebXRWebGPURenderTargetTextureProvider {
|
|
25
|
+
export declare class WebXRWebGPUCompositionLayerRenderTargetTextureProvider<LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType> extends WebXRWebGPURenderTargetTextureProvider<LayerTypeT> {
|
|
26
26
|
protected readonly _xrGPUBinding: XRGPUBinding;
|
|
27
|
-
readonly layerWrapper:
|
|
27
|
+
readonly layerWrapper: WebXRCompositionLayerWrapper<XRCompositionLayer, LayerTypeT>;
|
|
28
28
|
protected readonly _depthStencilFormat?: GPUTextureFormat | undefined;
|
|
29
29
|
protected _lastSubImages: Map<XREye, XRGPUSubImage>;
|
|
30
30
|
/**
|
|
@@ -43,7 +43,7 @@ export declare class WebXRWebGPUCompositionLayerRenderTargetTextureProvider exte
|
|
|
43
43
|
texture: RenderTargetTexture;
|
|
44
44
|
eye?: XREye;
|
|
45
45
|
}>;
|
|
46
|
-
constructor(_xrSessionManager: WebXRSessionManager, _xrGPUBinding: XRGPUBinding, layerWrapper:
|
|
46
|
+
constructor(_xrSessionManager: WebXRSessionManager, _xrGPUBinding: XRGPUBinding, layerWrapper: WebXRCompositionLayerWrapper<XRCompositionLayer, LayerTypeT>, _depthStencilFormat?: GPUTextureFormat | undefined);
|
|
47
47
|
protected _getRenderTargetForSubImage(subImage: XRGPUSubImage, eye?: XREye): WebXRLayerRenderTargetTexture;
|
|
48
48
|
private _getSubImageForEye;
|
|
49
49
|
getRenderTargetTextureForEye(eye?: XREye): Nullable<RenderTargetTexture>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXRWebGPUCompositionLayer.js","sourceRoot":"","sources":["../../../../../../dev/core/src/XR/features/Layers/WebXRWebGPUCompositionLayer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,EAAE,sCAAsC,EAAE,MAAM,gDAAgD,CAAC;AAGxG,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAEvE;;;;GAIG;AACH,MAAM,OAAO,kCAAmC,SAAQ,4BAA4B;IAChF,YACI,QAAsB,EACtB,SAAuB,EACvB,KAAyB,EACzB,SAAyB,EACzB,WAAoB,EACpB,iBAAmG;QAEnG,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;IACjF,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,OAAO,sDAAuD,SAAQ,sCAAsC;IAgB9G,YACI,iBAAsC,EACnB,aAA2B,EACrB,YAAgD,EACtD,mBAAsC;QAEzD,KAAK,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAJpB,kBAAa,GAAb,aAAa,CAAc;QACrB,iBAAY,GAAZ,YAAY,CAAoC;QACtD,wBAAmB,GAAnB,mBAAmB,CAAmB;QAnBnD,mBAAc,GAAG,IAAI,GAAG,EAAwB,CAAC;QAC3D;;;;;;WAMG;QACO,+BAA0B,GAAoC,EAAE,CAAC;QAE3E;;WAEG;QACI,2CAAsC,GAAG,IAAI,UAAU,EAAiD,CAAC;QAS5G,IAAI,CAAC,iBAAiB,GAAG,YAAY,CAAC,KAAK,CAAC;IAChD,CAAC;IAES,2B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AC,KAAK,CAAC;QACjD,MAAM,aAAa,GAAG,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC;QACnD,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC;QACrC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,YAAY,CAAC;QACzC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,aAAa,CAAC;QAC1C,QAAQ,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC;QACjD,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,aAAa,CAAC;IACxD,CAAC;IAEM,qBAAqB,CAAC,QAAkB,EAAE,IAAY;QACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxF,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import { type RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\nimport { type Viewport } from \"core/Maths/math.viewport\";\nimport { Observable } from \"core/Misc/observable\";\nimport { type WebXRLayerRenderTargetTexture } from \"core/XR/webXRLayerRenderTargetTexture\";\nimport { type WebXRLayerType } from \"core/XR/webXRLayerWrapper\";\nimport { type WebXRLayerRenderTargetTextureProvider } from \"core/XR/webXRRenderTargetTextureProvider\";\nimport { WebXRWebGPURenderTargetTextureProvider } from \"core/XR/webXRWebGPURenderTargetTextureProvider\";\nimport { type WebXRSessionManager } from \"core/XR/webXRSessionManager\";\nimport { type Nullable } from \"core/types\";\nimport { WebXRCompositionLayerWrapper } from \"./WebXRCompositionLayer\";\n\n/**\n * Wraps xr composition layers for the WebGPU (XRGPUBinding) backend.\n * Mirrors {@link WebXRCompositionLayerWrapper} for WebGPU.\n * @internal\n */\nexport class WebXRWebGPUCompositionLayerWrapper extends WebXRCompositionLayerWrapper {\n constructor(\n getWidth: () => number,\n getHeight: () => number,\n layer: XRCompositionLayer,\n layerType: WebXRLayerType,\n isMultiview: boolean,\n createRTTProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider\n ) {\n super(getWidth, getHeight, layer, layerType, isMultiview, createRTTProvider);\n }\n}\n\n/**\n * Provides render target textures and other important rendering information for a given XRCompositionLayer\n * on the WebGPU backend. Mirrors {@link WebXRCompositionLayerRenderTargetTextureProvider}, but wraps\n * {@link XRGPUSubImage} GPUTextures instead of WebGL textures.\n * @internal\n */\nexport class WebXRWebGPUCompositionLayerRenderTargetTextureProvider extends WebXRWebGPURenderTargetTextureProvider {\n protected _lastSubImages = new Map<XREye, XRGPUSubImage>();\n /**\n * Per-eye render targets, indexed by eye (0 = left/none, 1 = right). Kept separate from the base\n * `_renderTargetTextures` registry: that array is an append-only owned list (each entry is disposed once\n * on provider dispose), whereas this map is a mutable per-eye slot. Reusing `_renderTargetTextures` as\n * both would let a rebuilt eye target both stay in the registry (leaking / double-disposing the old one)\n * and grow the registry unboundedly on repeated size changes.\n */\n protected _renderTargetTexturesByEye: WebXRLayerRenderTargetTexture[] = [];\n private _compositionLayer: XRCompositionLayer;\n /**\n * Fires every time a new render target texture is created (either for eye, for view, or for the entire frame)\n */\n public onRenderTargetTextureCreatedObservable = new Observable<{ texture: RenderTargetTexture; eye?: XREye }>();\n\n constructor(\n _xrSessionManager: WebXRSessionManager,\n protected readonly _xrGPUBinding: XRGPUBinding,\n public override readonly layerWrapper: WebXRWebGPUCompositionLayerWrapper,\n protected readonly _depthStencilFormat?: GPUTextureFormat\n ) {\n super(_xrSessionManager, layerWrapper);\n this._compositionLayer = layerWrapper.layer;\n }\n\n protected _getRenderTargetForSubImage(subImage: XRGPUSubImage, eye: XREye = \"none\") {\n const lastSubImage = this._lastSubImages.get(eye);\n const eyeIndex = eye == \"right\" ? 1 : 0;\n\n const colorTexture = subImage.colorTexture;\n const colorTextureWidth = colorTexture.width;\n const colorTextureHeight = colorTexture.height;\n\n const depthStencilTexture = subImage.depthStencilTexture ?? null;\n\n const existingRenderTarget = this._renderTargetTexturesByEye[eyeIndex];\n const sizeChanged = !existingRenderTarget || lastSubImage?.colorTexture.width !== colorTextureWidth || lastSubImage?.colorTexture.height !== colorTextureHeight;\n\n if (sizeChanged) {\n if (existingRenderTarget) {\n // A previous target for this eye exists (the sub-image size changed, e.g. a scale-factor or\n // display-config change). Dispose it and remove it from the owned registry before creating the\n // replacement so the registry does not accumulate stale entries or double-dispose on teardown.\n this._destroyRenderTargetTexture(existingRenderTarget);\n }\n this._renderTargetTexturesByEye[eyeIndex] = this._createRenderTargetTextureFromGPUTextures(\n colorTextureWidth,\n colorTextureHeight,\n colorTexture,\n depthStencilTexture,\n this._depthStencilFormat,\n this.layerWrapper.isMultiview\n );\n\n this._framebufferDimensions = {\n framebufferWidth: colorTextureWidth,\n framebufferHeight: colorTextureHeight,\n };\n this.onRenderTargetTextureCreatedObservable.notifyObservers({ texture: this._renderTargetTexturesByEye[eyeIndex], eye });\n } else {\n // Same size: repoint the wrapped textures at this frame's GPUTextures, preserving the\n // RenderTargetTexture / InternalTexture identity held by the XR camera's outputRenderTarget.\n this._updateRenderTargetTextureFromGPUTextures(existingRenderTarget, colorTexture, depthStencilTexture);\n }\n\n this._lastSubImages.set(eye, subImage);\n\n // The projection-layer color/depth textures may be a texture ARRAY with one layer per eye\n // (depthOrArrayLayers > 1). The sub-image's view descriptor carries the authoritative array-layer\n // index for this eye, so route it into the render target's bind so each eye renders into its own\n // layer. For non-layered textures this is 0 (unchanged behavior).\n const renderTargetTexture = this._renderTargetTexturesByEye[eyeIndex];\n renderTargetTexture.layerIndex = subImage.getViewDescriptor().baseArrayLayer ?? 0;\n\n return renderTargetTexture;\n }\n\n private _getSubImageForEye(eye?: XREye): Nullable<XRGPUSubImage> {\n const currentFrame = this._xrSessionManager.currentFrame;\n if (currentFrame) {\n return this._xrGPUBinding.getSubImage(this._compositionLayer, currentFrame, eye);\n }\n return null;\n }\n\n public getRenderTargetTextureForEye(eye?: XREye): Nullable<RenderTargetTexture> {\n const subImage = this._getSubImageForEye(eye);\n if (subImage) {\n return this._getRenderTargetForSubImage(subImage, eye);\n }\n return null;\n }\n\n public getRenderTargetTextureForView(view?: XRView): Nullable<RenderTargetTexture> {\n return this.getRenderTargetTextureForEye(view?.eye);\n }\n\n protected _setViewportForSubImage(viewport: Viewport, subImage: XRGPUSubImage) {\n const textureWidth = subImage.colorTexture.width;\n const textureHeight = subImage.colorTexture.height;\n const xrViewport = subImage.viewport;\n viewport.x = xrViewport.x / textureWidth;\n viewport.y = xrViewport.y / textureHeight;\n viewport.width = xrViewport.width / textureWidth;\n viewport.height = xrViewport.height / textureHeight;\n }\n\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\n const subImage = this._lastSubImages.get(view.eye) || this._getSubImageForEye(view.eye);\n if (subImage) {\n this._setViewportForSubImage(viewport, subImage);\n return true;\n }\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"WebXRWebGPUCompositionLayer.js","sourceRoot":"","sources":["../../../../../../dev/core/src/XR/features/Layers/WebXRWebGPUCompositionLayer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,EAAE,sCAAsC,EAAE,MAAM,gDAAgD,CAAC;AAGxG,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAEvE;;;;GAIG;AACH,MAAM,OAAO,kCAAmC,SAAQ,4BAA4B;IAChF,YACI,QAAsB,EACtB,SAAuB,EACvB,KAAyB,EACzB,SAAyB,EACzB,WAAoB,EACpB,iBAAmG;QAEnG,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE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QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import { type RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\nimport { type Viewport } from \"core/Maths/math.viewport\";\nimport { Observable } from \"core/Misc/observable\";\nimport { type WebXRLayerRenderTargetTexture } from \"core/XR/webXRLayerRenderTargetTexture\";\nimport { type WebXRLayerType, type WebXRSupportedLayerType } from \"core/XR/webXRLayerWrapper\";\nimport { type WebXRLayerRenderTargetTextureProvider } from \"core/XR/webXRRenderTargetTextureProvider\";\nimport { WebXRWebGPURenderTargetTextureProvider } from \"core/XR/webXRWebGPURenderTargetTextureProvider\";\nimport { type WebXRSessionManager } from \"core/XR/webXRSessionManager\";\nimport { type Nullable } from \"core/types\";\nimport { WebXRCompositionLayerWrapper } from \"./WebXRCompositionLayer\";\n\n/**\n * Wraps xr composition layers for the WebGPU (XRGPUBinding) backend.\n * Mirrors {@link WebXRCompositionLayerWrapper} for WebGPU.\n * @internal\n */\nexport class WebXRWebGPUCompositionLayerWrapper extends WebXRCompositionLayerWrapper {\n constructor(\n getWidth: () => number,\n getHeight: () => number,\n layer: XRCompositionLayer,\n layerType: WebXRLayerType,\n isMultiview: boolean,\n createRTTProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider\n ) {\n super(getWidth, getHeight, layer, layerType, isMultiview, createRTTProvider);\n }\n}\n\n/**\n * Provides render target textures and other important rendering information for a given XRCompositionLayer\n * on the WebGPU backend. Mirrors {@link WebXRCompositionLayerRenderTargetTextureProvider}, but wraps\n * {@link XRGPUSubImage} GPUTextures instead of WebGL textures.\n * @internal\n */\nexport class WebXRWebGPUCompositionLayerRenderTargetTextureProvider<\n LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType,\n> extends WebXRWebGPURenderTargetTextureProvider<LayerTypeT> {\n protected _lastSubImages = new Map<XREye, XRGPUSubImage>();\n /**\n * Per-eye render targets, indexed by eye (0 = left/none, 1 = right). Kept separate from the base\n * `_renderTargetTextures` registry: that array is an append-only owned list (each entry is disposed once\n * on provider dispose), whereas this map is a mutable per-eye slot. Reusing `_renderTargetTextures` as\n * both would let a rebuilt eye target both stay in the registry (leaking / double-disposing the old one)\n * and grow the registry unboundedly on repeated size changes.\n */\n protected _renderTargetTexturesByEye: WebXRLayerRenderTargetTexture[] = [];\n private _compositionLayer: XRCompositionLayer;\n /**\n * Fires every time a new render target texture is created (either for eye, for view, or for the entire frame)\n */\n public onRenderTargetTextureCreatedObservable = new Observable<{ texture: RenderTargetTexture; eye?: XREye }>();\n\n constructor(\n _xrSessionManager: WebXRSessionManager,\n protected readonly _xrGPUBinding: XRGPUBinding,\n public override readonly layerWrapper: WebXRCompositionLayerWrapper<XRCompositionLayer, LayerTypeT>,\n protected readonly _depthStencilFormat?: GPUTextureFormat\n ) {\n super(_xrSessionManager, layerWrapper);\n this._compositionLayer = layerWrapper.layer;\n }\n\n protected _getRenderTargetForSubImage(subImage: XRGPUSubImage, eye: XREye = \"none\") {\n const lastSubImage = this._lastSubImages.get(eye);\n const eyeIndex = eye == \"right\" ? 1 : 0;\n\n const colorTexture = subImage.colorTexture;\n const colorTextureWidth = colorTexture.width;\n const colorTextureHeight = colorTexture.height;\n\n const depthStencilTexture = subImage.depthStencilTexture ?? null;\n\n const existingRenderTarget = this._renderTargetTexturesByEye[eyeIndex];\n const sizeChanged = !existingRenderTarget || lastSubImage?.colorTexture.width !== colorTextureWidth || lastSubImage?.colorTexture.height !== colorTextureHeight;\n\n if (sizeChanged) {\n if (existingRenderTarget) {\n // A previous target for this eye exists (the sub-image size changed, e.g. a scale-factor or\n // display-config change). Dispose it and remove it from the owned registry before creating the\n // replacement so the registry does not accumulate stale entries or double-dispose on teardown.\n this._destroyRenderTargetTexture(existingRenderTarget);\n }\n this._renderTargetTexturesByEye[eyeIndex] = this._createRenderTargetTextureFromGPUTextures(\n colorTextureWidth,\n colorTextureHeight,\n colorTexture,\n depthStencilTexture,\n this._depthStencilFormat,\n this.layerWrapper.isMultiview\n );\n\n this._framebufferDimensions = {\n framebufferWidth: colorTextureWidth,\n framebufferHeight: colorTextureHeight,\n };\n this.onRenderTargetTextureCreatedObservable.notifyObservers({ texture: this._renderTargetTexturesByEye[eyeIndex], eye });\n } else {\n // Same size: repoint the wrapped textures at this frame's GPUTextures, preserving the\n // RenderTargetTexture / InternalTexture identity held by the XR camera's outputRenderTarget.\n this._updateRenderTargetTextureFromGPUTextures(existingRenderTarget, colorTexture, depthStencilTexture);\n }\n\n this._lastSubImages.set(eye, subImage);\n\n // The projection-layer color/depth textures may be a texture ARRAY with one layer per eye\n // (depthOrArrayLayers > 1). The sub-image's view descriptor carries the authoritative array-layer\n // index for this eye, so route it into the render target's bind so each eye renders into its own\n // layer. For non-layered textures this is 0 (unchanged behavior).\n const renderTargetTexture = this._renderTargetTexturesByEye[eyeIndex];\n renderTargetTexture.layerIndex = subImage.getViewDescriptor().baseArrayLayer ?? 0;\n\n return renderTargetTexture;\n }\n\n private _getSubImageForEye(eye?: XREye): Nullable<XRGPUSubImage> {\n const currentFrame = this._xrSessionManager.currentFrame;\n if (currentFrame) {\n return this._xrGPUBinding.getSubImage(this._compositionLayer, currentFrame, eye);\n }\n return null;\n }\n\n public getRenderTargetTextureForEye(eye?: XREye): Nullable<RenderTargetTexture> {\n const subImage = this._getSubImageForEye(eye);\n if (subImage) {\n return this._getRenderTargetForSubImage(subImage, eye);\n }\n return null;\n }\n\n public getRenderTargetTextureForView(view?: XRView): Nullable<RenderTargetTexture> {\n return this.getRenderTargetTextureForEye(view?.eye);\n }\n\n protected _setViewportForSubImage(viewport: Viewport, subImage: XRGPUSubImage) {\n const textureWidth = subImage.colorTexture.width;\n const textureHeight = subImage.colorTexture.height;\n const xrViewport = subImage.viewport;\n viewport.x = xrViewport.x / textureWidth;\n viewport.y = xrViewport.y / textureHeight;\n viewport.width = xrViewport.width / textureWidth;\n viewport.height = xrViewport.height / textureHeight;\n }\n\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\n const subImage = this._lastSubImages.get(view.eye) || this._getSubImageForEye(view.eye);\n if (subImage) {\n this._setViewportForSubImage(viewport, subImage);\n return true;\n }\n return false;\n }\n}\n"]}
|