@onerjs/core 8.28.0 → 8.28.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 (109) hide show
  1. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  2. package/Collisions/gpuPicker.d.ts +40 -16
  3. package/Collisions/gpuPicker.js +216 -95
  4. package/Collisions/gpuPicker.js.map +1 -1
  5. package/Decorators/nodeDecorator.d.ts +5 -1
  6. package/Decorators/nodeDecorator.js +4 -0
  7. package/Decorators/nodeDecorator.js.map +1 -1
  8. package/Engines/abstractEngine.js +2 -2
  9. package/Engines/abstractEngine.js.map +1 -1
  10. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +30 -0
  11. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +56 -0
  12. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -0
  13. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +32 -0
  14. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +62 -0
  15. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -0
  16. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +36 -0
  17. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +88 -0
  18. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -0
  19. package/FrameGraph/Node/Blocks/index.d.ts +3 -0
  20. package/FrameGraph/Node/Blocks/index.js +3 -0
  21. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  22. package/FrameGraph/Tasks/PostProcesses/colorCorrectionTask.d.ts +17 -0
  23. package/FrameGraph/Tasks/PostProcesses/colorCorrectionTask.js +18 -0
  24. package/FrameGraph/Tasks/PostProcesses/colorCorrectionTask.js.map +1 -0
  25. package/FrameGraph/Tasks/PostProcesses/filterTask.d.ts +16 -0
  26. package/FrameGraph/Tasks/PostProcesses/filterTask.js +17 -0
  27. package/FrameGraph/Tasks/PostProcesses/filterTask.js.map +1 -0
  28. package/FrameGraph/Tasks/PostProcesses/tonemapTask.d.ts +16 -0
  29. package/FrameGraph/Tasks/PostProcesses/tonemapTask.js +17 -0
  30. package/FrameGraph/Tasks/PostProcesses/tonemapTask.js.map +1 -0
  31. package/FrameGraph/index.d.ts +3 -0
  32. package/FrameGraph/index.js +3 -0
  33. package/FrameGraph/index.js.map +1 -1
  34. package/Materials/Textures/texture.js +9 -2
  35. package/Materials/Textures/texture.js.map +1 -1
  36. package/Materials/effect.d.ts +1 -0
  37. package/Materials/effect.js +7 -1
  38. package/Materials/effect.js.map +1 -1
  39. package/Particles/gpuParticleSystem.js +2 -1
  40. package/Particles/gpuParticleSystem.js.map +1 -1
  41. package/Particles/thinParticleSystem.js +4 -3
  42. package/Particles/thinParticleSystem.js.map +1 -1
  43. package/Physics/v2/physicsAggregate.js +4 -3
  44. package/Physics/v2/physicsAggregate.js.map +1 -1
  45. package/PostProcesses/colorCorrectionPostProcess.d.ts +3 -3
  46. package/PostProcesses/colorCorrectionPostProcess.js +21 -21
  47. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  48. package/PostProcesses/filterPostProcess.d.ts +4 -2
  49. package/PostProcesses/filterPostProcess.js +22 -15
  50. package/PostProcesses/filterPostProcess.js.map +1 -1
  51. package/PostProcesses/index.d.ts +3 -0
  52. package/PostProcesses/index.js +3 -0
  53. package/PostProcesses/index.js.map +1 -1
  54. package/PostProcesses/thinColorCorrectionPostProcess.d.ts +30 -0
  55. package/PostProcesses/thinColorCorrectionPostProcess.js +52 -0
  56. package/PostProcesses/thinColorCorrectionPostProcess.js.map +1 -0
  57. package/PostProcesses/thinFilterPostProcess.d.ts +29 -0
  58. package/PostProcesses/thinFilterPostProcess.js +51 -0
  59. package/PostProcesses/thinFilterPostProcess.js.map +1 -0
  60. package/PostProcesses/thinTonemapPostProcess.d.ts +52 -0
  61. package/PostProcesses/thinTonemapPostProcess.js +83 -0
  62. package/PostProcesses/thinTonemapPostProcess.js.map +1 -0
  63. package/PostProcesses/tonemapPostProcess.d.ts +23 -21
  64. package/PostProcesses/tonemapPostProcess.js +55 -46
  65. package/PostProcesses/tonemapPostProcess.js.map +1 -1
  66. package/Rendering/geometryBufferRenderer.js +6 -1
  67. package/Rendering/geometryBufferRenderer.js.map +1 -1
  68. package/Shaders/geometry.fragment.js +3 -1
  69. package/Shaders/geometry.fragment.js.map +1 -1
  70. package/Shaders/geometry.vertex.js +10 -2
  71. package/Shaders/geometry.vertex.js.map +1 -1
  72. package/Shaders/picking.fragment.js +20 -6
  73. package/Shaders/picking.fragment.js.map +1 -1
  74. package/Shaders/picking.vertex.js +4 -3
  75. package/Shaders/picking.vertex.js.map +1 -1
  76. package/ShadersWGSL/geometry.fragment.js +3 -1
  77. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  78. package/ShadersWGSL/geometry.vertex.js +10 -2
  79. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  80. package/ShadersWGSL/picking.fragment.js +11 -6
  81. package/ShadersWGSL/picking.fragment.js.map +1 -1
  82. package/ShadersWGSL/picking.vertex.js +4 -3
  83. package/ShadersWGSL/picking.vertex.js.map +1 -1
  84. package/XR/features/WebXRAnchorSystem.d.ts +1 -1
  85. package/XR/features/WebXRBackgroundRemover.d.ts +1 -1
  86. package/XR/features/WebXRControllerMovement.d.ts +1 -1
  87. package/XR/features/WebXRControllerPhysics.d.ts +1 -1
  88. package/XR/features/WebXRControllerPointerSelection.d.ts +1 -1
  89. package/XR/features/WebXRControllerTeleportation.d.ts +1 -1
  90. package/XR/features/WebXRDOMOverlay.d.ts +1 -1
  91. package/XR/features/WebXRDepthSensing.d.ts +1 -1
  92. package/XR/features/WebXREyeTracking.d.ts +1 -1
  93. package/XR/features/WebXRFeaturePointSystem.d.ts +1 -1
  94. package/XR/features/WebXRHandTracking.d.ts +1 -1
  95. package/XR/features/WebXRHitTest.d.ts +1 -1
  96. package/XR/features/WebXRHitTestLegacy.d.ts +1 -1
  97. package/XR/features/WebXRImageTracking.d.ts +1 -1
  98. package/XR/features/WebXRLayers.d.ts +1 -1
  99. package/XR/features/WebXRLightEstimation.d.ts +1 -1
  100. package/XR/features/WebXRMeshDetector.d.ts +1 -1
  101. package/XR/features/WebXRNearInteraction.d.ts +1 -1
  102. package/XR/features/WebXRPlaneDetector.d.ts +1 -1
  103. package/XR/features/WebXRRawCameraAccess.d.ts +1 -1
  104. package/XR/features/WebXRSpaceWarp.d.ts +1 -1
  105. package/XR/webXRDefaultExperience.js +1 -1
  106. package/XR/webXRDefaultExperience.js.map +1 -1
  107. package/XR/webXRFeaturesManager.d.ts +116 -27
  108. package/XR/webXRFeaturesManager.js.map +1 -1
  109. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"webXRDefaultExperience.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRDefaultExperience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,+BAA+B,EAAE,MAAM,4CAA4C,CAAC;AAE7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,iBAAiB,EAAkC,MAAM,8BAA8B,CAAC;AACjG,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,6BAA6B;CA8EzC;AAED;;GAEG;AACH,MAAM,OAAO,sBAAsB;IA+B/B,gBAAuB,CAAC;IAExB;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAY,EAAE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ED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { WebXRExperienceHelper } from \"./webXRExperienceHelper\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IWebXRInputOptions } from \"./webXRInput\";\r\nimport { WebXRInput } from \"./webXRInput\";\r\nimport type { IWebXRControllerPointerSelectionOptions } from \"./features/WebXRControllerPointerSelection\";\r\nimport { WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection\";\r\nimport type { IWebXRNearInteractionOptions } from \"./features/WebXRNearInteraction\";\r\nimport { WebXRNearInteraction } from \"./features/WebXRNearInteraction\";\r\nimport type { WebXRRenderTarget } from \"./webXRTypes\";\r\nimport type { WebXREnterExitUIOptions } from \"./webXREnterExitUI\";\r\nimport { WebXREnterExitUI } from \"./webXREnterExitUI\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { WebXRManagedOutputCanvasOptions } from \"./webXRManagedOutputCanvas\";\r\nimport type { IWebXRTeleportationOptions } from \"./features/WebXRControllerTeleportation\";\r\nimport { WebXRHandTracking, type IWebXRHandTrackingOptions } from \"./features/WebXRHandTracking\";\r\nimport { WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation\";\r\nimport { Logger } from \"../Misc/logger\";\r\n\r\n/**\r\n * Options for the default xr helper\r\n */\r\nexport class WebXRDefaultExperienceOptions {\r\n /**\r\n * Enable or disable default UI to enter XR\r\n */\r\n public disableDefaultUI?: boolean;\r\n /**\r\n * Should pointer selection not initialize.\r\n * Note that disabling pointer selection also disables teleportation.\r\n * Defaults to false.\r\n */\r\n public disablePointerSelection?: boolean;\r\n /**\r\n * Should teleportation not initialize. Defaults to false.\r\n */\r\n public disableTeleportation?: boolean;\r\n /**\r\n * Should nearInteraction not initialize. Defaults to false.\r\n */\r\n public disableNearInteraction?: boolean;\r\n\r\n /**\r\n * Should hand tracking be disabled. Defaults to false.\r\n */\r\n public disableHandTracking?: boolean;\r\n /**\r\n * Floor meshes that will be used for teleport\r\n */\r\n public floorMeshes?: Array<AbstractMesh>;\r\n /**\r\n * If set to true, the first frame will not be used to reset position\r\n * The first frame is mainly used when copying transformation from the old camera\r\n * Mainly used in AR\r\n */\r\n public ignoreNativeCameraTransformation?: boolean;\r\n /**\r\n * Optional configuration for the XR input object\r\n */\r\n public inputOptions?: Partial<IWebXRInputOptions>;\r\n /**\r\n * optional configuration for pointer selection\r\n */\r\n public pointerSelectionOptions?: Partial<IWebXRControllerPointerSelectionOptions>;\r\n /**\r\n * optional configuration for near interaction\r\n */\r\n public nearInteractionOptions?: Partial<IWebXRNearInteractionOptions>;\r\n\r\n /**\r\n * optional configuration for hand tracking\r\n */\r\n public handSupportOptions?: Partial<IWebXRHandTrackingOptions>;\r\n /**\r\n * optional configuration for teleportation\r\n */\r\n public teleportationOptions?: Partial<IWebXRTeleportationOptions>;\r\n /**\r\n * optional configuration for the output canvas\r\n */\r\n public outputCanvasOptions?: WebXRManagedOutputCanvasOptions;\r\n /**\r\n * optional UI options. This can be used among other to change session mode and reference space type\r\n */\r\n public uiOptions?: Partial<WebXREnterExitUIOptions>;\r\n /**\r\n * When loading teleportation and pointer select, use stable versions instead of latest.\r\n */\r\n public useStablePlugins?: boolean;\r\n\r\n /**\r\n * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes\r\n */\r\n public renderingGroupId?: number;\r\n\r\n /**\r\n * A list of optional features to init the session with\r\n * If set to true, all features we support will be added\r\n */\r\n public optionalFeatures?: boolean | string[];\r\n}\r\n\r\n/**\r\n * Default experience for webxr\r\n */\r\nexport class WebXRDefaultExperience {\r\n /**\r\n * Base experience\r\n */\r\n public baseExperience: WebXRExperienceHelper;\r\n /**\r\n * Enables ui for entering/exiting xr\r\n */\r\n public enterExitUI: WebXREnterExitUI;\r\n /**\r\n * Input experience extension\r\n */\r\n public input: WebXRInput;\r\n /**\r\n * Enables laser pointer and selection\r\n */\r\n public pointerSelection: WebXRControllerPointerSelection;\r\n /**\r\n * Default target xr should render to\r\n */\r\n public renderTarget: WebXRRenderTarget;\r\n /**\r\n * Enables teleportation\r\n */\r\n public teleportation: WebXRMotionControllerTeleportation;\r\n\r\n /**\r\n * Enables near interaction for hands/controllers\r\n */\r\n public nearInteraction: WebXRNearInteraction;\r\n\r\n private constructor() {}\r\n\r\n /**\r\n * Creates the default xr experience\r\n * @param scene scene\r\n * @param options options for basic configuration\r\n * @returns resulting WebXRDefaultExperience\r\n */\r\n public static async CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions = {}) {\r\n const result = new WebXRDefaultExperience();\r\n scene.onDisposeObservable.addOnce(() => {\r\n result.dispose();\r\n });\r\n // init the UI right after construction\r\n if (!options.disableDefaultUI) {\r\n const uiOptions: WebXREnterExitUIOptions = {\r\n renderTarget: result.renderTarget,\r\n ...(options.uiOptions || {}),\r\n };\r\n if (options.optionalFeatures) {\r\n if (typeof options.optionalFeatures === \"boolean\") {\r\n uiOptions.optionalFeatures = [\"hit-test\", \"anchors\", \"plane-detection\", \"hand-tracking\"];\r\n } else {\r\n uiOptions.optionalFeatures = options.optionalFeatures;\r\n }\r\n }\r\n result.enterExitUI = new WebXREnterExitUI(scene, uiOptions);\r\n }\r\n\r\n try {\r\n // Create base experience\r\n const xrHelper = await WebXRExperienceHelper.CreateAsync(scene);\r\n // eslint-disable-next-line require-atomic-updates\r\n result.baseExperience = xrHelper;\r\n\r\n if (options.ignoreNativeCameraTransformation) {\r\n // eslint-disable-next-line require-atomic-updates\r\n result.baseExperience.camera.compensateOnFirstFrame = false;\r\n }\r\n\r\n // Add controller support\r\n // eslint-disable-next-line require-atomic-updates\r\n result.input = new WebXRInput(xrHelper.sessionManager, xrHelper.camera, {\r\n controllerOptions: {\r\n renderingGroupId: options.renderingGroupId,\r\n },\r\n ...(options.inputOptions || {}),\r\n });\r\n\r\n if (!options.disablePointerSelection) {\r\n // Add default pointer selection\r\n const pointerSelectionOptions = {\r\n ...options.pointerSelectionOptions,\r\n xrInput: result.input,\r\n renderingGroupId: options.renderingGroupId,\r\n };\r\n\r\n result.pointerSelection = <WebXRControllerPointerSelection>(\r\n result.baseExperience.featuresManager.enableFeature(\r\n WebXRControllerPointerSelection.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRControllerPointerSelectionOptions>pointerSelectionOptions\r\n )\r\n );\r\n\r\n if (!options.disableTeleportation) {\r\n // Add default teleportation, including rotation\r\n result.teleportation = <WebXRMotionControllerTeleportation>result.baseExperience.featuresManager.enableFeature(\r\n WebXRMotionControllerTeleportation.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRTeleportationOptions>{\r\n floorMeshes: options.floorMeshes,\r\n xrInput: result.input,\r\n renderingGroupId: options.renderingGroupId,\r\n ...options.teleportationOptions,\r\n }\r\n );\r\n result.teleportation.setSelectionFeature(result.pointerSelection);\r\n }\r\n }\r\n\r\n if (!options.disableNearInteraction) {\r\n // Add default pointer selection\r\n result.nearInteraction = <WebXRNearInteraction>result.baseExperience.featuresManager.enableFeature(\r\n WebXRNearInteraction.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRNearInteractionOptions>{\r\n xrInput: result.input,\r\n farInteractionFeature: result.pointerSelection,\r\n renderingGroupId: options.renderingGroupId,\r\n useUtilityLayer: true,\r\n enableNearInteractionOnAllControllers: true,\r\n ...options.nearInteractionOptions,\r\n }\r\n );\r\n }\r\n\r\n if (!options.disableHandTracking) {\r\n // Add default hand tracking\r\n result.baseExperience.featuresManager.enableFeature(\r\n WebXRHandTracking.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRHandTrackingOptions>{\r\n xrInput: result.input,\r\n ...options.handSupportOptions,\r\n },\r\n undefined,\r\n false\r\n );\r\n }\r\n\r\n // Create the WebXR output target\r\n result.renderTarget = result.baseExperience.sessionManager.getWebXRRenderTarget(options.outputCanvasOptions);\r\n\r\n if (!options.disableDefaultUI) {\r\n // Create ui for entering/exiting xr\r\n await result.enterExitUI.setHelperAsync(result.baseExperience, result.renderTarget);\r\n }\r\n return result;\r\n } catch (error) {\r\n Logger.Error(\"Error initializing XR\");\r\n Logger.Error(error);\r\n return result;\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the experience helper\r\n */\r\n public dispose() {\r\n if (this.baseExperience) {\r\n this.baseExperience.dispose();\r\n }\r\n if (this.input) {\r\n this.input.dispose();\r\n }\r\n if (this.enterExitUI) {\r\n this.enterExitUI.dispose();\r\n }\r\n if (this.renderTarget) {\r\n this.renderTarget.dispose();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webXRDefaultExperience.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRDefaultExperience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,+BAA+B,EAAE,MAAM,4CAA4C,CAAC;AAE7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,iBAAiB,EAAkC,MAAM,8BAA8B,CAAC;AACjG,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,M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ClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACtC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,MAAM,CAAC;QAClB,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { WebXRExperienceHelper } from \"./webXRExperienceHelper\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IWebXRInputOptions } from \"./webXRInput\";\r\nimport { WebXRInput } from \"./webXRInput\";\r\nimport type { IWebXRControllerPointerSelectionOptions } from \"./features/WebXRControllerPointerSelection\";\r\nimport { WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection\";\r\nimport type { IWebXRNearInteractionOptions } from \"./features/WebXRNearInteraction\";\r\nimport { WebXRNearInteraction } from \"./features/WebXRNearInteraction\";\r\nimport type { WebXRRenderTarget } from \"./webXRTypes\";\r\nimport type { WebXREnterExitUIOptions } from \"./webXREnterExitUI\";\r\nimport { WebXREnterExitUI } from \"./webXREnterExitUI\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { WebXRManagedOutputCanvasOptions } from \"./webXRManagedOutputCanvas\";\r\nimport type { IWebXRTeleportationOptions } from \"./features/WebXRControllerTeleportation\";\r\nimport { WebXRHandTracking, type IWebXRHandTrackingOptions } from \"./features/WebXRHandTracking\";\r\nimport { WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation\";\r\nimport { Logger } from \"../Misc/logger\";\r\n\r\n/**\r\n * Options for the default xr helper\r\n */\r\nexport class WebXRDefaultExperienceOptions {\r\n /**\r\n * Enable or disable default UI to enter XR\r\n */\r\n public disableDefaultUI?: boolean;\r\n /**\r\n * Should pointer selection not initialize.\r\n * Note that disabling pointer selection also disables teleportation.\r\n * Defaults to false.\r\n */\r\n public disablePointerSelection?: boolean;\r\n /**\r\n * Should teleportation not initialize. Defaults to false.\r\n */\r\n public disableTeleportation?: boolean;\r\n /**\r\n * Should nearInteraction not initialize. Defaults to false.\r\n */\r\n public disableNearInteraction?: boolean;\r\n\r\n /**\r\n * Should hand tracking be disabled. Defaults to false.\r\n */\r\n public disableHandTracking?: boolean;\r\n /**\r\n * Floor meshes that will be used for teleport\r\n */\r\n public floorMeshes?: Array<AbstractMesh>;\r\n /**\r\n * If set to true, the first frame will not be used to reset position\r\n * The first frame is mainly used when copying transformation from the old camera\r\n * Mainly used in AR\r\n */\r\n public ignoreNativeCameraTransformation?: boolean;\r\n /**\r\n * Optional configuration for the XR input object\r\n */\r\n public inputOptions?: Partial<IWebXRInputOptions>;\r\n /**\r\n * optional configuration for pointer selection\r\n */\r\n public pointerSelectionOptions?: Partial<IWebXRControllerPointerSelectionOptions>;\r\n /**\r\n * optional configuration for near interaction\r\n */\r\n public nearInteractionOptions?: Partial<IWebXRNearInteractionOptions>;\r\n\r\n /**\r\n * optional configuration for hand tracking\r\n */\r\n public handSupportOptions?: Partial<IWebXRHandTrackingOptions>;\r\n /**\r\n * optional configuration for teleportation\r\n */\r\n public teleportationOptions?: Partial<IWebXRTeleportationOptions>;\r\n /**\r\n * optional configuration for the output canvas\r\n */\r\n public outputCanvasOptions?: WebXRManagedOutputCanvasOptions;\r\n /**\r\n * optional UI options. This can be used among other to change session mode and reference space type\r\n */\r\n public uiOptions?: Partial<WebXREnterExitUIOptions>;\r\n /**\r\n * When loading teleportation and pointer select, use stable versions instead of latest.\r\n */\r\n public useStablePlugins?: boolean;\r\n\r\n /**\r\n * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes\r\n */\r\n public renderingGroupId?: number;\r\n\r\n /**\r\n * A list of optional features to init the session with\r\n * If set to true, all features we support will be added\r\n */\r\n public optionalFeatures?: boolean | string[];\r\n}\r\n\r\n/**\r\n * Default experience for webxr\r\n */\r\nexport class WebXRDefaultExperience {\r\n /**\r\n * Base experience\r\n */\r\n public baseExperience: WebXRExperienceHelper;\r\n /**\r\n * Enables ui for entering/exiting xr\r\n */\r\n public enterExitUI: WebXREnterExitUI;\r\n /**\r\n * Input experience extension\r\n */\r\n public input: WebXRInput;\r\n /**\r\n * Enables laser pointer and selection\r\n */\r\n public pointerSelection: WebXRControllerPointerSelection;\r\n /**\r\n * Default target xr should render to\r\n */\r\n public renderTarget: WebXRRenderTarget;\r\n /**\r\n * Enables teleportation\r\n */\r\n public teleportation: WebXRMotionControllerTeleportation;\r\n\r\n /**\r\n * Enables near interaction for hands/controllers\r\n */\r\n public nearInteraction: WebXRNearInteraction;\r\n\r\n private constructor() {}\r\n\r\n /**\r\n * Creates the default xr experience\r\n * @param scene scene\r\n * @param options options for basic configuration\r\n * @returns resulting WebXRDefaultExperience\r\n */\r\n public static async CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions = {}) {\r\n const result = new WebXRDefaultExperience();\r\n scene.onDisposeObservable.addOnce(() => {\r\n result.dispose();\r\n });\r\n // init the UI right after construction\r\n if (!options.disableDefaultUI) {\r\n const uiOptions: WebXREnterExitUIOptions = {\r\n renderTarget: result.renderTarget,\r\n ...(options.uiOptions || {}),\r\n };\r\n if (options.optionalFeatures) {\r\n if (typeof options.optionalFeatures === \"boolean\") {\r\n uiOptions.optionalFeatures = [\"hit-test\", \"anchors\", \"plane-detection\", \"hand-tracking\"];\r\n } else {\r\n uiOptions.optionalFeatures = options.optionalFeatures;\r\n }\r\n }\r\n result.enterExitUI = new WebXREnterExitUI(scene, uiOptions);\r\n }\r\n\r\n try {\r\n // Create base experience\r\n const xrHelper = await WebXRExperienceHelper.CreateAsync(scene);\r\n // eslint-disable-next-line require-atomic-updates\r\n result.baseExperience = xrHelper;\r\n\r\n if (options.ignoreNativeCameraTransformation) {\r\n // eslint-disable-next-line require-atomic-updates\r\n result.baseExperience.camera.compensateOnFirstFrame = false;\r\n }\r\n\r\n // Add controller support\r\n // eslint-disable-next-line require-atomic-updates\r\n result.input = new WebXRInput(xrHelper.sessionManager, xrHelper.camera, {\r\n controllerOptions: {\r\n renderingGroupId: options.renderingGroupId,\r\n },\r\n ...(options.inputOptions || {}),\r\n });\r\n\r\n if (!options.disablePointerSelection) {\r\n // Add default pointer selection\r\n const pointerSelectionOptions = {\r\n ...options.pointerSelectionOptions,\r\n xrInput: result.input,\r\n renderingGroupId: options.renderingGroupId,\r\n };\r\n\r\n result.pointerSelection = result.baseExperience.featuresManager.enableFeature(\r\n WebXRControllerPointerSelection.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRControllerPointerSelectionOptions>pointerSelectionOptions\r\n );\r\n\r\n if (!options.disableTeleportation) {\r\n // Add default teleportation, including rotation\r\n result.teleportation = result.baseExperience.featuresManager.enableFeature(\r\n WebXRMotionControllerTeleportation.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRTeleportationOptions>{\r\n floorMeshes: options.floorMeshes,\r\n xrInput: result.input,\r\n renderingGroupId: options.renderingGroupId,\r\n ...options.teleportationOptions,\r\n }\r\n );\r\n result.teleportation.setSelectionFeature(result.pointerSelection);\r\n }\r\n }\r\n\r\n if (!options.disableNearInteraction) {\r\n // Add default pointer selection\r\n result.nearInteraction = result.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, options.useStablePlugins ? \"stable\" : \"latest\", <\r\n IWebXRNearInteractionOptions\r\n >{\r\n xrInput: result.input,\r\n farInteractionFeature: result.pointerSelection,\r\n renderingGroupId: options.renderingGroupId,\r\n useUtilityLayer: true,\r\n enableNearInteractionOnAllControllers: true,\r\n ...options.nearInteractionOptions,\r\n });\r\n }\r\n\r\n if (!options.disableHandTracking) {\r\n // Add default hand tracking\r\n result.baseExperience.featuresManager.enableFeature(\r\n WebXRHandTracking.Name,\r\n options.useStablePlugins ? \"stable\" : \"latest\",\r\n <IWebXRHandTrackingOptions>{\r\n xrInput: result.input,\r\n ...options.handSupportOptions,\r\n },\r\n undefined,\r\n false\r\n );\r\n }\r\n\r\n // Create the WebXR output target\r\n result.renderTarget = result.baseExperience.sessionManager.getWebXRRenderTarget(options.outputCanvasOptions);\r\n\r\n if (!options.disableDefaultUI) {\r\n // Create ui for entering/exiting xr\r\n await result.enterExitUI.setHelperAsync(result.baseExperience, result.renderTarget);\r\n }\r\n return result;\r\n } catch (error) {\r\n Logger.Error(\"Error initializing XR\");\r\n Logger.Error(error);\r\n return result;\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the experience helper\r\n */\r\n public dispose() {\r\n if (this.baseExperience) {\r\n this.baseExperience.dispose();\r\n }\r\n if (this.input) {\r\n this.input.dispose();\r\n }\r\n if (this.enterExitUI) {\r\n this.enterExitUI.dispose();\r\n }\r\n if (this.renderTarget) {\r\n this.renderTarget.dispose();\r\n }\r\n }\r\n}\r\n"]}
