@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.
Files changed (261) hide show
  1. package/Animations/animation.pure.js +2 -2
  2. package/Animations/animation.pure.js.map +1 -1
  3. package/Animations/runtimeAnimation.js +4 -0
  4. package/Animations/runtimeAnimation.js.map +1 -1
  5. package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
  6. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  7. package/Behaviors/Meshes/followBehavior.js +1 -0
  8. package/Behaviors/Meshes/followBehavior.js.map +1 -1
  9. package/Behaviors/Meshes/surfaceMagnetismBehavior.js +1 -0
  10. package/Behaviors/Meshes/surfaceMagnetismBehavior.js.map +1 -1
  11. package/Cameras/Inputs/followCameraMouseWheelInput.js +2 -2
  12. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  13. package/Cameras/Inputs/followCameraPointersInput.d.ts +15 -0
  14. package/Cameras/Inputs/followCameraPointersInput.js +18 -3
  15. package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
  16. package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js +1 -1
  17. package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
  18. package/Cameras/Stereoscopic/stereoscopicUniversalCamera.pure.js +1 -1
  19. package/Cameras/Stereoscopic/stereoscopicUniversalCamera.pure.js.map +1 -1
  20. package/Cameras/arcRotateCamera.pure.js +1 -1
  21. package/Cameras/arcRotateCamera.pure.js.map +1 -1
  22. package/Collisions/gpuPicker.d.ts +1 -0
  23. package/Collisions/gpuPicker.js +5 -4
  24. package/Collisions/gpuPicker.js.map +1 -1
  25. package/Culling/Helper/boundingInfoHelper.js +1 -1
  26. package/Culling/Helper/boundingInfoHelper.js.map +1 -1
  27. package/Culling/boundingSphere.js +7 -4
  28. package/Culling/boundingSphere.js.map +1 -1
  29. package/Engines/Extensions/engine.prefilteredCubeTexture.pure.js +1 -1
  30. package/Engines/Extensions/engine.prefilteredCubeTexture.pure.js.map +1 -1
  31. package/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.js +48 -6
  32. package/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.js.map +1 -1
  33. package/Engines/Native/nativeInterfaces.d.ts +1 -1
  34. package/Engines/Native/nativeInterfaces.js.map +1 -1
  35. package/Engines/abstractEngine.pure.js +2 -2
  36. package/Engines/abstractEngine.pure.js.map +1 -1
  37. package/Engines/engine.d.ts +10 -1
  38. package/Engines/thinNativeEngine.pure.d.ts +6 -1
  39. package/Engines/thinNativeEngine.pure.js +29 -2
  40. package/Engines/thinNativeEngine.pure.js.map +1 -1
  41. package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.d.ts +3 -63
  42. package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.js +5 -71
  43. package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.js.map +1 -1
  44. package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.pure.d.ts +71 -0
  45. package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.pure.js +86 -0
  46. package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.pure.js.map +1 -0
  47. package/FlowGraph/Blocks/Data/pure.d.ts +1 -0
  48. package/FlowGraph/Blocks/Data/pure.js +1 -0
  49. package/FlowGraph/Blocks/Data/pure.js.map +1 -1
  50. package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.d.ts +3 -37
  51. package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.js +5 -39
  52. package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.js.map +1 -1
  53. package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.pure.d.ts +45 -0
  54. package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.pure.js +54 -0
  55. package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.pure.js.map +1 -0
  56. package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.d.ts +3 -17
  57. package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.js +5 -22
  58. package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.js.map +1 -1
  59. package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.pure.d.ts +25 -0
  60. package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.pure.js +37 -0
  61. package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.pure.js.map +1 -0
  62. package/FlowGraph/Blocks/Event/pure.d.ts +2 -0
  63. package/FlowGraph/Blocks/Event/pure.js +2 -0
  64. package/FlowGraph/Blocks/Event/pure.js.map +1 -1
  65. package/FlowGraph/Blocks/flowGraphBlockFactory.d.ts +1 -1
  66. package/FlowGraph/Blocks/flowGraphBlockFactory.js +198 -172
  67. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  68. package/FrameGraph/frameGraph.js +10 -1
  69. package/FrameGraph/frameGraph.js.map +1 -1
  70. package/Gamepads/gamepadManager.d.ts +1 -0
  71. package/Gamepads/gamepadManager.js +5 -2
  72. package/Gamepads/gamepadManager.js.map +1 -1
  73. package/Gizmos/scaleGizmo.js +1 -0
  74. package/Gizmos/scaleGizmo.js.map +1 -1
  75. package/Lights/IES/iesLoader.js +6 -8
  76. package/Lights/IES/iesLoader.js.map +1 -1
  77. package/Lights/Shadows/cascadedShadowGenerator.pure.js +4 -6
  78. package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
  79. package/Lights/Shadows/shadowGenerator.js +2 -2
  80. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  81. package/Lights/light.js +3 -5
  82. package/Lights/light.js.map +1 -1
  83. package/Lights/spotLight.pure.js +1 -1
  84. package/Lights/spotLight.pure.js.map +1 -1
  85. package/Materials/Background/backgroundMaterial.pure.d.ts +1 -1
  86. package/Materials/Background/backgroundMaterial.pure.js +3 -12
  87. package/Materials/Background/backgroundMaterial.pure.js.map +1 -1
  88. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +2 -0
  89. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
  90. package/Materials/Node/Blocks/Fragment/TBNBlock.pure.js +1 -1
  91. package/Materials/Node/Blocks/Fragment/TBNBlock.pure.js.map +1 -1
  92. package/Materials/PBR/openpbrMaterial.pure.d.ts +1 -1
  93. package/Materials/PBR/openpbrMaterial.pure.js +3 -12
  94. package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
  95. package/Materials/PBR/pbrBaseMaterial.pure.d.ts +1 -1
  96. package/Materials/PBR/pbrBaseMaterial.pure.js +3 -12
  97. package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
  98. package/Materials/Textures/renderTargetTexture.pure.js +1 -1
  99. package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
  100. package/Materials/material.pure.js +2 -2
  101. package/Materials/material.pure.js.map +1 -1
  102. package/Materials/standardMaterial.pure.d.ts +1 -1
  103. package/Materials/standardMaterial.pure.js +4 -13
  104. package/Materials/standardMaterial.pure.js.map +1 -1
  105. package/Maths/math.path.js +1 -1
  106. package/Maths/math.path.js.map +1 -1
  107. package/Maths/math.polar.js +1 -1
  108. package/Maths/math.polar.js.map +1 -1
  109. package/Maths/math.vector.pure.js +4 -3
  110. package/Maths/math.vector.pure.js.map +1 -1
  111. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +72 -0
  112. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +164 -1
  113. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  114. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +2 -1
  115. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +36 -18
  116. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  117. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.d.ts +5 -4
  118. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js +25 -8
  119. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js.map +1 -1
  120. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +3 -3
  121. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js.map +1 -1
  122. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js +1 -1
  123. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js.map +1 -1
  124. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js +2 -2
  125. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js.map +1 -1
  126. package/Meshes/Node/Blocks/mappingBlock.pure.js +2 -2
  127. package/Meshes/Node/Blocks/mappingBlock.pure.js.map +1 -1
  128. package/Meshes/csg.js +5 -5
  129. package/Meshes/csg.js.map +1 -1
  130. package/Meshes/groundMesh.pure.js +1 -1
  131. package/Meshes/groundMesh.pure.js.map +1 -1
  132. package/Meshes/mesh.pure.js +2 -2
  133. package/Meshes/mesh.pure.js.map +1 -1
  134. package/Misc/deepMerger.js +1 -1
  135. package/Misc/deepMerger.js.map +1 -1
  136. package/Misc/dumpTools.pure.js +1 -1
  137. package/Misc/dumpTools.pure.js.map +1 -1
  138. package/Misc/index.d.ts +1 -0
  139. package/Misc/index.js +1 -0
  140. package/Misc/index.js.map +1 -1
  141. package/Misc/pure.d.ts +1 -0
  142. package/Misc/pure.js +1 -0
  143. package/Misc/pure.js.map +1 -1
  144. package/Misc/shaderImportLoader.d.ts +25 -0
  145. package/Misc/shaderImportLoader.js +54 -0
  146. package/Misc/shaderImportLoader.js.map +1 -0
  147. package/Misc/tools.pure.js +1 -1
  148. package/Misc/tools.pure.js.map +1 -1
  149. package/Particles/Node/Blocks/particleClampBlock.pure.d.ts +0 -1
  150. package/Particles/Node/Blocks/particleClampBlock.pure.js +1 -6
  151. package/Particles/Node/Blocks/particleClampBlock.pure.js.map +1 -1
  152. package/Particles/Node/Blocks/particleMathBlock.pure.js +1 -1
  153. package/Particles/Node/Blocks/particleMathBlock.pure.js.map +1 -1
  154. package/Particles/Node/Blocks/particleNLerpBlock.pure.js +8 -3
  155. package/Particles/Node/Blocks/particleNLerpBlock.pure.js.map +1 -1
  156. package/Particles/Node/Blocks/particleSmoothStepBlock.pure.js +3 -2
  157. package/Particles/Node/Blocks/particleSmoothStepBlock.pure.js.map +1 -1
  158. package/Particles/Node/Blocks/particleStepBlock.pure.js +3 -2
  159. package/Particles/Node/Blocks/particleStepBlock.pure.js.map +1 -1
  160. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js +1 -1
  161. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js.map +1 -1
  162. package/PostProcesses/depthOfFieldEffect.js +1 -1
  163. package/PostProcesses/depthOfFieldEffect.js.map +1 -1
  164. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js +1 -1
  165. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js.map +1 -1
  166. package/PostProcesses/sharpenPostProcess.pure.js +1 -1
  167. package/PostProcesses/sharpenPostProcess.pure.js.map +1 -1
  168. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.d.ts +12 -0
  169. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +15 -1
  170. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
  171. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +14 -0
  172. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +122 -6
  173. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
  174. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +7 -0
  175. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +17 -0
  176. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
  177. package/Rendering/boundingBoxRenderer.pure.js +3 -3
  178. package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
  179. package/Rendering/outlineRenderer.pure.js +1 -0
  180. package/Rendering/outlineRenderer.pure.js.map +1 -1
  181. package/Rendering/subSurfaceConfiguration.js +1 -1
  182. package/Rendering/subSurfaceConfiguration.js.map +1 -1
  183. package/Rendering/subSurfaceSceneComponent.pure.d.ts +1 -1
  184. package/Rendering/subSurfaceSceneComponent.pure.js +1 -1
  185. package/Rendering/subSurfaceSceneComponent.pure.js.map +1 -1
  186. package/Rendering/utilityLayerRenderer.js +1 -1
  187. package/Rendering/utilityLayerRenderer.js.map +1 -1
  188. package/Shaders/gaussianSplattingVoxel.fragment.js +4 -10
  189. package/Shaders/gaussianSplattingVoxel.fragment.js.map +1 -1
  190. package/Shaders/iblCombineVoxelGrids.fragment.js +1 -1
  191. package/Shaders/iblCombineVoxelGrids.fragment.js.map +1 -1
  192. package/Shaders/iblShadowVoxelTracing.fragment.js +24 -7
  193. package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
  194. package/ShadersWGSL/ShadersInclude/iblVoxelOpacityAtomicMax.d.ts +5 -0
  195. package/ShadersWGSL/ShadersInclude/iblVoxelOpacityAtomicMax.js +13 -0
  196. package/ShadersWGSL/ShadersInclude/iblVoxelOpacityAtomicMax.js.map +1 -0
  197. package/ShadersWGSL/gaussianSplattingVoxel.fragment.js +15 -9
  198. package/ShadersWGSL/gaussianSplattingVoxel.fragment.js.map +1 -1
  199. package/ShadersWGSL/iblCombineVoxelGrids.fragment.js +1 -1
  200. package/ShadersWGSL/iblCombineVoxelGrids.fragment.js.map +1 -1
  201. package/ShadersWGSL/iblCopyVoxelBufferToGrid.compute.d.ts +5 -0
  202. package/ShadersWGSL/iblCopyVoxelBufferToGrid.compute.js +14 -0
  203. package/ShadersWGSL/iblCopyVoxelBufferToGrid.compute.js.map +1 -0
  204. package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +24 -7
  205. package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
  206. package/ShadersWGSL/iblVoxelGrid.fragment.js +26 -6
  207. package/ShadersWGSL/iblVoxelGrid.fragment.js.map +1 -1
  208. package/SmartAssets/smartAssetManager.pure.js +1 -1
  209. package/SmartAssets/smartAssetManager.pure.js.map +1 -1
  210. package/Sprites/thinSprite.js +1 -1
  211. package/Sprites/thinSprite.js.map +1 -1
  212. package/XR/features/Layers/WebXRCompositionLayer.d.ts +130 -12
  213. package/XR/features/Layers/WebXRCompositionLayer.js +192 -3
  214. package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
  215. package/XR/features/Layers/WebXRFallbackLayer.d.ts +84 -0
  216. package/XR/features/Layers/WebXRFallbackLayer.js +137 -0
  217. package/XR/features/Layers/WebXRFallbackLayer.js.map +1 -0
  218. package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +4 -4
  219. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -1
  220. package/XR/features/WebXRAnchorSystem.pure.d.ts +45 -0
  221. package/XR/features/WebXRAnchorSystem.pure.js +153 -13
  222. package/XR/features/WebXRAnchorSystem.pure.js.map +1 -1
  223. package/XR/features/WebXRLayers.pure.d.ts +171 -8
  224. package/XR/features/WebXRLayers.pure.js +500 -98
  225. package/XR/features/WebXRLayers.pure.js.map +1 -1
  226. package/XR/features/WebXRLayersFallback.d.ts +5 -0
  227. package/XR/features/WebXRLayersFallback.js +8 -0
  228. package/XR/features/WebXRLayersFallback.js.map +1 -0
  229. package/XR/features/WebXRLayersFallback.pure.d.ts +6 -0
  230. package/XR/features/WebXRLayersFallback.pure.js +44 -0
  231. package/XR/features/WebXRLayersFallback.pure.js.map +1 -0
  232. package/XR/features/WebXRLightEstimation.pure.d.ts +3 -4
  233. package/XR/features/WebXRLightEstimation.pure.js +22 -21
  234. package/XR/features/WebXRLightEstimation.pure.js.map +1 -1
  235. package/XR/features/WebXRMeshDetector.pure.d.ts +5 -0
  236. package/XR/features/WebXRMeshDetector.pure.js +1 -0
  237. package/XR/features/WebXRMeshDetector.pure.js.map +1 -1
  238. package/XR/features/WebXRNearInteraction.pure.js +3 -3
  239. package/XR/features/WebXRNearInteraction.pure.js.map +1 -1
  240. package/XR/features/WebXRPlaneDetector.pure.d.ts +9 -5
  241. package/XR/features/WebXRPlaneDetector.pure.js +12 -8
  242. package/XR/features/WebXRPlaneDetector.pure.js.map +1 -1
  243. package/XR/features/pure.d.ts +1 -0
  244. package/XR/features/pure.js +1 -0
  245. package/XR/features/pure.js.map +1 -1
  246. package/XR/webXRCamera.d.ts +2 -0
  247. package/XR/webXRCamera.js +8 -2
  248. package/XR/webXRCamera.js.map +1 -1
  249. package/XR/webXRLayerWrapper.d.ts +19 -5
  250. package/XR/webXRLayerWrapper.js +9 -0
  251. package/XR/webXRLayerWrapper.js.map +1 -1
  252. package/XR/webXRRenderTargetTextureProvider.d.ts +4 -4
  253. package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
  254. package/XR/webXRWebGLRenderTargetTextureProvider.d.ts +2 -1
  255. package/XR/webXRWebGLRenderTargetTextureProvider.js.map +1 -1
  256. package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +3 -3
  257. package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -1
  258. package/package.json +1 -1
  259. package/scene.pure.d.ts +5 -0
  260. package/scene.pure.js +25 -0
  261. package/scene.pure.js.map +1 -1
