@babylonjs/core 8.31.0 → 8.31.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 (129) 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/Tasks/PostProcesses/customPostProcessTask.d.ts +21 -0
  8. package/FrameGraph/Tasks/PostProcesses/customPostProcessTask.js +18 -0
  9. package/FrameGraph/Tasks/PostProcesses/customPostProcessTask.js.map +1 -0
  10. package/FrameGraph/frameGraphTextureManager.d.ts +6 -2
  11. package/FrameGraph/frameGraphTextureManager.js +22 -8
  12. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  13. package/FrameGraph/index.d.ts +1 -0
  14. package/FrameGraph/index.js +1 -0
  15. package/FrameGraph/index.js.map +1 -1
  16. package/Materials/PBR/openPbrMaterial.d.ts +39 -0
  17. package/Materials/PBR/openPbrMaterial.js +46 -0
  18. package/Materials/PBR/openPbrMaterial.js.map +1 -1
  19. package/Materials/Textures/texture.js +9 -2
  20. package/Materials/Textures/texture.js.map +1 -1
  21. package/Materials/materialHelper.functions.d.ts +1 -7
  22. package/Materials/materialHelper.functions.js +2 -15
  23. package/Materials/materialHelper.functions.js.map +1 -1
  24. package/Materials/materialHelper.functions.pure.d.ts +10 -0
  25. package/Materials/materialHelper.functions.pure.js +21 -0
  26. package/Materials/materialHelper.functions.pure.js.map +1 -0
  27. package/Meshes/Compression/dracoEncoder.js +1 -1
  28. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  29. package/Meshes/geometry.js +6 -6
  30. package/Meshes/geometry.js.map +1 -1
  31. package/Meshes/mesh.js +2 -2
  32. package/Meshes/mesh.js.map +1 -1
  33. package/Particles/gpuParticleSystem.js +2 -1
  34. package/Particles/gpuParticleSystem.js.map +1 -1
  35. package/Particles/thinParticleSystem.js +4 -3
  36. package/Particles/thinParticleSystem.js.map +1 -1
  37. package/PostProcesses/thinCustomPostProcess.d.ts +20 -0
  38. package/PostProcesses/thinCustomPostProcess.js +32 -0
  39. package/PostProcesses/thinCustomPostProcess.js.map +1 -0
  40. package/Rendering/geometryBufferRenderer.js +6 -1
  41. package/Rendering/geometryBufferRenderer.js.map +1 -1
  42. package/Shaders/ShadersInclude/openpbrDielectricReflectance.js +8 -9
  43. package/Shaders/ShadersInclude/openpbrDielectricReflectance.js.map +1 -1
  44. package/Shaders/ShadersInclude/openpbrDirectLighting.js +13 -6
  45. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  46. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +10 -2
  47. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  48. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +7 -1
  49. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
  50. package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js +2 -0
  51. package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
  52. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.d.ts +5 -0
  53. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js +27 -0
  54. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -0
  55. package/Shaders/ShadersInclude/openpbrUboDeclaration.js +1 -1
  56. package/Shaders/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  57. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +6 -0
  58. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
  59. package/Shaders/geometry.fragment.js +3 -1
  60. package/Shaders/geometry.fragment.js.map +1 -1
  61. package/Shaders/geometry.vertex.js +10 -2
  62. package/Shaders/geometry.vertex.js.map +1 -1
  63. package/Shaders/openpbr.fragment.d.ts +1 -0
  64. package/Shaders/openpbr.fragment.js +7 -1
  65. package/Shaders/openpbr.fragment.js.map +1 -1
  66. package/Shaders/openpbr.vertex.js +4 -0
  67. package/Shaders/openpbr.vertex.js.map +1 -1
  68. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +2 -2
  69. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  70. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +13 -6
  71. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  72. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +10 -2
  73. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  74. package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js +2 -0
  75. package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
  76. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.d.ts +5 -0
  77. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js +27 -0
  78. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -0
  79. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js +1 -1
  80. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  81. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +3 -3
  82. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  83. package/ShadersWGSL/geometry.fragment.js +3 -1
  84. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  85. package/ShadersWGSL/geometry.vertex.js +10 -2
  86. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  87. package/ShadersWGSL/openpbr.fragment.d.ts +1 -0
  88. package/ShadersWGSL/openpbr.fragment.js +7 -1
  89. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  90. package/ShadersWGSL/openpbr.vertex.js +4 -0
  91. package/ShadersWGSL/openpbr.vertex.js.map +1 -1
  92. package/ShadersWGSL/pbr.fragment.js +1 -1
  93. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  94. package/Sprites/spriteRenderer.js +1 -1
  95. package/Sprites/spriteRenderer.js.map +1 -1
  96. package/XR/features/WebXRAnchorSystem.d.ts +1 -1
  97. package/XR/features/WebXRBackgroundRemover.d.ts +1 -1
  98. package/XR/features/WebXRControllerMovement.d.ts +1 -1
  99. package/XR/features/WebXRControllerPhysics.d.ts +1 -1
  100. package/XR/features/WebXRControllerPointerSelection.d.ts +1 -1
  101. package/XR/features/WebXRControllerTeleportation.d.ts +1 -1
  102. package/XR/features/WebXRDOMOverlay.d.ts +1 -1
  103. package/XR/features/WebXRDepthSensing.d.ts +1 -1
  104. package/XR/features/WebXREyeTracking.d.ts +1 -1
  105. package/XR/features/WebXRFeaturePointSystem.d.ts +1 -1
  106. package/XR/features/WebXRHandTracking.d.ts +1 -1
  107. package/XR/features/WebXRHitTest.d.ts +1 -1
  108. package/XR/features/WebXRHitTestLegacy.d.ts +1 -1
  109. package/XR/features/WebXRImageTracking.d.ts +1 -1
  110. package/XR/features/WebXRLayers.d.ts +1 -1
  111. package/XR/features/WebXRLightEstimation.d.ts +1 -1
  112. package/XR/features/WebXRMeshDetector.d.ts +1 -1
  113. package/XR/features/WebXRNearInteraction.d.ts +1 -1
  114. package/XR/features/WebXRPlaneDetector.d.ts +1 -1
  115. package/XR/features/WebXRRawCameraAccess.d.ts +1 -1
  116. package/XR/features/WebXRSpaceWarp.d.ts +1 -1
  117. package/XR/motionController/index.d.ts +1 -0
  118. package/XR/motionController/index.js +1 -0
  119. package/XR/motionController/index.js.map +1 -1
  120. package/XR/motionController/webXRMotionControllerManager.js +1 -0
  121. package/XR/motionController/webXRMotionControllerManager.js.map +1 -1
  122. package/XR/motionController/webXROculusHandController.d.ts +25 -0
  123. package/XR/motionController/webXROculusHandController.js +246 -0
  124. package/XR/motionController/webXROculusHandController.js.map +1 -0
  125. package/XR/webXRDefaultExperience.js +1 -1
  126. package/XR/webXRDefaultExperience.js.map +1 -1
  127. package/XR/webXRFeaturesManager.d.ts +116 -27
  128. package/XR/webXRFeaturesManager.js.map +1 -1
  129. package/package.json +1 -1