@@ -1,6 +1,27 @@
1
- import type { WebXRSessionManager } from "./webXRSessionManager.js";
2
- import type { IDisposable } from "../scene.js";
3
1
  import type { Observable } from "../Misc/observable.js";
2
+ import type { IDisposable } from "../scene.js";
3
+ import type { IWebXRAnchorSystemOptions, WebXRAnchorSystem } from "./features/WebXRAnchorSystem.js";
4
+ import type { IWebXRBackgroundRemoverOptions, WebXRBackgroundRemover } from "./features/WebXRBackgroundRemover.js";
5
+ import type { IWebXRControllerMovementOptions, WebXRControllerMovement } from "./features/WebXRControllerMovement.js";
6
+ import type { IWebXRControllerPhysicsOptions, WebXRControllerPhysics } from "./features/WebXRControllerPhysics.js";
7
+ import type { IWebXRControllerPointerSelectionOptions, WebXRControllerPointerSelection } from "./features/WebXRControllerPointerSelection.js";
8
+ import type { IWebXRTeleportationOptions, WebXRMotionControllerTeleportation } from "./features/WebXRControllerTeleportation.js";
9
+ import type { IWebXRDepthSensingOptions, WebXRDepthSensing } from "./features/WebXRDepthSensing.js";
10
+ import type { IWebXRDomOverlayOptions, WebXRDomOverlay } from "./features/WebXRDOMOverlay.js";
11
+ import type { WebXREyeTracking } from "./features/WebXREyeTracking.js";
12
+ import type { WebXRFeaturePointSystem } from "./features/WebXRFeaturePointSystem.js";
13
+ import type { IWebXRHandTrackingOptions, WebXRHandTracking } from "./features/WebXRHandTracking.js";
14
+ import type { IWebXRHitTestOptions, WebXRHitTest } from "./features/WebXRHitTest.js";
15
+ import type { IWebXRImageTrackingOptions, WebXRImageTracking } from "./features/WebXRImageTracking.js";
16
+ import type { IWebXRLayersOptions, WebXRLayers } from "./features/WebXRLayers.js";
17
+ import type { IWebXRLightEstimationOptions, WebXRLightEstimation } from "./features/WebXRLightEstimation.js";
18
+ import type { IWebXRMeshDetectorOptions, WebXRMeshDetector } from "./features/WebXRMeshDetector.js";
19
+ import type { IWebXRNearInteractionOptions, WebXRNearInteraction } from "./features/WebXRNearInteraction.js";
20
+ import type { IWebXRPlaneDetectorOptions, WebXRPlaneDetector } from "./features/WebXRPlaneDetector.js";
21
+ import type { IWebXRRawCameraAccessOptions, WebXRRawCameraAccess } from "./features/WebXRRawCameraAccess.js";
22
+ import type { WebXRSpaceWarp } from "./features/WebXRSpaceWarp.js";
23
+ import type { IWebXRWalkingLocomotionOptions, WebXRWalkingLocomotion } from "./features/WebXRWalkingLocomotion.js";
24
+ import type { WebXRSessionManager } from "./webXRSessionManager.js";
4
25
  /**
5
26
  * Defining the interface required for a (webxr) feature
6
27
  */