package/XR/webXRCamera.js CHANGED
@@ -19,6 +19,8 @@ export class WebXRCamera extends FreeCamera {
19
19
  super(name, Vector3.Zero(), scene);
20
20
  this._xrSessionManager = _xrSessionManager;
21
21
  this._firstFrame = false;
22
+ this._xrSessionInitObserver = null;
23
+ this._xrFrameObserver = null;
22
24
  this._referenceQuaternion = Quaternion.Identity();
23
25
  this._referencedPosition = new Vector3();
24
26
  this._trackingState = 0 /* WebXRTrackingState.NOT_TRACKING */;
@@ -63,7 +65,7 @@ export class WebXRCamera extends FreeCamera {
63
65
  // freeze projection matrix, which will be copied later
64
66
  this.freezeProjectionMatrix();
65
67
  this._deferOnly = true;
66
- this._xrSessionManager.onXRSessionInit.add(() => {
68
+ this._xrSessionInitObserver = this._xrSessionManager.onXRSessionInit.add(() => {
67
69
  this._referencedPosition.copyFromFloats(0, 0, 0);
68
70
  this._referenceQuaternion.copyFromFloats(0, 0, 0, 1);
69
71
  // first frame - camera's y position should be 0 for the correct offset
@@ -72,7 +74,7 @@ export class WebXRCamera extends FreeCamera {
72
74
  this._xrSessionManager.onWorldScaleFactorChangedObservable.add(this._onWorldScaleFactorChanged);
73
75
  // Check transformation changes on each frame. Callback is added to be first so that the transformation will be
74
76
  // applied to the rest of the elements using the referenceSpace object
75
- this._xrSessionManager.onXRFrameObservable.add(() => {
77
+ this._xrFrameObserver = this._xrSessionManager.onXRFrameObservable.add(() => {
76
78
  if (this._firstFrame) {
77
79
  this._updateFromXRSession();
78
80
  }
@@ -169,6 +171,10 @@ export class WebXRCamera extends FreeCamera {
169
171
  }
170
172
  dispose() {
171
173
  this._xrSessionManager.onWorldScaleFactorChangedObservable.removeCallback(this._onWorldScaleFactorChanged);
174
+ this._xrSessionManager.onXRSessionInit.remove(this._xrSessionInitObserver);
175
+ this._xrSessionInitObserver = null;
176
+ this._xrSessionManager.onXRFrameObservable.remove(this._xrFrameObserver);
177
+ this._xrFrameObserver = null;
172
178
  super.dispose();
173
179
  this._lastXRViewerPose = undefined;
174
180
  this.onTrackingStateChanged.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"webXRCamera.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEpF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM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c,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;QACrH,CAAC;IACL,CAAC;;AAxac,0BAAc,GAAG,OAAO,CAAC,GAAG,EAAE,AAAhB,CAAiB","sourcesContent":["import { Vector3, Matrix, Quaternion, TmpVectors } from \"../Maths/math.vector.pure\";\r\nimport { type Scene } from \"../scene\";\r\nimport { Camera } from \"../Cameras/camera.pure\";\r\nimport { FreeCamera } from \"../Cameras/freeCamera.pure\";\r\nimport { TargetCamera } from \"../Cameras/targetCamera.pure\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport { Viewport } from \"../Maths/math.viewport\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { WebXRTrackingState } from \"./webXRTypes\";\r\n\r\n/**\r\n * WebXR Camera which holds the views for the xrSession\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/webXR/webXRCamera\r\n */\r\nexport class WebXRCamera extends FreeCamera {\r\n private static _ScaleReadOnly = Vector3.One();\r\n\r\n private _firstFrame = false;\r\n private _referenceQuaternion: Quaternion = Quaternion.Identity();\r\n private _referencedPosition: Vector3 = new Vector3();\r\n private _trackingState: WebXRTrackingState = WebXRTrackingState.NOT_TRACKING;\r\n\r\n private _onWorldScaleFactorChanged = () => {\r\n // only run if in session\r\n if (!this._xrSessionManager.currentFrame) {\r\n return;\r\n }\r\n this._updateDepthNearFar();\r\n };\r\n\r\n /**\r\n * This will be triggered after the first XR Frame initialized the camera,\r\n * including the right number of views and their rendering parameters\r\n */\r\n public onXRCameraInitializedObservable = new Observable<WebXRCamera>();\r\n\r\n /**\r\n * Observable raised before camera teleportation\r\n * @deprecated use onBeforeCameraTeleport of the teleportation feature instead\r\n */\r\n public onBeforeCameraTeleport = new Observable<Vector3>();\r\n\r\n /**\r\n * Observable raised after camera teleportation\r\n * @deprecated use onAfterCameraTeleport of the teleportation feature instead\r\n */\r\n public onAfterCameraTeleport = new Observable<Vector3>();\r\n\r\n /**\r\n * Notifies when the camera's tracking state has changed.\r\n * Notice - will also be triggered when tracking has started (at the beginning of the session)\r\n */\r\n public onTrackingStateChanged = new Observable<WebXRTrackingState>();\r\n\r\n /**\r\n * Should position compensation execute on first frame.\r\n * This is used when copying the position from a native (non XR) camera\r\n */\r\n public compensateOnFirstFrame: boolean = true;\r\n\r\n /**\r\n * The last XRViewerPose from the current XRFrame\r\n * @internal\r\n */\r\n public _lastXRViewerPose?: XRViewerPose;\r\n\r\n /**\r\n * webXRCamera relies on rotationQuaternion and doesn't use camera rotation property\r\n */\r\n public override rotationQuaternion: Quaternion;\r\n\r\n /**\r\n * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager\r\n * @param name the name of the camera\r\n * @param scene the scene to add the camera to\r\n * @param _xrSessionManager a constructed xr session manager\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n private _xrSessionManager: WebXRSessionManager\r\n ) {\r\n super(name, Vector3.Zero(), scene);\r\n\r\n // Initial camera configuration\r\n this.minZ = 0.1;\r\n this.rotationQuaternion = new Quaternion();\r\n this.cameraRigMode = Camera.RIG_MODE_CUSTOM;\r\n this.updateUpVectorFromRotation = true;\r\n this._updateNumberOfRigCameras(1);\r\n // freeze projection matrix, which will be copied later\r\n this.freezeProjectionMatrix();\r\n this._deferOnly = true;\r\n\r\n this._xrSessionManager.onXRSessionInit.add(() => {\r\n this._referencedPosition.copyFromFloats(0, 0, 0);\r\n this._referenceQuaternion.copyFromFloats(0, 0, 0, 1);\r\n // first frame - camera's y position should be 0 for the correct offset\r\n this._firstFrame = this.compensateOnFirstFrame;\r\n });\r\n\r\n this._xrSessionManager.onWorldScaleFactorChangedObservable.add(this._onWorldScaleFactorChanged);\r\n\r\n // Check transformation changes on each frame. Callback is added to be first so that the transformation will be\r\n // applied to the rest of the elements using the referenceSpace object\r\n this._xrSessionManager.onXRFrameObservable.add(\r\n () => {\r\n if (this._firstFrame) {\r\n this._updateFromXRSession();\r\n }\r\n if (this.onXRCameraInitializedObservable.hasObservers()) {\r\n this.onXRCameraInitializedObservable.notifyObservers(this);\r\n this.onXRCameraInitializedObservable.clear();\r\n }\r\n\r\n if (this._deferredUpdated) {\r\n this.position.copyFrom(this._deferredPositionUpdate);\r\n this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate);\r\n }\r\n\r\n this._updateReferenceSpace();\r\n this._updateFromXRSession();\r\n },\r\n undefined,\r\n true\r\n );\r\n }\r\n\r\n /**\r\n * Get the current XR tracking state of the camera\r\n */\r\n public get trackingState(): WebXRTrackingState {\r\n return this._trackingState;\r\n }\r\n\r\n private _setTrackingState(newState: WebXRTrackingState) {\r\n if (this._trackingState !== newState) {\r\n this._trackingState = newState;\r\n this.onTrackingStateChanged.notifyObservers(newState);\r\n }\r\n }\r\n\r\n /**\r\n * Return the user's height, unrelated to the current ground.\r\n * This will be the y position of this camera, when ground level is 0.\r\n *\r\n * Note - this value is multiplied by the worldScalingFactor (if set), so it will be in the same units as the scene.\r\n */\r\n public get realWorldHeight(): number {\r\n const basePose = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);\r\n if (basePose && basePose.transform) {\r\n return basePose.transform.position.y * this._xrSessionManager.worldScalingFactor;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _updateForDualEyeDebugging(/*pupilDistance = 0.01*/) {\r\n // Create initial camera rigs\r\n this._updateNumberOfRigCameras(2);\r\n this.rigCameras[0].viewport = new Viewport(0, 0, 0.5, 1.0);\r\n // this.rigCameras[0].position.x = -pupilDistance / 2;\r\n this.rigCameras[0].outputRenderTarget = null;\r\n this.rigCameras[1].viewport = new Viewport(0.5, 0, 0.5, 1.0);\r\n // this.rigCameras[1].position.x = pupilDistance / 2;\r\n this.rigCameras[1].outputRenderTarget = null;\r\n }\r\n\r\n /**\r\n * Sets this camera's transformation based on a non-vr camera\r\n * @param otherCamera the non-vr camera to copy the transformation from\r\n * @param resetToBaseReferenceSpace should XR reset to the base reference space\r\n */\r\n public setTransformationFromNonVRCamera(otherCamera: Camera = this.getScene().activeCamera!, resetToBaseReferenceSpace: boolean = true) {\r\n if (!otherCamera || otherCamera === this) {\r\n return;\r\n }\r\n const mat = otherCamera.computeWorldMatrix();\r\n mat.decompose(undefined, this.rotationQuaternion, this.position);\r\n // set the ground level\r\n this.position.y = 0;\r\n Quaternion.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion);\r\n this._firstFrame = true;\r\n if (resetToBaseReferenceSpace) {\r\n this._xrSessionManager.resetReferenceSpace();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current instance class name (\"WebXRCamera\").\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"WebXRCamera\";\r\n }\r\n\r\n /**\r\n * Set the target for the camera to look at.\r\n * Note that this only rotates around the Y axis, as opposed to the default behavior of other cameras\r\n * @param target the target to set the camera to look at\r\n */\r\n public override setTarget(target: Vector3): void {\r\n // only rotate around the y axis!\r\n const tmpVector = TmpVectors.Vector3[1];\r\n target.subtractToRef(this.position, tmpVector);\r\n tmpVector.y = 0;\r\n tmpVector.normalize();\r\n const yRotation = Math.atan2(tmpVector.x, tmpVector.z) + (this._scene.useRightHandedSystem ? Math.PI : 0);\r\n this.rotationQuaternion.toEulerAnglesToRef(tmpVector);\r\n Quaternion.FromEulerAnglesToRef(tmpVector.x, yRotation, tmpVector.z, this.rotationQuaternion);\r\n }\r\n\r\n public override dispose() {\r\n this._xrSessionManager.onWorldScaleFactorChangedObservable.removeCallback(this._onWorldScaleFactorChanged);\r\n super.dispose();\r\n this._lastXRViewerPose = undefined;\r\n this.onTrackingStateChanged.clear();\r\n }\r\n\r\n private _updateDepthNearFar() {\r\n const far = (this.maxZ || 10000) * this._xrSessionManager.worldScalingFactor;\r\n const xrRenderState: XRRenderStateInit = {\r\n // if maxZ is 0 it should be \"Infinity\", but it doesn't work with the WebXR API. Setting to a large number.\r\n depthFar: far,\r\n depthNear: this.minZ,\r\n };\r\n\r\n this._xrSessionManager.updateRenderState(xrRenderState);\r\n this._cache.minZ = this.minZ;\r\n this._cache.maxZ = far;\r\n }\r\n\r\n private _updateFromXRSession() {\r\n const pose = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);\r\n this._lastXRViewerPose = pose || undefined;\r\n if (!pose) {\r\n this._setTrackingState(WebXRTrackingState.NOT_TRACKING);\r\n return;\r\n }\r\n\r\n // Set the tracking state. if it didn't change it is a no-op\r\n const trackingState = pose.emulatedPosition ? WebXRTrackingState.TRACKING_LOST : WebXRTrackingState.TRACKING;\r\n this._setTrackingState(trackingState);\r\n\r\n // check min/max Z and update if not the same as in cache\r\n if (this.minZ !== this._cache.minZ || this.maxZ !== this._cache.maxZ) {\r\n this._updateDepthNearFar();\r\n }\r\n\r\n if (pose.transform) {\r\n const orientation = pose.transform.orientation;\r\n if (pose.transform.orientation.x === undefined) {\r\n // Babylon native polyfill can return an undefined orientation value\r\n // When not initialized\r\n return;\r\n }\r\n const pos = pose.transform.position;\r\n this._referencedPosition.set(pos.x, pos.y, pos.z).scaleInPlace(this._xrSessionManager.worldScalingFactor);\r\n\r\n this._referenceQuaternion.set(orientation.x, orientation.y, orientation.z, orientation.w);\r\n if (!this._scene.useRightHandedSystem) {\r\n this._referencedPosition.z *= -1;\r\n this._referenceQuaternion.z *= -1;\r\n this._referenceQuaternion.w *= -1;\r\n }\r\n\r\n if (this._firstFrame) {\r\n this._firstFrame = false;\r\n // we have the XR reference, now use this to find the offset to get the camera to be\r\n // in the right position\r\n\r\n // set the height to correlate to the current height\r\n this.position.y += this._referencedPosition.y;\r\n // avoid using the head rotation on the first frame.\r\n this._referenceQuaternion.copyFromFloats(0, 0, 0, 1);\r\n } else {\r\n // update position and rotation as reference\r\n this.rotationQuaternion.copyFrom(this._referenceQuaternion);\r\n this.position.copyFrom(this._referencedPosition);\r\n }\r\n }\r\n\r\n // Update camera rigs\r\n if (this.rigCameras.length !== pose.views.length) {\r\n this._updateNumberOfRigCameras(pose.views.length);\r\n }\r\n\r\n for (let i = 0; i < pose.views.length; i++) {\r\n const view = pose.views[i];\r\n const currentRig = <TargetCamera>this.rigCameras[i];\r\n // update right and left, where applicable\r\n if (!currentRig.isLeftCamera && !currentRig.isRightCamera) {\r\n if (view.eye === \"right\") {\r\n currentRig._isRightCamera = true;\r\n } else if (view.eye === \"left\") {\r\n currentRig._isLeftCamera = true;\r\n }\r\n }\r\n // add any custom render targets to this camera, if available in the scene\r\n const customRenderTargets = this.getScene().customRenderTargets;\r\n // use a for loop\r\n for (let i = 0; i < customRenderTargets.length; i++) {\r\n const rt = customRenderTargets[i];\r\n // make sure we don't add the same render target twice\r\n if (currentRig.customRenderTargets.indexOf(rt) === -1) {\r\n currentRig.customRenderTargets.push(rt);\r\n }\r\n }\r\n // Update view/projection matrix\r\n const pos = view.transform.position;\r\n const orientation = view.transform.orientation;\r\n\r\n currentRig.parent = this.parent;\r\n\r\n currentRig.position.set(pos.x, pos.y, pos.z).scaleInPlace(this._xrSessionManager.worldScalingFactor);\r\n currentRig.rotationQuaternion?.set(orientation.x, orientation.y, orientation.z, orientation.w);\r\n if (!this._scene.useRightHandedSystem && currentRig.rotationQuaternion) {\r\n currentRig.position.z *= -1;\r\n currentRig.rotationQuaternion.z *= -1;\r\n currentRig.rotationQuaternion.w *= -1;\r\n }\r\n Matrix.FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, currentRig._projectionMatrix);\r\n\r\n // WebGPU uses a [0, 1] clip-space depth range (engine.isNDCHalfZRange === true) whereas WebGL/OpenGL uses\r\n // [-1, 1]. The rig cameras freeze their projection (see _updateNumberOfRigCameras) and take the XR binding's\r\n // projection matrix verbatim, bypassing the engine's range-aware projection builders. If the binding hands\r\n // back a [-1, 1]-convention matrix while the engine clips at [0, 1], every fragment with NDC z in [-1, 0)\r\n // is clipped and all geometry disappears. On a half-Z engine we therefore detect the convention the binding\r\n // actually used and convert a [-1, 1] matrix to [0, 1]. Detection is empirical (coefficient inspection is\r\n // provably ambiguous): project the view-space near-plane point through the raw matrix, before the hand\r\n // toggle. WebXR view space is right-handed (-Z forward), so the near point is (0, 0, -near); a [-1, 1] matrix\r\n // maps it to NDC z ~= -1, a [0, 1] matrix to ~= 0. Assumes a non-reverse-Z projection (near -> 0 or -1),\r\n // which UA-provided XR matrices are. WebGL2 (isNDCHalfZRange === false) never enters this block, so its path\r\n // is byte-identical.\r\n if (this._scene.getEngine().isNDCHalfZRange) {\r\n const near = this.minZ;\r\n let needsHalfZConversion: boolean;\r\n if (near > 0) {\r\n const ndc = Vector3.TransformCoordinatesFromFloatsToRef(0, 0, -near, currentRig._projectionMatrix, TmpVectors.Vector3[0]);\r\n needsHalfZConversion = ndc.z < -0.5;\r\n } else {\r\n // depthNear must be > 0 per the WebXR spec; if it is not, the near-plane probe would divide by zero,\r\n // so default to converting (matches the [-1, 1] range current XRGPUBinding implementations return).\r\n needsHalfZConversion = true;\r\n }\r\n if (needsHalfZConversion) {\r\n currentRig._projectionMatrix._convertProjectionToHalfZRangeInPlace();\r\n }\r\n }\r\n\r\n if (!this._scene.useRightHandedSystem) {\r\n currentRig._projectionMatrix.toggleProjectionMatrixHandInPlace();\r\n }\r\n\r\n // fov\r\n const fov = Math.atan2(1, view.projectionMatrix[5]) * 2;\r\n currentRig.fov = fov;\r\n // first camera?\r\n if (i === 0) {\r\n this.fov = fov;\r\n this._projectionMatrix.copyFrom(currentRig._projectionMatrix);\r\n }\r\n\r\n const renderTargetTexture = this._xrSessionManager.getRenderTargetTextureForView(view);\r\n this._renderingMultiview = renderTargetTexture?._texture?.isMultiview || false;\r\n if (this._renderingMultiview) {\r\n // For multiview, the render target texture is the same per-view (just the slice index is different),\r\n // so we only need to set the output render target once for the rig parent.\r\n if (i == 0) {\r\n this._xrSessionManager.trySetViewportForView(this.viewport, view);\r\n this.outputRenderTarget = renderTargetTexture;\r\n }\r\n } else {\r\n // Update viewport\r\n this._xrSessionManager.trySetViewportForView(currentRig.viewport, view);\r\n\r\n // Set cameras to render to the session's render target\r\n currentRig.outputRenderTarget = renderTargetTexture || this._xrSessionManager.getRenderTargetTextureForView(view);\r\n }\r\n\r\n // Replicate parent rig camera behavior\r\n currentRig.layerMask = this.layerMask;\r\n }\r\n }\r\n\r\n private _updateNumberOfRigCameras(viewCount = 1) {\r\n while (this.rigCameras.length < viewCount) {\r\n const newCamera = new TargetCamera(\"XR-RigCamera: \" + this.rigCameras.length, Vector3.Zero(), this.getScene());\r\n newCamera.minZ = 0.1;\r\n newCamera.rotationQuaternion = new Quaternion();\r\n newCamera.updateUpVectorFromRotation = true;\r\n newCamera.isRigCamera = true;\r\n newCamera.rigParent = this;\r\n // do not compute projection matrix, provided by XR\r\n newCamera.freezeProjectionMatrix();\r\n this.rigCameras.push(newCamera);\r\n }\r\n while (this.rigCameras.length > viewCount) {\r\n const removedCamera = this.rigCameras.pop();\r\n if (removedCamera) {\r\n removedCamera.dispose();\r\n }\r\n }\r\n }\r\n\r\n private _updateReferenceSpace() {\r\n // were position & rotation updated OUTSIDE of the xr update loop\r\n if (!this.position.equals(this._referencedPosition) || !this.rotationQuaternion.equals(this._referenceQuaternion)) {\r\n const referencedMat = TmpVectors.Matrix[0];\r\n const poseMat = TmpVectors.Matrix[1];\r\n const transformMat = TmpVectors.Matrix[2];\r\n\r\n Matrix.ComposeToRef(WebXRCamera._ScaleReadOnly, this._referenceQuaternion, this._referencedPosition, referencedMat);\r\n Matrix.ComposeToRef(WebXRCamera._ScaleReadOnly, this.rotationQuaternion, this.position, poseMat);\r\n referencedMat.invert().multiplyToRef(poseMat, transformMat);\r\n transformMat.invert();\r\n\r\n if (!this._scene.useRightHandedSystem) {\r\n transformMat.toggleModelMatrixHandInPlace();\r\n }\r\n\r\n transformMat.decompose(undefined, this._referenceQuaternion, this._referencedPosition);\r\n const transform = new XRRigidTransform(\r\n {\r\n x: this._referencedPosition.x / this._xrSessionManager.worldScalingFactor,\r\n y: this._referencedPosition.y / this._xrSessionManager.worldScalingFactor,\r\n z: this._referencedPosition.z / this._xrSessionManager.worldScalingFactor,\r\n w: 1,\r\n },\r\n {\r\n x: this._referenceQuaternion.x,\r\n y: this._referenceQuaternion.y,\r\n z: this._referenceQuaternion.z,\r\n w: this._referenceQuaternion.w,\r\n }\r\n );\r\n this._xrSessionManager.referenceSpace = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(transform);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webXRCamera.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEpF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAI/D;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IA2DvC;;;;;OAKG;IACH,YACI,IAAY,EACZ,KAAY,EACJ,iBAAsC;QAE9C,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;QAF3B,sBAAiB,GAAjB,iBAAiB,CAAqB;QAjE1C,gBAAW,GAAG,KAAK,CAAC;QACpB,2BAAsB,GAAkC,IAAI,CAAC;QAC7D,qBAAgB,GAAgC,IAAI,CAAC;QACrD,yBAAoB,GAAe,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzD,wBAAmB,GAAY,IAAI,OAAO,EAAE,CAAC;QAC7C,mBAAc,2CAAuD;QAErE,+BAA0B,GAAG,GAAG,EAAE;YACtC,yBAAyB;YACzB,IAAI,CAAC,IAAI,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} from \"../scene\";\r\nimport { Camera } from \"../Cameras/camera.pure\";\r\nimport { FreeCamera } from \"../Cameras/freeCamera.pure\";\r\nimport { TargetCamera } from \"../Cameras/targetCamera.pure\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport { Viewport } from \"../Maths/math.viewport\";\r\nimport { Observable, type Observer } from \"../Misc/observable\";\r\nimport { WebXRTrackingState } from \"./webXRTypes\";\r\nimport { type Nullable } from \"../types\";\r\n\r\n/**\r\n * WebXR Camera which holds the views for the xrSession\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/webXR/webXRCamera\r\n */\r\nexport class WebXRCamera extends FreeCamera {\r\n private static _ScaleReadOnly = Vector3.One();\r\n\r\n private _firstFrame = false;\r\n private _xrSessionInitObserver: Nullable<Observer<XRSession>> = null;\r\n private _xrFrameObserver: Nullable<Observer<XRFrame>> = null;\r\n private _referenceQuaternion: Quaternion = Quaternion.Identity();\r\n private _referencedPosition: Vector3 = new Vector3();\r\n private _trackingState: WebXRTrackingState = WebXRTrackingState.NOT_TRACKING;\r\n\r\n private _onWorldScaleFactorChanged = () => {\r\n // only run if in session\r\n if (!this._xrSessionManager.currentFrame) {\r\n return;\r\n }\r\n this._updateDepthNearFar();\r\n };\r\n\r\n /**\r\n * This will be triggered after the first XR Frame initialized the camera,\r\n * including the right number of views and their rendering parameters\r\n */\r\n public onXRCameraInitializedObservable = new Observable<WebXRCamera>();\r\n\r\n /**\r\n * Observable raised before camera teleportation\r\n * @deprecated use onBeforeCameraTeleport of the teleportation feature instead\r\n */\r\n public onBeforeCameraTeleport = new Observable<Vector3>();\r\n\r\n /**\r\n * Observable raised after camera teleportation\r\n * @deprecated use onAfterCameraTeleport of the teleportation feature instead\r\n */\r\n public onAfterCameraTeleport = new Observable<Vector3>();\r\n\r\n /**\r\n * Notifies when the camera's tracking state has changed.\r\n * Notice - will also be triggered when tracking has started (at the beginning of the session)\r\n */\r\n public onTrackingStateChanged = new Observable<WebXRTrackingState>();\r\n\r\n /**\r\n * Should position compensation execute on first frame.\r\n * This is used when copying the position from a native (non XR) camera\r\n */\r\n public compensateOnFirstFrame: boolean = true;\r\n\r\n /**\r\n * The last XRViewerPose from the current XRFrame\r\n * @internal\r\n */\r\n public _lastXRViewerPose?: XRViewerPose;\r\n\r\n /**\r\n * webXRCamera relies on rotationQuaternion and doesn't use camera rotation property\r\n */\r\n public override rotationQuaternion: Quaternion;\r\n\r\n /**\r\n * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager\r\n * @param name the name of the camera\r\n * @param scene the scene to add the camera to\r\n * @param _xrSessionManager a constructed xr session manager\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n private _xrSessionManager: WebXRSessionManager\r\n ) {\r\n super(name, Vector3.Zero(), scene);\r\n\r\n // Initial camera configuration\r\n this.minZ = 0.1;\r\n this.rotationQuaternion = new Quaternion();\r\n this.cameraRigMode = Camera.RIG_MODE_CUSTOM;\r\n this.updateUpVectorFromRotation = true;\r\n this._updateNumberOfRigCameras(1);\r\n // freeze projection matrix, which will be copied later\r\n this.freezeProjectionMatrix();\r\n this._deferOnly = true;\r\n\r\n this._xrSessionInitObserver = this._xrSessionManager.onXRSessionInit.add(() => {\r\n this._referencedPosition.copyFromFloats(0, 0, 0);\r\n this._referenceQuaternion.copyFromFloats(0, 0, 0, 1);\r\n // first frame - camera's y position should be 0 for the correct offset\r\n this._firstFrame = this.compensateOnFirstFrame;\r\n });\r\n\r\n this._xrSessionManager.onWorldScaleFactorChangedObservable.add(this._onWorldScaleFactorChanged);\r\n\r\n // Check transformation changes on each frame. Callback is added to be first so that the transformation will be\r\n // applied to the rest of the elements using the referenceSpace object\r\n this._xrFrameObserver = this._xrSessionManager.onXRFrameObservable.add(\r\n () => {\r\n if (this._firstFrame) {\r\n this._updateFromXRSession();\r\n }\r\n if (this.onXRCameraInitializedObservable.hasObservers()) {\r\n this.onXRCameraInitializedObservable.notifyObservers(this);\r\n this.onXRCameraInitializedObservable.clear();\r\n }\r\n\r\n if (this._deferredUpdated) {\r\n this.position.copyFrom(this._deferredPositionUpdate);\r\n this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate);\r\n }\r\n\r\n this._updateReferenceSpace();\r\n this._updateFromXRSession();\r\n },\r\n undefined,\r\n true\r\n );\r\n }\r\n\r\n /**\r\n * Get the current XR tracking state of the camera\r\n */\r\n public get trackingState(): WebXRTrackingState {\r\n return this._trackingState;\r\n }\r\n\r\n private _setTrackingState(newState: WebXRTrackingState) {\r\n if (this._trackingState !== newState) {\r\n this._trackingState = newState;\r\n this.onTrackingStateChanged.notifyObservers(newState);\r\n }\r\n }\r\n\r\n /**\r\n * Return the user's height, unrelated to the current ground.\r\n * This will be the y position of this camera, when ground level is 0.\r\n *\r\n * Note - this value is multiplied by the worldScalingFactor (if set), so it will be in the same units as the scene.\r\n */\r\n public get realWorldHeight(): number {\r\n const basePose = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);\r\n if (basePose && basePose.transform) {\r\n return basePose.transform.position.y * this._xrSessionManager.worldScalingFactor;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _updateForDualEyeDebugging(/*pupilDistance = 0.01*/) {\r\n // Create initial camera rigs\r\n this._updateNumberOfRigCameras(2);\r\n this.rigCameras[0].viewport = new Viewport(0, 0, 0.5, 1.0);\r\n // this.rigCameras[0].position.x = -pupilDistance / 2;\r\n this.rigCameras[0].outputRenderTarget = null;\r\n this.rigCameras[1].viewport = new Viewport(0.5, 0, 0.5, 1.0);\r\n // this.rigCameras[1].position.x = pupilDistance / 2;\r\n this.rigCameras[1].outputRenderTarget = null;\r\n }\r\n\r\n /**\r\n * Sets this camera's transformation based on a non-vr camera\r\n * @param otherCamera the non-vr camera to copy the transformation from\r\n * @param resetToBaseReferenceSpace should XR reset to the base reference space\r\n */\r\n public setTransformationFromNonVRCamera(otherCamera: Camera = this.getScene().activeCamera!, resetToBaseReferenceSpace: boolean = true) {\r\n if (!otherCamera || otherCamera === this) {\r\n return;\r\n }\r\n const mat = otherCamera.computeWorldMatrix();\r\n mat.decompose(undefined, this.rotationQuaternion, this.position);\r\n // set the ground level\r\n this.position.y = 0;\r\n Quaternion.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion);\r\n this._firstFrame = true;\r\n if (resetToBaseReferenceSpace) {\r\n this._xrSessionManager.resetReferenceSpace();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current instance class name (\"WebXRCamera\").\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"WebXRCamera\";\r\n }\r\n\r\n /**\r\n * Set the target for the camera to look at.\r\n * Note that this only rotates around the Y axis, as opposed to the default behavior of other cameras\r\n * @param target the target to set the camera to look at\r\n */\r\n public override setTarget(target: Vector3): void {\r\n // only rotate around the y axis!\r\n const tmpVector = TmpVectors.Vector3[1];\r\n target.subtractToRef(this.position, tmpVector);\r\n tmpVector.y = 0;\r\n tmpVector.normalize();\r\n const yRotation = Math.atan2(tmpVector.x, tmpVector.z) + (this._scene.useRightHandedSystem ? Math.PI : 0);\r\n this.rotationQuaternion.toEulerAnglesToRef(tmpVector);\r\n Quaternion.FromEulerAnglesToRef(tmpVector.x, yRotation, tmpVector.z, this.rotationQuaternion);\r\n }\r\n\r\n public override dispose() {\r\n this._xrSessionManager.onWorldScaleFactorChangedObservable.removeCallback(this._onWorldScaleFactorChanged);\r\n this._xrSessionManager.onXRSessionInit.remove(this._xrSessionInitObserver);\r\n this._xrSessionInitObserver = null;\r\n this._xrSessionManager.onXRFrameObservable.remove(this._xrFrameObserver);\r\n this._xrFrameObserver = null;\r\n super.dispose();\r\n this._lastXRViewerPose = undefined;\r\n this.onTrackingStateChanged.clear();\r\n }\r\n\r\n private _updateDepthNearFar() {\r\n const far = (this.maxZ || 10000) * this._xrSessionManager.worldScalingFactor;\r\n const xrRenderState: XRRenderStateInit = {\r\n // if maxZ is 0 it should be \"Infinity\", but it doesn't work with the WebXR API. Setting to a large number.\r\n depthFar: far,\r\n depthNear: this.minZ,\r\n };\r\n\r\n this._xrSessionManager.updateRenderState(xrRenderState);\r\n this._cache.minZ = this.minZ;\r\n this._cache.maxZ = far;\r\n }\r\n\r\n private _updateFromXRSession() {\r\n const pose = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);\r\n this._lastXRViewerPose = pose || undefined;\r\n if (!pose) {\r\n this._setTrackingState(WebXRTrackingState.NOT_TRACKING);\r\n return;\r\n }\r\n\r\n // Set the tracking state. if it didn't change it is a no-op\r\n const trackingState = pose.emulatedPosition ? WebXRTrackingState.TRACKING_LOST : WebXRTrackingState.TRACKING;\r\n this._setTrackingState(trackingState);\r\n\r\n // check min/max Z and update if not the same as in cache\r\n if (this.minZ !== this._cache.minZ || this.maxZ !== this._cache.maxZ) {\r\n this._updateDepthNearFar();\r\n }\r\n\r\n if (pose.transform) {\r\n const orientation = pose.transform.orientation;\r\n if (pose.transform.orientation.x === undefined) {\r\n // Babylon native polyfill can return an undefined orientation value\r\n // When not initialized\r\n return;\r\n }\r\n const pos = pose.transform.position;\r\n this._referencedPosition.set(pos.x, pos.y, pos.z).scaleInPlace(this._xrSessionManager.worldScalingFactor);\r\n\r\n this._referenceQuaternion.set(orientation.x, orientation.y, orientation.z, orientation.w);\r\n if (!this._scene.useRightHandedSystem) {\r\n this._referencedPosition.z *= -1;\r\n this._referenceQuaternion.z *= -1;\r\n this._referenceQuaternion.w *= -1;\r\n }\r\n\r\n if (this._firstFrame) {\r\n this._firstFrame = false;\r\n // we have the XR reference, now use this to find the offset to get the camera to be\r\n // in the right position\r\n\r\n // set the height to correlate to the current height\r\n this.position.y += this._referencedPosition.y;\r\n // avoid using the head rotation on the first frame.\r\n this._referenceQuaternion.copyFromFloats(0, 0, 0, 1);\r\n } else {\r\n // update position and rotation as reference\r\n this.rotationQuaternion.copyFrom(this._referenceQuaternion);\r\n this.position.copyFrom(this._referencedPosition);\r\n }\r\n }\r\n\r\n // Update camera rigs\r\n if (this.rigCameras.length !== pose.views.length) {\r\n this._updateNumberOfRigCameras(pose.views.length);\r\n }\r\n\r\n for (let i = 0; i < pose.views.length; i++) {\r\n const view = pose.views[i];\r\n const currentRig = <TargetCamera>this.rigCameras[i];\r\n // update right and left, where applicable\r\n if (!currentRig.isLeftCamera && !currentRig.isRightCamera) {\r\n if (view.eye === \"right\") {\r\n currentRig._isRightCamera = true;\r\n } else if (view.eye === \"left\") {\r\n currentRig._isLeftCamera = true;\r\n }\r\n }\r\n // add any custom render targets to this camera, if available in the scene\r\n const customRenderTargets = this.getScene().customRenderTargets;\r\n // use a for loop\r\n for (let i = 0; i < customRenderTargets.length; i++) {\r\n const rt = customRenderTargets[i];\r\n // make sure we don't add the same render target twice\r\n if (currentRig.customRenderTargets.indexOf(rt) === -1) {\r\n currentRig.customRenderTargets.push(rt);\r\n }\r\n }\r\n // Update view/projection matrix\r\n const pos = view.transform.position;\r\n const orientation = view.transform.orientation;\r\n\r\n currentRig.parent = this.parent;\r\n\r\n currentRig.position.set(pos.x, pos.y, pos.z).scaleInPlace(this._xrSessionManager.worldScalingFactor);\r\n currentRig.rotationQuaternion?.set(orientation.x, orientation.y, orientation.z, orientation.w);\r\n if (!this._scene.useRightHandedSystem && currentRig.rotationQuaternion) {\r\n currentRig.position.z *= -1;\r\n currentRig.rotationQuaternion.z *= -1;\r\n currentRig.rotationQuaternion.w *= -1;\r\n }\r\n Matrix.FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, currentRig._projectionMatrix);\r\n\r\n // WebGPU uses a [0, 1] clip-space depth range (engine.isNDCHalfZRange === true) whereas WebGL/OpenGL uses\r\n // [-1, 1]. The rig cameras freeze their projection (see _updateNumberOfRigCameras) and take the XR binding's\r\n // projection matrix verbatim, bypassing the engine's range-aware projection builders. If the binding hands\r\n // back a [-1, 1]-convention matrix while the engine clips at [0, 1], every fragment with NDC z in [-1, 0)\r\n // is clipped and all geometry disappears. On a half-Z engine we therefore detect the convention the binding\r\n // actually used and convert a [-1, 1] matrix to [0, 1]. Detection is empirical (coefficient inspection is\r\n // provably ambiguous): project the view-space near-plane point through the raw matrix, before the hand\r\n // toggle. WebXR view space is right-handed (-Z forward), so the near point is (0, 0, -near); a [-1, 1] matrix\r\n // maps it to NDC z ~= -1, a [0, 1] matrix to ~= 0. Assumes a non-reverse-Z projection (near -> 0 or -1),\r\n // which UA-provided XR matrices are. WebGL2 (isNDCHalfZRange === false) never enters this block, so its path\r\n // is byte-identical.\r\n if (this._scene.getEngine().isNDCHalfZRange) {\r\n const near = this.minZ;\r\n let needsHalfZConversion: boolean;\r\n if (near > 0) {\r\n const ndc = Vector3.TransformCoordinatesFromFloatsToRef(0, 0, -near, currentRig._projectionMatrix, TmpVectors.Vector3[0]);\r\n needsHalfZConversion = ndc.z < -0.5;\r\n } else {\r\n // depthNear must be > 0 per the WebXR spec; if it is not, the near-plane probe would divide by zero,\r\n // so default to converting (matches the [-1, 1] range current XRGPUBinding implementations return).\r\n needsHalfZConversion = true;\r\n }\r\n if (needsHalfZConversion) {\r\n currentRig._projectionMatrix._convertProjectionToHalfZRangeInPlace();\r\n }\r\n }\r\n\r\n if (!this._scene.useRightHandedSystem) {\r\n currentRig._projectionMatrix.toggleProjectionMatrixHandInPlace();\r\n }\r\n\r\n // fov\r\n const fov = Math.atan2(1, view.projectionMatrix[5]) * 2;\r\n currentRig.fov = fov;\r\n // first camera?\r\n if (i === 0) {\r\n this.fov = fov;\r\n this._projectionMatrix.copyFrom(currentRig._projectionMatrix);\r\n }\r\n\r\n const renderTargetTexture = this._xrSessionManager.getRenderTargetTextureForView(view);\r\n this._renderingMultiview = renderTargetTexture?._texture?.isMultiview || false;\r\n if (this._renderingMultiview) {\r\n // For multiview, the render target texture is the same per-view (just the slice index is different),\r\n // so we only need to set the output render target once for the rig parent.\r\n if (i == 0) {\r\n this._xrSessionManager.trySetViewportForView(this.viewport, view);\r\n this.outputRenderTarget = renderTargetTexture;\r\n }\r\n } else {\r\n // Update viewport\r\n this._xrSessionManager.trySetViewportForView(currentRig.viewport, view);\r\n\r\n // Set cameras to render to the session's render target\r\n currentRig.outputRenderTarget = renderTargetTexture || this._xrSessionManager.getRenderTargetTextureForView(view);\r\n }\r\n\r\n // Replicate parent rig camera behavior\r\n currentRig.layerMask = this.layerMask;\r\n }\r\n }\r\n\r\n private _updateNumberOfRigCameras(viewCount = 1) {\r\n while (this.rigCameras.length < viewCount) {\r\n const newCamera = new TargetCamera(\"XR-RigCamera: \" + this.rigCameras.length, Vector3.Zero(), this.getScene());\r\n newCamera.minZ = 0.1;\r\n newCamera.rotationQuaternion = new Quaternion();\r\n newCamera.updateUpVectorFromRotation = true;\r\n newCamera.isRigCamera = true;\r\n newCamera.rigParent = this;\r\n // do not compute projection matrix, provided by XR\r\n newCamera.freezeProjectionMatrix();\r\n this.rigCameras.push(newCamera);\r\n }\r\n while (this.rigCameras.length > viewCount) {\r\n const removedCamera = this.rigCameras.pop();\r\n if (removedCamera) {\r\n removedCamera.dispose();\r\n }\r\n }\r\n }\r\n\r\n private _updateReferenceSpace() {\r\n // were position & rotation updated OUTSIDE of the xr update loop\r\n if (!this.position.equals(this._referencedPosition) || !this.rotationQuaternion.equals(this._referenceQuaternion)) {\r\n const referencedMat = TmpVectors.Matrix[0];\r\n const poseMat = TmpVectors.Matrix[1];\r\n const transformMat = TmpVectors.Matrix[2];\r\n\r\n Matrix.ComposeToRef(WebXRCamera._ScaleReadOnly, this._referenceQuaternion, this._referencedPosition, referencedMat);\r\n Matrix.ComposeToRef(WebXRCamera._ScaleReadOnly, this.rotationQuaternion, this.position, poseMat);\r\n referencedMat.invert().multiplyToRef(poseMat, transformMat);\r\n transformMat.invert();\r\n\r\n if (!this._scene.useRightHandedSystem) {\r\n transformMat.toggleModelMatrixHandInPlace();\r\n }\r\n\r\n transformMat.decompose(undefined, this._referenceQuaternion, this._referencedPosition);\r\n const transform = new XRRigidTransform(\r\n {\r\n x: this._referencedPosition.x / this._xrSessionManager.worldScalingFactor,\r\n y: this._referencedPosition.y / this._xrSessionManager.worldScalingFactor,\r\n z: this._referencedPosition.z / this._xrSessionManager.worldScalingFactor,\r\n w: 1,\r\n },\r\n {\r\n x: this._referenceQuaternion.x,\r\n y: this._referenceQuaternion.y,\r\n z: this._referenceQuaternion.z,\r\n w: this._referenceQuaternion.w,\r\n }\r\n );\r\n this._xrSessionManager.referenceSpace = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(transform);\r\n }\r\n }\r\n}\r\n"]}
@@ -3,14 +3,21 @@ import { type WebXRLayerRenderTargetTextureProvider } from "./webXRRenderTargetT
3
3
  import { type WebXRSessionManager } from "./webXRSessionManager.js";
4
4
  /** Covers all supported subclasses of WebXR's XRCompositionLayer */
5
5
  export type WebXRCompositionLayerType = "XRProjectionLayer";
6
+ /**
7
+ * The quad-layer type name.
8
+ */
6
9
  export type WebXRQuadLayerType = "XRQuadLayer";
7
10
  /** Covers all supported subclasses of WebXR's XRLayer */
8
11
  export type WebXRLayerType = "XRWebGLLayer" | WebXRCompositionLayerType | WebXRQuadLayerType;
12
+ /** Covers the spatial composition-layer types supported by WebXRLayers. */
13
+ export type WebXRSpatialLayerType = WebXRQuadLayerType | "XRCylinderLayer" | "XREquirectLayer" | "XRCubeLayer";
14
+ /** Covers every native layer type supported by Babylon.js. */
15
+ export type WebXRSupportedLayerType = WebXRLayerType | WebXRSpatialLayerType;
9
16
  /**
10
17
  * Wrapper over subclasses of XRLayer.
11
18
  * @internal
12
19
  */
13
- export declare class WebXRLayerWrapper {
20
+ export declare class WebXRLayerWrapper<LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType> {
14
21
  /** The width of the layer's framebuffer. */
15
22
  getWidth: () => number;
16
23
  /** The height of the layer's framebuffer. */
@@ -18,10 +25,14 @@ export declare class WebXRLayerWrapper {
18
25
  /** The XR layer that this WebXRLayerWrapper wraps. */
19
26
  readonly layer: XRLayer;
20
27
  /** The type of XR layer that is being wrapped. */
21
- readonly layerType: WebXRLayerType;
28
+ readonly layerType: LayerTypeT;
22
29
  /** Create a render target provider for the wrapped layer. */
23
30
  private _createRenderTargetTextureProvider;
24
31
  private _rttWrapper;
32
+ /**
33
+ * The render target provider created for this layer, or `null` until one is created.
34
+ */
35
+ get renderTargetTextureProvider(): Nullable<WebXRLayerRenderTargetTextureProvider<LayerTypeT>>;
25
36
  /**
26
37
  * Check if fixed foveation is supported on this device
27
38
  */
@@ -41,7 +52,10 @@ export declare class WebXRLayerWrapper {
41
52
  * @param xrSessionManager The XR Session Manager
42
53
  * @returns A new render target texture provider for the wrapped layer.
43
54
  */
44
- createRenderTargetTextureProvider(xrSessionManager: WebXRSessionManager): WebXRLayerRenderTargetTextureProvider;
55
+ createRenderTargetTextureProvider(xrSessionManager: WebXRSessionManager): WebXRLayerRenderTargetTextureProvider<LayerTypeT>;
56
+ /**
57
+ * Disposes the render target provider created for this layer.
58
+ */
45
59
  dispose(): void;
46
60
  protected constructor(
47
61
  /** The width of the layer's framebuffer. */
@@ -51,7 +65,7 @@ export declare class WebXRLayerWrapper {
51
65
  /** The XR layer that this WebXRLayerWrapper wraps. */
52
66
  layer: XRLayer,
53
67
  /** The type of XR layer that is being wrapped. */
54
- layerType: WebXRLayerType,
68
+ layerType: LayerTypeT,
55
69
  /** Create a render target provider for the wrapped layer. */
56
- _createRenderTargetTextureProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider);
70
+ _createRenderTargetTextureProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider<LayerTypeT>);
57
71
  }
@@ -3,6 +3,12 @@
3
3
  * @internal
4
4
  */
5
5
  export class WebXRLayerWrapper {
6
+ /**
7
+ * The render target provider created for this layer, or `null` until one is created.
8
+ */
9
+ get renderTargetTextureProvider() {
10
+ return this._rttWrapper;
11
+ }
6
12
  /**
7
13
  * Check if fixed foveation is supported on this device
8
14
  */
@@ -38,6 +44,9 @@ export class WebXRLayerWrapper {
38
44
  this._rttWrapper = this._createRenderTargetTextureProvider(xrSessionManager);
39
45
  return this._rttWrapper;
40
46
  }
47
+ /**
48
+ * Disposes the render target provider created for this layer.
49
+ */
41
50
  dispose() {
42
51
  if (this._rttWrapper) {
43
52
  this._rttWrapper.dispose();
@@ -1 +1 @@
1
- {"version":3,"file":"webXRLayerWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRLayerWrapper.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAE1B;;OAEG;IACH,IAAW,yBAAyB;QAChC,OAAO,IAAI,CAAC,SAAS,IAAI,cAAc,IAAI,OAAQ,IAAI,CAAC,KAAsB,CAAC,cAAc,IAAI,QAAQ,CAAC;IAC9G,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACrB,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;YACjC,OAAQ,IAAI,CAAC,KAAsB,CAAC,cAAe,CAAC;QACxD,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc,CAAC,KAAuB;QAC7C,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;YACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;YAChD,IAAI,CAAC,KAAsB,CAAC,cAAc,GAAG,GAAG,CAAC;QACtD,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,iCAAiC,CAAC,gBAAqC;QAC1E,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,kCAAkC,CAAC,gBAAgB,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAEM,OAAO;QACV,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC5B,CAAC;IACL,CAAC;IAED;IACI,4CAA4C;IACrC,QAAsB;IAC7B,6CAA6C;IACtC,SAAuB;IAC9B,sDAAsD;IACtC,KAAc;IAC9B,kDAAkD;IAClC,SAAyB;IACzC,6DAA6D;IACrD,kCAAoH;QARrH,aAAQ,GAAR,QAAQ,CAAc;QAEtB,cAAS,GAAT,SAAS,CAAc;QAEd,UAAK,GAAL,KAAK,CAAS;QAEd,cAAS,GAAT,SAAS,CAAgB;QAEjC,uCAAkC,GAAlC,kCAAkC,CAAkF;QAzDxH,gBAAW,GAAoD,IAAI,CAAC;IA0DzE,CAAC;CACP","sourcesContent":["import { type Nullable } from \"../types\";\r\nimport { type WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\n\r\n/** Covers all supported subclasses of WebXR's XRCompositionLayer */\r\n// TODO (rgerd): Extend for all other subclasses of XRCompositionLayer.\r\nexport type WebXRCompositionLayerType = \"XRProjectionLayer\";\r\nexport type WebXRQuadLayerType = \"XRQuadLayer\";\r\n\r\n/** Covers all supported subclasses of WebXR's XRLayer */\r\nexport type WebXRLayerType = \"XRWebGLLayer\" | WebXRCompositionLayerType | WebXRQuadLayerType;\r\n\r\n/**\r\n * Wrapper over subclasses of XRLayer.\r\n * @internal\r\n */\r\nexport class WebXRLayerWrapper {\r\n private _rttWrapper: Nullable<WebXRLayerRenderTargetTextureProvider> = null;\r\n /**\r\n * Check if fixed foveation is supported on this device\r\n */\r\n public get isFixedFoveationSupported(): boolean {\r\n return this.layerType == \"XRWebGLLayer\" && typeof (this.layer as XRWebGLLayer).fixedFoveation == \"number\";\r\n }\r\n\r\n /**\r\n * Get the fixed foveation currently set, as specified by the webxr specs\r\n * If this returns null, then fixed foveation is not supported\r\n */\r\n public get fixedFoveation(): Nullable<number> {\r\n if (this.isFixedFoveationSupported) {\r\n return (this.layer as XRWebGLLayer).fixedFoveation!;\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Set the fixed foveation to the specified value, as specified by the webxr specs\r\n * This value will be normalized to be between 0 and 1, 1 being max foveation, 0 being no foveation\r\n */\r\n public set fixedFoveation(value: Nullable<number>) {\r\n if (this.isFixedFoveationSupported) {\r\n const val = Math.max(0, Math.min(1, value || 0));\r\n (this.layer as XRWebGLLayer).fixedFoveation = val;\r\n }\r\n }\r\n\r\n /**\r\n * Create a render target provider for the wrapped layer.\r\n * @param xrSessionManager The XR Session Manager\r\n * @returns A new render target texture provider for the wrapped layer.\r\n */\r\n public createRenderTargetTextureProvider(xrSessionManager: WebXRSessionManager): WebXRLayerRenderTargetTextureProvider {\r\n this._rttWrapper = this._createRenderTargetTextureProvider(xrSessionManager);\r\n return this._rttWrapper;\r\n }\r\n\r\n public dispose(): void {\r\n if (this._rttWrapper) {\r\n this._rttWrapper.dispose();\r\n this._rttWrapper = null;\r\n }\r\n }\r\n\r\n protected constructor(\r\n /** The width of the layer's framebuffer. */\r\n public getWidth: () => number,\r\n /** The height of the layer's framebuffer. */\r\n public getHeight: () => number,\r\n /** The XR layer that this WebXRLayerWrapper wraps. */\r\n public readonly layer: XRLayer,\r\n /** The type of XR layer that is being wrapped. */\r\n public readonly layerType: WebXRLayerType,\r\n /** Create a render target provider for the wrapped layer. */\r\n private _createRenderTargetTextureProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider\r\n ) {}\r\n}\r\n"]}
1
+ {"version":3,"file":"webXRLayerWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRLayerWrapper.ts"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAG1B;;OAEG;IACH,IAAW,2BAA2B;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD;;OAEG;IACH,IAAW,yBAAyB;QAChC,OAAO,IAAI,CAAC,SAAS,IAAI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AgE,IAAI,CAAC;IAoErF,CAAC;CACP","sourcesContent":["import { type Nullable } from \"../types\";\r\nimport { type WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\n\r\n/** Covers all supported subclasses of WebXR's XRCompositionLayer */\r\nexport type WebXRCompositionLayerType = \"XRProjectionLayer\";\r\n\r\n/**\r\n * The quad-layer type name.\r\n */\r\nexport type WebXRQuadLayerType = \"XRQuadLayer\";\r\n\r\n/** Covers all supported subclasses of WebXR's XRLayer */\r\nexport type WebXRLayerType = \"XRWebGLLayer\" | WebXRCompositionLayerType | WebXRQuadLayerType;\r\n\r\n/** Covers the spatial composition-layer types supported by WebXRLayers. */\r\nexport type WebXRSpatialLayerType = WebXRQuadLayerType | \"XRCylinderLayer\" | \"XREquirectLayer\" | \"XRCubeLayer\";\r\n\r\n/** Covers every native layer type supported by Babylon.js. */\r\nexport type WebXRSupportedLayerType = WebXRLayerType | WebXRSpatialLayerType;\r\n\r\n/**\r\n * Wrapper over subclasses of XRLayer.\r\n * @internal\r\n */\r\nexport class WebXRLayerWrapper<LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType> {\r\n private _rttWrapper: Nullable<WebXRLayerRenderTargetTextureProvider<LayerTypeT>> = null;\r\n\r\n /**\r\n * The render target provider created for this layer, or `null` until one is created.\r\n */\r\n public get renderTargetTextureProvider(): Nullable<WebXRLayerRenderTargetTextureProvider<LayerTypeT>> {\r\n return this._rttWrapper;\r\n }\r\n /**\r\n * Check if fixed foveation is supported on this device\r\n */\r\n public get isFixedFoveationSupported(): boolean {\r\n return this.layerType == \"XRWebGLLayer\" && typeof (this.layer as XRWebGLLayer).fixedFoveation == \"number\";\r\n }\r\n\r\n /**\r\n * Get the fixed foveation currently set, as specified by the webxr specs\r\n * If this returns null, then fixed foveation is not supported\r\n */\r\n public get fixedFoveation(): Nullable<number> {\r\n if (this.isFixedFoveationSupported) {\r\n return (this.layer as XRWebGLLayer).fixedFoveation!;\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Set the fixed foveation to the specified value, as specified by the webxr specs\r\n * This value will be normalized to be between 0 and 1, 1 being max foveation, 0 being no foveation\r\n */\r\n public set fixedFoveation(value: Nullable<number>) {\r\n if (this.isFixedFoveationSupported) {\r\n const val = Math.max(0, Math.min(1, value || 0));\r\n (this.layer as XRWebGLLayer).fixedFoveation = val;\r\n }\r\n }\r\n\r\n /**\r\n * Create a render target provider for the wrapped layer.\r\n * @param xrSessionManager The XR Session Manager\r\n * @returns A new render target texture provider for the wrapped layer.\r\n */\r\n public createRenderTargetTextureProvider(xrSessionManager: WebXRSessionManager): WebXRLayerRenderTargetTextureProvider<LayerTypeT> {\r\n this._rttWrapper = this._createRenderTargetTextureProvider(xrSessionManager);\r\n return this._rttWrapper;\r\n }\r\n\r\n /**\r\n * Disposes the render target provider created for this layer.\r\n */\r\n public dispose(): void {\r\n if (this._rttWrapper) {\r\n this._rttWrapper.dispose();\r\n this._rttWrapper = null;\r\n }\r\n }\r\n\r\n protected constructor(\r\n /** The width of the layer's framebuffer. */\r\n public getWidth: () => number,\r\n /** The height of the layer's framebuffer. */\r\n public getHeight: () => number,\r\n /** The XR layer that this WebXRLayerWrapper wraps. */\r\n public readonly layer: XRLayer,\r\n /** The type of XR layer that is being wrapped. */\r\n public readonly layerType: LayerTypeT,\r\n /** Create a render target provider for the wrapped layer. */\r\n private _createRenderTargetTextureProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider<LayerTypeT>\r\n ) {}\r\n}\r\n"]}
@@ -4,7 +4,7 @@ import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.p
4
4
  import { type Viewport } from "../Maths/math.viewport.js";
5
5
  import { type IDisposable, type Scene } from "../scene.js";
6
6
  import { type Nullable } from "../types.js";
7
- import { type WebXRLayerWrapper } from "./webXRLayerWrapper.js";
7
+ import { type WebXRLayerType, type WebXRLayerWrapper, type WebXRSupportedLayerType } from "./webXRLayerWrapper.js";
8
8
  /**
9
9
  * An interface for objects that provide render target textures for XR rendering.
10
10
  */
@@ -34,9 +34,9 @@ export interface IWebXRRenderTargetTextureProvider extends IDisposable {
34
34
  * Provides render target textures and other important rendering information for a given XRLayer.
35
35
  * @internal
36
36
  */
37
- export declare abstract class WebXRLayerRenderTargetTextureProvider implements IWebXRRenderTargetTextureProvider {
37
+ export declare abstract class WebXRLayerRenderTargetTextureProvider<LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType> implements IWebXRRenderTargetTextureProvider {
38
38
  protected readonly _scene: Scene;
39
- readonly layerWrapper: WebXRLayerWrapper;
39
+ readonly layerWrapper: WebXRLayerWrapper<LayerTypeT>;
40
40
  abstract trySetViewportForView(viewport: Viewport, view: XRView): boolean;
41
41
  abstract getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;
42
42
  abstract getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;
@@ -46,7 +46,7 @@ export declare abstract class WebXRLayerRenderTargetTextureProvider implements I
46
46
  framebufferHeight: number;
47
47
  }>;
48
48
  protected _engine: AbstractEngine;
49
- constructor(_scene: Scene, layerWrapper: WebXRLayerWrapper);
49
+ constructor(_scene: Scene, layerWrapper: WebXRLayerWrapper<LayerTypeT>);
50
50
  /**
51
51
  * Creates the render target texture "shell" (with the correct multiview type and MSAA sample count)
52
52
  * without attaching any graphics-API-specific resource. Subclasses attach their own textures.
@@ -1 +1 @@
1
- {"version":3,"file":"webXRRenderTargetTextureProvider.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRRenderTargetTextureProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAgCrF;;;GAGG;AACH,MAAM,OAAgB,qCAAqC;IAUvD,YACuB,MAAa,EAChB,YAA+B;QAD5B,WAAM,GAAN,MAAM,CAAO;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AAgB,EAAE,CAAC;QAEvC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAErD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAES,2BAA2B,CAAC,mBAAwC;QAC1E,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9F,mBAAmB,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAEM,wBAAwB;QAC3B,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IAEM,OAAO;QACV,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC3C,GAAG,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import { type AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { type InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { MultiviewRenderTarget } from \"../Materials/Textures/MultiviewRenderTarget\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture.pure\";\r\nimport { type Viewport } from \"../Maths/math.viewport\";\r\nimport { type IDisposable, type Scene } from \"../scene\";\r\nimport { type Nullable } from \"../types\";\r\nimport { type WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\n\r\n/**\r\n * An interface for objects that provide render target textures for XR rendering.\r\n */\r\nexport interface IWebXRRenderTargetTextureProvider extends IDisposable {\r\n /**\r\n * Attempts to set the framebuffer-size-normalized viewport to be rendered this frame for this view.\r\n * In the event of a failure, the supplied viewport is not updated.\r\n * @param viewport the viewport to which the view will be rendered\r\n * @param view the view for which to set the viewport\r\n * @returns whether the operation was successful\r\n */\r\n trySetViewportForView(viewport: Viewport, view: XRView): boolean;\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this eye\r\n * @param eye the eye for which to get the render target\r\n * @returns the render target for the specified eye or null if not available\r\n */\r\n getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this view\r\n * @param view the view for which to get the render target\r\n * @returns the render target for the specified view or null if not available\r\n */\r\n getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRLayer.\r\n * @internal\r\n */\r\nexport abstract class WebXRLayerRenderTargetTextureProvider implements IWebXRRenderTargetTextureProvider {\r\n public abstract trySetViewportForView(viewport: Viewport, view: XRView): boolean;\r\n public abstract getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;\r\n public abstract getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;\r\n\r\n protected _renderTargetTextures = new Array<RenderTargetTexture>();\r\n protected _framebufferDimensions: Nullable<{ framebufferWidth: number; framebufferHeight: number }>;\r\n\r\n protected _engine: AbstractEngine;\r\n\r\n constructor(\r\n protected readonly _scene: Scene,\r\n public readonly layerWrapper: WebXRLayerWrapper\r\n ) {\r\n this._engine = _scene.getEngine();\r\n }\r\n\r\n /**\r\n * Creates the render target texture \"shell\" (with the correct multiview type and MSAA sample count)\r\n * without attaching any graphics-API-specific resource. Subclasses attach their own textures.\r\n * @param width the width of the render target\r\n * @param height the height of the render target\r\n * @param multiview whether the render target should be a multiview render target\r\n * @returns the created (but not yet registered) render target texture\r\n */\r\n protected _createRenderTargetTextureShell(width: number, height: number, multiview: boolean): RenderTargetTexture {\r\n const textureSize = { width, height };\r\n const renderTargetTexture = multiview ? new MultiviewRenderTarget(this._scene, textureSize) : new RenderTargetTexture(\"XR renderTargetTexture\", textureSize, this._scene);\r\n renderTargetTexture.renderTarget!._samples = renderTargetTexture.samples;\r\n return renderTargetTexture;\r\n }\r\n\r\n /**\r\n * Builds a render target texture from already-wrapped internal textures, without referencing any\r\n * graphics-API-specific type. A GPU-based backend (e.g. WebGPU / XRGPUBinding) wraps its native\r\n * textures with the engine and calls this hook; the WebGL backend has its own typed entry point.\r\n * @param width the width of the render target\r\n * @param height the height of the render target\r\n * @param colorTexture the internal texture to use as the color attachment, if any\r\n * @param depthStencilTexture the internal texture to use as the depth/stencil attachment, if any\r\n * @param multiview whether the render target should be a multiview render target\r\n * @returns the created render target texture\r\n */\r\n protected _createRenderTargetTextureInternal(\r\n width: number,\r\n height: number,\r\n colorTexture: Nullable<InternalTexture>,\r\n depthStencilTexture: Nullable<InternalTexture>,\r\n multiview: boolean\r\n ): RenderTargetTexture {\r\n if (multiview) {\r\n // The multiview color/depth array wiring is not implemented on this API-agnostic hook yet.\r\n // The WebGL provider still owns the array path via its own _createRenderTargetTexture.\r\n throw new Error(\"Multiview render targets are not yet supported by the API-agnostic render target creation path.\");\r\n }\r\n const renderTargetTexture = this._createRenderTargetTextureShell(width, height, multiview);\r\n const renderTargetWrapper = renderTargetTexture.renderTarget!;\r\n\r\n if (colorTexture) {\r\n renderTargetWrapper.setTexture(colorTexture, 0);\r\n renderTargetTexture._texture = colorTexture;\r\n }\r\n\r\n if (depthStencilTexture) {\r\n renderTargetWrapper._depthStencilTexture = depthStencilTexture;\r\n }\r\n\r\n renderTargetTexture.disableRescaling();\r\n\r\n this._renderTargetTextures.push(renderTargetTexture);\r\n\r\n return renderTargetTexture;\r\n }\r\n\r\n protected _destroyRenderTargetTexture(renderTargetTexture: RenderTargetTexture) {\r\n this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(renderTargetTexture), 1);\r\n renderTargetTexture.dispose();\r\n }\r\n\r\n public getFramebufferDimensions(): Nullable<{ framebufferWidth: number; framebufferHeight: number }> {\r\n return this._framebufferDimensions;\r\n }\r\n\r\n public dispose() {\r\n for (const rtt of this._renderTargetTextures) {\r\n rtt.dispose();\r\n }\r\n this._renderTargetTextures.length = 0;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webXRRenderTargetTextureProvider.js","sourceR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YAAa,CAAC;QAE9D,IAAI,YAAY,EAAE,CAAC;YACf,mBAAmB,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;YAChD,mBAAmB,CAAC,QAAQ,GAAG,YAAY,CAAC;QAChD,CAAC;QAED,IAAI,mBAAmB,EAAE,CAAC;YACtB,mBAAmB,CAAC,oBAAoB,GAAG,mBAAmB,CAAC;QACnE,CAAC;QAED,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;QAEvC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAErD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAES,2BAA2B,CAAC,mBAAwC;QAC1E,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9F,mBAAmB,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAEM,wBAAwB;QAC3B,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IAEM,OAAO;QACV,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC3C,GAAG,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import { type AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { type InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { MultiviewRenderTarget } from \"../Materials/Textures/MultiviewRenderTarget\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture.pure\";\r\nimport { type Viewport } from \"../Maths/math.viewport\";\r\nimport { type IDisposable, type Scene } from \"../scene\";\r\nimport { type Nullable } from \"../types\";\r\nimport { type WebXRLayerType, type WebXRLayerWrapper, type WebXRSupportedLayerType } from \"./webXRLayerWrapper\";\r\n\r\n/**\r\n * An interface for objects that provide render target textures for XR rendering.\r\n */\r\nexport interface IWebXRRenderTargetTextureProvider extends IDisposable {\r\n /**\r\n * Attempts to set the framebuffer-size-normalized viewport to be rendered this frame for this view.\r\n * In the event of a failure, the supplied viewport is not updated.\r\n * @param viewport the viewport to which the view will be rendered\r\n * @param view the view for which to set the viewport\r\n * @returns whether the operation was successful\r\n */\r\n trySetViewportForView(viewport: Viewport, view: XRView): boolean;\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this eye\r\n * @param eye the eye for which to get the render target\r\n * @returns the render target for the specified eye or null if not available\r\n */\r\n getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this view\r\n * @param view the view for which to get the render target\r\n * @returns the render target for the specified view or null if not available\r\n */\r\n getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRLayer.\r\n * @internal\r\n */\r\nexport abstract class WebXRLayerRenderTargetTextureProvider<LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType> implements IWebXRRenderTargetTextureProvider {\r\n public abstract trySetViewportForView(viewport: Viewport, view: XRView): boolean;\r\n public abstract getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;\r\n public abstract getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;\r\n\r\n protected _renderTargetTextures = new Array<RenderTargetTexture>();\r\n protected _framebufferDimensions: Nullable<{ framebufferWidth: number; framebufferHeight: number }>;\r\n\r\n protected _engine: AbstractEngine;\r\n\r\n constructor(\r\n protected readonly _scene: Scene,\r\n public readonly layerWrapper: WebXRLayerWrapper<LayerTypeT>\r\n ) {\r\n this._engine = _scene.getEngine();\r\n }\r\n\r\n /**\r\n * Creates the render target texture \"shell\" (with the correct multiview type and MSAA sample count)\r\n * without attaching any graphics-API-specific resource. Subclasses attach their own textures.\r\n * @param width the width of the render target\r\n * @param height the height of the render target\r\n * @param multiview whether the render target should be a multiview render target\r\n * @returns the created (but not yet registered) render target texture\r\n */\r\n protected _createRenderTargetTextureShell(width: number, height: number, multiview: boolean): RenderTargetTexture {\r\n const textureSize = { width, height };\r\n const renderTargetTexture = multiview ? new MultiviewRenderTarget(this._scene, textureSize) : new RenderTargetTexture(\"XR renderTargetTexture\", textureSize, this._scene);\r\n renderTargetTexture.renderTarget!._samples = renderTargetTexture.samples;\r\n return renderTargetTexture;\r\n }\r\n\r\n /**\r\n * Builds a render target texture from already-wrapped internal textures, without referencing any\r\n * graphics-API-specific type. A GPU-based backend (e.g. WebGPU / XRGPUBinding) wraps its native\r\n * textures with the engine and calls this hook; the WebGL backend has its own typed entry point.\r\n * @param width the width of the render target\r\n * @param height the height of the render target\r\n * @param colorTexture the internal texture to use as the color attachment, if any\r\n * @param depthStencilTexture the internal texture to use as the depth/stencil attachment, if any\r\n * @param multiview whether the render target should be a multiview render target\r\n * @returns the created render target texture\r\n */\r\n protected _createRenderTargetTextureInternal(\r\n width: number,\r\n height: number,\r\n colorTexture: Nullable<InternalTexture>,\r\n depthStencilTexture: Nullable<InternalTexture>,\r\n multiview: boolean\r\n ): RenderTargetTexture {\r\n if (multiview) {\r\n // The multiview color/depth array wiring is not implemented on this API-agnostic hook yet.\r\n // The WebGL provider still owns the array path via its own _createRenderTargetTexture.\r\n throw new Error(\"Multiview render targets are not yet supported by the API-agnostic render target creation path.\");\r\n }\r\n const renderTargetTexture = this._createRenderTargetTextureShell(width, height, multiview);\r\n const renderTargetWrapper = renderTargetTexture.renderTarget!;\r\n\r\n if (colorTexture) {\r\n renderTargetWrapper.setTexture(colorTexture, 0);\r\n renderTargetTexture._texture = colorTexture;\r\n }\r\n\r\n if (depthStencilTexture) {\r\n renderTargetWrapper._depthStencilTexture = depthStencilTexture;\r\n }\r\n\r\n renderTargetTexture.disableRescaling();\r\n\r\n this._renderTargetTextures.push(renderTargetTexture);\r\n\r\n return renderTargetTexture;\r\n }\r\n\r\n protected _destroyRenderTargetTexture(renderTargetTexture: RenderTargetTexture) {\r\n this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(renderTargetTexture), 1);\r\n renderTargetTexture.dispose();\r\n }\r\n\r\n public getFramebufferDimensions(): Nullable<{ framebufferWidth: number; framebufferHeight: number }> {\r\n return this._framebufferDimensions;\r\n }\r\n\r\n public dispose() {\r\n for (const rtt of this._renderTargetTextures) {\r\n rtt.dispose();\r\n }\r\n this._renderTargetTextures.length = 0;\r\n }\r\n}\r\n"]}
@@ -1,12 +1,13 @@
1
1
  import { type RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.pure.js";
2
2
  import { type Nullable } from "../types.js";
3
3
  import { WebXRLayerRenderTargetTextureProvider } from "./webXRRenderTargetTextureProvider.js";
4
+ import { type WebXRLayerType, type WebXRSupportedLayerType } from "./webXRLayerWrapper.js";
4
5
  /**
5
6
  * Provides render target textures for WebGL-backed XR layers. Owns all WebGL-specific
6
7
  * framebuffer/texture wiring so the base provider can stay graphics-API-agnostic.
7
8
  * @internal
8
9
  */
9
- export declare abstract class WebXRWebGLRenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {
10
+ export declare abstract class WebXRWebGLRenderTargetTextureProvider<LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType> extends WebXRLayerRenderTargetTextureProvider<LayerTypeT> {
10
11
  private _createInternalTexture;
11
12
  protected _createRenderTargetTexture(width: number, height: number, framebuffer: Nullable<WebGLFramebuffer>, colorTexture?: WebGLTexture, depthStencilTexture?: WebGLTexture, multiview?: boolean): RenderTargetTexture;
12
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webXRWebGLRenderTargetTextureProvider.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRWebGLRenderTargetTextureProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAyB,MAAM,uCAAuC,CAAC;AAG/F,OAAO,EAAE,qC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QAC1B,IAAI,YAAY,EAAE,CAAC;YACf,IAAI,SAAS,EAAE,CAAC;gBACZ,mBAAmB,CAAC,kBAAkB,GAAG,YAAY,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACJ,MAAM,eAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;gBAC/E,mBAAmB,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;gBACnD,mBAAmB,CAAC,QAAQ,GAAG,eAAe,CAAC;YACnD,CAAC;QACL,CAAC;QAED,IAAI,mBAAmB,EAAE,CAAC;YACtB,IAAI,SAAS,EAAE,CAAC;gBACZ,mBAAmB,CAAC,yBAAyB,GAAG,mBAAmB,CAAC;YACxE,CAAC;iBAAM,CAAC;gBACJ,mBAAmB,CAAC,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;YAC7G,CAAC;QACL,CAAC;QAED,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;QAEvC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAErD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["import { type ThinEngine } from \"../Engines/thinEngine\";\nimport { WebGLHardwareTexture } from \"../Engines/WebGL/webGLHardwareTexture\";\nimport { type WebGLRenderTargetWrapper } from \"../Engines/WebGL/webGLRenderTargetWrapper\";\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\nimport { type RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture.pure\";\nimport { type Nullable } from \"../types\";\nimport { WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\n\n/**\n * Provides render target textures for WebGL-backed XR layers. Owns all WebGL-specific\n * framebuffer/texture wiring so the base provider can stay graphics-API-agnostic.\n * @internal\n */\nexport abstract class WebXRWebGLRenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {\n private _createInternalTexture(textureSize: { width: number; height: number }, texture: WebGLTexture): InternalTexture {\n const gl = (this._engine as ThinEngine)._gl;\n if (!gl) {\n throw new Error(\"WebXRWebGLRenderTargetTextureProvider requires a WebGL-capable engine.\");\n }\n const internalTexture = new InternalTexture(this._engine, InternalTextureSource.Unknown, true);\n internalTexture.width = textureSize.width;\n internalTexture.height = textureSize.height;\n internalTexture._hardwareTexture = new WebGLHardwareTexture(texture, gl);\n internalTexture.isReady = true;\n return internalTexture;\n }\n\n protected _createRenderTargetTexture(\n width: number,\n height: number,\n framebuffer: Nullable<WebGLFramebuffer>,\n colorTexture?: WebGLTexture,\n depthStencilTexture?: WebGLTexture,\n multiview?: boolean\n ): RenderTargetTexture {\n if (!this._engine) {\n throw new Error(\"Engine is disposed\");\n }\n\n const textureSize = { width, height };\n\n const renderTargetTexture = this._createRenderTargetTextureShell(width, height, !!multiview);\n const renderTargetWrapper = renderTargetTexture.renderTarget as WebGLRenderTargetWrapper;\n // Set the framebuffer, make sure it works in all scenarios - emulator, no layers and layers.\n // This must happen before binding any texture, since setTexture binds it to the framebuffer.\n if (framebuffer || !colorTexture) {\n renderTargetWrapper._framebuffer = framebuffer;\n }\n\n // Create internal texture\n if (colorTexture) {\n if (multiview) {\n renderTargetWrapper._colorTextureArray = colorTexture;\n } else {\n const internalTexture = this._createInternalTexture(textureSize, colorTexture);\n renderTargetWrapper.setTexture(internalTexture, 0);\n renderTargetTexture._texture = internalTexture;\n }\n }\n\n if (depthStencilTexture) {\n if (multiview) {\n renderTargetWrapper._depthStencilTextureArray = depthStencilTexture;\n } else {\n renderTargetWrapper._depthStencilTexture = this._createInternalTexture(textureSize, depthStencilTexture);\n }\n }\n\n renderTargetTexture.disableRescaling();\n\n this._renderTargetTextures.push(renderTargetTexture);\n\n return renderTargetTexture;\n }\n}\n"]}
1
+ {"version":3,"file":"webXRWebGLRenderTargetTextureProvider.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRWebGLRender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AAC;QACzF,6FAA6F;QAC7F,6FAA6F;QAC7F,IAAI,WAAW,IAAI,CAAC,YAAY,EAAE,CAAC;YAC/B,mBAAmB,CAAC,YAAY,GAAG,WAAW,CAAC;QACnD,CAAC;QAED,0BAA0B;QAC1B,IAAI,YAAY,EAAE,CAAC;YACf,IAAI,SAAS,EAAE,CAAC;gBACZ,mBAAmB,CAAC,kBAAkB,GAAG,YAAY,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACJ,MAAM,eAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;gBAC/E,mBAAmB,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;gBACnD,mBAAmB,CAAC,QAAQ,GAAG,eAAe,CAAC;YACnD,CAAC;QACL,CAAC;QAED,IAAI,mBAAmB,EAAE,CAAC;YACtB,IAAI,SAAS,EAAE,CAAC;gBACZ,mBAAmB,CAAC,yBAAyB,GAAG,mBAAmB,CAAC;YACxE,CAAC;iBAAM,CAAC;gBACJ,mBAAmB,CAAC,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;YAC7G,CAAC;QACL,CAAC;QAED,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;QAEvC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAErD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["import { type ThinEngine } from \"../Engines/thinEngine\";\nimport { WebGLHardwareTexture } from \"../Engines/WebGL/webGLHardwareTexture\";\nimport { type WebGLRenderTargetWrapper } from \"../Engines/WebGL/webGLRenderTargetWrapper\";\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\nimport { type RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture.pure\";\nimport { type Nullable } from \"../types\";\nimport { WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\nimport { type WebXRLayerType, type WebXRSupportedLayerType } from \"./webXRLayerWrapper\";\n\n/**\n * Provides render target textures for WebGL-backed XR layers. Owns all WebGL-specific\n * framebuffer/texture wiring so the base provider can stay graphics-API-agnostic.\n * @internal\n */\nexport abstract class WebXRWebGLRenderTargetTextureProvider<LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType> extends WebXRLayerRenderTargetTextureProvider<LayerTypeT> {\n private _createInternalTexture(textureSize: { width: number; height: number }, texture: WebGLTexture): InternalTexture {\n const gl = (this._engine as ThinEngine)._gl;\n if (!gl) {\n throw new Error(\"WebXRWebGLRenderTargetTextureProvider requires a WebGL-capable engine.\");\n }\n const internalTexture = new InternalTexture(this._engine, InternalTextureSource.Unknown, true);\n internalTexture.width = textureSize.width;\n internalTexture.height = textureSize.height;\n internalTexture._hardwareTexture = new WebGLHardwareTexture(texture, gl);\n internalTexture.isReady = true;\n return internalTexture;\n }\n\n protected _createRenderTargetTexture(\n width: number,\n height: number,\n framebuffer: Nullable<WebGLFramebuffer>,\n colorTexture?: WebGLTexture,\n depthStencilTexture?: WebGLTexture,\n multiview?: boolean\n ): RenderTargetTexture {\n if (!this._engine) {\n throw new Error(\"Engine is disposed\");\n }\n\n const textureSize = { width, height };\n\n const renderTargetTexture = this._createRenderTargetTextureShell(width, height, !!multiview);\n const renderTargetWrapper = renderTargetTexture.renderTarget as WebGLRenderTargetWrapper;\n // Set the framebuffer, make sure it works in all scenarios - emulator, no layers and layers.\n // This must happen before binding any texture, since setTexture binds it to the framebuffer.\n if (framebuffer || !colorTexture) {\n renderTargetWrapper._framebuffer = framebuffer;\n }\n\n // Create internal texture\n if (colorTexture) {\n if (multiview) {\n renderTargetWrapper._colorTextureArray = colorTexture;\n } else {\n const internalTexture = this._createInternalTexture(textureSize, colorTexture);\n renderTargetWrapper.setTexture(internalTexture, 0);\n renderTargetTexture._texture = internalTexture;\n }\n }\n\n if (depthStencilTexture) {\n if (multiview) {\n renderTargetWrapper._depthStencilTextureArray = depthStencilTexture;\n } else {\n renderTargetWrapper._depthStencilTexture = this._createInternalTexture(textureSize, depthStencilTexture);\n }\n }\n\n renderTargetTexture.disableRescaling();\n\n this._renderTargetTextures.push(renderTargetTexture);\n\n return renderTargetTexture;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { type RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.pure.js";
2
2
  import { type Nullable } from "../types.js";
3
3
  import { WebXRLayerRenderTargetTexture } from "./webXRLayerRenderTargetTexture.js";
4
- import { type WebXRLayerWrapper } from "./webXRLayerWrapper.js";
4
+ import { type WebXRLayerType, type WebXRLayerWrapper, type WebXRSupportedLayerType } from "./webXRLayerWrapper.js";
5
5
  import { WebXRLayerRenderTargetTextureProvider } from "./webXRRenderTargetTextureProvider.js";
6
6
  import { type WebXRSessionManager } from "./webXRSessionManager.js";
7
7
  /**
@@ -11,10 +11,10 @@ import { type WebXRSessionManager } from "./webXRSessionManager.js";
11
11
  * WebGPU (XRGPUBinding) backend.
12
12
  * @internal
13
13
  */
14
- export declare abstract class WebXRWebGPURenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {
14
+ export declare abstract class WebXRWebGPURenderTargetTextureProvider<LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType> extends WebXRLayerRenderTargetTextureProvider<LayerTypeT> {
15
15
  protected readonly _xrSessionManager: WebXRSessionManager;
16
16
  private readonly _transparentClearColor;
17
- constructor(_xrSessionManager: WebXRSessionManager, layerWrapper: WebXRLayerWrapper);
17
+ constructor(_xrSessionManager: WebXRSessionManager, layerWrapper: WebXRLayerWrapper<LayerTypeT>);
18
18
  private get _webgpuEngine();
19
19
  private _wrapColorTexture;
20
20
  private _wrapDepthTexture;
@@ -1 +1 @@
1
- {"version":3,"file":"webXRWebGPURenderTargetTextureProvider.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRWebGPURenderTargetTextureProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE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BAAyC;QAC7J,MAAM,KAAK,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAC3C,IAAI,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,aAAa,CAAC,0BAA0B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACvE,CAAC;QACD,MAAM,KAAK,GAAG,mBAAmB,CAAC,YAAY,EAAE,oBAAoB,CAAC;QACrE,IAAI,KAAK,IAAI,mBAAmB,EAAE,CAAC;YAC/B,IAAI,CAAC,aAAa,CAAC,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;QAC9E,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Constants } from \"../Engines/constants\";\nimport { type WebGPUEngine } from \"../Engines/webgpuEngine\";\nimport { type WebGPURenderTargetWrapper } from \"../Engines/WebGPU/webgpuRenderTargetWrapper\";\nimport { type InternalTexture } from \"../Materials/Textures/internalTexture\";\nimport { type RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture.pure\";\nimport { Color4 } from \"../Maths/math.color.pure\";\nimport { type Nullable } from \"../types\";\nimport { WebXRLayerRenderTargetTexture } from \"./webXRLayerRenderTargetTexture\";\nimport { type WebXRLayerWrapper } from \"./webXRLayerWrapper\";\nimport { WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\n\n/**\n * Maps a WebGPU depth/stencil {@link GPUTextureFormat} to the matching Babylon `TEXTUREFORMAT_*` constant.\n *\n * The engine reads `InternalTexture.format` (a Babylon constant) when it builds the render pass depth\n * attachment for a render target, so a depth texture wrapped from an external `GPUTexture` must carry the\n * correct Babylon format or the depth attachment pipeline format will not match the sub-image's texture.\n * @param format the WebGPU depth/stencil format requested when the layer was created\n * @returns the matching Babylon texture format constant\n */\nfunction GetBabylonDepthFormat(format: GPUTextureFormat): number {\n switch (format) {\n case \"depth16unorm\":\n return Constants.TEXTUREFORMAT_DEPTH16;\n case \"depth24plus\":\n return Constants.TEXTUREFORMAT_DEPTH24;\n case \"depth24plus-stencil8\":\n return Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\n case \"depth32float\":\n return Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\n case \"depth32float-stencil8\":\n return Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8;\n case \"stencil8\":\n return Constants.TEXTUREFORMAT_STENCIL8;\n default:\n // Fall back to a combined depth/stencil format, which is the projection layer default.\n return Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\n }\n}\n\n/**\n * Provides render target textures for WebGPU-backed XR layers. Owns all WebGPU-specific texture wrapping\n * (via {@link WebGPUEngine.wrapWebGPUTexture} / {@link WebGPUEngine.updateWrappedWebGPUTexture}) so the base\n * provider can stay graphics-API-agnostic. Mirrors {@link WebXRWebGLRenderTargetTextureProvider} for the\n * WebGPU (XRGPUBinding) backend.\n * @internal\n */\nexport abstract class WebXRWebGPURenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {\n private readonly _transparentClearColor = new Color4(0, 0, 0, 0);\n\n constructor(\n protected readonly _xrSessionManager: WebXRSessionManager,\n layerWrapper: WebXRLayerWrapper\n ) {\n super(_xrSessionManager.scene, layerWrapper);\n }\n\n private get _webgpuEngine(): WebGPUEngine {\n return this._engine as WebGPUEngine;\n }\n\n private _wrapColorTexture(texture: GPUTexture): InternalTexture {\n return this._webgpuEngine.wrapWebGPUTexture(texture);\n }\n\n private _wrapDepthTexture(texture: GPUTexture, depthStencilFormat: GPUTextureFormat): InternalTexture {\n const internalTexture = this._webgpuEngine.wrapWebGPUTexture(texture);\n // The engine derives the color attachment format automatically from the wrapped hardware texture,\n // but the depth attachment format is read from the Babylon InternalTexture.format, which\n // wrapWebGPUTexture does not set. Assign it here from the format the layer was created with.\n internalTexture.format = GetBabylonDepthFormat(depthStencilFormat);\n return internalTexture;\n }\n\n /**\n * Builds the render target shell as a {@link WebXRLayerRenderTargetTexture} for the single-view path so\n * each eye can bind its own array layer of a layered projection-layer texture. Multiview is not yet\n * supported on this WebGPU path and is delegated to the base implementation.\n * @param width the width of the render target\n * @param height the height of the render target\n * @param multiview whether the render target should be a multiview render target\n * @returns the created (but not yet registered) render target texture\n */\n protected override _createRenderTargetTextureShell(width: number, height: number, multiview: boolean): RenderTargetTexture {\n if (multiview) {\n return super._createRenderTargetTextureShell(width, height, multiview);\n }\n const renderTargetTexture = new WebXRLayerRenderTargetTexture(\"XR renderTargetTexture\", { width, height }, this._scene);\n renderTargetTexture.renderTarget!._samples = renderTargetTexture.samples;\n // The projection-layer texture is presented directly by the XR compositor (top-left origin, never\n // re-sampled by Babylon), so opt this target out of the engine's render-target Y-flip / winding\n // compensation and render it upright, matching the WebXR/WebGPU spec's plain render pass.\n (renderTargetTexture.renderTarget as WebGPURenderTargetWrapper)._disableEngineYFlip = true;\n return renderTargetTexture;\n }\n\n /**\n * Wraps the sub-image's color (and optional depth/stencil) GPUTextures and builds a new render target\n * texture around them. Use this on first creation and whenever the sub-image texture size changes.\n * @param width the width of the render target\n * @param height the height of the render target\n * @param colorTexture the sub-image color GPUTexture\n * @param depthStencilTexture the sub-image depth/stencil GPUTexture, if any\n * @param depthStencilFormat the WebGPU depth/stencil format the layer was created with, if depth is provided\n * @param multiview whether the render target should be a multiview render target\n * @returns the created render target texture\n */\n protected _createRenderTargetTextureFromGPUTextures(\n width: number,\n height: number,\n colorTexture: GPUTexture,\n depthStencilTexture: Nullable<GPUTexture>,\n depthStencilFormat: GPUTextureFormat | undefined,\n multiview: boolean\n ): WebXRLayerRenderTargetTexture {\n const color = this._wrapColorTexture(colorTexture);\n const depth = depthStencilTexture && depthStencilFormat ? this._wrapDepthTexture(depthStencilTexture, depthStencilFormat) : null;\n // Single-view (the only path here) always builds a WebXRLayerRenderTargetTexture via the shell override above.\n const renderTargetTexture = this._createRenderTargetTextureInternal(width, height, color, depth, multiview) as WebXRLayerRenderTargetTexture;\n this._attachPerEyeClearObserver(renderTargetTexture);\n return renderTargetTexture;\n }\n\n /**\n * Ensures this render target is cleared every frame, including for the right eye.\n *\n * `Scene._clearFrameBuffer` skips clearing the right rig camera's framebuffer (`!camera.isRightCamera`).\n * That is a valid optimization for WebGL2 stereo, where both eyes render into a single side-by-side\n * texture and the left eye's full clear already covers the whole texture. WebGPU projection layers give\n * each eye its OWN render target (a distinct array layer rendered in a separate render pass), so the\n * right eye's color and — critically — depth would never be cleared, leaving its depth test to reject\n * every fragment (a black right eye). The scene notifies `onClearObservable` regardless of\n * `camera.isRightCamera`, so this observer clears both eyes' targets. WebGL providers never attach it,\n * so the WebGL path is unchanged.\n *\n * Color is cleared at most once per ENGINE FRAME, not once per `Scene.render`. The distinction matters:\n * more than one scene can render the same XR camera within a single XR frame. `UtilityLayerRenderer`\n * (used by controller pointer selection and near interaction) renders a second scene through the same\n * rig cameras, and every `Scene.render` resets `RenderTargetTexture._cleared` for those cameras' targets\n * (`Scene._checkCameraRenderTarget`), so a `_cleared`-based guard is defeated and each eye is re-cleared\n * after it was drawn — presenting a clear-colored frame with the geometry gone. `AbstractEngine.frameId`\n * only advances in `endFrame`, once per XR frame, so unlike `_cleared` it cannot be reset by another\n * scene rendering the same camera.\n *\n * In immersive AR, color is cleared to transparent when `WebXRExperienceHelper` disables\n * `Scene.autoClear`. WebGL XR framebuffers are cleared to transparent by the user agent, but WebGPU render\n * passes require the application to request that clear explicitly. Skipping it leaves pixels from prior\n * frames in passthrough regions, producing trails behind moving objects.\n *\n * Depth and stencil are still cleared on every notification, matching the previous behavior and the\n * expectations of overlay scenes that draw on top of the main scene.\n * @param renderTargetTexture the per-eye render target to clear each frame\n */\n private _attachPerEyeClearObserver(renderTargetTexture: RenderTargetTexture): void {\n let lastColorClearedFrameId = -1;\n renderTargetTexture.onClearObservable.add((engine) => {\n // Honor skipInitialClear so this observer preserves the default clear semantics it replaces.\n if (renderTargetTexture.skipInitialClear) {\n return;\n }\n const scene = renderTargetTexture.getScene();\n const isImmersiveAR = this._xrSessionManager.sessionMode === \"immersive-ar\";\n // When autoClear is disabled the scene does not clear render targets; match that so this observer\n // does not force a clear the user opted out of. Immersive AR is the exception: the experience\n // helper disables autoClear because WebGL XR is cleared by the user agent, while WebGPU is not.\n if (scene && !scene.autoClear && !isImmersiveAR) {\n return;\n }\n const clearColor = engine.frameId !== lastColorClearedFrameId;\n const color = isImmersiveAR && scene && !scene.autoClear ? this._transparentClearColor : (renderTargetTexture.clearColor ?? scene?.clearColor ?? null);\n engine.clear(color, clearColor, true, true);\n if (clearColor) {\n lastColorClearedFrameId = engine.frameId;\n }\n // Kept in sync so anything else reading the flag still sees this target as cleared this frame.\n renderTargetTexture._cleared = true;\n });\n }\n\n /**\n * Repoints the wrapped color/depth textures of an existing render target at the current frame's\n * GPUTextures, preserving the RenderTargetTexture / InternalTexture identity held by the XR camera's\n * `outputRenderTarget`. The sub-image textures are only valid for the current frame and may rotate from\n * a compositor pool, so this must run every frame. The new GPUTextures must have the same dimensions as\n * the wrapped ones (guaranteed by the caller's size-change branch, which rebuilds instead).\n * @param renderTargetTexture the render target whose wrapped textures should be repointed\n * @param colorTexture the current frame's color GPUTexture\n * @param depthStencilTexture the current frame's depth/stencil GPUTexture, if any\n */\n protected _updateRenderTargetTextureFromGPUTextures(renderTargetTexture: RenderTargetTexture, colorTexture: GPUTexture, depthStencilTexture: Nullable<GPUTexture>): void {\n const color = renderTargetTexture._texture;\n if (color) {\n this._webgpuEngine.updateWrappedWebGPUTexture(color, colorTexture);\n }\n const depth = renderTargetTexture.renderTarget?._depthStencilTexture;\n if (depth && depthStencilTexture) {\n this._webgpuEngine.updateWrappedWebGPUTexture(depth, depthStencilTexture);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"webXRWebGPURenderTargetTextureProvider.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRWebGPURenderTargetTextureProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKjD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAA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I,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,aAAa,CAAC,0BAA0B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACvE,CAAC;QACD,MAAM,KAAK,GAAG,mBAAmB,CAAC,YAAY,EAAE,oBAAoB,CAAC;QACrE,IAAI,KAAK,IAAI,mBAAmB,EAAE,CAAC;YAC/B,IAAI,CAAC,aAAa,CAAC,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;QAC9E,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Constants } from \"../Engines/constants\";\nimport { type WebGPUEngine } from \"../Engines/webgpuEngine\";\nimport { type WebGPURenderTargetWrapper } from \"../Engines/WebGPU/webgpuRenderTargetWrapper\";\nimport { type InternalTexture } from \"../Materials/Textures/internalTexture\";\nimport { type RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture.pure\";\nimport { Color4 } from \"../Maths/math.color.pure\";\nimport { type Nullable } from \"../types\";\nimport { WebXRLayerRenderTargetTexture } from \"./webXRLayerRenderTargetTexture\";\nimport { type WebXRLayerType, type WebXRLayerWrapper, type WebXRSupportedLayerType } from \"./webXRLayerWrapper\";\nimport { WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\n\n/**\n * Maps a WebGPU depth/stencil {@link GPUTextureFormat} to the matching Babylon `TEXTUREFORMAT_*` constant.\n *\n * The engine reads `InternalTexture.format` (a Babylon constant) when it builds the render pass depth\n * attachment for a render target, so a depth texture wrapped from an external `GPUTexture` must carry the\n * correct Babylon format or the depth attachment pipeline format will not match the sub-image's texture.\n * @param format the WebGPU depth/stencil format requested when the layer was created\n * @returns the matching Babylon texture format constant\n */\nfunction GetBabylonDepthFormat(format: GPUTextureFormat): number {\n switch (format) {\n case \"depth16unorm\":\n return Constants.TEXTUREFORMAT_DEPTH16;\n case \"depth24plus\":\n return Constants.TEXTUREFORMAT_DEPTH24;\n case \"depth24plus-stencil8\":\n return Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\n case \"depth32float\":\n return Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\n case \"depth32float-stencil8\":\n return Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8;\n case \"stencil8\":\n return Constants.TEXTUREFORMAT_STENCIL8;\n default:\n // Fall back to a combined depth/stencil format, which is the projection layer default.\n return Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\n }\n}\n\n/**\n * Provides render target textures for WebGPU-backed XR layers. Owns all WebGPU-specific texture wrapping\n * (via {@link WebGPUEngine.wrapWebGPUTexture} / {@link WebGPUEngine.updateWrappedWebGPUTexture}) so the base\n * provider can stay graphics-API-agnostic. Mirrors {@link WebXRWebGLRenderTargetTextureProvider} for the\n * WebGPU (XRGPUBinding) backend.\n * @internal\n */\nexport abstract class WebXRWebGPURenderTargetTextureProvider<\n LayerTypeT extends WebXRSupportedLayerType = WebXRLayerType,\n> extends WebXRLayerRenderTargetTextureProvider<LayerTypeT> {\n private readonly _transparentClearColor = new Color4(0, 0, 0, 0);\n\n constructor(\n protected readonly _xrSessionManager: WebXRSessionManager,\n layerWrapper: WebXRLayerWrapper<LayerTypeT>\n ) {\n super(_xrSessionManager.scene, layerWrapper);\n }\n\n private get _webgpuEngine(): WebGPUEngine {\n return this._engine as WebGPUEngine;\n }\n\n private _wrapColorTexture(texture: GPUTexture): InternalTexture {\n return this._webgpuEngine.wrapWebGPUTexture(texture);\n }\n\n private _wrapDepthTexture(texture: GPUTexture, depthStencilFormat: GPUTextureFormat): InternalTexture {\n const internalTexture = this._webgpuEngine.wrapWebGPUTexture(texture);\n // The engine derives the color attachment format automatically from the wrapped hardware texture,\n // but the depth attachment format is read from the Babylon InternalTexture.format, which\n // wrapWebGPUTexture does not set. Assign it here from the format the layer was created with.\n internalTexture.format = GetBabylonDepthFormat(depthStencilFormat);\n return internalTexture;\n }\n\n /**\n * Builds the render target shell as a {@link WebXRLayerRenderTargetTexture} for the single-view path so\n * each eye can bind its own array layer of a layered projection-layer texture. Multiview is not yet\n * supported on this WebGPU path and is delegated to the base implementation.\n * @param width the width of the render target\n * @param height the height of the render target\n * @param multiview whether the render target should be a multiview render target\n * @returns the created (but not yet registered) render target texture\n */\n protected override _createRenderTargetTextureShell(width: number, height: number, multiview: boolean): RenderTargetTexture {\n if (multiview) {\n return super._createRenderTargetTextureShell(width, height, multiview);\n }\n const renderTargetTexture = new WebXRLayerRenderTargetTexture(\"XR renderTargetTexture\", { width, height }, this._scene);\n renderTargetTexture.renderTarget!._samples = renderTargetTexture.samples;\n // The projection-layer texture is presented directly by the XR compositor (top-left origin, never\n // re-sampled by Babylon), so opt this target out of the engine's render-target Y-flip / winding\n // compensation and render it upright, matching the WebXR/WebGPU spec's plain render pass.\n (renderTargetTexture.renderTarget as WebGPURenderTargetWrapper)._disableEngineYFlip = true;\n return renderTargetTexture;\n }\n\n /**\n * Wraps the sub-image's color (and optional depth/stencil) GPUTextures and builds a new render target\n * texture around them. Use this on first creation and whenever the sub-image texture size changes.\n * @param width the width of the render target\n * @param height the height of the render target\n * @param colorTexture the sub-image color GPUTexture\n * @param depthStencilTexture the sub-image depth/stencil GPUTexture, if any\n * @param depthStencilFormat the WebGPU depth/stencil format the layer was created with, if depth is provided\n * @param multiview whether the render target should be a multiview render target\n * @returns the created render target texture\n */\n protected _createRenderTargetTextureFromGPUTextures(\n width: number,\n height: number,\n colorTexture: GPUTexture,\n depthStencilTexture: Nullable<GPUTexture>,\n depthStencilFormat: GPUTextureFormat | undefined,\n multiview: boolean\n ): WebXRLayerRenderTargetTexture {\n const color = this._wrapColorTexture(colorTexture);\n const depth = depthStencilTexture && depthStencilFormat ? this._wrapDepthTexture(depthStencilTexture, depthStencilFormat) : null;\n // Single-view (the only path here) always builds a WebXRLayerRenderTargetTexture via the shell override above.\n const renderTargetTexture = this._createRenderTargetTextureInternal(width, height, color, depth, multiview) as WebXRLayerRenderTargetTexture;\n this._attachPerEyeClearObserver(renderTargetTexture);\n return renderTargetTexture;\n }\n\n /**\n * Ensures this render target is cleared every frame, including for the right eye.\n *\n * `Scene._clearFrameBuffer` skips clearing the right rig camera's framebuffer (`!camera.isRightCamera`).\n * That is a valid optimization for WebGL2 stereo, where both eyes render into a single side-by-side\n * texture and the left eye's full clear already covers the whole texture. WebGPU projection layers give\n * each eye its OWN render target (a distinct array layer rendered in a separate render pass), so the\n * right eye's color and — critically — depth would never be cleared, leaving its depth test to reject\n * every fragment (a black right eye). The scene notifies `onClearObservable` regardless of\n * `camera.isRightCamera`, so this observer clears both eyes' targets. WebGL providers never attach it,\n * so the WebGL path is unchanged.\n *\n * Color is cleared at most once per ENGINE FRAME, not once per `Scene.render`. The distinction matters:\n * more than one scene can render the same XR camera within a single XR frame. `UtilityLayerRenderer`\n * (used by controller pointer selection and near interaction) renders a second scene through the same\n * rig cameras, and every `Scene.render` resets `RenderTargetTexture._cleared` for those cameras' targets\n * (`Scene._checkCameraRenderTarget`), so a `_cleared`-based guard is defeated and each eye is re-cleared\n * after it was drawn — presenting a clear-colored frame with the geometry gone. `AbstractEngine.frameId`\n * only advances in `endFrame`, once per XR frame, so unlike `_cleared` it cannot be reset by another\n * scene rendering the same camera.\n *\n * In immersive AR, color is cleared to transparent when `WebXRExperienceHelper` disables\n * `Scene.autoClear`. WebGL XR framebuffers are cleared to transparent by the user agent, but WebGPU render\n * passes require the application to request that clear explicitly. Skipping it leaves pixels from prior\n * frames in passthrough regions, producing trails behind moving objects.\n *\n * Depth and stencil are still cleared on every notification, matching the previous behavior and the\n * expectations of overlay scenes that draw on top of the main scene.\n * @param renderTargetTexture the per-eye render target to clear each frame\n */\n private _attachPerEyeClearObserver(renderTargetTexture: RenderTargetTexture): void {\n let lastColorClearedFrameId = -1;\n renderTargetTexture.onClearObservable.add((engine) => {\n // Honor skipInitialClear so this observer preserves the default clear semantics it replaces.\n if (renderTargetTexture.skipInitialClear) {\n return;\n }\n const scene = renderTargetTexture.getScene();\n const isImmersiveAR = this._xrSessionManager.sessionMode === \"immersive-ar\";\n // When autoClear is disabled the scene does not clear render targets; match that so this observer\n // does not force a clear the user opted out of. Immersive AR is the exception: the experience\n // helper disables autoClear because WebGL XR is cleared by the user agent, while WebGPU is not.\n if (scene && !scene.autoClear && !isImmersiveAR) {\n return;\n }\n const clearColor = engine.frameId !== lastColorClearedFrameId;\n const color = isImmersiveAR && scene && !scene.autoClear ? this._transparentClearColor : (renderTargetTexture.clearColor ?? scene?.clearColor ?? null);\n engine.clear(color, clearColor, true, true);\n if (clearColor) {\n lastColorClearedFrameId = engine.frameId;\n }\n // Kept in sync so anything else reading the flag still sees this target as cleared this frame.\n renderTargetTexture._cleared = true;\n });\n }\n\n /**\n * Repoints the wrapped color/depth textures of an existing render target at the current frame's\n * GPUTextures, preserving the RenderTargetTexture / InternalTexture identity held by the XR camera's\n * `outputRenderTarget`. The sub-image textures are only valid for the current frame and may rotate from\n * a compositor pool, so this must run every frame. The new GPUTextures must have the same dimensions as\n * the wrapped ones (guaranteed by the caller's size-change branch, which rebuilds instead).\n * @param renderTargetTexture the render target whose wrapped textures should be repointed\n * @param colorTexture the current frame's color GPUTexture\n * @param depthStencilTexture the current frame's depth/stencil GPUTexture, if any\n */\n protected _updateRenderTargetTextureFromGPUTextures(renderTargetTexture: RenderTargetTexture, colorTexture: GPUTexture, depthStencilTexture: Nullable<GPUTexture>): void {\n const color = renderTargetTexture._texture;\n if (color) {\n this._webgpuEngine.updateWrappedWebGPUTexture(color, colorTexture);\n }\n const depth = renderTargetTexture.renderTarget?._depthStencilTexture;\n if (depth && depthStencilTexture) {\n this._webgpuEngine.updateWrappedWebGPUTexture(depth, depthStencilTexture);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onerjs/core",
3
- "version": "8.55.8",
3
+ "version": "8.55.9",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
package/scene.pure.d.ts CHANGED
@@ -1105,6 +1105,7 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
1105
1105
  _cachedVisibility: Nullable<number>;
1106
1106
  private _renderId;
1107
1107
  private _frameId;
1108
+ private _renderingMeshEvaluationDepth;
1108
1109
  private _executeWhenReadyTimeoutId;
1109
1110
  /** @internal */
1110
1111
  _intermediateRendering: boolean;
@@ -2245,6 +2246,8 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
2245
2246
  freeRenderingGroups(): void;
2246
2247
  /** @internal */
2247
2248
  _isInIntermediateRendering(): boolean;
2249
+ /** @internal */
2250
+ _isInRenderingMeshEvaluation(): boolean;
2248
2251
  /**
2249
2252
  * Lambda returning the list of potentially active meshes.
2250
2253
  */
@@ -2329,6 +2332,7 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
2329
2332
  */
2330
2333
  customRenderFunction?: (updateCameras: boolean, ignoreAnimations: boolean) => void;
2331
2334
  private _renderWithFrameGraph;
2335
+ private _renderWithFrameGraphAfterBeforeRender;
2332
2336
  /**
2333
2337
  * @internal
2334
2338
  */
@@ -2340,6 +2344,7 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
2340
2344
  * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
2341
2345
  */
2342
2346
  render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
2347
+ private _renderFrame;
2343
2348
  /**
2344
2349
  * Freeze all materials
2345
2350
  * A frozen material will not be updatable but should be faster to render