@babylonjs/core 8.30.5 → 8.31.1

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 (160) hide show
  1. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  2. package/Buffers/bufferUtils.d.ts +1 -2
  3. package/Buffers/bufferUtils.js +3 -4
  4. package/Buffers/bufferUtils.js.map +1 -1
  5. package/Engines/abstractEngine.js +2 -2
  6. package/Engines/abstractEngine.js.map +1 -1
  7. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +39 -0
  8. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +86 -0
  9. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -0
  10. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +34 -0
  11. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +74 -0
  12. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -0
  13. package/FrameGraph/Node/Blocks/index.d.ts +2 -0
  14. package/FrameGraph/Node/Blocks/index.js +2 -0
  15. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  16. package/FrameGraph/Tasks/PostProcesses/customPostProcessTask.d.ts +21 -0
  17. package/FrameGraph/Tasks/PostProcesses/customPostProcessTask.js +18 -0
  18. package/FrameGraph/Tasks/PostProcesses/customPostProcessTask.js.map +1 -0
  19. package/FrameGraph/Tasks/PostProcesses/screenSpaceCurvatureTask.d.ts +22 -0
  20. package/FrameGraph/Tasks/PostProcesses/screenSpaceCurvatureTask.js +27 -0
  21. package/FrameGraph/Tasks/PostProcesses/screenSpaceCurvatureTask.js.map +1 -0
  22. package/FrameGraph/Tasks/PostProcesses/sharpenTask.d.ts +17 -0
  23. package/FrameGraph/Tasks/PostProcesses/sharpenTask.js +23 -0
  24. package/FrameGraph/Tasks/PostProcesses/sharpenTask.js.map +1 -0
  25. package/FrameGraph/frameGraphTextureManager.d.ts +6 -2
  26. package/FrameGraph/frameGraphTextureManager.js +22 -8
  27. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  28. package/FrameGraph/index.d.ts +3 -0
  29. package/FrameGraph/index.js +3 -0
  30. package/FrameGraph/index.js.map +1 -1
  31. package/Materials/PBR/openPbrMaterial.d.ts +39 -0
  32. package/Materials/PBR/openPbrMaterial.js +46 -0
  33. package/Materials/PBR/openPbrMaterial.js.map +1 -1
  34. package/Materials/Textures/texture.js +9 -2
  35. package/Materials/Textures/texture.js.map +1 -1
  36. package/Materials/materialHelper.functions.d.ts +1 -7
  37. package/Materials/materialHelper.functions.js +2 -15
  38. package/Materials/materialHelper.functions.js.map +1 -1
  39. package/Materials/materialHelper.functions.pure.d.ts +10 -0
  40. package/Materials/materialHelper.functions.pure.js +21 -0
  41. package/Materials/materialHelper.functions.pure.js.map +1 -0
  42. package/Meshes/Compression/dracoEncoder.js +1 -1
  43. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  44. package/Meshes/geometry.js +6 -6
  45. package/Meshes/geometry.js.map +1 -1
  46. package/Meshes/mesh.js +2 -2
  47. package/Meshes/mesh.js.map +1 -1
  48. package/Particles/gpuParticleSystem.js +2 -1
  49. package/Particles/gpuParticleSystem.js.map +1 -1
  50. package/Particles/thinParticleSystem.js +4 -3
  51. package/Particles/thinParticleSystem.js.map +1 -1
  52. package/PostProcesses/index.d.ts +2 -0
  53. package/PostProcesses/index.js +2 -0
  54. package/PostProcesses/index.js.map +1 -1
  55. package/PostProcesses/screenSpaceCurvaturePostProcess.d.ts +6 -2
  56. package/PostProcesses/screenSpaceCurvaturePostProcess.js +37 -13
  57. package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
  58. package/PostProcesses/sharpenPostProcess.d.ts +6 -3
  59. package/PostProcesses/sharpenPostProcess.js +39 -24
  60. package/PostProcesses/sharpenPostProcess.js.map +1 -1
  61. package/PostProcesses/thinCustomPostProcess.d.ts +20 -0
  62. package/PostProcesses/thinCustomPostProcess.js +32 -0
  63. package/PostProcesses/thinCustomPostProcess.js.map +1 -0
  64. package/PostProcesses/thinScreenSpaceCurvaturePostProcess.d.ts +36 -0
  65. package/PostProcesses/thinScreenSpaceCurvaturePostProcess.js +61 -0
  66. package/PostProcesses/thinScreenSpaceCurvaturePostProcess.js.map +1 -0
  67. package/PostProcesses/thinSharpenPostProcess.d.ts +40 -0
  68. package/PostProcesses/thinSharpenPostProcess.js +64 -0
  69. package/PostProcesses/thinSharpenPostProcess.js.map +1 -0
  70. package/Rendering/geometryBufferRenderer.js +6 -1
  71. package/Rendering/geometryBufferRenderer.js.map +1 -1
  72. package/Rendering/objectRenderer.js +3 -1
  73. package/Rendering/objectRenderer.js.map +1 -1
  74. package/Shaders/ShadersInclude/openpbrDielectricReflectance.js +8 -9
  75. package/Shaders/ShadersInclude/openpbrDielectricReflectance.js.map +1 -1
  76. package/Shaders/ShadersInclude/openpbrDirectLighting.js +13 -6
  77. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  78. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +10 -2
  79. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  80. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +7 -1
  81. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
  82. package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js +2 -0
  83. package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
  84. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.d.ts +5 -0
  85. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js +27 -0
  86. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -0
  87. package/Shaders/ShadersInclude/openpbrUboDeclaration.js +1 -1
  88. package/Shaders/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  89. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +6 -0
  90. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
  91. package/Shaders/geometry.vertex.js +10 -2
  92. package/Shaders/geometry.vertex.js.map +1 -1
  93. package/Shaders/openpbr.fragment.d.ts +1 -0
  94. package/Shaders/openpbr.fragment.js +7 -1
  95. package/Shaders/openpbr.fragment.js.map +1 -1
  96. package/Shaders/openpbr.vertex.js +4 -0
  97. package/Shaders/openpbr.vertex.js.map +1 -1
  98. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +2 -2
  99. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  100. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +13 -6
  101. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  102. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +10 -2
  103. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  104. package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js +2 -0
  105. package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
  106. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.d.ts +5 -0
  107. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js +27 -0
  108. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -0
  109. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js +1 -1
  110. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  111. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +3 -3
  112. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  113. package/ShadersWGSL/geometry.vertex.js +10 -2
  114. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  115. package/ShadersWGSL/openpbr.fragment.d.ts +1 -0
  116. package/ShadersWGSL/openpbr.fragment.js +7 -1
  117. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  118. package/ShadersWGSL/openpbr.vertex.js +4 -0
  119. package/ShadersWGSL/openpbr.vertex.js.map +1 -1
  120. package/ShadersWGSL/pbr.fragment.js +1 -1
  121. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  122. package/ShadersWGSL/screenSpaceCurvature.fragment.d.ts +5 -0
  123. package/ShadersWGSL/screenSpaceCurvature.fragment.js +25 -0
  124. package/ShadersWGSL/screenSpaceCurvature.fragment.js.map +1 -0
  125. package/Sprites/spriteRenderer.js +1 -1
  126. package/Sprites/spriteRenderer.js.map +1 -1
  127. package/XR/features/WebXRAnchorSystem.d.ts +1 -1
  128. package/XR/features/WebXRBackgroundRemover.d.ts +1 -1
  129. package/XR/features/WebXRControllerMovement.d.ts +1 -1
  130. package/XR/features/WebXRControllerPhysics.d.ts +1 -1
  131. package/XR/features/WebXRControllerPointerSelection.d.ts +1 -1
  132. package/XR/features/WebXRControllerTeleportation.d.ts +1 -1
  133. package/XR/features/WebXRDOMOverlay.d.ts +1 -1
  134. package/XR/features/WebXRDepthSensing.d.ts +1 -1
  135. package/XR/features/WebXREyeTracking.d.ts +1 -1
  136. package/XR/features/WebXRFeaturePointSystem.d.ts +1 -1
  137. package/XR/features/WebXRHandTracking.d.ts +1 -1
  138. package/XR/features/WebXRHitTest.d.ts +1 -1
  139. package/XR/features/WebXRHitTestLegacy.d.ts +1 -1
  140. package/XR/features/WebXRImageTracking.d.ts +1 -1
  141. package/XR/features/WebXRLayers.d.ts +1 -1
  142. package/XR/features/WebXRLightEstimation.d.ts +1 -1
  143. package/XR/features/WebXRMeshDetector.d.ts +1 -1
  144. package/XR/features/WebXRNearInteraction.d.ts +1 -1
  145. package/XR/features/WebXRPlaneDetector.d.ts +1 -1
  146. package/XR/features/WebXRRawCameraAccess.d.ts +1 -1
  147. package/XR/features/WebXRSpaceWarp.d.ts +1 -1
  148. package/XR/motionController/index.d.ts +1 -0
  149. package/XR/motionController/index.js +1 -0
  150. package/XR/motionController/index.js.map +1 -1
  151. package/XR/motionController/webXRMotionControllerManager.js +1 -0
  152. package/XR/motionController/webXRMotionControllerManager.js.map +1 -1
  153. package/XR/motionController/webXROculusHandController.d.ts +25 -0
  154. package/XR/motionController/webXROculusHandController.js +246 -0
  155. package/XR/motionController/webXROculusHandController.js.map +1 -0
  156. package/XR/webXRDefaultExperience.js +1 -1
  157. package/XR/webXRDefaultExperience.js.map +1 -1
  158. package/XR/webXRFeaturesManager.d.ts +116 -27
  159. package/XR/webXRFeaturesManager.js.map +1 -1
  160. package/package.json +1 -1