@@ -67,88 +88,155 @@ export declare class WebXRFeatureName {
67
88
  /**
68
89
  * The name of the anchor system feature
69
90
  */
70
- static readonly ANCHOR_SYSTEM = "xr-anchor-system";
91
+ static readonly ANCHOR_SYSTEM: "xr-anchor-system";
71
92
  /**
72
93
  * The name of the background remover feature
73
94
  */
74
- static readonly BACKGROUND_REMOVER = "xr-background-remover";
95
+ static readonly BACKGROUND_REMOVER: "xr-background-remover";
75
96
  /**
76
97
  * The name of the hit test feature
77
98
  */
78
- static readonly HIT_TEST = "xr-hit-test";
99
+ static readonly HIT_TEST: "xr-hit-test";
79
100
  /**
80
101
  * The name of the mesh detection feature
81
102
  */
82
- static readonly MESH_DETECTION = "xr-mesh-detection";
103
+ static readonly MESH_DETECTION: "xr-mesh-detection";
83
104
  /**
84
105
  * physics impostors for xr controllers feature
85
106
  */
86
- static readonly PHYSICS_CONTROLLERS = "xr-physics-controller";
107
+ static readonly PHYSICS_CONTROLLERS: "xr-physics-controller";
87
108
  /**
88
109
  * The name of the plane detection feature
89
110
  */
90
- static readonly PLANE_DETECTION = "xr-plane-detection";
111
+ static readonly PLANE_DETECTION: "xr-plane-detection";
91
112
  /**
92
113
  * The name of the pointer selection feature
93
114
  */
94
- static readonly POINTER_SELECTION = "xr-controller-pointer-selection";
115
+ static readonly POINTER_SELECTION: "xr-controller-pointer-selection";
95
116
  /**
96
117
  * The name of the teleportation feature
97
118
  */
98
- static readonly TELEPORTATION = "xr-controller-teleportation";
119
+ static readonly TELEPORTATION: "xr-controller-teleportation";
99
120
  /**
100
121
  * The name of the feature points feature.
101
122
  */
102
- static readonly FEATURE_POINTS = "xr-feature-points";
123
+ static readonly FEATURE_POINTS: "xr-feature-points";
103
124
  /**
104
125
  * The name of the hand tracking feature.
105
126
  */
106
- static readonly HAND_TRACKING = "xr-hand-tracking";
127
+ static readonly HAND_TRACKING: "xr-hand-tracking";
107
128
  /**
108
129
  * The name of the image tracking feature
109
130
  */
110
- static readonly IMAGE_TRACKING = "xr-image-tracking";
131
+ static readonly IMAGE_TRACKING: "xr-image-tracking";
111
132
  /**
112
133
  * The name of the near interaction feature
113
134
  */
114
- static readonly NEAR_INTERACTION = "xr-near-interaction";
135
+ static readonly NEAR_INTERACTION: "xr-near-interaction";
115
136
  /**
116
137
  * The name of the DOM overlay feature
117
138
  */
118
- static readonly DOM_OVERLAY = "xr-dom-overlay";
139
+ static readonly DOM_OVERLAY: "xr-dom-overlay";
119
140
  /**
120
141
  * The name of the movement feature
121
142
  */
122
- static readonly MOVEMENT = "xr-controller-movement";
143
+ static readonly MOVEMENT: "xr-controller-movement";
123
144
  /**
124
145
  * The name of the light estimation feature
125
146
  */
126
- static readonly LIGHT_ESTIMATION = "xr-light-estimation";
147
+ static readonly LIGHT_ESTIMATION: "xr-light-estimation";
127
148
  /**
128
149
  * The name of the eye tracking feature
129
150
  */
130
- static readonly EYE_TRACKING = "xr-eye-tracking";
151
+ static readonly EYE_TRACKING: "xr-eye-tracking";
131
152
  /**
132
153
  * The name of the walking locomotion feature
133
154
  */
134
- static readonly WALKING_LOCOMOTION = "xr-walking-locomotion";
155
+ static readonly WALKING_LOCOMOTION: "xr-walking-locomotion";
135
156
  /**
136
157
  * The name of the composition layers feature
137
158
  */
138
- static readonly LAYERS = "xr-layers";
159
+ static readonly LAYERS: "xr-layers";
139
160
  /**
140
161
  * The name of the depth sensing feature
141
162
  */
142
- static readonly DEPTH_SENSING = "xr-depth-sensing";
163
+ static readonly DEPTH_SENSING: "xr-depth-sensing";
143
164
  /**
144
165
  * The name of the WebXR Space Warp feature
145
166
  */
146
- static readonly SPACE_WARP = "xr-space-warp";
167
+ static readonly SPACE_WARP: "xr-space-warp";
147
168
  /**
148
169
  * The name of the WebXR Raw Camera Access feature
149
170
  */
150
- static readonly RAW_CAMERA_ACCESS = "xr-raw-camera-access";
171
+ static readonly RAW_CAMERA_ACCESS: "xr-raw-camera-access";
172
+ }
173
+ export type WebXRFeatureNameType = (typeof WebXRFeatureName)[Exclude<keyof typeof WebXRFeatureName, "prototype">];
174
+ export interface IWebXRFeatureNameTypeMap {
175
+ [WebXRFeatureName.ANCHOR_SYSTEM]: WebXRAnchorSystem;
176
+ [WebXRFeatureName.BACKGROUND_REMOVER]: WebXRBackgroundRemover;
177
+ [WebXRFeatureName.DEPTH_SENSING]: WebXRDepthSensing;
178
+ [WebXRFeatureName.DOM_OVERLAY]: WebXRDomOverlay;
179
+ [WebXRFeatureName.EYE_TRACKING]: WebXREyeTracking;
180
+ [WebXRFeatureName.FEATURE_POINTS]: WebXRFeaturePointSystem;
181
+ [WebXRFeatureName.HAND_TRACKING]: WebXRHandTracking;
182
+ [WebXRFeatureName.HIT_TEST]: WebXRHitTest;
183
+ [WebXRFeatureName.IMAGE_TRACKING]: WebXRImageTracking;
184
+ [WebXRFeatureName.LAYERS]: WebXRLayers;
185
+ [WebXRFeatureName.LIGHT_ESTIMATION]: WebXRLightEstimation;
186
+ [WebXRFeatureName.MESH_DETECTION]: WebXRMeshDetector;
187
+ [WebXRFeatureName.MOVEMENT]: WebXRControllerMovement;
188
+ [WebXRFeatureName.NEAR_INTERACTION]: WebXRNearInteraction;
189
+ [WebXRFeatureName.PHYSICS_CONTROLLERS]: WebXRControllerPhysics;
190
+ [WebXRFeatureName.PLANE_DETECTION]: WebXRPlaneDetector;
191
+ [WebXRFeatureName.POINTER_SELECTION]: WebXRControllerPointerSelection;
192
+ [WebXRFeatureName.RAW_CAMERA_ACCESS]: WebXRRawCameraAccess;
193
+ [WebXRFeatureName.SPACE_WARP]: WebXRSpaceWarp;
194
+ [WebXRFeatureName.TELEPORTATION]: WebXRMotionControllerTeleportation;
195
+ [WebXRFeatureName.WALKING_LOCOMOTION]: WebXRWalkingLocomotion;
196
+ }
197
+ /**
198
+ * Maps feature names to their corresponding options interfaces.
199
+ */
200
+ export interface IWebXRFeatureNameOptionsMap {
201
+ [WebXRFeatureName.ANCHOR_SYSTEM]: IWebXRAnchorSystemOptions;
202
+ [WebXRFeatureName.BACKGROUND_REMOVER]: IWebXRBackgroundRemoverOptions;
203
+ [WebXRFeatureName.DEPTH_SENSING]: IWebXRDepthSensingOptions;
204
+ [WebXRFeatureName.DOM_OVERLAY]: IWebXRDomOverlayOptions;
205
+ [WebXRFeatureName.EYE_TRACKING]: undefined;
206
+ [WebXRFeatureName.FEATURE_POINTS]: undefined;
207
+ [WebXRFeatureName.HAND_TRACKING]: IWebXRHandTrackingOptions;
208
+ [WebXRFeatureName.HIT_TEST]: IWebXRHitTestOptions;
209
+ [WebXRFeatureName.IMAGE_TRACKING]: IWebXRImageTrackingOptions;
210
+ [WebXRFeatureName.LAYERS]: IWebXRLayersOptions;
211
+ [WebXRFeatureName.LIGHT_ESTIMATION]: IWebXRLightEstimationOptions;
212
+ [WebXRFeatureName.MESH_DETECTION]: IWebXRMeshDetectorOptions;
213
+ [WebXRFeatureName.MOVEMENT]: IWebXRControllerMovementOptions;
214
+ [WebXRFeatureName.NEAR_INTERACTION]: IWebXRNearInteractionOptions;
215
+ [WebXRFeatureName.PHYSICS_CONTROLLERS]: IWebXRControllerPhysicsOptions;
216
+ [WebXRFeatureName.PLANE_DETECTION]: IWebXRPlaneDetectorOptions;
217
+ [WebXRFeatureName.POINTER_SELECTION]: IWebXRControllerPointerSelectionOptions;
218
+ [WebXRFeatureName.RAW_CAMERA_ACCESS]: IWebXRRawCameraAccessOptions;
219
+ [WebXRFeatureName.SPACE_WARP]: undefined;
220
+ [WebXRFeatureName.TELEPORTATION]: IWebXRTeleportationOptions;
221
+ [WebXRFeatureName.WALKING_LOCOMOTION]: IWebXRWalkingLocomotionOptions;
151
222
  }
