@onerjs/core 8.55.9 → 8.56.2

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 (265) hide show
  1. package/AudioV2/webAudio/webAudioEngine.d.ts +7 -0
  2. package/AudioV2/webAudio/webAudioEngine.js +6 -5
  3. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  4. package/Cameras/arcRotateCamera.pure.js +24 -0
  5. package/Cameras/arcRotateCamera.pure.js.map +1 -1
  6. package/Culling/Helper/boundingInfoHelper.js +8 -4
  7. package/Culling/Helper/boundingInfoHelper.js.map +1 -1
  8. package/Engines/AbstractEngine/abstractEngine.textureLoaders.d.ts +5 -1
  9. package/Engines/AbstractEngine/abstractEngine.textureLoaders.js +7 -3
  10. package/Engines/AbstractEngine/abstractEngine.textureLoaders.js.map +1 -1
  11. package/Engines/AbstractEngine/abstractEngine.textureLoaders.pure.d.ts +6 -0
  12. package/Engines/AbstractEngine/abstractEngine.textureLoaders.pure.js +16 -0
  13. package/Engines/AbstractEngine/abstractEngine.textureLoaders.pure.js.map +1 -0
  14. package/Engines/AbstractEngine/pure.d.ts +1 -0
  15. package/Engines/AbstractEngine/pure.js +1 -0
  16. package/Engines/AbstractEngine/pure.js.map +1 -1
  17. package/Engines/IDrawContext.d.ts +2 -0
  18. package/Engines/IDrawContext.js.map +1 -1
  19. package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
  20. package/Engines/WebGPU/webgpuDrawContext.js +15 -0
  21. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  22. package/Engines/abstractEngine.pure.js +2 -2
  23. package/Engines/abstractEngine.pure.js.map +1 -1
  24. package/Engines/constants.d.ts +5 -0
  25. package/Engines/constants.js +5 -0
  26. package/Engines/constants.js.map +1 -1
  27. package/Engines/engine.d.ts +11 -3
  28. package/Engines/webgpuEngine.d.ts +1 -0
  29. package/Engines/webgpuEngine.js +1 -0
  30. package/Engines/webgpuEngine.js.map +1 -1
  31. package/Engines/webgpuEngine.pure.d.ts +10 -0
  32. package/Engines/webgpuEngine.pure.js +15 -1
  33. package/Engines/webgpuEngine.pure.js.map +1 -1
  34. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.d.ts +4 -0
  35. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js +12 -0
  36. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js.map +1 -1
  37. package/FrameGraph/Node/Blocks/inputBlock.pure.js +2 -1
  38. package/FrameGraph/Node/Blocks/inputBlock.pure.js.map +1 -1
  39. package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +2 -0
  40. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +2 -0
  41. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
  42. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +21 -0
  43. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +45 -0
  44. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  45. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js +2 -5
  46. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js.map +1 -1
  47. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.d.ts +1 -0
  48. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js +18 -3
  49. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js.map +1 -1
  50. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js +2 -0
  51. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js.map +1 -1
  52. package/Materials/Node/Blocks/Fragment/prePassOutputBlock.pure.js +5 -21
  53. package/Materials/Node/Blocks/Fragment/prePassOutputBlock.pure.js.map +1 -1
  54. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +1 -0
  55. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
  56. package/Materials/Node/Blocks/powBlock.pure.js +2 -1
  57. package/Materials/Node/Blocks/powBlock.pure.js.map +1 -1
  58. package/Materials/Node/Blocks/triPlanarBlock.pure.js +14 -12
  59. package/Materials/Node/Blocks/triPlanarBlock.pure.js.map +1 -1
  60. package/Materials/Node/nodeMaterial.pure.d.ts +11 -0
  61. package/Materials/Node/nodeMaterial.pure.js +11 -0
  62. package/Materials/Node/nodeMaterial.pure.js.map +1 -1
  63. package/Materials/Node/nodeMaterialBuildState.d.ts +4 -3
  64. package/Materials/Node/nodeMaterialBuildState.js +7 -1
  65. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  66. package/Materials/PBR/openpbrMaterial.pure.d.ts +4 -0
  67. package/Materials/PBR/pbrBaseMaterial.pure.d.ts +4 -0
  68. package/Materials/Textures/index.d.ts +1 -0
  69. package/Materials/Textures/index.js +1 -0
  70. package/Materials/Textures/index.js.map +1 -1
  71. package/Materials/Textures/textureProcessor.d.ts +29 -6
  72. package/Materials/Textures/textureProcessor.js +22 -16
  73. package/Materials/Textures/textureProcessor.js.map +1 -1
  74. package/Materials/drawWrapper.js +3 -0
  75. package/Materials/drawWrapper.js.map +1 -1
  76. package/Materials/imageProcessingConfiguration.defines.d.ts +3 -0
  77. package/Materials/imageProcessingConfiguration.defines.js +2 -0
  78. package/Materials/imageProcessingConfiguration.defines.js.map +1 -1
  79. package/Materials/imageProcessingConfiguration.functions.js +3 -0
  80. package/Materials/imageProcessingConfiguration.functions.js.map +1 -1
  81. package/Materials/imageProcessingConfiguration.pure.d.ts +58 -0
  82. package/Materials/imageProcessingConfiguration.pure.js +123 -2
  83. package/Materials/imageProcessingConfiguration.pure.js.map +1 -1
  84. package/Materials/materialHelper.geometryrendering.d.ts +19 -0
  85. package/Materials/materialHelper.geometryrendering.js +29 -1
  86. package/Materials/materialHelper.geometryrendering.js.map +1 -1
  87. package/Materials/prepass.defines.d.ts +3 -0
  88. package/Materials/prepass.defines.js +3 -0
  89. package/Materials/prepass.defines.js.map +1 -1
  90. package/Materials/standardMaterial.pure.d.ts +4 -0
  91. package/Materials/uniformBuffer.d.ts +29 -0
  92. package/Materials/uniformBuffer.js +146 -0
  93. package/Materials/uniformBuffer.js.map +1 -1
  94. package/Maths/colorTemperature.functions.d.ts +29 -0
  95. package/Maths/colorTemperature.functions.js +196 -0
  96. package/Maths/colorTemperature.functions.js.map +1 -0
  97. package/Maths/index.d.ts +1 -0
  98. package/Maths/index.js +1 -0
  99. package/Maths/index.js.map +1 -1
  100. package/Maths/math.vector.pure.d.ts +1 -5
  101. package/Maths/math.vector.pure.js.map +1 -1
  102. package/Maths/pure.d.ts +1 -0
  103. package/Maths/pure.js +1 -0
  104. package/Maths/pure.js.map +1 -1
  105. package/Misc/filesInput.d.ts +15 -0
  106. package/Misc/filesInput.js +156 -74
  107. package/Misc/filesInput.js.map +1 -1
  108. package/Misc/observable.pure.js +1 -3
  109. package/Misc/observable.pure.js.map +1 -1
  110. package/Misc/tools.pure.js +1 -1
  111. package/Misc/tools.pure.js.map +1 -1
  112. package/PostProcesses/imageProcessingPostProcess.d.ts +41 -1
  113. package/PostProcesses/imageProcessingPostProcess.js +41 -1
  114. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  115. package/PostProcesses/thinImageProcessingPostProcess.d.ts +50 -0
  116. package/PostProcesses/thinImageProcessingPostProcess.js +65 -0
  117. package/PostProcesses/thinImageProcessingPostProcess.js.map +1 -1
  118. package/Rendering/IBLShadows/iblShadowsMaterialCompatibility.pure.d.ts +12 -0
  119. package/Rendering/IBLShadows/iblShadowsMaterialCompatibility.pure.js +22 -0
  120. package/Rendering/IBLShadows/iblShadowsMaterialCompatibility.pure.js.map +1 -0
  121. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.d.ts +1 -0
  122. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js +39 -0
  123. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js.map +1 -1
  124. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +2 -4
  125. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
  126. package/Rendering/IBLShadows/pure.d.ts +1 -0
  127. package/Rendering/IBLShadows/pure.js +1 -0
  128. package/Rendering/IBLShadows/pure.js.map +1 -1
  129. package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +11 -0
  130. package/Rendering/fluidRenderer/fluidRenderingObject.js +36 -14
  131. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
  132. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.d.ts +5 -0
  133. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +16 -3
  134. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
  135. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +5 -0
  136. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +12 -0
  137. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
  138. package/Rendering/geometryBufferRenderer.pure.d.ts +30 -0
  139. package/Rendering/geometryBufferRenderer.pure.js +84 -0
  140. package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
  141. package/Rendering/iblCdfGenerator.js +10 -1
  142. package/Rendering/iblCdfGenerator.js.map +1 -1
  143. package/Shaders/ShadersInclude/hdrFilteringFunctions.js +1 -1
  144. package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  145. package/Shaders/ShadersInclude/helperFunctions.js +2 -2
  146. package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
  147. package/Shaders/ShadersInclude/imageProcessingDeclaration.js +3 -0
  148. package/Shaders/ShadersInclude/imageProcessingDeclaration.js.map +1 -1
  149. package/Shaders/ShadersInclude/imageProcessingFunctions.js +3 -0
  150. package/Shaders/ShadersInclude/imageProcessingFunctions.js.map +1 -1
  151. package/Shaders/ShadersInclude/objectIdFunctions.d.ts +5 -0
  152. package/Shaders/ShadersInclude/objectIdFunctions.js +22 -0
  153. package/Shaders/ShadersInclude/objectIdFunctions.js.map +1 -0
  154. package/Shaders/ShadersInclude/openpbrBlockPrePass.js +3 -0
  155. package/Shaders/ShadersInclude/openpbrBlockPrePass.js.map +1 -1
  156. package/Shaders/ShadersInclude/openpbrDirectLighting.js +34 -4
  157. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  158. package/Shaders/ShadersInclude/openpbrIblFunctions.js +8 -2
  159. package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  160. package/Shaders/ShadersInclude/pbrBlockPrePass.js +3 -0
  161. package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -1
  162. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +5 -0
  163. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  164. package/Shaders/ShadersInclude/prePassDeclaration.d.ts +1 -0
  165. package/Shaders/ShadersInclude/prePassDeclaration.js +5 -0
  166. package/Shaders/ShadersInclude/prePassDeclaration.js.map +1 -1
  167. package/Shaders/default.fragment.js +5 -1
  168. package/Shaders/default.fragment.js.map +1 -1
  169. package/Shaders/fluidRenderingParticleDepth.vertex.js +7 -1
  170. package/Shaders/fluidRenderingParticleDepth.vertex.js.map +1 -1
  171. package/Shaders/fluidRenderingParticleDiffuse.vertex.js +7 -1
  172. package/Shaders/fluidRenderingParticleDiffuse.vertex.js.map +1 -1
  173. package/Shaders/fluidRenderingParticleThickness.vertex.js +7 -1
  174. package/Shaders/fluidRenderingParticleThickness.vertex.js.map +1 -1
  175. package/Shaders/geometry.fragment.js +9 -1
  176. package/Shaders/geometry.fragment.js.map +1 -1
  177. package/Shaders/openpbr.fragment.js +2 -1
  178. package/Shaders/openpbr.fragment.js.map +1 -1
  179. package/Shaders/pbr.fragment.js +2 -1
  180. package/Shaders/pbr.fragment.js.map +1 -1
  181. package/ShadersWGSL/ShadersInclude/imageProcessingDeclaration.js +3 -0
  182. package/ShadersWGSL/ShadersInclude/imageProcessingDeclaration.js.map +1 -1
  183. package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js +3 -0
  184. package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js.map +1 -1
  185. package/ShadersWGSL/ShadersInclude/objectIdFunctions.d.ts +5 -0
  186. package/ShadersWGSL/ShadersInclude/objectIdFunctions.js +22 -0
  187. package/ShadersWGSL/ShadersInclude/objectIdFunctions.js.map +1 -0
  188. package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.js +3 -0
  189. package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.js.map +1 -1
  190. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +35 -5
  191. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  192. package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js +1 -1
  193. package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
  194. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +8 -2
  195. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  196. package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +3 -0
  197. package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
  198. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +5 -0
  199. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  200. package/ShadersWGSL/ShadersInclude/prePassDeclaration.d.ts +1 -0
  201. package/ShadersWGSL/ShadersInclude/prePassDeclaration.js +5 -0
  202. package/ShadersWGSL/ShadersInclude/prePassDeclaration.js.map +1 -1
  203. package/ShadersWGSL/default.fragment.js +5 -1
  204. package/ShadersWGSL/default.fragment.js.map +1 -1
  205. package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js +16 -4
  206. package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js.map +1 -1
  207. package/ShadersWGSL/fluidRenderingParticleDiffuse.vertex.js +15 -3
  208. package/ShadersWGSL/fluidRenderingParticleDiffuse.vertex.js.map +1 -1
  209. package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js +15 -3
  210. package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js.map +1 -1
  211. package/ShadersWGSL/geometry.fragment.js +9 -1
  212. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  213. package/ShadersWGSL/openpbr.fragment.js +2 -1
  214. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  215. package/ShadersWGSL/pbr.fragment.js +2 -1
  216. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  217. package/XR/features/Layers/WebXRCompositionLayer.d.ts +52 -0
  218. package/XR/features/Layers/WebXRCompositionLayer.js +80 -0
  219. package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
  220. package/XR/features/WebXRControllerPointerSelection.pure.js +2 -1
  221. package/XR/features/WebXRControllerPointerSelection.pure.js.map +1 -1
  222. package/XR/features/WebXRControllerTeleportation.pure.js +2 -1
  223. package/XR/features/WebXRControllerTeleportation.pure.js.map +1 -1
  224. package/XR/features/WebXRDepthSensing.pure.d.ts +21 -0
  225. package/XR/features/WebXRDepthSensing.pure.js +42 -0
  226. package/XR/features/WebXRDepthSensing.pure.js.map +1 -1
  227. package/XR/features/WebXRHandTracking.pure.js +2 -0
  228. package/XR/features/WebXRHandTracking.pure.js.map +1 -1
  229. package/XR/features/WebXRLayers.pure.d.ts +12 -0
  230. package/XR/features/WebXRLayers.pure.js +31 -1
  231. package/XR/features/WebXRLayers.pure.js.map +1 -1
  232. package/XR/features/WebXRTrackedSources.d.ts +5 -0
  233. package/XR/features/WebXRTrackedSources.js +8 -0
  234. package/XR/features/WebXRTrackedSources.js.map +1 -0
  235. package/XR/features/WebXRTrackedSources.pure.d.ts +70 -0
  236. package/XR/features/WebXRTrackedSources.pure.js +153 -0
  237. package/XR/features/WebXRTrackedSources.pure.js.map +1 -0
  238. package/XR/features/index.d.ts +1 -0
  239. package/XR/features/index.js +1 -0
  240. package/XR/features/index.js.map +1 -1
  241. package/XR/features/pure.d.ts +1 -0
  242. package/XR/features/pure.js +1 -0
  243. package/XR/features/pure.js.map +1 -1
  244. package/XR/motionController/webXRAbstractMotionController.d.ts +53 -1
  245. package/XR/motionController/webXRAbstractMotionController.js +61 -0
  246. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  247. package/XR/webXRDefaultExperience.js +8 -4
  248. package/XR/webXRDefaultExperience.js.map +1 -1
  249. package/XR/webXRExperienceHelper.js +86 -44
  250. package/XR/webXRExperienceHelper.js.map +1 -1
  251. package/XR/webXRFeaturesManager.d.ts +9 -0
  252. package/XR/webXRFeaturesManager.js +4 -0
  253. package/XR/webXRFeaturesManager.js.map +1 -1
  254. package/XR/webXRGraphicsBinding.d.ts +29 -0
  255. package/XR/webXRGraphicsBinding.js +40 -0
  256. package/XR/webXRGraphicsBinding.js.map +1 -1
  257. package/XR/webXRInputSource.js +1 -1
  258. package/XR/webXRInputSource.js.map +1 -1
  259. package/XR/webXRLayerWrapper.d.ts +7 -5
  260. package/XR/webXRLayerWrapper.js +10 -7
  261. package/XR/webXRLayerWrapper.js.map +1 -1
  262. package/XR/webXRSessionManager.d.ts +45 -0
  263. package/XR/webXRSessionManager.js +174 -29
  264. package/XR/webXRSessionManager.js.map +1 -1
  265. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"webXRFeaturesManager.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRFeaturesManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAwB3C,OAAO,EAAE,0CAA0C,EAAE,MAAM,+BAA+B,CAAC;AA2E3F;;GAEG;AACH,MAAM,OAAO,gBAAgB;;AACzB;;GAEG;AACoB,8BAAa,GAAG,kBAA2B,CAAC;AACnE;;GAEG;AACoB,mCAAkB,GAAG,uBAAgC,CAAC;AAC7E;;GAEG;AACoB,yBAAQ,GAAG,aAAsB,CAAC;AACzD;;GAEG;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AAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBACpD,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACJ,aAAa,CAAC,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,IAAI,EAAE,CAAC;oBACtE,IAAI,aAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;wBAC5D,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBACpD,CAAC;gBACL,CAAC;YACL,CAAC;YACD,IAAI,OAAO,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBAC1D,4CAA4C;gBAC5C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBACjF,aAAa,GAAG;oBACZ,GAAG,aAAa;oBAChB,GAAG,QAAQ;iBACd,CAAC;YACN,CAAC;QACL,CAAC;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;;AAnWuB,uCAAkB,GAMtC,EAAE,AANoC,CAMnC;AAWP;;GAEG;AACqB,yCAAoB,GAA8B;IACtE,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAC,QAAQ;IAC3D,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,aAAa;CAC9D,AAH2C,CAG1C","sourcesContent":["import { type Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"../Misc/tools.pure\";\r\nimport { type IDisposable } from \"../scene\";\r\nimport { type IWebXRAnchorSystemOptions, type WebXRAnchorSystem } from \"./features/WebXRAnchorSystem\";\r\nimport { type IWebXRBackgroundRemoverOptions, type WebXRBackgroundRemover } from \"./features/WebXRBackgroundRemover\";\r\nimport { type IWebXRBodyTrackingOptions, type WebXRBodyTracking } from \"./features/WebXRBodyTracking\";\r\nimport { type IWebXRControllerMovementOptions, type WebXRControllerMovement } from \"./features/WebXRControllerMovement\";\r\nimport { type IWebXRControllerPhysicsOptions, type WebXRControllerPhysics } from \"./features/WebXRControllerPhysics\";\r\nimport { type IWebXRControllerPointerSelectionOptions, type WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection\";\r\nimport { type IWebXRTeleportationOptions, type WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation\";\r\nimport { type IWebXRDepthSensingOptions, type WebXRDepthSensing } from \"./features/WebXRDepthSensing\";\r\nimport { type IWebXRDomOverlayOptions, type WebXRDomOverlay } from \"./features/WebXRDOMOverlay\";\r\nimport { type WebXREyeTracking } from \"./features/WebXREyeTracking\";\r\nimport { type WebXRFeaturePointSystem } from \"./features/WebXRFeaturePointSystem\";\r\nimport { type IWebXRHandTrackingOptions, type WebXRHandTracking } from \"./features/WebXRHandTracking\";\r\nimport { type IWebXRHitTestOptions, type WebXRHitTest } from \"./features/WebXRHitTest\";\r\nimport { type IWebXRImageTrackingOptions, type WebXRImageTracking } from \"./features/WebXRImageTracking\";\r\nimport { type IWebXRLayersOptions, type WebXRLayers } from \"./features/WebXRLayers\";\r\nimport { type IWebXRLightEstimationOptions, type WebXRLightEstimation } from \"./features/WebXRLightEstimation\";\r\nimport { type IWebXRMeshDetectorOptions, type WebXRMeshDetector } from \"./features/WebXRMeshDetector\";\r\nimport { type IWebXRNearInteractionOptions, type WebXRNearInteraction } from \"./features/WebXRNearInteraction\";\r\nimport { type IWebXRPlaneDetectorOptions, type WebXRPlaneDetector } from \"./features/WebXRPlaneDetector\";\r\nimport { type IWebXRRawCameraAccessOptions, type WebXRRawCameraAccess } from \"./features/WebXRRawCameraAccess\";\r\nimport { type WebXRSpaceWarp } from \"./features/WebXRSpaceWarp\";\r\nimport { type IWebXRWalkingLocomotionOptions, type WebXRWalkingLocomotion } from \"./features/WebXRWalkingLocomotion\";\r\nimport { _ConsumeWebXRFeatureSpecificDisableWarning } from \"./webXRFeatureWarningRegistry\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\n\r\n/**\r\n * Defining the interface required for a (webxr) feature\r\n */\r\nexport interface IWebXRFeature extends IDisposable {\r\n /**\r\n * Is this feature attached\r\n */\r\n attached: boolean;\r\n /**\r\n * Should auto-attach be disabled?\r\n */\r\n disableAutoAttach: boolean;\r\n /**\r\n * The auto-attach policy in effect before the features manager starts a manual attachment.\r\n * @internal\r\n */\r\n _autoAttachPolicyBeforeAttach?: boolean;\r\n\r\n /**\r\n * Attach the feature to the session\r\n * Will usually be called by the features manager\r\n *\r\n * @param force should attachment be forced (even when already attached)\r\n * @returns true if successful.\r\n */\r\n attach(force?: boolean): boolean;\r\n /**\r\n * Detach the feature from the session\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n detach(): boolean;\r\n\r\n /**\r\n * This function will be executed during before enabling the feature and can be used to not-allow enabling it.\r\n * Note that at this point the session has NOT started, so this is purely checking if the browser supports it\r\n *\r\n * @returns whether or not the feature is compatible in this environment\r\n */\r\n isCompatible(): boolean;\r\n\r\n /**\r\n * Was this feature disposed;\r\n */\r\n isDisposed: boolean;\r\n\r\n /**\r\n * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)\r\n */\r\n xrNativeFeatureName?: string;\r\n\r\n /**\r\n * A list of (Babylon WebXR) features this feature depends on\r\n */\r\n dependsOn?: string[];\r\n\r\n /**\r\n * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object\r\n */\r\n getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;\r\n\r\n /**\r\n * Triggered when the feature is attached\r\n */\r\n onFeatureAttachObservable: Observable<IWebXRFeature>;\r\n /**\r\n * Triggered when the feature is detached\r\n */\r\n onFeatureDetachObservable: Observable<IWebXRFeature>;\r\n}\r\n\r\n/**\r\n * A list of the currently available features without referencing them\r\n */\r\nexport class WebXRFeatureName {\r\n /**\r\n * The name of the anchor system feature\r\n */\r\n public static readonly ANCHOR_SYSTEM = \"xr-anchor-system\" as const;\r\n /**\r\n * The name of the background remover feature\r\n */\r\n public static readonly BACKGROUND_REMOVER = \"xr-background-remover\" as const;\r\n /**\r\n * The name of the hit test feature\r\n */\r\n public static readonly HIT_TEST = \"xr-hit-test\" as const;\r\n /**\r\n * The name of the mesh detection feature\r\n */\r\n public static readonly MESH_DETECTION = \"xr-mesh-detection\" as const;\r\n /**\r\n * physics impostors for xr controllers feature\r\n */\r\n public static readonly PHYSICS_CONTROLLERS = \"xr-physics-controller\" as const;\r\n /**\r\n * The name of the plane detection feature\r\n */\r\n public static readonly PLANE_DETECTION = \"xr-plane-detection\" as const;\r\n /**\r\n * The name of the pointer selection feature\r\n */\r\n public static readonly POINTER_SELECTION = \"xr-controller-pointer-selection\" as const;\r\n /**\r\n * The name of the teleportation feature\r\n */\r\n public static readonly TELEPORTATION = \"xr-controller-teleportation\" as const;\r\n /**\r\n * The name of the feature points feature.\r\n */\r\n public static readonly FEATURE_POINTS = \"xr-feature-points\" as const;\r\n /**\r\n * The name of the hand tracking feature.\r\n */\r\n public static readonly HAND_TRACKING = \"xr-hand-tracking\" as const;\r\n /**\r\n * The name of the image tracking feature\r\n */\r\n public static readonly IMAGE_TRACKING = \"xr-image-tracking\" as const;\r\n /**\r\n * The name of the near interaction feature\r\n */\r\n public static readonly NEAR_INTERACTION = \"xr-near-interaction\" as const;\r\n /**\r\n * The name of the DOM overlay feature\r\n */\r\n public static readonly DOM_OVERLAY = \"xr-dom-overlay\" as const;\r\n /**\r\n * The name of the movement feature\r\n */\r\n public static readonly MOVEMENT = \"xr-controller-movement\" as const;\r\n /**\r\n * The name of the light estimation feature\r\n */\r\n public static readonly LIGHT_ESTIMATION = \"xr-light-estimation\" as const;\r\n /**\r\n * The name of the eye tracking feature\r\n */\r\n public static readonly EYE_TRACKING = \"xr-eye-tracking\" as const;\r\n /**\r\n * The name of the walking locomotion feature\r\n */\r\n public static readonly WALKING_LOCOMOTION = \"xr-walking-locomotion\" as const;\r\n /**\r\n * The name of the composition layers feature\r\n */\r\n public static readonly LAYERS = \"xr-layers\" as const;\r\n /**\r\n * The name of the depth sensing feature\r\n */\r\n public static readonly DEPTH_SENSING = \"xr-depth-sensing\" as const;\r\n /**\r\n * The name of the WebXR Space Warp feature\r\n */\r\n public static readonly SPACE_WARP = \"xr-space-warp\" as const;\r\n /**\r\n * The name of the WebXR Raw Camera Access feature\r\n */\r\n public static readonly RAW_CAMERA_ACCESS = \"xr-raw-camera-access\" as const;\r\n /**\r\n * The name of the body tracking feature\r\n */\r\n public static readonly BODY_TRACKING = \"xr-body-tracking\" as const;\r\n}\r\n\r\nexport type WebXRFeatureNameType = (typeof WebXRFeatureName)[Exclude<keyof typeof WebXRFeatureName, \"prototype\">];\r\n\r\n/**\r\n * Maps feature names to their corresponding feature implementation classes.\r\n */\r\nexport interface IWebXRFeatureNameTypeMap {\r\n /** Anchor system feature implementation. */\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: WebXRAnchorSystem;\r\n /** Background remover feature implementation. */\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: WebXRBackgroundRemover;\r\n /** Depth sensing feature implementation. */\r\n [WebXRFeatureName.DEPTH_SENSING]: WebXRDepthSensing;\r\n /** DOM overlay feature implementation. */\r\n [WebXRFeatureName.DOM_OVERLAY]: WebXRDomOverlay;\r\n /** Eye tracking feature implementation. */\r\n [WebXRFeatureName.EYE_TRACKING]: WebXREyeTracking;\r\n /** Feature points feature implementation. */\r\n [WebXRFeatureName.FEATURE_POINTS]: WebXRFeaturePointSystem;\r\n /** Hand tracking feature implementation. */\r\n [WebXRFeatureName.HAND_TRACKING]: WebXRHandTracking;\r\n /** Hit test feature implementation. */\r\n [WebXRFeatureName.HIT_TEST]: WebXRHitTest;\r\n /** Image tracking feature implementation. */\r\n [WebXRFeatureName.IMAGE_TRACKING]: WebXRImageTracking;\r\n /** Layers feature implementation. */\r\n [WebXRFeatureName.LAYERS]: WebXRLayers;\r\n /** Light estimation feature implementation. */\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: WebXRLightEstimation;\r\n /** Mesh detection feature implementation. */\r\n [WebXRFeatureName.MESH_DETECTION]: WebXRMeshDetector;\r\n /** Controller movement feature implementation. */\r\n [WebXRFeatureName.MOVEMENT]: WebXRControllerMovement;\r\n /** Near interaction feature implementation. */\r\n [WebXRFeatureName.NEAR_INTERACTION]: WebXRNearInteraction;\r\n /** Physics controllers feature implementation. */\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: WebXRControllerPhysics;\r\n /** Plane detection feature implementation. */\r\n [WebXRFeatureName.PLANE_DETECTION]: WebXRPlaneDetector;\r\n /** Controller pointer selection feature implementation. */\r\n [WebXRFeatureName.POINTER_SELECTION]: WebXRControllerPointerSelection;\r\n /** Raw camera access feature implementation. */\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: WebXRRawCameraAccess;\r\n /** Space warp feature implementation. */\r\n [WebXRFeatureName.SPACE_WARP]: WebXRSpaceWarp;\r\n /** Teleportation feature implementation. */\r\n [WebXRFeatureName.TELEPORTATION]: WebXRMotionControllerTeleportation;\r\n /** Walking locomotion feature implementation. */\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: WebXRWalkingLocomotion;\r\n /** Body tracking feature implementation. */\r\n [WebXRFeatureName.BODY_TRACKING]: WebXRBodyTracking;\r\n}\r\n\r\n/**\r\n * Maps feature names to their corresponding options interfaces.\r\n */\r\nexport interface IWebXRFeatureNameOptionsMap {\r\n /** Anchor system feature options. */\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: IWebXRAnchorSystemOptions;\r\n /** Background remover feature options. */\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: IWebXRBackgroundRemoverOptions;\r\n /** Depth sensing feature options. */\r\n [WebXRFeatureName.DEPTH_SENSING]: IWebXRDepthSensingOptions;\r\n /** DOM overlay feature options. */\r\n [WebXRFeatureName.DOM_OVERLAY]: IWebXRDomOverlayOptions;\r\n /** Eye tracking feature options. */\r\n [WebXRFeatureName.EYE_TRACKING]: undefined;\r\n /** Feature points feature options. */\r\n [WebXRFeatureName.FEATURE_POINTS]: undefined;\r\n /** Hand tracking feature options. */\r\n [WebXRFeatureName.HAND_TRACKING]: IWebXRHandTrackingOptions;\r\n /** Hit test feature options. */\r\n [WebXRFeatureName.HIT_TEST]: IWebXRHitTestOptions;\r\n /** Image tracking feature options. */\r\n [WebXRFeatureName.IMAGE_TRACKING]: IWebXRImageTrackingOptions;\r\n /** Layers feature options. */\r\n [WebXRFeatureName.LAYERS]: IWebXRLayersOptions;\r\n /** Light estimation feature options. */\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: IWebXRLightEstimationOptions;\r\n /** Mesh detection feature options. */\r\n [WebXRFeatureName.MESH_DETECTION]: IWebXRMeshDetectorOptions;\r\n /** Controller movement feature options. */\r\n [WebXRFeatureName.MOVEMENT]: IWebXRControllerMovementOptions;\r\n /** Near interaction feature options. */\r\n [WebXRFeatureName.NEAR_INTERACTION]: IWebXRNearInteractionOptions;\r\n /** Physics controllers feature options. */\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: IWebXRControllerPhysicsOptions;\r\n /** Plane detection feature options. */\r\n [WebXRFeatureName.PLANE_DETECTION]: IWebXRPlaneDetectorOptions;\r\n /** Controller pointer selection feature options. */\r\n [WebXRFeatureName.POINTER_SELECTION]: IWebXRControllerPointerSelectionOptions;\r\n /** Raw camera access feature options. */\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: IWebXRRawCameraAccessOptions;\r\n /** Space warp feature options. */\r\n [WebXRFeatureName.SPACE_WARP]: undefined;\r\n /** Teleportation feature options. */\r\n [WebXRFeatureName.TELEPORTATION]: IWebXRTeleportationOptions;\r\n /** Walking locomotion feature options. */\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: IWebXRWalkingLocomotionOptions;\r\n /** Body tracking feature options. */\r\n [WebXRFeatureName.BODY_TRACKING]: IWebXRBodyTrackingOptions;\r\n}\r\n\r\n/**\r\n * Helper type that expands/flattens a type to show its properties inline in IntelliSense\r\n */\r\ntype Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;\r\n\r\n/**\r\n * Helper type to resolve the specific feature type based on the feature name,\r\n * or fallback to IWebXRFeature if the feature name is not in the type map.\r\n */\r\nexport type ResolveWebXRFeature<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameTypeMap ? IWebXRFeatureNameTypeMap[T] : IWebXRFeature;\r\n\r\n/**\r\n * Helper type to resolve the options type for a specific feature based on the feature name,\r\n * or fallback to any if the feature name is not in the type map.\r\n * The Expand utility type flattens the interface to show properties inline in IntelliSense.\r\n */\r\nexport type ResolveWebXRFeatureOptions<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameOptionsMap\r\n ? IWebXRFeatureNameOptionsMap[T] extends undefined\r\n ? undefined\r\n : Expand<IWebXRFeatureNameOptionsMap[T]>\r\n : any;\r\n\r\n/**\r\n * Defining the constructor of a feature. Used to register the modules.\r\n */\r\nexport type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;\r\n\r\n/**\r\n * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.\r\n * It is mainly used in AR sessions.\r\n *\r\n * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).\r\n */\r\nexport class WebXRFeaturesManager implements IDisposable {\r\n private static readonly _AvailableFeatures: {\r\n [name: string]: {\r\n stable: number;\r\n latest: number;\r\n [version: number]: WebXRFeatureConstructor;\r\n };\r\n } = {};\r\n\r\n private _features: {\r\n [name: string]: {\r\n featureImplementation: IWebXRFeature;\r\n version: number;\r\n enabled: boolean;\r\n required: boolean;\r\n };\r\n } = {};\r\n\r\n /**\r\n * The key is the feature to check and the value is the feature that conflicts.\r\n */\r\n private static readonly _ConflictingFeatures: { [key: string]: string } = {\r\n [WebXRFeatureName.TELEPORTATION]: WebXRFeatureName.MOVEMENT,\r\n [WebXRFeatureName.MOVEMENT]: WebXRFeatureName.TELEPORTATION,\r\n };\r\n\r\n /**\r\n * constructs a new features manages.\r\n *\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n */\r\n constructor(private _xrSessionManager: WebXRSessionManager) {\r\n // when session starts / initialized - attach\r\n this._xrSessionManager.onXRSessionInit.add(() => {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && !feature.featureImplementation.attached && !feature.featureImplementation.disableAutoAttach) {\r\n this.attachFeature(featureName);\r\n }\r\n }\r\n });\r\n\r\n // when session ends - detach\r\n this._xrSessionManager.onXRSessionEnded.add(() => {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && feature.featureImplementation.attached) {\r\n // detach, but don't disable!\r\n this.detachFeature(featureName);\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Used to register a module. After calling this function a developer can use this feature in the scene.\r\n * Mainly used internally.\r\n *\r\n * @param featureName the name of the feature to register\r\n * @param constructorFunction the function used to construct the module\r\n * @param version the (babylon) version of the module\r\n * @param stable is that a stable version of this module\r\n */\r\n public static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version: number = 1, stable: boolean = false) {\r\n this._AvailableFeatures[featureName] = this._AvailableFeatures[featureName] || { latest: version };\r\n if (version > this._AvailableFeatures[featureName].latest) {\r\n this._AvailableFeatures[featureName].latest = version;\r\n }\r\n if (stable) {\r\n this._AvailableFeatures[featureName].stable = version;\r\n }\r\n this._AvailableFeatures[featureName][version] = constructorFunction;\r\n }\r\n\r\n /**\r\n * Returns a constructor of a specific feature.\r\n *\r\n * @param featureName the name of the feature to construct\r\n * @param version the version of the feature to load\r\n * @param xrSessionManager the xrSessionManager. Used to construct the module\r\n * @param options optional options provided to the module.\r\n * @returns a function that, when called, will return a new instance of this feature\r\n */\r\n public static ConstructFeature(featureName: string, version: number = 1, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature {\r\n const constructorFunction = this._AvailableFeatures[featureName][version];\r\n if (!constructorFunction) {\r\n // throw an error? return nothing?\r\n throw new Error(\"feature not found\");\r\n }\r\n\r\n return constructorFunction(xrSessionManager, options);\r\n }\r\n\r\n /**\r\n * Can be used to return the list of features currently registered\r\n *\r\n * @returns an Array of available features\r\n */\r\n public static GetAvailableFeatures() {\r\n return Object.keys(this._AvailableFeatures);\r\n }\r\n\r\n /**\r\n * Gets the versions available for a specific feature\r\n * @param featureName the name of the feature\r\n * @returns an array with the available versions\r\n */\r\n public static GetAvailableVersions(featureName: string) {\r\n return Object.keys(this._AvailableFeatures[featureName]);\r\n }\r\n\r\n /**\r\n * Return the latest unstable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetLatestVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].latest) || -1;\r\n }\r\n\r\n /**\r\n * Return the latest stable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetStableVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].stable) || -1;\r\n }\r\n\r\n /**\r\n * Attach a feature to the current session. Mainly used when session started to start the feature effect.\r\n * Can be used during a session to start a feature\r\n * @param featureName the name of feature to attach\r\n */\r\n public attachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.enabled && !feature.featureImplementation.attached) {\r\n const disableAutoAttachBeforeAttach = feature.featureImplementation.disableAutoAttach;\r\n feature.featureImplementation._autoAttachPolicyBeforeAttach = disableAutoAttachBeforeAttach;\r\n feature.featureImplementation.disableAutoAttach = false;\r\n let attached: boolean;\r\n try {\r\n attached = feature.featureImplementation.attach();\r\n } finally {\r\n delete feature.featureImplementation._autoAttachPolicyBeforeAttach;\r\n }\r\n const intentionallyDisabledDuringAttach = feature.featureImplementation.disableAutoAttach;\r\n if (!intentionallyDisabledDuringAttach) {\r\n feature.featureImplementation.disableAutoAttach = disableAutoAttachBeforeAttach;\r\n }\r\n if (!attached && !intentionallyDisabledDuringAttach) {\r\n Tools.Warn(`Feature ${featureName} failed to attach`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Can be used inside a session or when the session ends to detach a specific feature\r\n * @param featureName the name of the feature to detach\r\n */\r\n public detachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.featureImplementation.attached) {\r\n const detached = feature.featureImplementation.detach();\r\n if (!detached) {\r\n Tools.Warn(`Feature ${featureName} failed to detach`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Used to disable an already-enabled feature\r\n * The feature will be disposed and will be recreated once enabled.\r\n * @param featureName the feature to disable\r\n * @returns true if disable was successful\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public disableFeature(featureName: string | { Name: string }): boolean {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n const feature = this._features[name];\r\n if (feature && feature.enabled) {\r\n feature.enabled = false;\r\n this.detachFeature(name);\r\n feature.featureImplementation.dispose();\r\n delete this._features[name];\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * dispose this features manager\r\n */\r\n public dispose(): void {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n this.disableFeature(featureName);\r\n }\r\n }\r\n\r\n /**\r\n * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.\r\n * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.\r\n *\r\n * @param featureName the name of the feature to load or the class of the feature\r\n * @param version optional version to load. if not provided the latest version will be enabled\r\n * @param moduleOptions options provided to the module. Ses the module documentation / constructor\r\n * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible\r\n * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.\r\n * @returns a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.\r\n */\r\n public enableFeature<T extends WebXRFeatureNameType>(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n featureName: T | { Name: T },\r\n version: number | string = \"latest\",\r\n moduleOptions: ResolveWebXRFeatureOptions<T> = {} as ResolveWebXRFeatureOptions<T>,\r\n attachIfPossible: boolean = true,\r\n required: boolean = true\r\n ): ResolveWebXRFeature<T> {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n let versionToLoad: number;\r\n if (typeof version === \"string\") {\r\n if (!version) {\r\n throw new Error(`Error in provided version - ${name} (${version})`);\r\n }\r\n if (version === \"stable\") {\r\n versionToLoad = WebXRFeaturesManager.GetStableVersionOfFeature(name);\r\n } else if (version === \"latest\") {\r\n versionToLoad = WebXRFeaturesManager.GetLatestVersionOfFeature(name);\r\n } else {\r\n // try loading the number the string represents\r\n versionToLoad = +version;\r\n }\r\n if (versionToLoad === -1 || isNaN(versionToLoad)) {\r\n throw new Error(`feature not found - ${name} (${version})`);\r\n }\r\n } else {\r\n versionToLoad = version;\r\n }\r\n\r\n // check if there is a feature conflict\r\n const conflictingFeature = WebXRFeaturesManager._ConflictingFeatures[name];\r\n if (conflictingFeature !== undefined && this.getEnabledFeatures().indexOf(conflictingFeature) !== -1) {\r\n throw new Error(`Feature ${name} cannot be enabled while ${conflictingFeature} is enabled.`);\r\n }\r\n\r\n // check if already initialized\r\n const feature = this._features[name];\r\n const constructFunction = WebXRFeaturesManager.ConstructFeature(name, versionToLoad, this._xrSessionManager, moduleOptions);\r\n if (!constructFunction) {\r\n // report error?\r\n throw new Error(`feature not found - ${name}`);\r\n }\r\n\r\n /* If the feature is already enabled, detach and dispose it, and create a new one */\r\n if (feature) {\r\n this.disableFeature(name);\r\n }\r\n\r\n const constructed = constructFunction();\r\n if (constructed.dependsOn) {\r\n const dependentsFound = constructed.dependsOn.every((featureName) => !!this._features[featureName]);\r\n if (!dependentsFound) {\r\n throw new Error(`Dependant features missing. Make sure the following features are enabled - ${constructed.dependsOn.join(\", \")}`);\r\n }\r\n }\r\n _ConsumeWebXRFeatureSpecificDisableWarning(constructed);\r\n const isCompatible = constructed.isCompatible();\r\n const emittedSpecificDisableWarning = _ConsumeWebXRFeatureSpecificDisableWarning(constructed);\r\n if (isCompatible) {\r\n this._features[name] = {\r\n featureImplementation: constructed,\r\n enabled: true,\r\n version: versionToLoad,\r\n required,\r\n };\r\n\r\n if (attachIfPossible) {\r\n // if session started already, request and enable\r\n if (this._xrSessionManager.session && !this._features[name].featureImplementation.attached) {\r\n // enable feature\r\n this.attachFeature(name);\r\n }\r\n } else {\r\n // disable auto-attach when session starts\r\n this._features[name].featureImplementation.disableAutoAttach = true;\r\n }\r\n\r\n return this._features[name].featureImplementation as ResolveWebXRFeature<T>;\r\n } else {\r\n if (required) {\r\n throw new Error(\"required feature not compatible\");\r\n } else {\r\n if (!emittedSpecificDisableWarning) {\r\n Tools.Warn(`Feature ${name} not compatible with the current environment/browser and was not enabled.`);\r\n }\r\n return constructed as ResolveWebXRFeature<T>;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * get the implementation of an enabled feature.\r\n * @param featureName the name of the feature to load\r\n * @returns the feature class, if found\r\n */\r\n public getEnabledFeature<T extends WebXRFeatureNameType>(featureName: T): ResolveWebXRFeature<T> {\r\n return this._features[featureName] && (this._features[featureName].featureImplementation as ResolveWebXRFeature<T>);\r\n }\r\n\r\n /**\r\n * Get the list of enabled features\r\n * @returns an array of enabled features\r\n */\r\n public getEnabledFeatures() {\r\n return Object.keys(this._features);\r\n }\r\n\r\n /**\r\n * This function will extend the session creation configuration object with enabled features.\r\n * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,\r\n * according to the defined \"required\" variable, provided during enableFeature call\r\n * @param xrSessionInit the xr Session init object to extend\r\n *\r\n * @returns an extended XRSessionInit object\r\n */\r\n public async _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit> {\r\n const enabledFeatures = this.getEnabledFeatures();\r\n for (const featureName of enabledFeatures) {\r\n const feature = this._features[featureName];\r\n const nativeName = feature.featureImplementation.xrNativeFeatureName;\r\n if (nativeName) {\r\n if (feature.required) {\r\n xrSessionInit.requiredFeatures = xrSessionInit.requiredFeatures || [];\r\n if (xrSessionInit.requiredFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.requiredFeatures.push(nativeName);\r\n }\r\n } else {\r\n xrSessionInit.optionalFeatures = xrSessionInit.optionalFeatures || [];\r\n if (xrSessionInit.optionalFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.optionalFeatures.push(nativeName);\r\n }\r\n }\r\n }\r\n if (feature.featureImplementation.getXRSessionInitExtension) {\r\n // eslint-disable-next-line no-await-in-loop\r\n const extended = await feature.featureImplementation.getXRSessionInitExtension();\r\n xrSessionInit = {\r\n ...xrSessionInit,\r\n ...extended,\r\n };\r\n }\r\n }\r\n return xrSessionInit;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webXRFeaturesManager.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRFeaturesManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAyB3C,OAAO,EAAE,0CAA0C,EAAE,MAAM,+BAA+B,CAAC;AA2E3F;;GAEG;AACH,MAAM,OAAO,gBAAgB;;AACzB;;GAEG;AACoB,8BAAa,GAAG,kBAA2B,CAAC;AACnE;;GAEG;AACoB,mCAAkB,GAAG,uBAAgC,CAAC;AAC7E;;GAEG;AACoB,yBAAQ,GAAG,aAAsB,CAAC;AACzD;;GAEG;AACoB,+BAAc,GAAG,mBAA4B,CAAC;AACrE;;GAEG;AACoB,oCAAmB,GAAG,uBAAgC,CAAC;AAC9E;;GAEG;AACoB,gCAAe,GAAG,oBAA6B,CAAC;AACvE;;GAEG;AACoB,kCAAiB,GAAG,iCAA0C,CAAC;AACtF;;GAEG;AACoB,8BAAa,GAAG,6BAAsC,CAAC;AAC9E;;GAEG;AACoB,+BAAc,GAAG,mBAA4B,CAAC;AACrE;;GAEG;AACoB,8BAAa,GAAG,kBAA2B,CAAC;AACnE;;GAEG;AACoB,+BAAc,GAAG,mBAA4B,CAAC;A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AC;oBACpD,CAAC;gBACL,CAAC;YACL,CAAC;YACD,IAAI,OAAO,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBAC1D,4CAA4C;gBAC5C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBACjF,aAAa,GAAG;oBACZ,GAAG,aAAa;oBAChB,GAAG,QAAQ;iBACd,CAAC;YACN,CAAC;QACL,CAAC;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;;AAnWuB,uCAAkB,GAMtC,EAAE,AANoC,CAMnC;AAWP;;GAEG;AACqB,yCAAoB,GAA8B;IACtE,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAC,QAAQ;IAC3D,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,aAAa;CAC9D,AAH2C,CAG1C","sourcesContent":["import { type Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"../Misc/tools.pure\";\r\nimport { type IDisposable } from \"../scene\";\r\nimport { type IWebXRAnchorSystemOptions, type WebXRAnchorSystem } from \"./features/WebXRAnchorSystem\";\r\nimport { type IWebXRBackgroundRemoverOptions, type WebXRBackgroundRemover } from \"./features/WebXRBackgroundRemover\";\r\nimport { type IWebXRBodyTrackingOptions, type WebXRBodyTracking } from \"./features/WebXRBodyTracking\";\r\nimport { type IWebXRControllerMovementOptions, type WebXRControllerMovement } from \"./features/WebXRControllerMovement\";\r\nimport { type IWebXRControllerPhysicsOptions, type WebXRControllerPhysics } from \"./features/WebXRControllerPhysics\";\r\nimport { type IWebXRControllerPointerSelectionOptions, type WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection\";\r\nimport { type IWebXRTeleportationOptions, type WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation\";\r\nimport { type IWebXRDepthSensingOptions, type WebXRDepthSensing } from \"./features/WebXRDepthSensing\";\r\nimport { type IWebXRDomOverlayOptions, type WebXRDomOverlay } from \"./features/WebXRDOMOverlay\";\r\nimport { type WebXREyeTracking } from \"./features/WebXREyeTracking\";\r\nimport { type WebXRFeaturePointSystem } from \"./features/WebXRFeaturePointSystem\";\r\nimport { type IWebXRHandTrackingOptions, type WebXRHandTracking } from \"./features/WebXRHandTracking\";\r\nimport { type IWebXRHitTestOptions, type WebXRHitTest } from \"./features/WebXRHitTest\";\r\nimport { type IWebXRImageTrackingOptions, type WebXRImageTracking } from \"./features/WebXRImageTracking\";\r\nimport { type IWebXRLayersOptions, type WebXRLayers } from \"./features/WebXRLayers\";\r\nimport { type IWebXRLightEstimationOptions, type WebXRLightEstimation } from \"./features/WebXRLightEstimation\";\r\nimport { type IWebXRMeshDetectorOptions, type WebXRMeshDetector } from \"./features/WebXRMeshDetector\";\r\nimport { type IWebXRNearInteractionOptions, type WebXRNearInteraction } from \"./features/WebXRNearInteraction\";\r\nimport { type IWebXRPlaneDetectorOptions, type WebXRPlaneDetector } from \"./features/WebXRPlaneDetector\";\r\nimport { type IWebXRRawCameraAccessOptions, type WebXRRawCameraAccess } from \"./features/WebXRRawCameraAccess\";\r\nimport { type WebXRSpaceWarp } from \"./features/WebXRSpaceWarp\";\r\nimport { type WebXRTrackedSources } from \"./features/WebXRTrackedSources\";\r\nimport { type IWebXRWalkingLocomotionOptions, type WebXRWalkingLocomotion } from \"./features/WebXRWalkingLocomotion\";\r\nimport { _ConsumeWebXRFeatureSpecificDisableWarning } from \"./webXRFeatureWarningRegistry\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\n\r\n/**\r\n * Defining the interface required for a (webxr) feature\r\n */\r\nexport interface IWebXRFeature extends IDisposable {\r\n /**\r\n * Is this feature attached\r\n */\r\n attached: boolean;\r\n /**\r\n * Should auto-attach be disabled?\r\n */\r\n disableAutoAttach: boolean;\r\n /**\r\n * The auto-attach policy in effect before the features manager starts a manual attachment.\r\n * @internal\r\n */\r\n _autoAttachPolicyBeforeAttach?: boolean;\r\n\r\n /**\r\n * Attach the feature to the session\r\n * Will usually be called by the features manager\r\n *\r\n * @param force should attachment be forced (even when already attached)\r\n * @returns true if successful.\r\n */\r\n attach(force?: boolean): boolean;\r\n /**\r\n * Detach the feature from the session\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n detach(): boolean;\r\n\r\n /**\r\n * This function will be executed during before enabling the feature and can be used to not-allow enabling it.\r\n * Note that at this point the session has NOT started, so this is purely checking if the browser supports it\r\n *\r\n * @returns whether or not the feature is compatible in this environment\r\n */\r\n isCompatible(): boolean;\r\n\r\n /**\r\n * Was this feature disposed;\r\n */\r\n isDisposed: boolean;\r\n\r\n /**\r\n * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)\r\n */\r\n xrNativeFeatureName?: string;\r\n\r\n /**\r\n * A list of (Babylon WebXR) features this feature depends on\r\n */\r\n dependsOn?: string[];\r\n\r\n /**\r\n * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object\r\n */\r\n getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;\r\n\r\n /**\r\n * Triggered when the feature is attached\r\n */\r\n onFeatureAttachObservable: Observable<IWebXRFeature>;\r\n /**\r\n * Triggered when the feature is detached\r\n */\r\n onFeatureDetachObservable: Observable<IWebXRFeature>;\r\n}\r\n\r\n/**\r\n * A list of the currently available features without referencing them\r\n */\r\nexport class WebXRFeatureName {\r\n /**\r\n * The name of the anchor system feature\r\n */\r\n public static readonly ANCHOR_SYSTEM = \"xr-anchor-system\" as const;\r\n /**\r\n * The name of the background remover feature\r\n */\r\n public static readonly BACKGROUND_REMOVER = \"xr-background-remover\" as const;\r\n /**\r\n * The name of the hit test feature\r\n */\r\n public static readonly HIT_TEST = \"xr-hit-test\" as const;\r\n /**\r\n * The name of the mesh detection feature\r\n */\r\n public static readonly MESH_DETECTION = \"xr-mesh-detection\" as const;\r\n /**\r\n * physics impostors for xr controllers feature\r\n */\r\n public static readonly PHYSICS_CONTROLLERS = \"xr-physics-controller\" as const;\r\n /**\r\n * The name of the plane detection feature\r\n */\r\n public static readonly PLANE_DETECTION = \"xr-plane-detection\" as const;\r\n /**\r\n * The name of the pointer selection feature\r\n */\r\n public static readonly POINTER_SELECTION = \"xr-controller-pointer-selection\" as const;\r\n /**\r\n * The name of the teleportation feature\r\n */\r\n public static readonly TELEPORTATION = \"xr-controller-teleportation\" as const;\r\n /**\r\n * The name of the feature points feature.\r\n */\r\n public static readonly FEATURE_POINTS = \"xr-feature-points\" as const;\r\n /**\r\n * The name of the hand tracking feature.\r\n */\r\n public static readonly HAND_TRACKING = \"xr-hand-tracking\" as const;\r\n /**\r\n * The name of the image tracking feature\r\n */\r\n public static readonly IMAGE_TRACKING = \"xr-image-tracking\" as const;\r\n /**\r\n * The name of the near interaction feature\r\n */\r\n public static readonly NEAR_INTERACTION = \"xr-near-interaction\" as const;\r\n /**\r\n * The name of the DOM overlay feature\r\n */\r\n public static readonly DOM_OVERLAY = \"xr-dom-overlay\" as const;\r\n /**\r\n * The name of the movement feature\r\n */\r\n public static readonly MOVEMENT = \"xr-controller-movement\" as const;\r\n /**\r\n * The name of the light estimation feature\r\n */\r\n public static readonly LIGHT_ESTIMATION = \"xr-light-estimation\" as const;\r\n /**\r\n * The name of the eye tracking feature\r\n */\r\n public static readonly EYE_TRACKING = \"xr-eye-tracking\" as const;\r\n /**\r\n * The name of the walking locomotion feature\r\n */\r\n public static readonly WALKING_LOCOMOTION = \"xr-walking-locomotion\" as const;\r\n /**\r\n * The name of the composition layers feature\r\n */\r\n public static readonly LAYERS = \"xr-layers\" as const;\r\n /**\r\n * The name of the depth sensing feature\r\n */\r\n public static readonly DEPTH_SENSING = \"xr-depth-sensing\" as const;\r\n /**\r\n * The name of the WebXR Space Warp feature\r\n */\r\n public static readonly SPACE_WARP = \"xr-space-warp\" as const;\r\n /**\r\n * The name of the WebXR Raw Camera Access feature\r\n */\r\n public static readonly RAW_CAMERA_ACCESS = \"xr-raw-camera-access\" as const;\r\n /**\r\n * The name of the body tracking feature\r\n */\r\n public static readonly BODY_TRACKING = \"xr-body-tracking\" as const;\r\n /**\r\n * The name of the tracked sources feature\r\n */\r\n public static readonly TRACKED_SOURCES = \"xr-tracked-sources\" as const;\r\n}\r\n\r\nexport type WebXRFeatureNameType = (typeof WebXRFeatureName)[Exclude<keyof typeof WebXRFeatureName, \"prototype\">];\r\n\r\n/**\r\n * Maps feature names to their corresponding feature implementation classes.\r\n */\r\nexport interface IWebXRFeatureNameTypeMap {\r\n /** Anchor system feature implementation. */\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: WebXRAnchorSystem;\r\n /** Background remover feature implementation. */\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: WebXRBackgroundRemover;\r\n /** Depth sensing feature implementation. */\r\n [WebXRFeatureName.DEPTH_SENSING]: WebXRDepthSensing;\r\n /** DOM overlay feature implementation. */\r\n [WebXRFeatureName.DOM_OVERLAY]: WebXRDomOverlay;\r\n /** Eye tracking feature implementation. */\r\n [WebXRFeatureName.EYE_TRACKING]: WebXREyeTracking;\r\n /** Feature points feature implementation. */\r\n [WebXRFeatureName.FEATURE_POINTS]: WebXRFeaturePointSystem;\r\n /** Hand tracking feature implementation. */\r\n [WebXRFeatureName.HAND_TRACKING]: WebXRHandTracking;\r\n /** Hit test feature implementation. */\r\n [WebXRFeatureName.HIT_TEST]: WebXRHitTest;\r\n /** Image tracking feature implementation. */\r\n [WebXRFeatureName.IMAGE_TRACKING]: WebXRImageTracking;\r\n /** Layers feature implementation. */\r\n [WebXRFeatureName.LAYERS]: WebXRLayers;\r\n /** Light estimation feature implementation. */\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: WebXRLightEstimation;\r\n /** Mesh detection feature implementation. */\r\n [WebXRFeatureName.MESH_DETECTION]: WebXRMeshDetector;\r\n /** Controller movement feature implementation. */\r\n [WebXRFeatureName.MOVEMENT]: WebXRControllerMovement;\r\n /** Near interaction feature implementation. */\r\n [WebXRFeatureName.NEAR_INTERACTION]: WebXRNearInteraction;\r\n /** Physics controllers feature implementation. */\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: WebXRControllerPhysics;\r\n /** Plane detection feature implementation. */\r\n [WebXRFeatureName.PLANE_DETECTION]: WebXRPlaneDetector;\r\n /** Controller pointer selection feature implementation. */\r\n [WebXRFeatureName.POINTER_SELECTION]: WebXRControllerPointerSelection;\r\n /** Raw camera access feature implementation. */\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: WebXRRawCameraAccess;\r\n /** Space warp feature implementation. */\r\n [WebXRFeatureName.SPACE_WARP]: WebXRSpaceWarp;\r\n /** Teleportation feature implementation. */\r\n [WebXRFeatureName.TELEPORTATION]: WebXRMotionControllerTeleportation;\r\n /** Walking locomotion feature implementation. */\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: WebXRWalkingLocomotion;\r\n /** Body tracking feature implementation. */\r\n [WebXRFeatureName.BODY_TRACKING]: WebXRBodyTracking;\r\n /** Tracked sources feature implementation. */\r\n [WebXRFeatureName.TRACKED_SOURCES]: WebXRTrackedSources;\r\n}\r\n\r\n/**\r\n * Maps feature names to their corresponding options interfaces.\r\n */\r\nexport interface IWebXRFeatureNameOptionsMap {\r\n /** Anchor system feature options. */\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: IWebXRAnchorSystemOptions;\r\n /** Background remover feature options. */\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: IWebXRBackgroundRemoverOptions;\r\n /** Depth sensing feature options. */\r\n [WebXRFeatureName.DEPTH_SENSING]: IWebXRDepthSensingOptions;\r\n /** DOM overlay feature options. */\r\n [WebXRFeatureName.DOM_OVERLAY]: IWebXRDomOverlayOptions;\r\n /** Eye tracking feature options. */\r\n [WebXRFeatureName.EYE_TRACKING]: undefined;\r\n /** Feature points feature options. */\r\n [WebXRFeatureName.FEATURE_POINTS]: undefined;\r\n /** Hand tracking feature options. */\r\n [WebXRFeatureName.HAND_TRACKING]: IWebXRHandTrackingOptions;\r\n /** Hit test feature options. */\r\n [WebXRFeatureName.HIT_TEST]: IWebXRHitTestOptions;\r\n /** Image tracking feature options. */\r\n [WebXRFeatureName.IMAGE_TRACKING]: IWebXRImageTrackingOptions;\r\n /** Layers feature options. */\r\n [WebXRFeatureName.LAYERS]: IWebXRLayersOptions;\r\n /** Light estimation feature options. */\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: IWebXRLightEstimationOptions;\r\n /** Mesh detection feature options. */\r\n [WebXRFeatureName.MESH_DETECTION]: IWebXRMeshDetectorOptions;\r\n /** Controller movement feature options. */\r\n [WebXRFeatureName.MOVEMENT]: IWebXRControllerMovementOptions;\r\n /** Near interaction feature options. */\r\n [WebXRFeatureName.NEAR_INTERACTION]: IWebXRNearInteractionOptions;\r\n /** Physics controllers feature options. */\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: IWebXRControllerPhysicsOptions;\r\n /** Plane detection feature options. */\r\n [WebXRFeatureName.PLANE_DETECTION]: IWebXRPlaneDetectorOptions;\r\n /** Controller pointer selection feature options. */\r\n [WebXRFeatureName.POINTER_SELECTION]: IWebXRControllerPointerSelectionOptions;\r\n /** Raw camera access feature options. */\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: IWebXRRawCameraAccessOptions;\r\n /** Space warp feature options. */\r\n [WebXRFeatureName.SPACE_WARP]: undefined;\r\n /** Teleportation feature options. */\r\n [WebXRFeatureName.TELEPORTATION]: IWebXRTeleportationOptions;\r\n /** Walking locomotion feature options. */\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: IWebXRWalkingLocomotionOptions;\r\n /** Body tracking feature options. */\r\n [WebXRFeatureName.BODY_TRACKING]: IWebXRBodyTrackingOptions;\r\n /** Tracked sources feature options. */\r\n [WebXRFeatureName.TRACKED_SOURCES]: undefined;\r\n}\r\n\r\n/**\r\n * Helper type that expands/flattens a type to show its properties inline in IntelliSense\r\n */\r\ntype Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;\r\n\r\n/**\r\n * Helper type to resolve the specific feature type based on the feature name,\r\n * or fallback to IWebXRFeature if the feature name is not in the type map.\r\n */\r\nexport type ResolveWebXRFeature<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameTypeMap ? IWebXRFeatureNameTypeMap[T] : IWebXRFeature;\r\n\r\n/**\r\n * Helper type to resolve the options type for a specific feature based on the feature name,\r\n * or fallback to any if the feature name is not in the type map.\r\n * The Expand utility type flattens the interface to show properties inline in IntelliSense.\r\n */\r\nexport type ResolveWebXRFeatureOptions<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameOptionsMap\r\n ? IWebXRFeatureNameOptionsMap[T] extends undefined\r\n ? undefined\r\n : Expand<IWebXRFeatureNameOptionsMap[T]>\r\n : any;\r\n\r\n/**\r\n * Defining the constructor of a feature. Used to register the modules.\r\n */\r\nexport type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;\r\n\r\n/**\r\n * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.\r\n * It is mainly used in AR sessions.\r\n *\r\n * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).\r\n */\r\nexport class WebXRFeaturesManager implements IDisposable {\r\n private static readonly _AvailableFeatures: {\r\n [name: string]: {\r\n stable: number;\r\n latest: number;\r\n [version: number]: WebXRFeatureConstructor;\r\n };\r\n } = {};\r\n\r\n private _features: {\r\n [name: string]: {\r\n featureImplementation: IWebXRFeature;\r\n version: number;\r\n enabled: boolean;\r\n required: boolean;\r\n };\r\n } = {};\r\n\r\n /**\r\n * The key is the feature to check and the value is the feature that conflicts.\r\n */\r\n private static readonly _ConflictingFeatures: { [key: string]: string } = {\r\n [WebXRFeatureName.TELEPORTATION]: WebXRFeatureName.MOVEMENT,\r\n [WebXRFeatureName.MOVEMENT]: WebXRFeatureName.TELEPORTATION,\r\n };\r\n\r\n /**\r\n * constructs a new features manages.\r\n *\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n */\r\n constructor(private _xrSessionManager: WebXRSessionManager) {\r\n // when session starts / initialized - attach\r\n this._xrSessionManager.onXRSessionInit.add(() => {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && !feature.featureImplementation.attached && !feature.featureImplementation.disableAutoAttach) {\r\n this.attachFeature(featureName);\r\n }\r\n }\r\n });\r\n\r\n // when session ends - detach\r\n this._xrSessionManager.onXRSessionEnded.add(() => {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && feature.featureImplementation.attached) {\r\n // detach, but don't disable!\r\n this.detachFeature(featureName);\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Used to register a module. After calling this function a developer can use this feature in the scene.\r\n * Mainly used internally.\r\n *\r\n * @param featureName the name of the feature to register\r\n * @param constructorFunction the function used to construct the module\r\n * @param version the (babylon) version of the module\r\n * @param stable is that a stable version of this module\r\n */\r\n public static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version: number = 1, stable: boolean = false) {\r\n this._AvailableFeatures[featureName] = this._AvailableFeatures[featureName] || { latest: version };\r\n if (version > this._AvailableFeatures[featureName].latest) {\r\n this._AvailableFeatures[featureName].latest = version;\r\n }\r\n if (stable) {\r\n this._AvailableFeatures[featureName].stable = version;\r\n }\r\n this._AvailableFeatures[featureName][version] = constructorFunction;\r\n }\r\n\r\n /**\r\n * Returns a constructor of a specific feature.\r\n *\r\n * @param featureName the name of the feature to construct\r\n * @param version the version of the feature to load\r\n * @param xrSessionManager the xrSessionManager. Used to construct the module\r\n * @param options optional options provided to the module.\r\n * @returns a function that, when called, will return a new instance of this feature\r\n */\r\n public static ConstructFeature(featureName: string, version: number = 1, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature {\r\n const constructorFunction = this._AvailableFeatures[featureName][version];\r\n if (!constructorFunction) {\r\n // throw an error? return nothing?\r\n throw new Error(\"feature not found\");\r\n }\r\n\r\n return constructorFunction(xrSessionManager, options);\r\n }\r\n\r\n /**\r\n * Can be used to return the list of features currently registered\r\n *\r\n * @returns an Array of available features\r\n */\r\n public static GetAvailableFeatures() {\r\n return Object.keys(this._AvailableFeatures);\r\n }\r\n\r\n /**\r\n * Gets the versions available for a specific feature\r\n * @param featureName the name of the feature\r\n * @returns an array with the available versions\r\n */\r\n public static GetAvailableVersions(featureName: string) {\r\n return Object.keys(this._AvailableFeatures[featureName]);\r\n }\r\n\r\n /**\r\n * Return the latest unstable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetLatestVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].latest) || -1;\r\n }\r\n\r\n /**\r\n * Return the latest stable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetStableVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].stable) || -1;\r\n }\r\n\r\n /**\r\n * Attach a feature to the current session. Mainly used when session started to start the feature effect.\r\n * Can be used during a session to start a feature\r\n * @param featureName the name of feature to attach\r\n */\r\n public attachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.enabled && !feature.featureImplementation.attached) {\r\n const disableAutoAttachBeforeAttach = feature.featureImplementation.disableAutoAttach;\r\n feature.featureImplementation._autoAttachPolicyBeforeAttach = disableAutoAttachBeforeAttach;\r\n feature.featureImplementation.disableAutoAttach = false;\r\n let attached: boolean;\r\n try {\r\n attached = feature.featureImplementation.attach();\r\n } finally {\r\n delete feature.featureImplementation._autoAttachPolicyBeforeAttach;\r\n }\r\n const intentionallyDisabledDuringAttach = feature.featureImplementation.disableAutoAttach;\r\n if (!intentionallyDisabledDuringAttach) {\r\n feature.featureImplementation.disableAutoAttach = disableAutoAttachBeforeAttach;\r\n }\r\n if (!attached && !intentionallyDisabledDuringAttach) {\r\n Tools.Warn(`Feature ${featureName} failed to attach`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Can be used inside a session or when the session ends to detach a specific feature\r\n * @param featureName the name of the feature to detach\r\n */\r\n public detachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.featureImplementation.attached) {\r\n const detached = feature.featureImplementation.detach();\r\n if (!detached) {\r\n Tools.Warn(`Feature ${featureName} failed to detach`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Used to disable an already-enabled feature\r\n * The feature will be disposed and will be recreated once enabled.\r\n * @param featureName the feature to disable\r\n * @returns true if disable was successful\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public disableFeature(featureName: string | { Name: string }): boolean {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n const feature = this._features[name];\r\n if (feature && feature.enabled) {\r\n feature.enabled = false;\r\n this.detachFeature(name);\r\n feature.featureImplementation.dispose();\r\n delete this._features[name];\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * dispose this features manager\r\n */\r\n public dispose(): void {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n this.disableFeature(featureName);\r\n }\r\n }\r\n\r\n /**\r\n * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.\r\n * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.\r\n *\r\n * @param featureName the name of the feature to load or the class of the feature\r\n * @param version optional version to load. if not provided the latest version will be enabled\r\n * @param moduleOptions options provided to the module. Ses the module documentation / constructor\r\n * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible\r\n * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.\r\n * @returns a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.\r\n */\r\n public enableFeature<T extends WebXRFeatureNameType>(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n featureName: T | { Name: T },\r\n version: number | string = \"latest\",\r\n moduleOptions: ResolveWebXRFeatureOptions<T> = {} as ResolveWebXRFeatureOptions<T>,\r\n attachIfPossible: boolean = true,\r\n required: boolean = true\r\n ): ResolveWebXRFeature<T> {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n let versionToLoad: number;\r\n if (typeof version === \"string\") {\r\n if (!version) {\r\n throw new Error(`Error in provided version - ${name} (${version})`);\r\n }\r\n if (version === \"stable\") {\r\n versionToLoad = WebXRFeaturesManager.GetStableVersionOfFeature(name);\r\n } else if (version === \"latest\") {\r\n versionToLoad = WebXRFeaturesManager.GetLatestVersionOfFeature(name);\r\n } else {\r\n // try loading the number the string represents\r\n versionToLoad = +version;\r\n }\r\n if (versionToLoad === -1 || isNaN(versionToLoad)) {\r\n throw new Error(`feature not found - ${name} (${version})`);\r\n }\r\n } else {\r\n versionToLoad = version;\r\n }\r\n\r\n // check if there is a feature conflict\r\n const conflictingFeature = WebXRFeaturesManager._ConflictingFeatures[name];\r\n if (conflictingFeature !== undefined && this.getEnabledFeatures().indexOf(conflictingFeature) !== -1) {\r\n throw new Error(`Feature ${name} cannot be enabled while ${conflictingFeature} is enabled.`);\r\n }\r\n\r\n // check if already initialized\r\n const feature = this._features[name];\r\n const constructFunction = WebXRFeaturesManager.ConstructFeature(name, versionToLoad, this._xrSessionManager, moduleOptions);\r\n if (!constructFunction) {\r\n // report error?\r\n throw new Error(`feature not found - ${name}`);\r\n }\r\n\r\n /* If the feature is already enabled, detach and dispose it, and create a new one */\r\n if (feature) {\r\n this.disableFeature(name);\r\n }\r\n\r\n const constructed = constructFunction();\r\n if (constructed.dependsOn) {\r\n const dependentsFound = constructed.dependsOn.every((featureName) => !!this._features[featureName]);\r\n if (!dependentsFound) {\r\n throw new Error(`Dependant features missing. Make sure the following features are enabled - ${constructed.dependsOn.join(\", \")}`);\r\n }\r\n }\r\n _ConsumeWebXRFeatureSpecificDisableWarning(constructed);\r\n const isCompatible = constructed.isCompatible();\r\n const emittedSpecificDisableWarning = _ConsumeWebXRFeatureSpecificDisableWarning(constructed);\r\n if (isCompatible) {\r\n this._features[name] = {\r\n featureImplementation: constructed,\r\n enabled: true,\r\n version: versionToLoad,\r\n required,\r\n };\r\n\r\n if (attachIfPossible) {\r\n // if session started already, request and enable\r\n if (this._xrSessionManager.session && !this._features[name].featureImplementation.attached) {\r\n // enable feature\r\n this.attachFeature(name);\r\n }\r\n } else {\r\n // disable auto-attach when session starts\r\n this._features[name].featureImplementation.disableAutoAttach = true;\r\n }\r\n\r\n return this._features[name].featureImplementation as ResolveWebXRFeature<T>;\r\n } else {\r\n if (required) {\r\n throw new Error(\"required feature not compatible\");\r\n } else {\r\n if (!emittedSpecificDisableWarning) {\r\n Tools.Warn(`Feature ${name} not compatible with the current environment/browser and was not enabled.`);\r\n }\r\n return constructed as ResolveWebXRFeature<T>;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * get the implementation of an enabled feature.\r\n * @param featureName the name of the feature to load\r\n * @returns the feature class, if found\r\n */\r\n public getEnabledFeature<T extends WebXRFeatureNameType>(featureName: T): ResolveWebXRFeature<T> {\r\n return this._features[featureName] && (this._features[featureName].featureImplementation as ResolveWebXRFeature<T>);\r\n }\r\n\r\n /**\r\n * Get the list of enabled features\r\n * @returns an array of enabled features\r\n */\r\n public getEnabledFeatures() {\r\n return Object.keys(this._features);\r\n }\r\n\r\n /**\r\n * This function will extend the session creation configuration object with enabled features.\r\n * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,\r\n * according to the defined \"required\" variable, provided during enableFeature call\r\n * @param xrSessionInit the xr Session init object to extend\r\n *\r\n * @returns an extended XRSessionInit object\r\n */\r\n public async _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit> {\r\n const enabledFeatures = this.getEnabledFeatures();\r\n for (const featureName of enabledFeatures) {\r\n const feature = this._features[featureName];\r\n const nativeName = feature.featureImplementation.xrNativeFeatureName;\r\n if (nativeName) {\r\n if (feature.required) {\r\n xrSessionInit.requiredFeatures = xrSessionInit.requiredFeatures || [];\r\n if (xrSessionInit.requiredFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.requiredFeatures.push(nativeName);\r\n }\r\n } else {\r\n xrSessionInit.optionalFeatures = xrSessionInit.optionalFeatures || [];\r\n if (xrSessionInit.optionalFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.optionalFeatures.push(nativeName);\r\n }\r\n }\r\n }\r\n if (feature.featureImplementation.getXRSessionInitExtension) {\r\n // eslint-disable-next-line no-await-in-loop\r\n const extended = await feature.featureImplementation.getXRSessionInitExtension();\r\n xrSessionInit = {\r\n ...xrSessionInit,\r\n ...extended,\r\n };\r\n }\r\n }\r\n return xrSessionInit;\r\n }\r\n}\r\n"]}