@@ -40,6 +40,7 @@ export class WebXRMotionControllerManager {
40
40
  this.RegisterFallbacksForProfileId("samsung-odyssey", ["generic-touchpad"]);
41
41
  this.RegisterFallbacksForProfileId("valve-index", ["generic-trigger-squeeze-touchpad-thumbstick"]);
42
42
  this.RegisterFallbacksForProfileId("generic-hand-select", ["generic-trigger"]);
43
+ this.RegisterFallbacksForProfileId("oculus-hand", ["generic-trigger"]);
43
44
  }
44
45
  /**
45
46
  * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
@@ -1 +1 @@
1
- {"version":3,"file":"webXRMotionControllerManager.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXRMotionControllerManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAErF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAShF;;;;;;;GAOG;AAEH,MAAM,eAAe,GAIhB,EAAE,CAAC;AAER;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IA0BrC;;OAEG;IACI,MAAM,CAAC,kBAAkB;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;OAGG;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YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnB,SAAS;YACb,CAAC;YACD,MAAM,SAAS,GAAG,IAAI,CAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YAClE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBACxC,MAAM,oBAAoB,GAAG,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtE,IAAI,oBAAoB,EAAE,CAAC;oBACvB,OAAO,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAChD,CAAC;YACL,CAAC;QACL,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IAC3F,CAAC;;AA5Oc,kDAAqB,GAAoD,EAAE,CAAC;AAC5E,uCAAU,GAAsC,EAAE,CAAC;AAClE,oBAAoB;AACL,oDAAuB,GAAiE,EAAE,CAAC;AAG1G;;GAEG;AACW,8CAAiB,GAAG,2EAA2E,CAAC;AAC9G;;GAEG;AACW,uDAA0B,GAAY,IAAI,CAAC;AACzD;;GAEG;AACW,gDAAmB,GAAY,IAAI,CAAC;AAElD;;;GAGG;AACW,mDAAsB,GAAY,IAAI,CAAC;AAwNzD,qEAAqE;AACrE,4BAA4B,CAAC,kBAAkB,CAAC,mCAAmC,CAAC,SAAS,EAAE,CAAC,OAAsB,EAAE,KAAY,EAAE,EAAE;IACpI,OAAO,IAAI,mCAAmC,CAAC,KAAK,EAAO,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACpG,CAAC,CAAC,CAAC;AAEH,qBAAqB;AACrB,4BAA4B,CAAC,gBAAgB,EAAE,CAAC","sourcesContent":["import type { WebXRAbstractMotionController, IMotionControllerProfile } from \"./webXRAbstractMotionController\";\r\nimport { WebXRGenericTriggerMotionController } from \"./webXRGenericMotionController\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { WebXRProfiledMotionController } from \"./webXRProfiledMotionController\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\n\r\n/**\r\n * A construction function type to create a new controller based on an xrInput object\r\n */\r\nexport type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;\r\n\r\n/**\r\n * The MotionController Manager manages all registered motion controllers and loads the right one when needed.\r\n *\r\n * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets\r\n * it should be replaced with auto-loaded controllers.\r\n *\r\n * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes\r\n */\r\n\r\nconst ControllerCache: Array<{\r\n filename: string;\r\n path: string;\r\n meshes: AbstractMesh[];\r\n}> = [];\r\n\r\n/**\r\n * Motion controller manager is managing the different webxr profiles and makes sure the right\r\n * controller is being loaded.\r\n */\r\nexport class WebXRMotionControllerManager {\r\n private static _AvailableControllers: { [type: string]: MotionControllerConstructor } = {};\r\n private static _Fallbacks: { [profileId: string]: string[] } = {};\r\n // cache for loading\r\n private static _ProfileLoadingPromises: { [profileName: string]: Promise<IMotionControllerProfile> } = {};\r\n private static _ProfilesList: Nullable<Promise<{ [profile: string]: string }>>;\r\n\r\n /**\r\n * The base URL of the online controller repository. Can be changed at any time.\r\n */\r\n public static BaseRepositoryUrl = \"https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist\";\r\n /**\r\n * Which repository gets priority - local or online\r\n */\r\n public static PrioritizeOnlineRepository: boolean = true;\r\n /**\r\n * Use the online repository, or use only locally-defined controllers\r\n */\r\n public static UseOnlineRepository: boolean = true;\r\n\r\n /**\r\n * Disable the controller cache and load the models each time a new WebXRProfileMotionController is loaded.\r\n * Defaults to true.\r\n */\r\n public static DisableControllerCache: boolean = true;\r\n\r\n /**\r\n * Clear the cache used for profile loading and reload when requested again\r\n */\r\n public static ClearProfilesCache() {\r\n this._ProfilesList = null;\r\n this._ProfileLoadingPromises = {};\r\n }\r\n\r\n /**\r\n * Register the default fallbacks.\r\n * This function is called automatically when this file is imported.\r\n */\r\n public static DefaultFallbacks() {\r\n this.RegisterFallbacksForProfileId(\"google-daydream\", [\"generic-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"htc-vive-focus\", [\"generic-trigger-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"htc-vive\", [\"generic-trigger-squeeze-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"magicleap-one\", [\"generic-trigger-squeeze-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"windows-mixed-reality\", [\"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"microsoft-mixed-reality\", [\"windows-mixed-reality\", \"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-go\", [\"generic-trigger-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-touch-v2\", [\"oculus-touch\", \"generic-trigger-squeeze-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-touch\", [\"generic-trigger-squeeze-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"samsung-gearvr\", [\"windows-mixed-reality\", \"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"samsung-odyssey\", [\"generic-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"valve-index\", [\"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"generic-hand-select\", [\"generic-trigger\"]);\r\n }\r\n\r\n /**\r\n * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.\r\n * @param profileId the profile to which a fallback needs to be found\r\n * @returns an array with corresponding fallback profiles\r\n */\r\n public static FindFallbackWithProfileId(profileId: string): string[] {\r\n const returnArray = this._Fallbacks[profileId] || [];\r\n\r\n returnArray.unshift(profileId);\r\n return returnArray;\r\n }\r\n\r\n /**\r\n * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.\r\n * The order of search:\r\n *\r\n * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller\r\n * 2) (If not found) search in the gamepad id and try using it (legacy versions only)\r\n * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)\r\n * 4) return the generic trigger controller if none were found\r\n *\r\n * @param xrInput the xrInput to which a new controller is initialized\r\n * @param scene the scene to which the model will be added\r\n * @param forceProfile force a certain profile for this controller\r\n * @returns A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found\r\n */\r\n public static async GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController> {\r\n const profileArray: string[] = [];\r\n if (forceProfile) {\r\n profileArray.push(forceProfile);\r\n }\r\n profileArray.push(...(xrInput.profiles || []));\r\n\r\n // emulator support\r\n if (profileArray.length && !profileArray[0]) {\r\n // remove the first \"undefined\" that the emulator is adding\r\n profileArray.pop();\r\n }\r\n\r\n // legacy support - try using the gamepad id\r\n if (xrInput.gamepad && xrInput.gamepad.id) {\r\n switch (xrInput.gamepad.id) {\r\n case xrInput.gamepad.id.match(/oculus touch/gi) ? xrInput.gamepad.id : undefined:\r\n // oculus in gamepad id\r\n profileArray.push(\"oculus-touch-v2\");\r\n break;\r\n }\r\n }\r\n\r\n // make sure microsoft/windows mixed reality works correctly\r\n const windowsMRIdx = profileArray.indexOf(\"windows-mixed-reality\");\r\n if (windowsMRIdx !== -1) {\r\n profileArray.splice(windowsMRIdx, 0, \"microsoft-mixed-reality\");\r\n }\r\n\r\n if (!profileArray.length) {\r\n profileArray.push(\"generic-trigger\");\r\n }\r\n\r\n if (this.UseOnlineRepository) {\r\n const firstFunction = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepositoryAsync : this._LoadProfilesFromAvailableControllersAsync;\r\n const secondFunction = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllersAsync : this._LoadProfileFromRepositoryAsync;\r\n\r\n // eslint-disable-next-line github/no-then\r\n return firstFunction.call(this, profileArray, xrInput, scene).catch(() => {\r\n return secondFunction.call(this, profileArray, xrInput, scene);\r\n });\r\n } else {\r\n // use only available functions\r\n return await this._LoadProfilesFromAvailableControllersAsync(profileArray, xrInput, scene);\r\n }\r\n }\r\n\r\n /**\r\n * Register a new controller based on its profile. This function will be called by the controller classes themselves.\r\n *\r\n * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.\r\n *\r\n * @param type the profile type to register\r\n * @param constructFunction the function to be called when loading this profile\r\n */\r\n public static RegisterController(type: string, constructFunction: MotionControllerConstructor) {\r\n this._AvailableControllers[type] = constructFunction;\r\n }\r\n\r\n /**\r\n * Register a fallback to a specific profile.\r\n * @param profileId the profileId that will receive the fallbacks\r\n * @param fallbacks A list of fallback profiles\r\n */\r\n public static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void {\r\n if (this._Fallbacks[profileId]) {\r\n this._Fallbacks[profileId].push(...fallbacks);\r\n } else {\r\n this._Fallbacks[profileId] = fallbacks;\r\n }\r\n }\r\n\r\n /**\r\n * Will update the list of profiles available in the repository\r\n * @returns a promise that resolves to a map of profiles available online\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static async UpdateProfilesList(): Promise<{\r\n [profile: string]: string;\r\n }> {\r\n const data = await Tools.LoadFileAsync(this.BaseRepositoryUrl + \"/profiles/profilesList.json\", false);\r\n this._ProfilesList = JSON.parse(data);\r\n return await this._ProfilesList!;\r\n }\r\n\r\n /**\r\n * Clear the controller's cache (usually happens at the end of a session)\r\n */\r\n public static ClearControllerCache() {\r\n for (const cacheItem of ControllerCache) {\r\n for (const mesh of cacheItem.meshes) {\r\n mesh.dispose(false, true);\r\n }\r\n }\r\n ControllerCache.length = 0;\r\n }\r\n\r\n private static async _LoadProfileFromRepositoryAsync(profileArray: string[], xrInput: XRInputSource, scene: Scene): Promise<WebXRAbstractMotionController> {\r\n return await Promise.resolve()\r\n // eslint-disable-next-line github/no-then\r\n .then(async () => {\r\n if (!this._ProfilesList) {\r\n return await this.UpdateProfilesList();\r\n } else {\r\n return await this._ProfilesList;\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then((profilesList: { [profile: string]: string }) => {\r\n // load the right profile\r\n for (let i = 0; i < profileArray.length; ++i) {\r\n // defensive\r\n if (!profileArray[i]) {\r\n continue;\r\n }\r\n if (profilesList[profileArray[i]]) {\r\n return profileArray[i];\r\n }\r\n }\r\n\r\n throw new Error(`neither controller ${profileArray[0]} nor all fallbacks were found in the repository,`);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then(async (profileToLoad: string) => {\r\n // load the profile\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n if (!this._ProfileLoadingPromises[profileToLoad]) {\r\n // eslint-disable-next-line github/no-then\r\n this._ProfileLoadingPromises[profileToLoad] = Tools.LoadFileAsync(`${this.BaseRepositoryUrl}/profiles/${profileToLoad}/profile.json`, false).then(\r\n (data) => <IMotionControllerProfile>JSON.parse(data)\r\n );\r\n }\r\n return await this._ProfileLoadingPromises[profileToLoad];\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then((profile: IMotionControllerProfile) => {\r\n return new WebXRProfiledMotionController(scene, xrInput, profile, this.BaseRepositoryUrl, this.DisableControllerCache ? undefined : ControllerCache);\r\n });\r\n }\r\n\r\n private static async _LoadProfilesFromAvailableControllersAsync(profileArray: string[], xrInput: XRInputSource, scene: Scene) {\r\n // check fallbacks\r\n for (let i = 0; i < profileArray.length; ++i) {\r\n // defensive\r\n if (!profileArray[i]) {\r\n continue;\r\n }\r\n const fallbacks = this.FindFallbackWithProfileId(profileArray[i]);\r\n for (let j = 0; j < fallbacks.length; ++j) {\r\n const constructionFunction = this._AvailableControllers[fallbacks[j]];\r\n if (constructionFunction) {\r\n return constructionFunction(xrInput, scene);\r\n }\r\n }\r\n }\r\n\r\n throw new Error(`no controller requested was found in the available controllers list`);\r\n }\r\n}\r\n\r\n// register the generic profile(s) here so we will at least have them\r\nWebXRMotionControllerManager.RegisterController(WebXRGenericTriggerMotionController.ProfileId, (xrInput: XRInputSource, scene: Scene) => {\r\n return new WebXRGenericTriggerMotionController(scene, <any>xrInput.gamepad, xrInput.handedness);\r\n});\r\n\r\n// register fallbacks\r\nWebXRMotionControllerManager.DefaultFallbacks();\r\n"]}
1
+ {"version":3,"file":"webXRMotionControllerManager.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXRMotionControllerManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAErF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAShF;;;;;;;GAOG;AAEH,MAAM,eAAe,GAIhB,EAAE,CAAC;AAER;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IA0BrC;;OAEG;IACI,MAAM,CAAC,kBAAkB;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,gBAAgB;QAC1B,IAAI,CAAC,6BAA6B,CAAC,iBAAiB,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,6BAA6B,CAAC,gBAAgB,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,6BAA6B,CAAC,UAAU,EAAE,CAAC,kCAAkC,CAAC,CAAC,CAAC;QACrF,IAAI,CAAC,6BAA6B,CAAC,eAAe,EAAE,CAAC,kCAAkC,CAAC,CAAC,CAAC;QAC1F,IAAI,CAAC,6BAA6B,CAAC,uBAAuB,EAAE,CAAC,6CAA6C,CAAC,CAAC,CAAC;QAC7G,IAAI,CAAC,6BAA6B,CAAC,yBAA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AAO,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAChD,CAAC;YACL,CAAC;QACL,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IAC3F,CAAC;;AA7Oc,kDAAqB,GAAoD,EAAE,CAAC;AAC5E,uCAAU,GAAsC,EAAE,CAAC;AAClE,oBAAoB;AACL,oDAAuB,GAAiE,EAAE,CAAC;AAG1G;;GAEG;AACW,8CAAiB,GAAG,2EAA2E,CAAC;AAC9G;;GAEG;AACW,uDAA0B,GAAY,IAAI,CAAC;AACzD;;GAEG;AACW,gDAAmB,GAAY,IAAI,CAAC;AAElD;;;GAGG;AACW,mDAAsB,GAAY,IAAI,CAAC;AAyNzD,qEAAqE;AACrE,4BAA4B,CAAC,kBAAkB,CAAC,mCAAmC,CAAC,SAAS,EAAE,CAAC,OAAsB,EAAE,KAAY,EAAE,EAAE;IACpI,OAAO,IAAI,mCAAmC,CAAC,KAAK,EAAO,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACpG,CAAC,CAAC,CAAC;AAEH,qBAAqB;AACrB,4BAA4B,CAAC,gBAAgB,EAAE,CAAC","sourcesContent":["import type { WebXRAbstractMotionController, IMotionControllerProfile } from \"./webXRAbstractMotionController\";\r\nimport { WebXRGenericTriggerMotionController } from \"./webXRGenericMotionController\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { WebXRProfiledMotionController } from \"./webXRProfiledMotionController\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\n\r\n/**\r\n * A construction function type to create a new controller based on an xrInput object\r\n */\r\nexport type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;\r\n\r\n/**\r\n * The MotionController Manager manages all registered motion controllers and loads the right one when needed.\r\n *\r\n * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets\r\n * it should be replaced with auto-loaded controllers.\r\n *\r\n * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes\r\n */\r\n\r\nconst ControllerCache: Array<{\r\n filename: string;\r\n path: string;\r\n meshes: AbstractMesh[];\r\n}> = [];\r\n\r\n/**\r\n * Motion controller manager is managing the different webxr profiles and makes sure the right\r\n * controller is being loaded.\r\n */\r\nexport class WebXRMotionControllerManager {\r\n private static _AvailableControllers: { [type: string]: MotionControllerConstructor } = {};\r\n private static _Fallbacks: { [profileId: string]: string[] } = {};\r\n // cache for loading\r\n private static _ProfileLoadingPromises: { [profileName: string]: Promise<IMotionControllerProfile> } = {};\r\n private static _ProfilesList: Nullable<Promise<{ [profile: string]: string }>>;\r\n\r\n /**\r\n * The base URL of the online controller repository. Can be changed at any time.\r\n */\r\n public static BaseRepositoryUrl = \"https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist\";\r\n /**\r\n * Which repository gets priority - local or online\r\n */\r\n public static PrioritizeOnlineRepository: boolean = true;\r\n /**\r\n * Use the online repository, or use only locally-defined controllers\r\n */\r\n public static UseOnlineRepository: boolean = true;\r\n\r\n /**\r\n * Disable the controller cache and load the models each time a new WebXRProfileMotionController is loaded.\r\n * Defaults to true.\r\n */\r\n public static DisableControllerCache: boolean = true;\r\n\r\n /**\r\n * Clear the cache used for profile loading and reload when requested again\r\n */\r\n public static ClearProfilesCache() {\r\n this._ProfilesList = null;\r\n this._ProfileLoadingPromises = {};\r\n }\r\n\r\n /**\r\n * Register the default fallbacks.\r\n * This function is called automatically when this file is imported.\r\n */\r\n public static DefaultFallbacks() {\r\n this.RegisterFallbacksForProfileId(\"google-daydream\", [\"generic-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"htc-vive-focus\", [\"generic-trigger-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"htc-vive\", [\"generic-trigger-squeeze-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"magicleap-one\", [\"generic-trigger-squeeze-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"windows-mixed-reality\", [\"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"microsoft-mixed-reality\", [\"windows-mixed-reality\", \"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-go\", [\"generic-trigger-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-touch-v2\", [\"oculus-touch\", \"generic-trigger-squeeze-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-touch\", [\"generic-trigger-squeeze-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"samsung-gearvr\", [\"windows-mixed-reality\", \"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"samsung-odyssey\", [\"generic-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"valve-index\", [\"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"generic-hand-select\", [\"generic-trigger\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-hand\", [\"generic-trigger\"]);\r\n }\r\n\r\n /**\r\n * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.\r\n * @param profileId the profile to which a fallback needs to be found\r\n * @returns an array with corresponding fallback profiles\r\n */\r\n public static FindFallbackWithProfileId(profileId: string): string[] {\r\n const returnArray = this._Fallbacks[profileId] || [];\r\n\r\n returnArray.unshift(profileId);\r\n return returnArray;\r\n }\r\n\r\n /**\r\n * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.\r\n * The order of search:\r\n *\r\n * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller\r\n * 2) (If not found) search in the gamepad id and try using it (legacy versions only)\r\n * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)\r\n * 4) return the generic trigger controller if none were found\r\n *\r\n * @param xrInput the xrInput to which a new controller is initialized\r\n * @param scene the scene to which the model will be added\r\n * @param forceProfile force a certain profile for this controller\r\n * @returns A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found\r\n */\r\n public static async GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController> {\r\n const profileArray: string[] = [];\r\n if (forceProfile) {\r\n profileArray.push(forceProfile);\r\n }\r\n profileArray.push(...(xrInput.profiles || []));\r\n\r\n // emulator support\r\n if (profileArray.length && !profileArray[0]) {\r\n // remove the first \"undefined\" that the emulator is adding\r\n profileArray.pop();\r\n }\r\n\r\n // legacy support - try using the gamepad id\r\n if (xrInput.gamepad && xrInput.gamepad.id) {\r\n switch (xrInput.gamepad.id) {\r\n case xrInput.gamepad.id.match(/oculus touch/gi) ? xrInput.gamepad.id : undefined:\r\n // oculus in gamepad id\r\n profileArray.push(\"oculus-touch-v2\");\r\n break;\r\n }\r\n }\r\n\r\n // make sure microsoft/windows mixed reality works correctly\r\n const windowsMRIdx = profileArray.indexOf(\"windows-mixed-reality\");\r\n if (windowsMRIdx !== -1) {\r\n profileArray.splice(windowsMRIdx, 0, \"microsoft-mixed-reality\");\r\n }\r\n\r\n if (!profileArray.length) {\r\n profileArray.push(\"generic-trigger\");\r\n }\r\n\r\n if (this.UseOnlineRepository) {\r\n const firstFunction = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepositoryAsync : this._LoadProfilesFromAvailableControllersAsync;\r\n const secondFunction = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllersAsync : this._LoadProfileFromRepositoryAsync;\r\n\r\n // eslint-disable-next-line github/no-then\r\n return firstFunction.call(this, profileArray, xrInput, scene).catch(() => {\r\n return secondFunction.call(this, profileArray, xrInput, scene);\r\n });\r\n } else {\r\n // use only available functions\r\n return await this._LoadProfilesFromAvailableControllersAsync(profileArray, xrInput, scene);\r\n }\r\n }\r\n\r\n /**\r\n * Register a new controller based on its profile. This function will be called by the controller classes themselves.\r\n *\r\n * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.\r\n *\r\n * @param type the profile type to register\r\n * @param constructFunction the function to be called when loading this profile\r\n */\r\n public static RegisterController(type: string, constructFunction: MotionControllerConstructor) {\r\n this._AvailableControllers[type] = constructFunction;\r\n }\r\n\r\n /**\r\n * Register a fallback to a specific profile.\r\n * @param profileId the profileId that will receive the fallbacks\r\n * @param fallbacks A list of fallback profiles\r\n */\r\n public static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void {\r\n if (this._Fallbacks[profileId]) {\r\n this._Fallbacks[profileId].push(...fallbacks);\r\n } else {\r\n this._Fallbacks[profileId] = fallbacks;\r\n }\r\n }\r\n\r\n /**\r\n * Will update the list of profiles available in the repository\r\n * @returns a promise that resolves to a map of profiles available online\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static async UpdateProfilesList(): Promise<{\r\n [profile: string]: string;\r\n }> {\r\n const data = await Tools.LoadFileAsync(this.BaseRepositoryUrl + \"/profiles/profilesList.json\", false);\r\n this._ProfilesList = JSON.parse(data);\r\n return await this._ProfilesList!;\r\n }\r\n\r\n /**\r\n * Clear the controller's cache (usually happens at the end of a session)\r\n */\r\n public static ClearControllerCache() {\r\n for (const cacheItem of ControllerCache) {\r\n for (const mesh of cacheItem.meshes) {\r\n mesh.dispose(false, true);\r\n }\r\n }\r\n ControllerCache.length = 0;\r\n }\r\n\r\n private static async _LoadProfileFromRepositoryAsync(profileArray: string[], xrInput: XRInputSource, scene: Scene): Promise<WebXRAbstractMotionController> {\r\n return await Promise.resolve()\r\n // eslint-disable-next-line github/no-then\r\n .then(async () => {\r\n if (!this._ProfilesList) {\r\n return await this.UpdateProfilesList();\r\n } else {\r\n return await this._ProfilesList;\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then((profilesList: { [profile: string]: string }) => {\r\n // load the right profile\r\n for (let i = 0; i < profileArray.length; ++i) {\r\n // defensive\r\n if (!profileArray[i]) {\r\n continue;\r\n }\r\n if (profilesList[profileArray[i]]) {\r\n return profileArray[i];\r\n }\r\n }\r\n\r\n throw new Error(`neither controller ${profileArray[0]} nor all fallbacks were found in the repository,`);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then(async (profileToLoad: string) => {\r\n // load the profile\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n if (!this._ProfileLoadingPromises[profileToLoad]) {\r\n // eslint-disable-next-line github/no-then\r\n this._ProfileLoadingPromises[profileToLoad] = Tools.LoadFileAsync(`${this.BaseRepositoryUrl}/profiles/${profileToLoad}/profile.json`, false).then(\r\n (data) => <IMotionControllerProfile>JSON.parse(data)\r\n );\r\n }\r\n return await this._ProfileLoadingPromises[profileToLoad];\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then((profile: IMotionControllerProfile) => {\r\n return new WebXRProfiledMotionController(scene, xrInput, profile, this.BaseRepositoryUrl, this.DisableControllerCache ? undefined : ControllerCache);\r\n });\r\n }\r\n\r\n private static async _LoadProfilesFromAvailableControllersAsync(profileArray: string[], xrInput: XRInputSource, scene: Scene) {\r\n // check fallbacks\r\n for (let i = 0; i < profileArray.length; ++i) {\r\n // defensive\r\n if (!profileArray[i]) {\r\n continue;\r\n }\r\n const fallbacks = this.FindFallbackWithProfileId(profileArray[i]);\r\n for (let j = 0; j < fallbacks.length; ++j) {\r\n const constructionFunction = this._AvailableControllers[fallbacks[j]];\r\n if (constructionFunction) {\r\n return constructionFunction(xrInput, scene);\r\n }\r\n }\r\n }\r\n\r\n throw new Error(`no controller requested was found in the available controllers list`);\r\n }\r\n}\r\n\r\n// register the generic profile(s) here so we will at least have them\r\nWebXRMotionControllerManager.RegisterController(WebXRGenericTriggerMotionController.ProfileId, (xrInput: XRInputSource, scene: Scene) => {\r\n return new WebXRGenericTriggerMotionController(scene, <any>xrInput.gamepad, xrInput.handedness);\r\n});\r\n\r\n// register fallbacks\r\nWebXRMotionControllerManager.DefaultFallbacks();\r\n"]}
@@ -0,0 +1,25 @@
1
+ import type { IMinimalMotionControllerObject, MotionControllerHandedness } from "./webXRAbstractMotionController.js";
2
+ import { WebXRAbstractMotionController } from "./webXRAbstractMotionController.js";
3
+ import type { Scene } from "../../scene.js";
4
+ import type { AbstractMesh } from "../../Meshes/abstractMesh.js";
5
+ /**
6
+ * Oculus hand controller class that supports microgestures
7
+ */
8
+ export declare class WebXROculusHandController extends WebXRAbstractMotionController {
9
+ profileId: string;
10
+ /**
11
+ * Create a new hand controller object, without loading a controller model
12
+ * @param scene the scene to use to create this controller
13
+ * @param gamepadObject the corresponding gamepad object
14
+ * @param handedness the handedness of the controller
15
+ */
16
+ constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
17
+ protected _getFilenameAndPath(): {
18
+ filename: string;
19
+ path: string;
20
+ };
21
+ protected _getModelLoadingConstraints(): boolean;
22
+ protected _processLoadedModel(_meshes: AbstractMesh[]): void;
23
+ protected _setRootMesh(meshes: AbstractMesh[]): void;
24
+ protected _updateModel(): void;
25
+ }
@@ -0,0 +1,246 @@
1
+ import { WebXRAbstractMotionController } from "./webXRAbstractMotionController.js";
2
+ import { WebXRMotionControllerManager } from "./webXRMotionControllerManager.js";
3
+ /**
4
+ * Oculus hand controller class that supports microgestures
5
+ */
6
+ export class WebXROculusHandController extends WebXRAbstractMotionController {
7
+ /**
8
+ * Create a new hand controller object, without loading a controller model
9
+ * @param scene the scene to use to create this controller
10
+ * @param gamepadObject the corresponding gamepad object
11
+ * @param handedness the handedness of the controller
12
+ */
13
+ constructor(scene, gamepadObject, handedness) {
14
+ // Don't load the controller model - for now, hands have no real model.
15
+ super(scene, OculusHandProfile[handedness], gamepadObject, handedness, true);
16
+ this.profileId = "oculus-hand";
17
+ }
18
+ _getFilenameAndPath() {
19
+ return {
20
+ filename: "generic.babylon",
21
+ path: "https://controllers.babylonjs.com/generic/",
22
+ };
23
+ }
24
+ _getModelLoadingConstraints() {
25
+ return true;
26
+ }
27
+ _processLoadedModel(_meshes) {
28
+ // no-op
29
+ }
30
+ _setRootMesh(meshes) {
31
+ // no-op
32
+ }
33
+ _updateModel() {
34
+ // no-op
35
+ }
36
+ }
37
+ // register the profiles
38
+ WebXRMotionControllerManager.RegisterController("oculus-hand", (xrInput, scene) => {
39
+ return new WebXROculusHandController(scene, xrInput.gamepad, xrInput.handedness);
40
+ });
41
+ // https://github.com/immersive-web/webxr-input-profiles/blob/main/packages/registry/profiles/oculus/oculus-hand.json
42
+ const OculusHandProfile = {
43
+ left: {
44
+ selectComponentId: "xr-standard-trigger",
45
+ components: {
46
+ // eslint-disable-next-line @typescript-eslint/naming-convention
47
+ "xr-standard-trigger": {
48
+ type: "trigger",
49
+ gamepadIndices: {
50
+ button: 0,
51
+ },
52
+ rootNodeName: "xr-standard-trigger",
53
+ visualResponses: {},
54
+ },
55
+ menu: {
56
+ type: "button",
57
+ gamepadIndices: {
58
+ button: 4,
59
+ },
60
+ rootNodeName: "menu",
61
+ visualResponses: {},
62
+ },
63
+ // eslint-disable-next-line @typescript-eslint/naming-convention
64
+ "swipe-left": {
65
+ type: "button",
66
+ gamepadIndices: {
67
+ button: 5,
68
+ },
69
+ rootNodeName: "swipe-left",
70
+ visualResponses: {},
71
+ },
72
+ // eslint-disable-next-line @typescript-eslint/naming-convention
73
+ "swipe-right": {
74
+ type: "button",
75
+ gamepadIndices: {
76
+ button: 6,
77
+ },
78
+ rootNodeName: "swipe-right",
79
+ visualResponses: {},
80
+ },
81
+ // eslint-disable-next-line @typescript-eslint/naming-convention
82
+ "swipe-forward": {
83
+ type: "button",
84
+ gamepadIndices: {
85
+ button: 7,
86
+ },
87
+ rootNodeName: "swipe-forward",
88
+ visualResponses: {},
89
+ },
90
+ // eslint-disable-next-line @typescript-eslint/naming-convention
91
+ "swipe-backward": {
92
+ type: "button",
93
+ gamepadIndices: {
94
+ button: 8,
95
+ },
96
+ rootNodeName: "swipe-backward",
97
+ visualResponses: {},
98
+ },
99
+ // eslint-disable-next-line @typescript-eslint/naming-convention
100
+ "tap-thumb": {
101
+ type: "button",
102
+ gamepadIndices: {
103
+ button: 9,
104
+ },
105
+ rootNodeName: "tap-thumb",
106
+ visualResponses: {},
107
+ },
108
+ },
109
+ gamepadMapping: "xr-standard",
110
+ rootNodeName: "oculus-hand-left",
111
+ assetPath: "left.glb",
112
+ },
113
+ right: {
114
+ selectComponentId: "xr-standard-trigger",
115
+ components: {
116
+ // eslint-disable-next-line @typescript-eslint/naming-convention
117
+ "xr-standard-trigger": {
118
+ type: "trigger",
119
+ gamepadIndices: {
120
+ button: 0,
121
+ },
122
+ rootNodeName: "xr-standard-trigger",
123
+ visualResponses: {},
124
+ },
125
+ // eslint-disable-next-line @typescript-eslint/naming-convention
126
+ "swipe-left": {
127
+ type: "button",
128
+ gamepadIndices: {
129
+ button: 5,
130
+ },
131
+ rootNodeName: "swipe-left",
132
+ visualResponses: {},
133
+ },
134
+ // eslint-disable-next-line @typescript-eslint/naming-convention
135
+ "swipe-right": {
136
+ type: "button",
137
+ gamepadIndices: {
138
+ button: 6,
139
+ },
140
+ rootNodeName: "swipe-right",
141
+ visualResponses: {},
142
+ },
143
+ // eslint-disable-next-line @typescript-eslint/naming-convention
144
+ "swipe-forward": {
145
+ type: "button",
146
+ gamepadIndices: {
147
+ button: 7,
148
+ },
149
+ rootNodeName: "swipe-forward",
150
+ visualResponses: {},
151
+ },
152
+ // eslint-disable-next-line @typescript-eslint/naming-convention
153
+ "swipe-backward": {
154
+ type: "button",
155
+ gamepadIndices: {
156
+ button: 8,
157
+ },
158
+ rootNodeName: "swipe-backward",
159
+ visualResponses: {},
160
+ },
161
+ // eslint-disable-next-line @typescript-eslint/naming-convention
162
+ "tap-thumb": {
163
+ type: "button",
164
+ gamepadIndices: {
165
+ button: 9,
166
+ },
167
+ rootNodeName: "tap-thumb",
168
+ visualResponses: {},
169
+ },
170
+ },
171
+ gamepadMapping: "xr-standard",
172
+ rootNodeName: "oculus-hand-right",
173
+ assetPath: "right.glb",
174
+ },
175
+ none: {
176
+ selectComponentId: "xr-standard-trigger",
177
+ components: {
178
+ // eslint-disable-next-line @typescript-eslint/naming-convention
179
+ "xr-standard-trigger": {
180
+ type: "trigger",
181
+ gamepadIndices: {
182
+ button: 0,
183
+ },
184
+ rootNodeName: "xr-standard-trigger",
185
+ visualResponses: {},
186
+ },
187
+ menu: {
188
+ type: "button",
189
+ gamepadIndices: {
190
+ button: 4,
191
+ },
192
+ rootNodeName: "menu",
193
+ visualResponses: {},
194
+ },
195
+ // eslint-disable-next-line @typescript-eslint/naming-convention
196
+ "swipe-left": {
197
+ type: "button",
198
+ gamepadIndices: {
199
+ button: 5,
200
+ },
201
+ rootNodeName: "swipe-left",
202
+ visualResponses: {},
203
+ },
204
+ // eslint-disable-next-line @typescript-eslint/naming-convention
205
+ "swipe-right": {
206
+ type: "button",
207
+ gamepadIndices: {
208
+ button: 6,
209
+ },
210
+ rootNodeName: "swipe-right",
211
+ visualResponses: {},
212
+ },
213
+ // eslint-disable-next-line @typescript-eslint/naming-convention
214
+ "swipe-forward": {
215
+ type: "button",
216
+ gamepadIndices: {
217
+ button: 7,
218
+ },
219
+ rootNodeName: "swipe-forward",
220
+ visualResponses: {},
221
+ },
222
+ // eslint-disable-next-line @typescript-eslint/naming-convention
223
+ "swipe-backward": {
224
+ type: "button",
225
+ gamepadIndices: {
226
+ button: 8,
227
+ },
228
+ rootNodeName: "swipe-backward",
229
+ visualResponses: {},
230
+ },
231
+ // eslint-disable-next-line @typescript-eslint/naming-convention
232
+ "tap-thumb": {
233
+ type: "button",
234
+ gamepadIndices: {
235
+ button: 9,
236
+ },
237
+ rootNodeName: "tap-thumb",
238
+ visualResponses: {},
239
+ },
240
+ },
241
+ gamepadMapping: "xr-standard",
242
+ rootNodeName: "oculus-hand-none",
243
+ assetPath: "none.glb",
244
+ },
245
+ };
246
+ //# sourceMappingURL=webXROculusHandController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webXROculusHandController.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXROculusHandController.ts"],"names":[],"mappings":"AAEA,OAAO,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AAE,MAAM;gBACpB,eAAe,EAAE,EAAE;aACtB;YACD,gEAAgE;YAChE,YAAY,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,cAAc,EAAE;oBACZ,MAAM,EAAE,CAAC;iBACZ;gBACD,YAAY,EAAE,YAAY;gBAC1B,eAAe,EAAE,EAAE;aACtB;YACD,gEAAgE;YAChE,aAAa,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,cAAc,EAAE;oBACZ,MAAM,EAAE,CAAC;iBACZ;gBACD,YAAY,EAAE,aAAa;gBAC3B,eAAe,EAAE,EAAE;aACtB;YACD,gEAAgE;YAChE,eAAe,EAAE;gBACb,IAAI,EAAE,QAAQ;gBACd,cAAc,EAAE;oBACZ,MAAM,EAAE,CAAC;iBACZ;gBACD,YAAY,EAAE,eAAe;gBAC7B,eAAe,EAAE,EAAE;aACtB;YACD,gEAAgE;YAChE,gBAAgB,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,cAAc,EAAE;oBACZ,MAAM,EAAE,CAAC;iBACZ;gBACD,YAAY,EAAE,gBAAgB;gBAC9B,eAAe,EAAE,EAAE;aACtB;YACD,gEAAgE;YAChE,WAAW,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,cAAc,EAAE;oBACZ,MAAM,EAAE,CAAC;iBACZ;gBACD,YAAY,EAAE,WAAW;gBACzB,eAAe,EAAE,EAAE;aACtB;SACJ;QACD,cAAc,EAAE,aAAa;QAC7B,YAAY,EAAE,kBAAkB;QAChC,SAAS,EAAE,UAAU;KACxB;CACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { IMotionControllerLayoutMap, IMinimalMotionControllerObject, MotionControllerHandedness } from \"./webXRAbstractMotionController\";\r\nimport { WebXRAbstractMotionController } from \"./webXRAbstractMotionController\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { WebXRMotionControllerManager } from \"./webXRMotionControllerManager\";\r\n\r\n/**\r\n * Oculus hand controller class that supports microgestures\r\n */\r\nexport class WebXROculusHandController extends WebXRAbstractMotionController {\r\n public profileId = \"oculus-hand\";\r\n\r\n /**\r\n * Create a new hand controller object, without loading a controller model\r\n * @param scene the scene to use to create this controller\r\n * @param gamepadObject the corresponding gamepad object\r\n * @param handedness the handedness of the controller\r\n */\r\n constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness) {\r\n // Don't load the controller model - for now, hands have no real model.\r\n super(scene, OculusHandProfile[handedness], gamepadObject, handedness, true);\r\n }\r\n\r\n protected _getFilenameAndPath(): { filename: string; path: string } {\r\n return {\r\n filename: \"generic.babylon\",\r\n path: \"https://controllers.babylonjs.com/generic/\",\r\n };\r\n }\r\n\r\n protected _getModelLoadingConstraints(): boolean {\r\n return true;\r\n }\r\n\r\n protected _processLoadedModel(_meshes: AbstractMesh[]): void {\r\n // no-op\r\n }\r\n\r\n protected _setRootMesh(meshes: AbstractMesh[]): void {\r\n // no-op\r\n }\r\n\r\n protected _updateModel(): void {\r\n // no-op\r\n }\r\n}\r\n\r\n// register the profiles\r\nWebXRMotionControllerManager.RegisterController(\"oculus-hand\", (xrInput: XRInputSource, scene: Scene) => {\r\n return new WebXROculusHandController(scene, <any>xrInput.gamepad, xrInput.handedness);\r\n});\r\n\r\n// https://github.com/immersive-web/webxr-input-profiles/blob/main/packages/registry/profiles/oculus/oculus-hand.json\r\nconst OculusHandProfile: IMotionControllerLayoutMap = {\r\n left: {\r\n selectComponentId: \"xr-standard-trigger\",\r\n components: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"xr-standard-trigger\": {\r\n type: \"trigger\",\r\n gamepadIndices: {\r\n button: 0,\r\n },\r\n rootNodeName: \"xr-standard-trigger\",\r\n visualResponses: {},\r\n },\r\n menu: {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 4,\r\n },\r\n rootNodeName: \"menu\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-left\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 5,\r\n },\r\n rootNodeName: \"swipe-left\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-right\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 6,\r\n },\r\n rootNodeName: \"swipe-right\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-forward\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 7,\r\n },\r\n rootNodeName: \"swipe-forward\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-backward\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 8,\r\n },\r\n rootNodeName: \"swipe-backward\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"tap-thumb\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 9,\r\n },\r\n rootNodeName: \"tap-thumb\",\r\n visualResponses: {},\r\n },\r\n },\r\n gamepadMapping: \"xr-standard\",\r\n rootNodeName: \"oculus-hand-left\",\r\n assetPath: \"left.glb\",\r\n },\r\n right: {\r\n selectComponentId: \"xr-standard-trigger\",\r\n components: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"xr-standard-trigger\": {\r\n type: \"trigger\",\r\n gamepadIndices: {\r\n button: 0,\r\n },\r\n rootNodeName: \"xr-standard-trigger\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-left\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 5,\r\n },\r\n rootNodeName: \"swipe-left\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-right\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 6,\r\n },\r\n rootNodeName: \"swipe-right\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-forward\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 7,\r\n },\r\n rootNodeName: \"swipe-forward\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-backward\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 8,\r\n },\r\n rootNodeName: \"swipe-backward\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"tap-thumb\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 9,\r\n },\r\n rootNodeName: \"tap-thumb\",\r\n visualResponses: {},\r\n },\r\n },\r\n gamepadMapping: \"xr-standard\",\r\n rootNodeName: \"oculus-hand-right\",\r\n assetPath: \"right.glb\",\r\n },\r\n none: {\r\n selectComponentId: \"xr-standard-trigger\",\r\n components: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"xr-standard-trigger\": {\r\n type: \"trigger\",\r\n gamepadIndices: {\r\n button: 0,\r\n },\r\n rootNodeName: \"xr-standard-trigger\",\r\n visualResponses: {},\r\n },\r\n menu: {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 4,\r\n },\r\n rootNodeName: \"menu\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-left\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 5,\r\n },\r\n rootNodeName: \"swipe-left\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-right\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 6,\r\n },\r\n rootNodeName: \"swipe-right\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-forward\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 7,\r\n },\r\n rootNodeName: \"swipe-forward\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"swipe-backward\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 8,\r\n },\r\n rootNodeName: \"swipe-backward\",\r\n visualResponses: {},\r\n },\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"tap-thumb\": {\r\n type: \"button\",\r\n gamepadIndices: {\r\n button: 9,\r\n },\r\n rootNodeName: \"tap-thumb\",\r\n visualResponses: {},\r\n },\r\n },\r\n gamepadMapping: \"xr-standard\",\r\n rootNodeName: \"oculus-hand-none\",\r\n assetPath: \"none.glb\",\r\n },\r\n};\r\n"]}
@@ -67,7 +67,7 @@ export class WebXRDefaultExperience {
67
67
  xrInput: result.input,
68
68
  renderingGroupId: options.renderingGroupId,
69
69
  };
70
- result.pointerSelection = (result.baseExperience.featuresManager.enableFeature(WebXRControllerPointerSelection.Name, options.useStablePlugins ? "stable" : "latest", pointerSelectionOptions));
70
+ result.pointerSelection = result.baseExperience.featuresManager.enableFeature(WebXRControllerPointerSelection.Name, options.useStablePlugins ? "stable" : "latest", pointerSelectionOptions);
71
71
  if (!options.disableTeleportation) {
72
72
  // Add default teleportation, including rotation
73
73
  result.teleportation = result.baseExperience.featuresManager.enableFeature(WebXRMotionControllerTeleportation.Name, options.useStablePlugins ? "stable" : "latest", {
@@ -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,oB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C;gBAC5B,oCAAoC;gBACpC,MAAM,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YACxF,CAAC;YACD,OAAO,MAAM,CAAC;QAClB,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 = <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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YACN,CAAC;YAED,iCAAiC;YACjC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,oBAAoB,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;YAE7G,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;gBAC5B,oCAAoC;gBACpC,MAAM,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YACxF,CAAC;YACD,OAAO,MAAM,CAAC;QAClB,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"]}