223
+ /**
224
+ * Helper type that expands/flattens a type to show its properties inline in IntelliSense
225
+ */
226
+ type Expand<T> = T extends infer O ? {
227
+ [K in keyof O]: O[K];
228
+ } : never;
229
+ /**
230
+ * Helper type to resolve the specific feature type based on the feature name,
231
+ * or fallback to IWebXRFeature if the feature name is not in the type map.
232
+ */
233
+ export type ResolveWebXRFeature<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameTypeMap ? IWebXRFeatureNameTypeMap[T] : IWebXRFeature;
234
+ /**
235
+ * Helper type to resolve the options type for a specific feature based on the feature name,
236
+ * or fallback to any if the feature name is not in the type map.
237
+ * The Expand utility type flattens the interface to show properties inline in IntelliSense.
238
+ */
239
+ export type ResolveWebXRFeatureOptions<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameOptionsMap ? IWebXRFeatureNameOptionsMap[T] extends undefined ? undefined : Expand<IWebXRFeatureNameOptionsMap[T]> : any;
152
240
  /**
153
241
  * Defining the constructor of a feature. Used to register the modules.
154
242
  */
@@ -252,15 +340,15 @@ export declare class WebXRFeaturesManager implements IDisposable {
252
340
  * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
253
341
  * @returns a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.
254
342
  */
255
- enableFeature(featureName: string | {
256
- Name: string;
257
- }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
343
+ enableFeature<T extends WebXRFeatureNameType>(featureName: T | {
344
+ Name: T;
345
+ }, version?: number | string, moduleOptions?: ResolveWebXRFeatureOptions<T>, attachIfPossible?: boolean, required?: boolean): ResolveWebXRFeature<T>;
258
346
  /**
259
347
  * get the implementation of an enabled feature.
260
348
  * @param featureName the name of the feature to load
261
349
  * @returns the feature class, if found
262
350
  */
263
- getEnabledFeature(featureName: string): IWebXRFeature;
351
+ getEnabledFeature<T extends WebXRFeatureNameType>(featureName: T): ResolveWebXRFeature<T>;
264
352
  /**
265
353
  * Get the list of enabled features
266
354
  * @returns an array of enabled features
@@ -276,3 +364,4 @@ export declare class WebXRFeaturesManager implements IDisposable {
276
364
  */
277
365
  _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
278
366
  }
367
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"webXRFeaturesManager.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRFeaturesManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAsEtC;;GAEG;AACH,MAAM,OAAO,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BACd,CAAC;YACN,CAAC;QACL,CAAC;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;;AAlVuB,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 { WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport type { IDisposable } from \"../scene\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport type { Observable } from \"core/Misc/observable\";\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 /**\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\";\r\n /**\r\n * The name of the background remover feature\r\n */\r\n public static readonly BACKGROUND_REMOVER = \"xr-background-remover\";\r\n /**\r\n * The name of the hit test feature\r\n */\r\n public static readonly HIT_TEST = \"xr-hit-test\";\r\n /**\r\n * The name of the mesh detection feature\r\n */\r\n public static readonly MESH_DETECTION = \"xr-mesh-detection\";\r\n /**\r\n * physics impostors for xr controllers feature\r\n */\r\n public static readonly PHYSICS_CONTROLLERS = \"xr-physics-controller\";\r\n /**\r\n * The name of the plane detection feature\r\n */\r\n public static readonly PLANE_DETECTION = \"xr-plane-detection\";\r\n /**\r\n * The name of the pointer selection feature\r\n */\r\n public static readonly POINTER_SELECTION = \"xr-controller-pointer-selection\";\r\n /**\r\n * The name of the teleportation feature\r\n */\r\n public static readonly TELEPORTATION = \"xr-controller-teleportation\";\r\n /**\r\n * The name of the feature points feature.\r\n */\r\n public static readonly FEATURE_POINTS = \"xr-feature-points\";\r\n /**\r\n * The name of the hand tracking feature.\r\n */\r\n public static readonly HAND_TRACKING = \"xr-hand-tracking\";\r\n /**\r\n * The name of the image tracking feature\r\n */\r\n public static readonly IMAGE_TRACKING = \"xr-image-tracking\";\r\n /**\r\n * The name of the near interaction feature\r\n */\r\n public static readonly NEAR_INTERACTION = \"xr-near-interaction\";\r\n /**\r\n * The name of the DOM overlay feature\r\n */\r\n public static readonly DOM_OVERLAY = \"xr-dom-overlay\";\r\n /**\r\n * The name of the movement feature\r\n */\r\n public static readonly MOVEMENT = \"xr-controller-movement\";\r\n /**\r\n * The name of the light estimation feature\r\n */\r\n public static readonly LIGHT_ESTIMATION = \"xr-light-estimation\";\r\n /**\r\n * The name of the eye tracking feature\r\n */\r\n public static readonly EYE_TRACKING = \"xr-eye-tracking\";\r\n /**\r\n * The name of the walking locomotion feature\r\n */\r\n public static readonly WALKING_LOCOMOTION = \"xr-walking-locomotion\";\r\n /**\r\n * The name of the composition layers feature\r\n */\r\n public static readonly LAYERS = \"xr-layers\";\r\n /**\r\n * The name of the depth sensing feature\r\n */\r\n public static readonly DEPTH_SENSING = \"xr-depth-sensing\";\r\n /**\r\n * The name of the WebXR Space Warp feature\r\n */\r\n public static readonly SPACE_WARP = \"xr-space-warp\";\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\";\r\n}\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 attached = feature.featureImplementation.attach();\r\n if (!attached) {\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(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n featureName: string | { Name: string },\r\n version: number | string = \"latest\",\r\n moduleOptions: any = {},\r\n attachIfPossible: boolean = true,\r\n required: boolean = true\r\n ): IWebXRFeature {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n let versionToLoad = 0;\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 if (constructed.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;\r\n } else {\r\n if (required) {\r\n throw new Error(\"required feature not compatible\");\r\n } else {\r\n Tools.Warn(`Feature ${name} not compatible with the current environment/browser and was not enabled.`);\r\n return constructed;\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(featureName: string): IWebXRFeature {\r\n return this._features[featureName] && this._features[featureName].featureImplementation;\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,eAAe,CAAC;AA4FtC;;GAEG;AACH,MAAM,OAAO,g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iBACd,CAAC;YACN,CAAC;QACL,CAAC;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;;AAlVuB,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\";\r\nimport type { IDisposable } from \"../scene\";\r\nimport type { IWebXRAnchorSystemOptions, WebXRAnchorSystem } from \"./features/WebXRAnchorSystem\";\r\nimport type { IWebXRBackgroundRemoverOptions, WebXRBackgroundRemover } from \"./features/WebXRBackgroundRemover\";\r\nimport type { IWebXRControllerMovementOptions, WebXRControllerMovement } from \"./features/WebXRControllerMovement\";\r\nimport type { IWebXRControllerPhysicsOptions, WebXRControllerPhysics } from \"./features/WebXRControllerPhysics\";\r\nimport type { IWebXRControllerPointerSelectionOptions, WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection\";\r\nimport type { IWebXRTeleportationOptions, WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation\";\r\nimport type { IWebXRDepthSensingOptions, WebXRDepthSensing } from \"./features/WebXRDepthSensing\";\r\nimport type { IWebXRDomOverlayOptions, WebXRDomOverlay } from \"./features/WebXRDOMOverlay\";\r\nimport type { WebXREyeTracking } from \"./features/WebXREyeTracking\";\r\nimport type { WebXRFeaturePointSystem } from \"./features/WebXRFeaturePointSystem\";\r\nimport type { IWebXRHandTrackingOptions, WebXRHandTracking } from \"./features/WebXRHandTracking\";\r\nimport type { IWebXRHitTestOptions, WebXRHitTest } from \"./features/WebXRHitTest\";\r\nimport type { IWebXRImageTrackingOptions, WebXRImageTracking } from \"./features/WebXRImageTracking\";\r\nimport type { IWebXRLayersOptions, WebXRLayers } from \"./features/WebXRLayers\";\r\nimport type { IWebXRLightEstimationOptions, WebXRLightEstimation } from \"./features/WebXRLightEstimation\";\r\nimport type { IWebXRMeshDetectorOptions, WebXRMeshDetector } from \"./features/WebXRMeshDetector\";\r\nimport type { IWebXRNearInteractionOptions, WebXRNearInteraction } from \"./features/WebXRNearInteraction\";\r\nimport type { IWebXRPlaneDetectorOptions, WebXRPlaneDetector } from \"./features/WebXRPlaneDetector\";\r\nimport type { IWebXRRawCameraAccessOptions, WebXRRawCameraAccess } from \"./features/WebXRRawCameraAccess\";\r\nimport type { WebXRSpaceWarp } from \"./features/WebXRSpaceWarp\";\r\nimport type { IWebXRWalkingLocomotionOptions, WebXRWalkingLocomotion } from \"./features/WebXRWalkingLocomotion\";\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 /**\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\r\nexport type WebXRFeatureNameType = (typeof WebXRFeatureName)[Exclude<keyof typeof WebXRFeatureName, \"prototype\">];\r\n\r\nexport interface IWebXRFeatureNameTypeMap {\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: WebXRAnchorSystem;\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: WebXRBackgroundRemover;\r\n [WebXRFeatureName.DEPTH_SENSING]: WebXRDepthSensing;\r\n [WebXRFeatureName.DOM_OVERLAY]: WebXRDomOverlay;\r\n [WebXRFeatureName.EYE_TRACKING]: WebXREyeTracking;\r\n [WebXRFeatureName.FEATURE_POINTS]: WebXRFeaturePointSystem;\r\n [WebXRFeatureName.HAND_TRACKING]: WebXRHandTracking;\r\n [WebXRFeatureName.HIT_TEST]: WebXRHitTest;\r\n [WebXRFeatureName.IMAGE_TRACKING]: WebXRImageTracking;\r\n [WebXRFeatureName.LAYERS]: WebXRLayers;\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: WebXRLightEstimation;\r\n [WebXRFeatureName.MESH_DETECTION]: WebXRMeshDetector;\r\n [WebXRFeatureName.MOVEMENT]: WebXRControllerMovement;\r\n [WebXRFeatureName.NEAR_INTERACTION]: WebXRNearInteraction;\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: WebXRControllerPhysics;\r\n [WebXRFeatureName.PLANE_DETECTION]: WebXRPlaneDetector;\r\n [WebXRFeatureName.POINTER_SELECTION]: WebXRControllerPointerSelection;\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: WebXRRawCameraAccess;\r\n [WebXRFeatureName.SPACE_WARP]: WebXRSpaceWarp;\r\n [WebXRFeatureName.TELEPORTATION]: WebXRMotionControllerTeleportation;\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: WebXRWalkingLocomotion;\r\n}\r\n\r\n/**\r\n * Maps feature names to their corresponding options interfaces.\r\n */\r\nexport interface IWebXRFeatureNameOptionsMap {\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: IWebXRAnchorSystemOptions;\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: IWebXRBackgroundRemoverOptions;\r\n [WebXRFeatureName.DEPTH_SENSING]: IWebXRDepthSensingOptions;\r\n [WebXRFeatureName.DOM_OVERLAY]: IWebXRDomOverlayOptions;\r\n [WebXRFeatureName.EYE_TRACKING]: undefined;\r\n [WebXRFeatureName.FEATURE_POINTS]: undefined;\r\n [WebXRFeatureName.HAND_TRACKING]: IWebXRHandTrackingOptions;\r\n [WebXRFeatureName.HIT_TEST]: IWebXRHitTestOptions;\r\n [WebXRFeatureName.IMAGE_TRACKING]: IWebXRImageTrackingOptions;\r\n [WebXRFeatureName.LAYERS]: IWebXRLayersOptions;\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: IWebXRLightEstimationOptions;\r\n [WebXRFeatureName.MESH_DETECTION]: IWebXRMeshDetectorOptions;\r\n [WebXRFeatureName.MOVEMENT]: IWebXRControllerMovementOptions;\r\n [WebXRFeatureName.NEAR_INTERACTION]: IWebXRNearInteractionOptions;\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: IWebXRControllerPhysicsOptions;\r\n [WebXRFeatureName.PLANE_DETECTION]: IWebXRPlaneDetectorOptions;\r\n [WebXRFeatureName.POINTER_SELECTION]: IWebXRControllerPointerSelectionOptions;\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: IWebXRRawCameraAccessOptions;\r\n [WebXRFeatureName.SPACE_WARP]: undefined;\r\n [WebXRFeatureName.TELEPORTATION]: IWebXRTeleportationOptions;\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: IWebXRWalkingLocomotionOptions;\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 attached = feature.featureImplementation.attach();\r\n if (!attached) {\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 = 0;\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 if (constructed.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 Tools.Warn(`Feature ${name} not compatible with the current environment/browser and was not enabled.`);\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onerjs/core",
3
- "version": "8.28.0",
3
+ "version": "8.28.2",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",