@@ -1,4 +1,33 @@
1
1
  import { type AbstractEngine } from "../Engines/abstractEngine.js";
2
+ /**
3
+ * The error shown when the active WebGPU engine cannot start an XR session.
4
+ * @internal
5
+ */
6
+ export declare const WebGPUXRNotSupportedErrorMessage = "WebGPU XR is unavailable in this browser or device. This experimental path requires XRGPUBinding with projection-layer support. To fall back, create a WebGL engine before creating the scene; Babylon.js cannot switch an existing scene's rendering backend.";
7
+ /**
8
+ * The error shown when a WebGPU XR session request is rejected as unsupported.
9
+ * @internal
10
+ */
11
+ export declare const WebGPUXRSessionNotSupportedErrorMessage = "The WebGPU XR session request was rejected as unsupported. The session mode, WebGPU or Layers requirements, or another required feature may be unavailable. If WebGPU XR is unavailable, create a WebGL engine before creating the scene.";
12
+ /**
13
+ * The error shown when the active WebGPU engine was not created with XR compatibility enabled.
14
+ * @internal
15
+ */
16
+ export declare const WebGPUXREngineNotCompatibleErrorMessage = "WebGPU XR requires a WebGPUEngine created with { xrCompatible: true }. Select an XR-capable WebGPU engine or WebGL before creating scene resources.";
17
+ /**
18
+ * Checks whether the runtime exposes the XRGPUBinding projection path required by Babylon.js.
19
+ * This is an advisory shape check; session negotiation can still reject for the active device.
20
+ * @returns whether the required WebGPU-XR binding APIs are exposed
21
+ * @internal
22
+ */
23
+ export declare function IsWebGPUXRSupported(): boolean;
24
+ /**
25
+ * Checks whether an engine was initialized with the adapter option required for WebGPU XR.
26
+ * @param engine the engine to test
27
+ * @returns true for non-WebGPU engines or WebGPU engines created with xrCompatible enabled
28
+ * @internal
29
+ */
30
+ export declare function IsWebGPUXREngineCompatible(engine: AbstractEngine): boolean;
2
31
  /**
3
32
  * The kind of underlying native binding an {@link IWebXRGraphicsBinding} wraps.
4
33
  * @internal
@@ -1,3 +1,43 @@
1
+ /**
2
+ * The error shown when the active WebGPU engine cannot start an XR session.
3
+ * @internal
4
+ */
5
+ export const WebGPUXRNotSupportedErrorMessage = "WebGPU XR is unavailable in this browser or device. This experimental path requires XRGPUBinding with projection-layer support. To fall back, create a WebGL engine before creating the scene; Babylon.js cannot switch an existing scene's rendering backend.";
6
+ /**
7
+ * The error shown when a WebGPU XR session request is rejected as unsupported.
8
+ * @internal
9
+ */
10
+ export const WebGPUXRSessionNotSupportedErrorMessage = "The WebGPU XR session request was rejected as unsupported. The session mode, WebGPU or Layers requirements, or another required feature may be unavailable. If WebGPU XR is unavailable, create a WebGL engine before creating the scene.";
11
+ /**
12
+ * The error shown when the active WebGPU engine was not created with XR compatibility enabled.
13
+ * @internal
14
+ */
15
+ export const WebGPUXREngineNotCompatibleErrorMessage = "WebGPU XR requires a WebGPUEngine created with { xrCompatible: true }. Select an XR-capable WebGPU engine or WebGL before creating scene resources.";
16
+ /**
17
+ * Checks whether the runtime exposes the XRGPUBinding projection path required by Babylon.js.
18
+ * This is an advisory shape check; session negotiation can still reject for the active device.
19
+ * @returns whether the required WebGPU-XR binding APIs are exposed
20
+ * @internal
21
+ */
22
+ // eslint-disable-next-line @typescript-eslint/naming-convention
23
+ export function IsWebGPUXRSupported() {
24
+ return (typeof XRGPUBinding === "function" &&
25
+ typeof XRGPUBinding.prototype.createProjectionLayer === "function" &&
26
+ typeof XRGPUBinding.prototype.getViewSubImage === "function" &&
27
+ typeof XRGPUBinding.prototype.getPreferredColorFormat === "function" &&
28
+ typeof XRGPUSubImage === "function" &&
29
+ typeof XRGPUSubImage.prototype.getViewDescriptor === "function");
30
+ }
31
+ /**
32
+ * Checks whether an engine was initialized with the adapter option required for WebGPU XR.
33
+ * @param engine the engine to test
34
+ * @returns true for non-WebGPU engines or WebGPU engines created with xrCompatible enabled
35
+ * @internal
36
+ */
37
+ // eslint-disable-next-line @typescript-eslint/naming-convention
38
+ export function IsWebGPUXREngineCompatible(engine) {
39
+ return !engine.isWebGPU || engine._options?.xrCompatible === true;
40
+ }
1
41
  /**
2
42
  * The kind of underlying native binding an {@link IWebXRGraphicsBinding} wraps.
3
43
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"webXRGraphicsBinding.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRGraphicsBinding.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAN,IAAkB,wBAUjB;AAVD,WAAkB,wBAAwB;IACtC;;OAEG;IACH,yEAAK,CAAA;IAEL;;OAEG;IACH,2EAAM,CAAA;AACV,CAAC,EAViB,wBAAwB,KAAxB,wBAAwB,QAUzC;AAaD;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAWlC;;;;OAIG;IACH,YACI,OAAkB;IAClB;;OAEG;IACa,OAAuD;QAAvD,YAAO,GAAP,OAAO,CAAgD;QApB3E;;WAEG;QACa,gBAAW,0CAAkC;QAmBzD,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,OAAkB,EAAE,MAAsB;QACrE,MAAM,EAAE,GAAI,MAAqB,CAAC,GAAG,CAAC;QACtC,IAAI,CAAC,EAAE,EAAE,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,OAAO,0BAA0B;IAWnC;;;;OAIG;IACH,YAAY,OAAkB,EAAE,MAAiB;QAfjD;;WAEG;QACa,gBAAW,2CAAmC;QAa1D,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,OAAkB,EAAE,MAAsB;QACrE,MAAM,MAAM,GAAI,MAAuB,CAAC,OAAO,CAAC;QAChD,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QACpF,CAAC;QACD,OAAO,IAAI,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;CACJ","sourcesContent":["import { type AbstractEngine } from \"../Engines/abstractEngine\";\nimport { type ThinEngine } from \"../Engines/thinEngine\";\nimport { type WebGPUEngine } from \"../Engines/webgpuEngine\";\n\n/**\n * The kind of underlying native binding an {@link IWebXRGraphicsBinding} wraps.\n * @internal\n */\nexport const enum WebXRGraphicsBindingType {\n /**\n * Backed by an XRWebGLBinding (WebGL / WebGL2).\n */\n WebGL,\n\n /**\n * Backed by an XRGPUBinding (WebGPU).\n */\n WebGPU,\n}\n\n/**\n * Abstraction over the native WebXR graphics binding used to interact with the XR compositor.\n * @internal\n */\nexport interface IWebXRGraphicsBinding {\n /**\n * The kind of native binding that is wrapped.\n */\n readonly bindingType: WebXRGraphicsBindingType;\n}\n\n/**\n * WebGL implementation of {@link IWebXRGraphicsBinding}, wrapping an `XRWebGLBinding`.\n * @internal\n */\nexport class WebXRWebGLGraphicsBinding implements IWebXRGraphicsBinding {\n /**\n * The kind of native binding that is wrapped.\n */\n public readonly bindingType = WebXRGraphicsBindingType.WebGL;\n\n /**\n * The wrapped native `XRWebGLBinding`.\n */\n public readonly binding: XRWebGLBinding;\n\n /**\n * Creates a new WebGL graphics binding.\n * @param session the XR session the binding is created for\n * @param context the WebGL rendering context to bind to\n */\n constructor(\n session: XRSession,\n /**\n * The WebGL rendering context used by the native binding.\n */\n public readonly context: WebGLRenderingContext | WebGL2RenderingContext\n ) {\n this.binding = new XRWebGLBinding(session, context);\n }\n\n /**\n * Creates a new WebGL graphics binding from an engine, extracting its WebGL context.\n * The WebGL-specific context access is localized here so callers can stay graphics-API-agnostic.\n * @param session the XR session the binding is created for\n * @param engine the engine whose WebGL context should be bound\n * @returns the created WebGL graphics binding\n */\n public static CreateFromEngine(session: XRSession, engine: AbstractEngine): WebXRWebGLGraphicsBinding {\n const gl = (engine as ThinEngine)._gl;\n if (!gl) {\n throw new Error(\"WebXRWebGLGraphicsBinding requires a WebGL-capable engine.\");\n }\n return new WebXRWebGLGraphicsBinding(session, gl);\n }\n}\n\n/**\n * WebGPU implementation of {@link IWebXRGraphicsBinding}, wrapping an `XRGPUBinding`.\n *\n * The `XRGPUBinding` requires a WebGPU-compatible XR session (created with the `webgpu` feature\n * descriptor) and a `GPUDevice` obtained from an `xrCompatible` adapter, otherwise its constructor throws.\n * @internal\n */\nexport class WebXRWebGPUGraphicsBinding implements IWebXRGraphicsBinding {\n /**\n * The kind of native binding that is wrapped.\n */\n public readonly bindingType = WebXRGraphicsBindingType.WebGPU;\n\n /**\n * The wrapped native `XRGPUBinding`.\n */\n public readonly binding: XRGPUBinding;\n\n /**\n * Creates a new WebGPU graphics binding.\n * @param session the XR session the binding is created for\n * @param device the WebGPU device to bind to\n */\n constructor(session: XRSession, device: GPUDevice) {\n this.binding = new XRGPUBinding(session, device);\n }\n\n /**\n * Creates a new WebGPU graphics binding from an engine, extracting its `GPUDevice`.\n * The WebGPU-specific device access is localized here so callers can stay graphics-API-agnostic.\n * @param session the XR session the binding is created for\n * @param engine the engine whose WebGPU device should be bound\n * @returns the created WebGPU graphics binding\n */\n public static CreateFromEngine(session: XRSession, engine: AbstractEngine): WebXRWebGPUGraphicsBinding {\n const device = (engine as WebGPUEngine)._device;\n if (!device) {\n throw new Error(\"WebXRWebGPUGraphicsBinding requires a WebGPU-capable engine.\");\n }\n return new WebXRWebGPUGraphicsBinding(session, device);\n }\n}\n\n/**\n * The graphics bindings supported by the WebXR session manager.\n * @internal\n */\nexport type WebXRGraphicsBinding = WebXRWebGLGraphicsBinding | WebXRWebGPUGraphicsBinding;\n"]}
1
+ {"version":3,"file":"webXRGraphicsBinding.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRGraphicsBinding.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GACzC,gQAAgQ,CAAC;AAErQ;;;GAGG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAChD,2OAA2O,CAAC;AAEhP;;;GAGG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAChD,qJAAqJ,CAAC;AAE1J;;;;;GAKG;AACH,gEAAgE;AAChE,MAAM,UAAU,mBAAmB;IAC/B,OAAO,CACH,OAAO,YAAY,KAAK,UAAU;QAClC,OAAO,YAAY,CAAC,SAAS,CAAC,qBAAqB,KAAK,UAAU;QAClE,OAAO,YAAY,CAAC,SAAS,CAAC,eAAe,KAAK,UAAU;QAC5D,OAAO,YAAY,CAAC,SAAS,CAAC,uBAAuB,KAAK,UAAU;QACpE,OAAO,aAAa,KAAK,UAAU;QACnC,OAAO,aAAa,CAAC,SAAS,CAAC,iBAAiB,KAAK,UAAU,CAClE,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,gEAAgE;AAChE,MAAM,UAAU,0BAA0B,CAAC,MAAsB;IAC7D,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAK,MAAuB,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;AACxF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAN,IAAkB,wBAUjB;AAVD,WAAkB,wBAAwB;IACtC;;OAEG;IACH,yEAAK,CAAA;IAEL;;OAEG;IACH,2EAAM,CAAA;AACV,CAAC,EAViB,wBAAwB,KAAxB,wBAAwB,QAUzC;AAaD;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAWlC;;;;OAIG;IACH,YACI,OAAkB;IAClB;;OAEG;IACa,OAAuD;QAAvD,YAAO,GAAP,OAAO,CAAgD;QApB3E;;WAEG;QACa,gBAAW,0CAAkC;QAmBzD,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,OAAkB,EAAE,MAAsB;QACrE,MAAM,EAAE,GAAI,MAAqB,CAAC,GAAG,CAAC;QACtC,IAAI,CAAC,EAAE,EAAE,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,OAAO,0BAA0B;IAWnC;;;;OAIG;IACH,YAAY,OAAkB,EAAE,MAAiB;QAfjD;;WAEG;QACa,gBAAW,2CAAmC;QAa1D,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,OAAkB,EAAE,MAAsB;QACrE,MAAM,MAAM,GAAI,MAAuB,CAAC,OAAO,CAAC;QAChD,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QACpF,CAAC;QACD,OAAO,IAAI,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;CACJ","sourcesContent":["import { type AbstractEngine } from \"../Engines/abstractEngine\";\nimport { type ThinEngine } from \"../Engines/thinEngine\";\nimport { type WebGPUEngine } from \"../Engines/webgpuEngine\";\n\n/**\n * The error shown when the active WebGPU engine cannot start an XR session.\n * @internal\n */\nexport const WebGPUXRNotSupportedErrorMessage =\n \"WebGPU XR is unavailable in this browser or device. This experimental path requires XRGPUBinding with projection-layer support. To fall back, create a WebGL engine before creating the scene; Babylon.js cannot switch an existing scene's rendering backend.\";\n\n/**\n * The error shown when a WebGPU XR session request is rejected as unsupported.\n * @internal\n */\nexport const WebGPUXRSessionNotSupportedErrorMessage =\n \"The WebGPU XR session request was rejected as unsupported. The session mode, WebGPU or Layers requirements, or another required feature may be unavailable. If WebGPU XR is unavailable, create a WebGL engine before creating the scene.\";\n\n/**\n * The error shown when the active WebGPU engine was not created with XR compatibility enabled.\n * @internal\n */\nexport const WebGPUXREngineNotCompatibleErrorMessage =\n \"WebGPU XR requires a WebGPUEngine created with { xrCompatible: true }. Select an XR-capable WebGPU engine or WebGL before creating scene resources.\";\n\n/**\n * Checks whether the runtime exposes the XRGPUBinding projection path required by Babylon.js.\n * This is an advisory shape check; session negotiation can still reject for the active device.\n * @returns whether the required WebGPU-XR binding APIs are exposed\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function IsWebGPUXRSupported(): boolean {\n return (\n typeof XRGPUBinding === \"function\" &&\n typeof XRGPUBinding.prototype.createProjectionLayer === \"function\" &&\n typeof XRGPUBinding.prototype.getViewSubImage === \"function\" &&\n typeof XRGPUBinding.prototype.getPreferredColorFormat === \"function\" &&\n typeof XRGPUSubImage === \"function\" &&\n typeof XRGPUSubImage.prototype.getViewDescriptor === \"function\"\n );\n}\n\n/**\n * Checks whether an engine was initialized with the adapter option required for WebGPU XR.\n * @param engine the engine to test\n * @returns true for non-WebGPU engines or WebGPU engines created with xrCompatible enabled\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function IsWebGPUXREngineCompatible(engine: AbstractEngine): boolean {\n return !engine.isWebGPU || (engine as WebGPUEngine)._options?.xrCompatible === true;\n}\n\n/**\n * The kind of underlying native binding an {@link IWebXRGraphicsBinding} wraps.\n * @internal\n */\nexport const enum WebXRGraphicsBindingType {\n /**\n * Backed by an XRWebGLBinding (WebGL / WebGL2).\n */\n WebGL,\n\n /**\n * Backed by an XRGPUBinding (WebGPU).\n */\n WebGPU,\n}\n\n/**\n * Abstraction over the native WebXR graphics binding used to interact with the XR compositor.\n * @internal\n */\nexport interface IWebXRGraphicsBinding {\n /**\n * The kind of native binding that is wrapped.\n */\n readonly bindingType: WebXRGraphicsBindingType;\n}\n\n/**\n * WebGL implementation of {@link IWebXRGraphicsBinding}, wrapping an `XRWebGLBinding`.\n * @internal\n */\nexport class WebXRWebGLGraphicsBinding implements IWebXRGraphicsBinding {\n /**\n * The kind of native binding that is wrapped.\n */\n public readonly bindingType = WebXRGraphicsBindingType.WebGL;\n\n /**\n * The wrapped native `XRWebGLBinding`.\n */\n public readonly binding: XRWebGLBinding;\n\n /**\n * Creates a new WebGL graphics binding.\n * @param session the XR session the binding is created for\n * @param context the WebGL rendering context to bind to\n */\n constructor(\n session: XRSession,\n /**\n * The WebGL rendering context used by the native binding.\n */\n public readonly context: WebGLRenderingContext | WebGL2RenderingContext\n ) {\n this.binding = new XRWebGLBinding(session, context);\n }\n\n /**\n * Creates a new WebGL graphics binding from an engine, extracting its WebGL context.\n * The WebGL-specific context access is localized here so callers can stay graphics-API-agnostic.\n * @param session the XR session the binding is created for\n * @param engine the engine whose WebGL context should be bound\n * @returns the created WebGL graphics binding\n */\n public static CreateFromEngine(session: XRSession, engine: AbstractEngine): WebXRWebGLGraphicsBinding {\n const gl = (engine as ThinEngine)._gl;\n if (!gl) {\n throw new Error(\"WebXRWebGLGraphicsBinding requires a WebGL-capable engine.\");\n }\n return new WebXRWebGLGraphicsBinding(session, gl);\n }\n}\n\n/**\n * WebGPU implementation of {@link IWebXRGraphicsBinding}, wrapping an `XRGPUBinding`.\n *\n * The `XRGPUBinding` requires a WebGPU-compatible XR session (created with the `webgpu` feature\n * descriptor) and a `GPUDevice` obtained from an `xrCompatible` adapter, otherwise its constructor throws.\n * @internal\n */\nexport class WebXRWebGPUGraphicsBinding implements IWebXRGraphicsBinding {\n /**\n * The kind of native binding that is wrapped.\n */\n public readonly bindingType = WebXRGraphicsBindingType.WebGPU;\n\n /**\n * The wrapped native `XRGPUBinding`.\n */\n public readonly binding: XRGPUBinding;\n\n /**\n * Creates a new WebGPU graphics binding.\n * @param session the XR session the binding is created for\n * @param device the WebGPU device to bind to\n */\n constructor(session: XRSession, device: GPUDevice) {\n this.binding = new XRGPUBinding(session, device);\n }\n\n /**\n * Creates a new WebGPU graphics binding from an engine, extracting its `GPUDevice`.\n * The WebGPU-specific device access is localized here so callers can stay graphics-API-agnostic.\n * @param session the XR session the binding is created for\n * @param engine the engine whose WebGPU device should be bound\n * @returns the created WebGPU graphics binding\n */\n public static CreateFromEngine(session: XRSession, engine: AbstractEngine): WebXRWebGPUGraphicsBinding {\n const device = (engine as WebGPUEngine)._device;\n if (!device) {\n throw new Error(\"WebXRWebGPUGraphicsBinding requires a WebGPU-capable engine.\");\n }\n return new WebXRWebGPUGraphicsBinding(session, device);\n }\n}\n\n/**\n * The graphics bindings supported by the WebXR session manager.\n * @internal\n */\nexport type WebXRGraphicsBinding = WebXRWebGLGraphicsBinding | WebXRWebGPUGraphicsBinding;\n"]}
@@ -54,7 +54,7 @@ export class WebXRInputSource {
54
54
  this.motionController = motionController;
55
55
  this.onMotionControllerInitObservable.notifyObservers(motionController);
56
56
  // should the model be loaded?
57
- if (!this._options.doNotLoadControllerMesh && !this.motionController._doNotLoadControllerMesh) {
57
+ if (!this._options.doNotLoadControllerMesh && !this.inputSource.skipRendering && !this.motionController._doNotLoadControllerMesh) {
58
58
  // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then
59
59
  this.motionController.loadModel().then((success) => {
60
60
  if (success && this.motionController && this.motionController.rootMesh) {
@@ -1 +1 @@
1
- {"version":3,"file":"webXRInputSource.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRInputSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,U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,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;gBAC9F,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;oBACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC3B,IAAI,CAAC,IAAI,CAAC,kBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;oBACtC,IAAI,CAAC,IAAI,CAAC,kBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC1C,CAAC;YACL,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,kEAAkE;YAClE,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Observable } from \"../Misc/observable\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Quaternion, Vector3 } from \"../Maths/math.vector.pure\";\r\nimport { type Ray } from \"../Culling/ray\";\r\nimport { type Scene } from \"../scene\";\r\nimport { type WebXRAbstractMotionController } from \"./motionController/webXRAbstractMotionController\";\r\nimport { WebXRMotionControllerManager } from \"./motionController/webXRMotionControllerManager.pure\";\r\nimport { Tools } from \"../Misc/tools.pure\";\r\nimport { type WebXRCamera } from \"./webXRCamera\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport { Mesh } from \"../Meshes/mesh.pure\";\r\n\r\nlet IdCount = 0;\r\n\r\n/**\r\n * Configuration options for the WebXR controller creation\r\n */\r\nexport interface IWebXRControllerOptions {\r\n /**\r\n * Should the controller mesh be animated when a user interacts with it\r\n * The pressed buttons / thumbstick and touchpad animations will be disabled\r\n */\r\n disableMotionControllerAnimation?: boolean;\r\n /**\r\n * Do not load the controller mesh, in case a different mesh needs to be loaded.\r\n */\r\n doNotLoadControllerMesh?: boolean;\r\n /**\r\n * Force a specific controller type for this controller.\r\n * This can be used when creating your own profile or when testing different controllers\r\n */\r\n forceControllerProfile?: string;\r\n /**\r\n * Defines a rendering group ID for meshes that will be loaded.\r\n * This is for the default controllers only.\r\n */\r\n renderingGroupId?: number;\r\n}\r\n\r\n/**\r\n * Represents an XR controller\r\n */\r\nexport class WebXRInputSource {\r\n private _tmpVector = new Vector3();\r\n private _uniqueId: string;\r\n private _disposed = false;\r\n\r\n /**\r\n * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if that's the case only the pointer from the head will be available\r\n */\r\n public grip?: AbstractMesh;\r\n /**\r\n * If available, this is the gamepad object related to this controller.\r\n * Using this object it is possible to get click events and trackpad changes of the\r\n * webxr controller that is currently being used.\r\n */\r\n public motionController?: WebXRAbstractMotionController;\r\n /**\r\n * Event that fires when the controller is removed/disposed.\r\n * The object provided as event data is this controller, after associated assets were disposed.\r\n * uniqueId is still available.\r\n */\r\n public onDisposeObservable = new Observable<WebXRInputSource>();\r\n /**\r\n * Will be triggered when the mesh associated with the motion controller is done loading.\r\n * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh\r\n * A shortened version of controller -> motion controller -> on mesh loaded.\r\n */\r\n public onMeshLoadedObservable = new Observable<AbstractMesh>();\r\n /**\r\n * Observers registered here will trigger when a motion controller profile was assigned to this xr controller\r\n */\r\n public onMotionControllerInitObservable = new Observable<WebXRAbstractMotionController>();\r\n /**\r\n * Pointer which can be used to select objects or attach a visible laser to\r\n */\r\n public pointer: AbstractMesh;\r\n\r\n /**\r\n * The last XRPose the was calculated on the current XRFrame\r\n * @internal\r\n */\r\n public _lastXRPose?: XRPose;\r\n\r\n /**\r\n * Creates the input source object\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/webXR/webXRInputControllerSupport\r\n * @param _scene the scene which the controller should be associated to\r\n * @param inputSource the underlying input source for the controller\r\n * @param _options options for this controller creation\r\n */\r\n constructor(\r\n private _scene: Scene,\r\n /** The underlying input source for the controller */\r\n public inputSource: XRInputSource,\r\n private _options: IWebXRControllerOptions = {}\r\n ) {\r\n this._uniqueId = `controller-${IdCount++}-${inputSource.targetRayMode}-${inputSource.handedness}`;\r\n\r\n this.pointer = new Mesh(`${this._uniqueId}-pointer`, _scene);\r\n this.pointer.rotationQuaternion = new Quaternion();\r\n\r\n if (this.inputSource.gripSpace) {\r\n this.grip = new Mesh(`${this._uniqueId}-grip`, this._scene);\r\n this.grip.rotationQuaternion = new Quaternion();\r\n }\r\n\r\n this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1.0 : 1.0);\r\n\r\n // for now only load motion controllers if gamepad object available\r\n if (this.inputSource.gamepad && this.inputSource.targetRayMode === \"tracked-pointer\") {\r\n // eslint-disable-next-line github/no-then\r\n WebXRMotionControllerManager.GetMotionControllerWithXRInput(inputSource, _scene, this._options.forceControllerProfile).then(\r\n (motionController) => {\r\n this.motionController = motionController;\r\n this.onMotionControllerInitObservable.notifyObservers(motionController);\r\n // should the model be loaded?\r\n if (!this._options.doNotLoadControllerMesh && !this.motionController._doNotLoadControllerMesh) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this.motionController.loadModel().then((success) => {\r\n if (success && this.motionController && this.motionController.rootMesh) {\r\n if (this._options.renderingGroupId) {\r\n // anything other than 0?\r\n this.motionController.rootMesh.renderingGroupId = this._options.renderingGroupId;\r\n const childMeshes = this.motionController.rootMesh.getChildMeshes(false);\r\n for (const mesh of childMeshes) {\r\n mesh.renderingGroupId = this._options.renderingGroupId!;\r\n }\r\n }\r\n this.onMeshLoadedObservable.notifyObservers(this.motionController.rootMesh);\r\n this.motionController.rootMesh.parent = this.grip || this.pointer;\r\n this.motionController.disableAnimation = !!this._options.disableMotionControllerAnimation;\r\n }\r\n // make sure to dispose is the controller is already disposed\r\n if (this._disposed) {\r\n this.motionController?.dispose();\r\n }\r\n });\r\n }\r\n },\r\n () => {\r\n Tools.Warn(`Could not find a matching motion controller for the registered input source`);\r\n }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Get this controllers unique id\r\n */\r\n public get uniqueId() {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Disposes of the object\r\n */\r\n public dispose() {\r\n if (this.grip) {\r\n this.grip.dispose(true);\r\n }\r\n if (this.motionController) {\r\n this.motionController.dispose();\r\n }\r\n this.pointer.dispose(true);\r\n this.onMotionControllerInitObservable.clear();\r\n this.onMeshLoadedObservable.clear();\r\n this.onDisposeObservable.notifyObservers(this);\r\n this.onDisposeObservable.clear();\r\n this._disposed = true;\r\n }\r\n\r\n /**\r\n * Gets a world space ray coming from the pointer or grip\r\n * @param result the resulting ray\r\n * @param gripIfAvailable use the grip mesh instead of the pointer, if available\r\n */\r\n public getWorldPointerRayToRef(result: Ray, gripIfAvailable: boolean = false) {\r\n const object = gripIfAvailable && this.grip ? this.grip : this.pointer;\r\n Vector3.TransformNormalToRef(this._tmpVector, object.getWorldMatrix(), result.direction);\r\n result.direction.normalize();\r\n result.origin.copyFrom(object.absolutePosition);\r\n result.length = 1000;\r\n }\r\n\r\n /**\r\n * Updates the controller pose based on the given XRFrame\r\n * @param xrFrame xr frame to update the pose with\r\n * @param referenceSpace reference space to use\r\n * @param xrCamera the xr camera, used for parenting\r\n * @param xrSessionManager the session manager used to get the world reference system\r\n */\r\n public updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, xrCamera: WebXRCamera, xrSessionManager: WebXRSessionManager) {\r\n const pose = xrFrame.getPose(this.inputSource.targetRaySpace, referenceSpace);\r\n this._lastXRPose = pose;\r\n\r\n // Update the pointer mesh\r\n if (pose) {\r\n const pos = pose.transform.position;\r\n this.pointer.position.set(pos.x, pos.y, pos.z).scaleInPlace(xrSessionManager.worldScalingFactor);\r\n const orientation = pose.transform.orientation;\r\n this.pointer.rotationQuaternion!.set(orientation.x, orientation.y, orientation.z, orientation.w);\r\n if (!this._scene.useRightHandedSystem) {\r\n this.pointer.position.z *= -1;\r\n this.pointer.rotationQuaternion!.z *= -1;\r\n this.pointer.rotationQuaternion!.w *= -1;\r\n }\r\n this.pointer.parent = xrCamera.parent;\r\n this.pointer.scaling.setAll(xrSessionManager.worldScalingFactor);\r\n }\r\n\r\n // Update the grip mesh if it exists\r\n if (this.inputSource.gripSpace && this.grip) {\r\n const pose = xrFrame.getPose(this.inputSource.gripSpace, referenceSpace);\r\n if (pose) {\r\n const pos = pose.transform.position;\r\n const orientation = pose.transform.orientation;\r\n this.grip.position.set(pos.x, pos.y, pos.z).scaleInPlace(xrSessionManager.worldScalingFactor);\r\n this.grip.rotationQuaternion!.set(orientation.x, orientation.y, orientation.z, orientation.w);\r\n if (!this._scene.useRightHandedSystem) {\r\n this.grip.position.z *= -1;\r\n this.grip.rotationQuaternion!.z *= -1;\r\n this.grip.rotationQuaternion!.w *= -1;\r\n }\r\n }\r\n this.grip.parent = xrCamera.parent;\r\n this.grip.scaling.setAll(xrSessionManager.worldScalingFactor);\r\n }\r\n if (this.motionController) {\r\n // either update buttons only or also position, if in gamepad mode\r\n this.motionController.updateFromXRFrame(xrFrame);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webXRInputSource.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRInputSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAIhE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sDAAsD,CAAC;AACpG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,IAAI,OAAO,GAAG,CAAC,CAAC;AA2BhB;;GA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C,kBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;oBACtC,IAAI,CAAC,IAAI,CAAC,kBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC1C,CAAC;YACL,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,kEAAkE;YAClE,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Observable } from \"../Misc/observable\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Quaternion, Vector3 } from \"../Maths/math.vector.pure\";\r\nimport { type Ray } from \"../Culling/ray\";\r\nimport { type Scene } from \"../scene\";\r\nimport { type WebXRAbstractMotionController } from \"./motionController/webXRAbstractMotionController\";\r\nimport { WebXRMotionControllerManager } from \"./motionController/webXRMotionControllerManager.pure\";\r\nimport { Tools } from \"../Misc/tools.pure\";\r\nimport { type WebXRCamera } from \"./webXRCamera\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport { Mesh } from \"../Meshes/mesh.pure\";\r\n\r\nlet IdCount = 0;\r\n\r\n/**\r\n * Configuration options for the WebXR controller creation\r\n */\r\nexport interface IWebXRControllerOptions {\r\n /**\r\n * Should the controller mesh be animated when a user interacts with it\r\n * The pressed buttons / thumbstick and touchpad animations will be disabled\r\n */\r\n disableMotionControllerAnimation?: boolean;\r\n /**\r\n * Do not load the controller mesh, in case a different mesh needs to be loaded.\r\n */\r\n doNotLoadControllerMesh?: boolean;\r\n /**\r\n * Force a specific controller type for this controller.\r\n * This can be used when creating your own profile or when testing different controllers\r\n */\r\n forceControllerProfile?: string;\r\n /**\r\n * Defines a rendering group ID for meshes that will be loaded.\r\n * This is for the default controllers only.\r\n */\r\n renderingGroupId?: number;\r\n}\r\n\r\n/**\r\n * Represents an XR controller\r\n */\r\nexport class WebXRInputSource {\r\n private _tmpVector = new Vector3();\r\n private _uniqueId: string;\r\n private _disposed = false;\r\n\r\n /**\r\n * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if that's the case only the pointer from the head will be available\r\n */\r\n public grip?: AbstractMesh;\r\n /**\r\n * If available, this is the gamepad object related to this controller.\r\n * Using this object it is possible to get click events and trackpad changes of the\r\n * webxr controller that is currently being used.\r\n */\r\n public motionController?: WebXRAbstractMotionController;\r\n /**\r\n * Event that fires when the controller is removed/disposed.\r\n * The object provided as event data is this controller, after associated assets were disposed.\r\n * uniqueId is still available.\r\n */\r\n public onDisposeObservable = new Observable<WebXRInputSource>();\r\n /**\r\n * Will be triggered when the mesh associated with the motion controller is done loading.\r\n * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh\r\n * A shortened version of controller -> motion controller -> on mesh loaded.\r\n */\r\n public onMeshLoadedObservable = new Observable<AbstractMesh>();\r\n /**\r\n * Observers registered here will trigger when a motion controller profile was assigned to this xr controller\r\n */\r\n public onMotionControllerInitObservable = new Observable<WebXRAbstractMotionController>();\r\n /**\r\n * Pointer which can be used to select objects or attach a visible laser to\r\n */\r\n public pointer: AbstractMesh;\r\n\r\n /**\r\n * The last XRPose the was calculated on the current XRFrame\r\n * @internal\r\n */\r\n public _lastXRPose?: XRPose;\r\n\r\n /**\r\n * Creates the input source object\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/webXR/webXRInputControllerSupport\r\n * @param _scene the scene which the controller should be associated to\r\n * @param inputSource the underlying input source for the controller\r\n * @param _options options for this controller creation\r\n */\r\n constructor(\r\n private _scene: Scene,\r\n /** The underlying input source for the controller */\r\n public inputSource: XRInputSource,\r\n private _options: IWebXRControllerOptions = {}\r\n ) {\r\n this._uniqueId = `controller-${IdCount++}-${inputSource.targetRayMode}-${inputSource.handedness}`;\r\n\r\n this.pointer = new Mesh(`${this._uniqueId}-pointer`, _scene);\r\n this.pointer.rotationQuaternion = new Quaternion();\r\n\r\n if (this.inputSource.gripSpace) {\r\n this.grip = new Mesh(`${this._uniqueId}-grip`, this._scene);\r\n this.grip.rotationQuaternion = new Quaternion();\r\n }\r\n\r\n this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1.0 : 1.0);\r\n\r\n // for now only load motion controllers if gamepad object available\r\n if (this.inputSource.gamepad && this.inputSource.targetRayMode === \"tracked-pointer\") {\r\n // eslint-disable-next-line github/no-then\r\n WebXRMotionControllerManager.GetMotionControllerWithXRInput(inputSource, _scene, this._options.forceControllerProfile).then(\r\n (motionController) => {\r\n this.motionController = motionController;\r\n this.onMotionControllerInitObservable.notifyObservers(motionController);\r\n // should the model be loaded?\r\n if (!this._options.doNotLoadControllerMesh && !this.inputSource.skipRendering && !this.motionController._doNotLoadControllerMesh) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this.motionController.loadModel().then((success) => {\r\n if (success && this.motionController && this.motionController.rootMesh) {\r\n if (this._options.renderingGroupId) {\r\n // anything other than 0?\r\n this.motionController.rootMesh.renderingGroupId = this._options.renderingGroupId;\r\n const childMeshes = this.motionController.rootMesh.getChildMeshes(false);\r\n for (const mesh of childMeshes) {\r\n mesh.renderingGroupId = this._options.renderingGroupId!;\r\n }\r\n }\r\n this.onMeshLoadedObservable.notifyObservers(this.motionController.rootMesh);\r\n this.motionController.rootMesh.parent = this.grip || this.pointer;\r\n this.motionController.disableAnimation = !!this._options.disableMotionControllerAnimation;\r\n }\r\n // make sure to dispose is the controller is already disposed\r\n if (this._disposed) {\r\n this.motionController?.dispose();\r\n }\r\n });\r\n }\r\n },\r\n () => {\r\n Tools.Warn(`Could not find a matching motion controller for the registered input source`);\r\n }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Get this controllers unique id\r\n */\r\n public get uniqueId() {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Disposes of the object\r\n */\r\n public dispose() {\r\n if (this.grip) {\r\n this.grip.dispose(true);\r\n }\r\n if (this.motionController) {\r\n this.motionController.dispose();\r\n }\r\n this.pointer.dispose(true);\r\n this.onMotionControllerInitObservable.clear();\r\n this.onMeshLoadedObservable.clear();\r\n this.onDisposeObservable.notifyObservers(this);\r\n this.onDisposeObservable.clear();\r\n this._disposed = true;\r\n }\r\n\r\n /**\r\n * Gets a world space ray coming from the pointer or grip\r\n * @param result the resulting ray\r\n * @param gripIfAvailable use the grip mesh instead of the pointer, if available\r\n */\r\n public getWorldPointerRayToRef(result: Ray, gripIfAvailable: boolean = false) {\r\n const object = gripIfAvailable && this.grip ? this.grip : this.pointer;\r\n Vector3.TransformNormalToRef(this._tmpVector, object.getWorldMatrix(), result.direction);\r\n result.direction.normalize();\r\n result.origin.copyFrom(object.absolutePosition);\r\n result.length = 1000;\r\n }\r\n\r\n /**\r\n * Updates the controller pose based on the given XRFrame\r\n * @param xrFrame xr frame to update the pose with\r\n * @param referenceSpace reference space to use\r\n * @param xrCamera the xr camera, used for parenting\r\n * @param xrSessionManager the session manager used to get the world reference system\r\n */\r\n public updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, xrCamera: WebXRCamera, xrSessionManager: WebXRSessionManager) {\r\n const pose = xrFrame.getPose(this.inputSource.targetRaySpace, referenceSpace);\r\n this._lastXRPose = pose;\r\n\r\n // Update the pointer mesh\r\n if (pose) {\r\n const pos = pose.transform.position;\r\n this.pointer.position.set(pos.x, pos.y, pos.z).scaleInPlace(xrSessionManager.worldScalingFactor);\r\n const orientation = pose.transform.orientation;\r\n this.pointer.rotationQuaternion!.set(orientation.x, orientation.y, orientation.z, orientation.w);\r\n if (!this._scene.useRightHandedSystem) {\r\n this.pointer.position.z *= -1;\r\n this.pointer.rotationQuaternion!.z *= -1;\r\n this.pointer.rotationQuaternion!.w *= -1;\r\n }\r\n this.pointer.parent = xrCamera.parent;\r\n this.pointer.scaling.setAll(xrSessionManager.worldScalingFactor);\r\n }\r\n\r\n // Update the grip mesh if it exists\r\n if (this.inputSource.gripSpace && this.grip) {\r\n const pose = xrFrame.getPose(this.inputSource.gripSpace, referenceSpace);\r\n if (pose) {\r\n const pos = pose.transform.position;\r\n const orientation = pose.transform.orientation;\r\n this.grip.position.set(pos.x, pos.y, pos.z).scaleInPlace(xrSessionManager.worldScalingFactor);\r\n this.grip.rotationQuaternion!.set(orientation.x, orientation.y, orientation.z, orientation.w);\r\n if (!this._scene.useRightHandedSystem) {\r\n this.grip.position.z *= -1;\r\n this.grip.rotationQuaternion!.z *= -1;\r\n this.grip.rotationQuaternion!.w *= -1;\r\n }\r\n }\r\n this.grip.parent = xrCamera.parent;\r\n this.grip.scaling.setAll(xrSessionManager.worldScalingFactor);\r\n }\r\n if (this.motionController) {\r\n // either update buttons only or also position, if in gamepad mode\r\n this.motionController.updateFromXRFrame(xrFrame);\r\n }\r\n }\r\n}\r\n"]}
@@ -34,17 +34,19 @@ export declare class WebXRLayerWrapper<LayerTypeT extends WebXRSupportedLayerTyp
34
34
  */
35
35
  get renderTargetTextureProvider(): Nullable<WebXRLayerRenderTargetTextureProvider<LayerTypeT>>;
36
36
  /**
37
- * Check if fixed foveation is supported on this device
37
+ * Check if fixed foveation is supported by the wrapped XRWebGLLayer or XRProjectionLayer.
38
38
  */
39
39
  get isFixedFoveationSupported(): boolean;
40
40
  /**
41
- * Get the fixed foveation currently set, as specified by the webxr specs
42
- * If this returns null, then fixed foveation is not supported
41
+ * Gets the fixed foveation currently set, as specified by the WebXR specs.
42
+ * @returns The fixed foveation level, or `null` when fixed foveation is not supported.
43
43
  */
44
44
  get fixedFoveation(): Nullable<number>;
45
45
  /**
46
- * Set the fixed foveation to the specified value, as specified by the webxr specs
47
- * This value will be normalized to be between 0 and 1, 1 being max foveation, 0 being no foveation
46
+ * Sets the fixed foveation level, as specified by the WebXR specs.
47
+ * The value is normalized between 0 and 1, where 1 is maximum foveation and 0 is no foveation.
48
+ * Unsupported native layers ignore the assignment, matching the WebXR fixed-foveation contract.
49
+ * @param value The fixed foveation level, or `null` to use no foveation.
48
50
  */
49
51
  set fixedFoveation(value: Nullable<number>);
50
52
  /**
@@ -10,24 +10,27 @@ export class WebXRLayerWrapper {
10
10
  return this._rttWrapper;
11
11
  }
12
12
  /**
13
- * Check if fixed foveation is supported on this device
13
+ * Check if fixed foveation is supported by the wrapped XRWebGLLayer or XRProjectionLayer.
14
14
  */
15
15
  get isFixedFoveationSupported() {
16
- return this.layerType == "XRWebGLLayer" && typeof this.layer.fixedFoveation == "number";
16
+ const isFoveationLayer = this.layerType === "XRWebGLLayer" || this.layerType === "XRProjectionLayer";
17
+ return isFoveationLayer && typeof this.layer.fixedFoveation === "number";
17
18
  }
18
19
  /**
19
- * Get the fixed foveation currently set, as specified by the webxr specs
20
- * If this returns null, then fixed foveation is not supported
20
+ * Gets the fixed foveation currently set, as specified by the WebXR specs.
21
+ * @returns The fixed foveation level, or `null` when fixed foveation is not supported.
21
22
  */
22
23
  get fixedFoveation() {
23
24
  if (this.isFixedFoveationSupported) {
24
- return this.layer.fixedFoveation;
25
+ return this.layer.fixedFoveation ?? null;
25
26
  }
26
27
  return null;
27
28
  }
28
29
  /**
29
- * Set the fixed foveation to the specified value, as specified by the webxr specs
30
- * This value will be normalized to be between 0 and 1, 1 being max foveation, 0 being no foveation
30
+ * Sets the fixed foveation level, as specified by the WebXR specs.
31
+ * The value is normalized between 0 and 1, where 1 is maximum foveation and 0 is no foveation.
32
+ * Unsupported native layers ignore the assignment, matching the WebXR fixed-foveation contract.
33
+ * @param value The fixed foveation level, or `null` to use no foveation.
31
34
  */
32
35
  set fixedFoveation(value) {
33
36
  if (this.isFixedFoveationSupported) {
@@ -1 +1 @@
1
- {"version":3,"file":"webXRLayerWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRLayerWrapper.ts"],"names":[],"mappings":"AAqBA;;;GAGG;AAC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AQ,GAAR,QAAQ,CAAc;QAEtB,cAAS,GAAT,SAAS,CAAc;QAEd,UAAK,GAAL,KAAK,CAAS;QAEd,cAAS,GAAT,SAAS,CAAY;QAE7B,uCAAkC,GAAlC,kCAAkC,CAA8F;QAnEpI,gBAAW,GAAgE,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"]}
1
+ {"version":3,"file":"webXRLayerWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRLayer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IACrC,QAAsB;IAC7B,6CAA6C;IACtC,SAAuB;IAC9B,sDAAsD;IACtC,KAAc;IAC9B,kDAAkD;IAClC,SAAqB;IACrC,6DAA6D;IACrD,kCAAgI;QARjI,aAAQ,GAAR,QAAQ,CAAc;QAEtB,cAAS,GAAT,SAAS,CAAc;QAEd,UAAK,GAAL,KAAK,CAAS;QAEd,cAAS,GAAT,SAAS,CAAY;QAE7B,uCAAkC,GAAlC,kCAAkC,CAA8F;QAtEpI,gBAAW,GAAgE,IAAI,CAAC;IAuErF,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 by the wrapped XRWebGLLayer or XRProjectionLayer.\r\n */\r\n public get isFixedFoveationSupported(): boolean {\r\n const isFoveationLayer = this.layerType === \"XRWebGLLayer\" || this.layerType === \"XRProjectionLayer\";\r\n return isFoveationLayer && typeof (this.layer as XRWebGLLayer | XRProjectionLayer).fixedFoveation === \"number\";\r\n }\r\n\r\n /**\r\n * Gets the fixed foveation currently set, as specified by the WebXR specs.\r\n * @returns The fixed foveation level, or `null` when 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 | XRProjectionLayer).fixedFoveation ?? null;\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Sets the fixed foveation level, as specified by the WebXR specs.\r\n * The value is normalized between 0 and 1, where 1 is maximum foveation and 0 is no foveation.\r\n * Unsupported native layers ignore the assignment, matching the WebXR fixed-foveation contract.\r\n * @param value The fixed foveation level, or `null` to use 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 | XRProjectionLayer).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"]}
@@ -23,6 +23,8 @@ export declare class WebXRSessionManager implements IDisposable, IWebXRRenderTar
23
23
  private _xrNavigator;
24
24
  private _sessionMode;
25
25
  private _onEngineDisposedObserver;
26
+ private _sessionCleanup;
27
+ private _referenceSpaceInitialized;
26
28
  /**
27
29
  * The base reference space from which the session started. good if you want to reset your
28
30
  * reference space
@@ -143,6 +145,39 @@ export declare class WebXRSessionManager implements IDisposable, IWebXRRenderTar
143
145
  * @returns the render target for the specified view or null if not available
144
146
  */
145
147
  getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;
148
+ /**
149
+ * Checks whether the current XR view exposes the dynamic viewport scaling API.
150
+ * API availability does not guarantee that the active XR device will change the viewport dimensions.
151
+ * This method must be called during an active XR frame.
152
+ * @param viewIndex the index of the view in the current viewer pose
153
+ * @returns whether dynamic viewport scaling is exposed for the view
154
+ * @see https://playground.babylonjs.com/#BAGIIM#0
155
+ */
156
+ isViewportScaleSupported(viewIndex: number): boolean;
157
+ /**
158
+ * Gets the runtime-recommended viewport scale for the current XR view.
159
+ * A number is returned when the runtime has a recommendation, `null` when the API is supported but
160
+ * the runtime has no recommendation, and `undefined` when the API is not supported.
161
+ * This method must be called during an active XR frame.
162
+ * @param viewIndex the index of the view in the current viewer pose
163
+ * @returns the recommended viewport scale, `null` when no recommendation is available, or `undefined` when unsupported
164
+ * @see https://playground.babylonjs.com/#BAGIIM#0
165
+ */
166
+ getRecommendedViewportScale(viewIndex: number): Nullable<number> | undefined;
167
+ /**
168
+ * Requests a viewport scale for the current XR view.
169
+ * The request is a hint to the runtime. Babylon uses the native viewport returned on subsequent frames
170
+ * and does not derive viewport dimensions from this value. Pass `1` to restore the full viewport scale;
171
+ * `null` follows the native no-op behavior. Native ignored-value, clamping, and exception behavior is preserved.
172
+ * Requests made from an application observer of `onXRFrameObservable` apply to a future frame because
173
+ * Babylon's camera acquires the current frame's viewport before notifying application observers.
174
+ * This method must be called during an active XR frame.
175
+ * @param viewIndex the index of the view in the current viewer pose
176
+ * @param scale the viewport scale requested from the runtime
177
+ * @see https://playground.babylonjs.com/#BAGIIM#0
178
+ */
179
+ requestViewportScale(viewIndex: number, scale: Nullable<number>): void;
180
+ private _getCurrentXRView;
146
181
  /**
147
182
  * Obtains the XR graphics binding for the current session, creating it lazily.
148
183
  * This is the API-agnostic seam used by WebGL and WebGPU XR features to share a binding.
@@ -216,6 +251,16 @@ export declare class WebXRSessionManager implements IDisposable, IWebXRRenderTar
216
251
  * @returns a promise with boolean as final value
217
252
  */
218
253
  static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
254
+ /**
255
+ * Returns whether the runtime exposes the WebGPU-XR binding APIs required by Babylon.js.
256
+ *
257
+ * This is an advisory check only. XR session negotiation can still fail for the active device,
258
+ * permissions, or adapter. A WebGPU engine intended for XR must also be created with
259
+ * `xrCompatible: true`.
260
+ * @returns whether the required XRGPUBinding projection APIs are exposed
261
+ * @experimental WebGPU-XR support is experimental and may change.
262
+ */
263
+ static get IsWebGPUXRSupported(): boolean;
219
264
  /**
220
265
  * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
221
266
  */