@@ -40,7 +40,7 @@ export declare class WebXRBackgroundRemover extends WebXRAbstractFeature {
40
40
  /**
41
41
  * The module's name
42
42
  */
43
- static readonly Name = "xr-background-remover";
43
+ static readonly Name: "xr-background-remover";
44
44
  /**
45
45
  * The (Babylon) version of this module.
46
46
  * This is an integer representing the implementation version.
@@ -132,7 +132,7 @@ export declare class WebXRControllerMovement extends WebXRAbstractFeature {
132
132
  /**
133
133
  * The module's name
134
134
  */
135
- static readonly Name = "xr-controller-movement";
135
+ static readonly Name: "xr-controller-movement";
136
136
  /**
137
137
  * Standard controller configurations.
138
138
  */
@@ -91,7 +91,7 @@ export declare class WebXRControllerPhysics extends WebXRAbstractFeature {
91
91
  /**
92
92
  * The module's name
93
93
  */
94
- static readonly Name = "xr-physics-controller";
94
+ static readonly Name: "xr-physics-controller";
95
95
  /**
96
96
  * The (Babylon) version of this module.
97
97
  * This is an integer representing the implementation version.
@@ -121,7 +121,7 @@ export declare class WebXRControllerPointerSelection extends WebXRAbstractFeatur
121
121
  /**
122
122
  * The module's name
123
123
  */
124
- static readonly Name = "xr-controller-pointer-selection";
124
+ static readonly Name: "xr-controller-pointer-selection";
125
125
  /**
126
126
  * The (Babylon) version of this module.
127
127
  * This is an integer representing the implementation version.
@@ -156,7 +156,7 @@ export declare class WebXRMotionControllerTeleportation extends WebXRAbstractFea
156
156
  /**
157
157
  * The module's name
158
158
  */
159
- static readonly Name = "xr-controller-teleportation";
159
+ static readonly Name: "xr-controller-teleportation";
160
160
  /**
161
161
  * The (Babylon) version of this module.
162
162
  * This is an integer representing the implementation version.
@@ -57,7 +57,7 @@ export declare class WebXRDomOverlay extends WebXRAbstractFeature {
57
57
  /**
58
58
  * The module's name
59
59
  */
60
- static readonly Name = "xr-dom-overlay";
60
+ static readonly Name: "xr-dom-overlay";
61
61
  /**
62
62
  * The (Babylon) version of this module.
63
63
  * This is an integer representing the implementation version.
@@ -102,7 +102,7 @@ export declare class WebXRDepthSensing extends WebXRAbstractFeature {
102
102
  /**
103
103
  * The module's name
104
104
  */
105
- static readonly Name = "xr-depth-sensing";
105
+ static readonly Name: "xr-depth-sensing";
106
106
  /**
107
107
  * The (Babylon) version of this module.
108
108
  * This is an integer representing the implementation version.
@@ -13,7 +13,7 @@ export declare class WebXREyeTracking extends WebXRAbstractFeature {
13
13
  /**
14
14
  * The module's name
15
15
  */
16
- static readonly Name = "xr-eye-tracking";
16
+ static readonly Name: "xr-eye-tracking";
17
17
  /**
18
18
  * The (Babylon) version of this module.
19
19
  * This is an integer representing the implementation version.
@@ -27,7 +27,7 @@ export declare class WebXRFeaturePointSystem extends WebXRAbstractFeature {
27
27
  /**
28
28
  * The module's name
29
29
  */
30
- static readonly Name = "xr-feature-points";
30
+ static readonly Name: "xr-feature-points";
31
31
  /**
32
32
  * The (Babylon) version of this module.
33
33
  * This is an integer representing the implementation version.
@@ -298,7 +298,7 @@ export declare class WebXRHandTracking extends WebXRAbstractFeature {
298
298
  /**
299
299
  * The module's name
300
300
  */
301
- static readonly Name = "xr-hand-tracking";
301
+ static readonly Name: "xr-hand-tracking";
302
302
  /**
303
303
  * The (Babylon) version of this module.
304
304
  * This is an integer representing the implementation version.
@@ -83,7 +83,7 @@ export declare class WebXRHitTest extends WebXRAbstractFeature implements IWebXR
83
83
  /**
84
84
  * The module's name
85
85
  */
86
- static readonly Name = "xr-hit-test";
86
+ static readonly Name: "xr-hit-test";
87
87
  /**
88
88
  * The (Babylon) version of this module.
89
89
  * This is an integer representing the implementation version.
@@ -56,7 +56,7 @@ export declare class WebXRHitTestLegacy extends WebXRAbstractFeature implements
56
56
  /**
57
57
  * The module's name
58
58
  */
59
- static readonly Name = "xr-hit-test";
59
+ static readonly Name: "xr-hit-test";
60
60
  /**
61
61
  * The (Babylon) version of this module.
62
62
  * This is an integer representing the implementation version.
@@ -66,7 +66,7 @@ export declare class WebXRImageTracking extends WebXRAbstractFeature {
66
66
  /**
67
67
  * The module's name
68
68
  */
69
- static readonly Name = "xr-image-tracking";
69
+ static readonly Name: "xr-image-tracking";
70
70
  /**
71
71
  * The (Babylon) version of this module.
72
72
  * This is an integer representing the implementation version.
@@ -28,7 +28,7 @@ export declare class WebXRLayers extends WebXRAbstractFeature {
28
28
  /**
29
29
  * The module's name
30
30
  */
31
- static readonly Name = "xr-layers";
31
+ static readonly Name: "xr-layers";
32
32
  /**
33
33
  * The (Babylon) version of this module.
34
34
  * This is an integer representing the implementation version.
@@ -98,7 +98,7 @@ export declare class WebXRLightEstimation extends WebXRAbstractFeature {
98
98
  /**
99
99
  * The module's name
100
100
  */
101
- static readonly Name = "xr-light-estimation";
101
+ static readonly Name: "xr-light-estimation";
102
102
  /**
103
103
  * The (Babylon) version of this module.
104
104
  * This is an integer representing the implementation version.
@@ -90,7 +90,7 @@ export declare class WebXRMeshDetector extends WebXRAbstractFeature {
90
90
  /**
91
91
  * The module's name
92
92
  */
93
- static readonly Name = "xr-mesh-detection";
93
+ static readonly Name: "xr-mesh-detection";
94
94
  /**
95
95
  * The (Babylon) version of this module.
96
96
  * This is an integer representing the implementation version.
@@ -92,7 +92,7 @@ export declare class WebXRNearInteraction extends WebXRAbstractFeature {
92
92
  /**
93
93
  * The module's name
94
94
  */
95
- static readonly Name = "xr-near-interaction";
95
+ static readonly Name: "xr-near-interaction";
96
96
  /**
97
97
  * The (Babylon) version of this module.
98
98
  * This is an integer representing the implementation version.
@@ -58,7 +58,7 @@ export declare class WebXRPlaneDetector extends WebXRAbstractFeature {
58
58
  /**
59
59
  * The module's name
60
60
  */
61
- static readonly Name = "xr-plane-detection";
61
+ static readonly Name: "xr-plane-detection";
62
62
  /**
63
63
  * The (Babylon) version of this module.
64
64
  * This is an integer representing the implementation version.
@@ -53,7 +53,7 @@ export declare class WebXRRawCameraAccess extends WebXRAbstractFeature {
53
53
  /**
54
54
  * The module's name
55
55
  */
56
- static readonly Name = "xr-raw-camera-access";
56
+ static readonly Name: "xr-raw-camera-access";
57
57
  /**
58
58
  * The (Babylon) version of this module.
59
59
  * This is an integer representing the implementation version.
@@ -77,7 +77,7 @@ export declare class WebXRSpaceWarp extends WebXRAbstractFeature {
77
77
  /**
78
78
  * The module's name
79
79
  */
80
- static readonly Name = "xr-space-warp";
80
+ static readonly Name: "xr-space-warp";
81
81
  /**
82
82
  * The (Babylon) version of this module.
83
83
  * This is an integer representing the implementation version.
@@ -5,5 +5,6 @@ export * from "./webXRGenericMotionController.js";
5
5
  export * from "./webXRMicrosoftMixedRealityController.js";
6
6
  export * from "./webXRMotionControllerManager.js";
7
7
  export * from "./webXROculusTouchMotionController.js";
8
+ export * from "./webXROculusHandController.js";
8
9
  export * from "./webXRHTCViveMotionController.js";
9
10
  export * from "./webXRProfiledMotionController.js";
@@ -5,6 +5,7 @@ export * from "./webXRGenericMotionController.js";
5
5
  export * from "./webXRMicrosoftMixedRealityController.js";
6
6
  export * from "./webXRMotionControllerManager.js";
7
7
  export * from "./webXROculusTouchMotionController.js";
8
+ export * from "./webXROculusHandController.js";
8
9
  export * from "./webXRHTCViveMotionController.js";
9
10
  export * from "./webXRProfiledMotionController.js";
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from \"./webXRAbstractMotionController\";\r\nexport * from \"./webXRControllerComponent\";\r\nexport * from \"./webXRGenericHandController\";\r\nexport * from \"./webXRGenericMotionController\";\r\nexport * from \"./webXRMicrosoftMixedRealityController\";\r\nexport * from \"./webXRMotionControllerManager\";\r\nexport * from \"./webXROculusTouchMotionController\";\r\nexport * from \"./webXRHTCViveMotionController\";\r\nexport * from \"./webXRProfiledMotionController\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from \"./webXRAbstractMotionController\";\r\nexport * from \"./webXRControllerComponent\";\r\nexport * from \"./webXRGenericHandController\";\r\nexport * from \"./webXRGenericMotionController\";\r\nexport * from \"./webXRMicrosoftMixedRealityController\";\r\nexport * from \"./webXRMotionControllerManager\";\r\nexport * from \"./webXROculusTouchMotionController\";\r\nexport * from \"./webXROculusHandController\";\r\nexport * from \"./webXRHTCViveMotionController\";\r\nexport * from \"./webXRProfiledMotionController\";\r\n"]}
@@ -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":"webXRMotionControll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EG;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;I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ent":["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