@babylonjs/core 6.23.1 → 6.25.0

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 (344) hide show
  1. package/Buffers/buffer.align.d.ts +25 -0
  2. package/Buffers/buffer.align.js +120 -0
  3. package/Buffers/buffer.align.js.map +1 -0
  4. package/Buffers/buffer.d.ts +15 -3
  5. package/Buffers/buffer.js +27 -7
  6. package/Buffers/buffer.js.map +1 -1
  7. package/Buffers/index.d.ts +1 -0
  8. package/Buffers/index.js +1 -0
  9. package/Buffers/index.js.map +1 -1
  10. package/Cameras/Inputs/BaseCameraPointersInput.js +0 -3
  11. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  12. package/Cameras/Inputs/flyCameraMouseInput.js +1 -4
  13. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  14. package/Cameras/Inputs/freeCameraMouseInput.js +0 -6
  15. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  16. package/Cameras/RigModes/index.d.ts +0 -1
  17. package/Cameras/RigModes/index.js +0 -1
  18. package/Cameras/RigModes/index.js.map +1 -1
  19. package/Cameras/RigModes/vrRigMode.js +1 -1
  20. package/Cameras/RigModes/vrRigMode.js.map +1 -1
  21. package/Cameras/VR/index.d.ts +0 -1
  22. package/Cameras/VR/index.js +0 -1
  23. package/Cameras/VR/index.js.map +1 -1
  24. package/Cameras/VR/vrExperienceHelper.d.ts +7 -66
  25. package/Cameras/VR/vrExperienceHelper.js +17 -702
  26. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  27. package/Cameras/camera.d.ts +15 -20
  28. package/Cameras/camera.js +41 -36
  29. package/Cameras/camera.js.map +1 -1
  30. package/Cameras/targetCamera.js +1 -1
  31. package/Cameras/targetCamera.js.map +1 -1
  32. package/Engines/Extensions/index.d.ts +0 -1
  33. package/Engines/Extensions/index.js +0 -1
  34. package/Engines/Extensions/index.js.map +1 -1
  35. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +4 -0
  36. package/Engines/WebGL/webGLRenderTargetWrapper.js +4 -0
  37. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  38. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +8 -7
  39. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  40. package/Engines/WebGPU/webgpuCacheSampler.js +1 -1
  41. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  42. package/Engines/constants.d.ts +0 -4
  43. package/Engines/constants.js +0 -4
  44. package/Engines/constants.js.map +1 -1
  45. package/Engines/engine.d.ts +38 -258
  46. package/Engines/engine.js +0 -65
  47. package/Engines/engine.js.map +1 -1
  48. package/Engines/engineFactory.js +9 -14
  49. package/Engines/engineFactory.js.map +1 -1
  50. package/Engines/engineFeatures.d.ts +2 -0
  51. package/Engines/engineFeatures.js.map +1 -1
  52. package/Engines/nativeEngine.js +1 -0
  53. package/Engines/nativeEngine.js.map +1 -1
  54. package/Engines/nullEngine.js +1 -0
  55. package/Engines/nullEngine.js.map +1 -1
  56. package/Engines/thinEngine.d.ts +22 -5
  57. package/Engines/thinEngine.js +55 -22
  58. package/Engines/thinEngine.js.map +1 -1
  59. package/Engines/webgpuEngine.d.ts +1 -0
  60. package/Engines/webgpuEngine.js +4 -2
  61. package/Engines/webgpuEngine.js.map +1 -1
  62. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.d.ts +9 -8
  63. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js +34 -16
  64. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js.map +1 -1
  65. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.d.ts +4 -3
  66. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.js +14 -6
  67. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.js.map +1 -1
  68. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.d.ts +19 -14
  69. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.js +64 -27
  70. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.js.map +1 -1
  71. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.d.ts +39 -41
  72. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js +152 -74
  73. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js.map +1 -1
  74. package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.d.ts +12 -12
  75. package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.js +42 -21
  76. package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.js.map +1 -1
  77. package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.d.ts +17 -14
  78. package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.js +62 -26
  79. package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.js.map +1 -1
  80. package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.d.ts +13 -10
  81. package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.js +46 -18
  82. package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.js.map +1 -1
  83. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.d.ts +4 -1
  84. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +6 -2
  85. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
  86. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +3 -1
  87. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +7 -2
  88. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
  89. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.d.ts +5 -3
  90. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js +10 -5
  91. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
  92. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +4 -1
  93. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +6 -2
  94. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
  95. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.d.ts +3 -1
  96. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js +7 -2
  97. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js.map +1 -1
  98. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +3 -1
  99. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +7 -2
  100. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
  101. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.d.ts +4 -1
  102. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +6 -2
  103. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
  104. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +6 -2
  105. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +12 -3
  106. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  107. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +5 -3
  108. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +11 -6
  109. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  110. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +1 -0
  111. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +7 -2
  112. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
  113. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.d.ts +1 -0
  114. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js +7 -2
  115. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
  116. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +3 -1
  117. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +7 -2
  118. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
  119. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +3 -1
  120. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +8 -3
  121. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  122. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +3 -1
  123. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +7 -2
  124. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  125. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.d.ts +3 -1
  126. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js +7 -2
  127. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +1 -1
  128. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.d.ts +3 -1
  129. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js +7 -2
  130. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +1 -1
  131. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.d.ts +3 -1
  132. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js +7 -2
  133. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -1
  134. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +3 -1
  135. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +7 -2
  136. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
  137. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +3 -1
  138. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +7 -2
  139. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
  140. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +3 -1
  141. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +7 -2
  142. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
  143. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.d.ts +3 -1
  144. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +7 -2
  145. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -1
  146. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.d.ts +3 -1
  147. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +7 -2
  148. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
  149. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +6 -3
  150. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +22 -16
  151. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
  152. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +7 -4
  153. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +15 -10
  154. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
  155. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +3 -1
  156. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +7 -2
  157. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  158. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.d.ts +3 -1
  159. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js +8 -3
  160. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -1
  161. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +7 -4
  162. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +14 -7
  163. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
  164. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +5 -3
  165. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +9 -4
  166. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
  167. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.d.ts +3 -1
  168. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +7 -2
  169. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
  170. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +3 -1
  171. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +8 -3
  172. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
  173. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +3 -1
  174. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +7 -2
  175. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  176. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +3 -1
  177. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +7 -2
  178. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  179. package/FlowGraph/flowGraph.d.ts +41 -3
  180. package/FlowGraph/flowGraph.js +135 -0
  181. package/FlowGraph/flowGraph.js.map +1 -1
  182. package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +2 -1
  183. package/FlowGraph/flowGraphAsyncExecutionBlock.js +2 -2
  184. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -1
  185. package/FlowGraph/flowGraphBlock.d.ts +15 -3
  186. package/FlowGraph/flowGraphBlock.js +50 -7
  187. package/FlowGraph/flowGraphBlock.js.map +1 -1
  188. package/FlowGraph/flowGraphConnection.d.ts +34 -4
  189. package/FlowGraph/flowGraphConnection.js +49 -3
  190. package/FlowGraph/flowGraphConnection.js.map +1 -1
  191. package/FlowGraph/flowGraphContext.d.ts +25 -5
  192. package/FlowGraph/flowGraphContext.js +86 -4
  193. package/FlowGraph/flowGraphContext.js.map +1 -1
  194. package/FlowGraph/flowGraphCoordinator.d.ts +7 -1
  195. package/FlowGraph/flowGraphCoordinator.js +18 -2
  196. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  197. package/FlowGraph/flowGraphDataConnection.d.ts +4 -11
  198. package/FlowGraph/flowGraphDataConnection.js +16 -14
  199. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  200. package/FlowGraph/flowGraphExecutionBlock.d.ts +8 -3
  201. package/FlowGraph/flowGraphExecutionBlock.js +37 -6
  202. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  203. package/FlowGraph/flowGraphRichTypes.d.ts +5 -9
  204. package/FlowGraph/flowGraphRichTypes.js +29 -44
  205. package/FlowGraph/flowGraphRichTypes.js.map +1 -1
  206. package/FlowGraph/flowGraphSignalConnection.js +2 -0
  207. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  208. package/FlowGraph/flowGraphVariableDefinitions.d.ts +22 -2
  209. package/FlowGraph/flowGraphVariableDefinitions.js +29 -0
  210. package/FlowGraph/flowGraphVariableDefinitions.js.map +1 -1
  211. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +2 -1
  212. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +2 -2
  213. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -1
  214. package/Gamepads/gamepadManager.js +0 -5
  215. package/Gamepads/gamepadManager.js.map +1 -1
  216. package/Gamepads/index.d.ts +0 -1
  217. package/Gamepads/index.js +0 -2
  218. package/Gamepads/index.js.map +1 -1
  219. package/Gizmos/gizmo.js +1 -4
  220. package/Gizmos/gizmo.js.map +1 -1
  221. package/Materials/GreasedLine/greasedLineMaterialDefaults.d.ts +24 -0
  222. package/Materials/GreasedLine/greasedLineMaterialDefaults.js +19 -0
  223. package/Materials/GreasedLine/greasedLineMaterialDefaults.js.map +1 -0
  224. package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +243 -0
  225. package/Materials/GreasedLine/greasedLineMaterialInterfaces.js +55 -0
  226. package/Materials/GreasedLine/greasedLineMaterialInterfaces.js.map +1 -0
  227. package/Materials/GreasedLine/greasedLinePluginMaterial.d.ts +253 -0
  228. package/Materials/{greasedLinePluginMaterial.js → GreasedLine/greasedLinePluginMaterial.js} +148 -205
  229. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -0
  230. package/Materials/{greasedLineSimpleMaterial.d.ts → GreasedLine/greasedLineSimpleMaterial.d.ts} +20 -48
  231. package/Materials/{greasedLineSimpleMaterial.js → GreasedLine/greasedLineSimpleMaterial.js} +74 -91
  232. package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -0
  233. package/Materials/Node/Blocks/Input/prePassTextureBlock.d.ts +1 -1
  234. package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
  235. package/Materials/Textures/texture.js +1 -0
  236. package/Materials/Textures/texture.js.map +1 -1
  237. package/Materials/index.d.ts +4 -1
  238. package/Materials/index.js +4 -1
  239. package/Materials/index.js.map +1 -1
  240. package/Maths/math.vector.d.ts +32 -22
  241. package/Maths/math.vector.js +54 -43
  242. package/Maths/math.vector.js.map +1 -1
  243. package/Meshes/Builders/greasedLineBuilder.d.ts +7 -6
  244. package/Meshes/Builders/greasedLineBuilder.js +65 -31
  245. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  246. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +216 -0
  247. package/Meshes/GreasedLine/greasedLineBaseMesh.js +247 -0
  248. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -0
  249. package/Meshes/GreasedLine/greasedLineMesh.d.ts +92 -0
  250. package/Meshes/{greasedLineMesh.js → GreasedLine/greasedLineMesh.js} +29 -223
  251. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -0
  252. package/Meshes/GreasedLine/greasedLineRibbonMesh.d.ts +107 -0
  253. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +462 -0
  254. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -0
  255. package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +9 -2
  256. package/Meshes/Node/Blocks/Sources/meshBlock.js +17 -5
  257. package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
  258. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +15 -0
  259. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +50 -1
  260. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
  261. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js +5 -5
  262. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
  263. package/Meshes/Node/nodeGeometry.d.ts +1 -2
  264. package/Meshes/Node/nodeGeometry.js +3 -4
  265. package/Meshes/Node/nodeGeometry.js.map +1 -1
  266. package/Meshes/Node/nodeGeometryBlock.d.ts +1 -2
  267. package/Meshes/Node/nodeGeometryBlock.js +1 -2
  268. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  269. package/Meshes/geometry.js +6 -12
  270. package/Meshes/geometry.js.map +1 -1
  271. package/Meshes/index.d.ts +3 -1
  272. package/Meshes/index.js +3 -1
  273. package/Meshes/index.js.map +1 -1
  274. package/Meshes/mesh.d.ts +4 -0
  275. package/Meshes/mesh.js +7 -0
  276. package/Meshes/mesh.js.map +1 -1
  277. package/Misc/deepCopier.js +3 -0
  278. package/Misc/deepCopier.js.map +1 -1
  279. package/Misc/greasedLineTools.d.ts +52 -5
  280. package/Misc/greasedLineTools.js +180 -10
  281. package/Misc/greasedLineTools.js.map +1 -1
  282. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +9 -2
  283. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  284. package/PostProcesses/motionBlurPostProcess.js +4 -1
  285. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  286. package/PostProcesses/postProcess.js +1 -6
  287. package/PostProcesses/postProcess.js.map +1 -1
  288. package/Rendering/geometryBufferRenderer.js +4 -0
  289. package/Rendering/geometryBufferRenderer.js.map +1 -1
  290. package/Shaders/greasedLine.fragment.js +2 -5
  291. package/Shaders/greasedLine.fragment.js.map +1 -1
  292. package/Shaders/greasedLine.vertex.js +15 -4
  293. package/Shaders/greasedLine.vertex.js.map +1 -1
  294. package/XR/webXRDefaultExperience.d.ts +1 -1
  295. package/XR/webXRDefaultExperience.js +1 -1
  296. package/XR/webXRDefaultExperience.js.map +1 -1
  297. package/package.json +1 -1
  298. package/scene.d.ts +17 -10
  299. package/scene.js +25 -30
  300. package/scene.js.map +1 -1
  301. package/Cameras/RigModes/webVRRigMode.d.ts +0 -5
  302. package/Cameras/RigModes/webVRRigMode.js +0 -34
  303. package/Cameras/RigModes/webVRRigMode.js.map +0 -1
  304. package/Cameras/VR/webVRCamera.d.ts +0 -316
  305. package/Cameras/VR/webVRCamera.js +0 -618
  306. package/Cameras/VR/webVRCamera.js.map +0 -1
  307. package/Engines/Extensions/engine.webVR.d.ts +0 -91
  308. package/Engines/Extensions/engine.webVR.js +0 -195
  309. package/Engines/Extensions/engine.webVR.js.map +0 -1
  310. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.d.ts +0 -23
  311. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.js +0 -18
  312. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.js.map +0 -1
  313. package/Gamepads/Controllers/daydreamController.d.ts +0 -38
  314. package/Gamepads/Controllers/daydreamController.js +0 -70
  315. package/Gamepads/Controllers/daydreamController.js.map +0 -1
  316. package/Gamepads/Controllers/gearVRController.d.ts +0 -39
  317. package/Gamepads/Controllers/gearVRController.js +0 -79
  318. package/Gamepads/Controllers/gearVRController.js.map +0 -1
  319. package/Gamepads/Controllers/genericController.d.ts +0 -34
  320. package/Gamepads/Controllers/genericController.js +0 -48
  321. package/Gamepads/Controllers/genericController.js.map +0 -1
  322. package/Gamepads/Controllers/index.d.ts +0 -8
  323. package/Gamepads/Controllers/index.js +0 -9
  324. package/Gamepads/Controllers/index.js.map +0 -1
  325. package/Gamepads/Controllers/oculusTouchController.d.ts +0 -78
  326. package/Gamepads/Controllers/oculusTouchController.js +0 -196
  327. package/Gamepads/Controllers/oculusTouchController.js.map +0 -1
  328. package/Gamepads/Controllers/poseEnabledController.d.ts +0 -219
  329. package/Gamepads/Controllers/poseEnabledController.js +0 -293
  330. package/Gamepads/Controllers/poseEnabledController.js.map +0 -1
  331. package/Gamepads/Controllers/viveController.d.ts +0 -52
  332. package/Gamepads/Controllers/viveController.js +0 -115
  333. package/Gamepads/Controllers/viveController.js.map +0 -1
  334. package/Gamepads/Controllers/webVRController.d.ts +0 -85
  335. package/Gamepads/Controllers/webVRController.js +0 -122
  336. package/Gamepads/Controllers/webVRController.js.map +0 -1
  337. package/Gamepads/Controllers/windowsMotionController.d.ts +0 -212
  338. package/Gamepads/Controllers/windowsMotionController.js +0 -519
  339. package/Gamepads/Controllers/windowsMotionController.js.map +0 -1
  340. package/Materials/greasedLinePluginMaterial.d.ts +0 -496
  341. package/Materials/greasedLinePluginMaterial.js.map +0 -1
  342. package/Materials/greasedLineSimpleMaterial.js.map +0 -1
  343. package/Meshes/greasedLineMesh.d.ts +0 -204
  344. package/Meshes/greasedLineMesh.js.map +0 -1
@@ -1,519 +0,0 @@
1
- import { Logger } from "../../Misc/logger.js";
2
- import { Observable } from "../../Misc/observable.js";
3
- import { Quaternion, Vector3 } from "../../Maths/math.vector.js";
4
- import { Mesh } from "../../Meshes/mesh.js";
5
- import { Ray } from "../../Culling/ray.js";
6
- import { SceneLoader } from "../../Loading/sceneLoader.js";
7
- import { WebVRController } from "./webVRController.js";
8
- import { GenericController } from "./genericController.js";
9
- import { PoseEnabledController, PoseEnabledControllerType, PoseEnabledControllerHelper } from "./poseEnabledController.js";
10
- /**
11
- * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
12
- */
13
- class LoadedMeshInfo {
14
- constructor() {
15
- /**
16
- * Map of the button meshes contained in the controller
17
- */
18
- this.buttonMeshes = {};
19
- /**
20
- * Map of the axis meshes contained in the controller
21
- */
22
- this.axisMeshes = {};
23
- }
24
- }
25
- /**
26
- * Defines the WindowsMotionController object that the state of the windows motion controller
27
- */
28
- export class WindowsMotionController extends WebVRController {
29
- /**
30
- * Creates a new WindowsMotionController from a gamepad
31
- * @param vrGamepad the gamepad that the controller should be created from
32
- */
33
- constructor(vrGamepad) {
34
- super(vrGamepad);
35
- this._mapping = {
36
- // Semantic button names
37
- buttons: ["thumbstick", "trigger", "grip", "menu", "trackpad"],
38
- // trigger, grip, trackpad, thumbstick, menu
39
- // A mapping of the button name to glTF model node name
40
- // that should be transformed by button value.
41
- buttonMeshNames: {
42
- trigger: "SELECT",
43
- menu: "MENU",
44
- grip: "GRASP",
45
- thumbstick: "THUMBSTICK_PRESS",
46
- trackpad: "TOUCHPAD_PRESS",
47
- },
48
- // This mapping is used to translate from the Motion Controller to Babylon semantics
49
- buttonObservableNames: {
50
- trigger: "onTriggerStateChangedObservable",
51
- menu: "onSecondaryButtonStateChangedObservable",
52
- grip: "onMainButtonStateChangedObservable",
53
- thumbstick: "onPadStateChangedObservable",
54
- trackpad: "onTrackpadChangedObservable",
55
- },
56
- // A mapping of the axis name to glTF model node name
57
- // that should be transformed by axis value.
58
- // This array mirrors the browserGamepad.axes array, such that
59
- // the mesh corresponding to axis 0 is in this array index 0.
60
- axisMeshNames: ["THUMBSTICK_X", "THUMBSTICK_Y", "TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y"],
61
- // upside down in webxr
62
- pointingPoseMeshName: PoseEnabledController.POINTING_POSE,
63
- };
64
- /**
65
- * Fired when the trackpad on this controller is clicked
66
- */
67
- this.onTrackpadChangedObservable = new Observable();
68
- /**
69
- * Fired when the trackpad on this controller is modified
70
- */
71
- this.onTrackpadValuesChangedObservable = new Observable();
72
- /**
73
- * The current x and y values of this controller's trackpad
74
- */
75
- this.trackpad = { x: 0, y: 0 };
76
- this.controllerType = PoseEnabledControllerType.WINDOWS;
77
- this._loadedMeshInfo = null;
78
- }
79
- /**
80
- * Fired when the trigger on this controller is modified
81
- */
82
- get onTriggerButtonStateChangedObservable() {
83
- return this.onTriggerStateChangedObservable;
84
- }
85
- /**
86
- * Fired when the menu button on this controller is modified
87
- */
88
- get onMenuButtonStateChangedObservable() {
89
- return this.onSecondaryButtonStateChangedObservable;
90
- }
91
- /**
92
- * Fired when the grip button on this controller is modified
93
- */
94
- get onGripButtonStateChangedObservable() {
95
- return this.onMainButtonStateChangedObservable;
96
- }
97
- /**
98
- * Fired when the thumbstick button on this controller is modified
99
- */
100
- get onThumbstickButtonStateChangedObservable() {
101
- return this.onPadStateChangedObservable;
102
- }
103
- /**
104
- * Fired when the touchpad button on this controller is modified
105
- */
106
- get onTouchpadButtonStateChangedObservable() {
107
- return this.onTrackpadChangedObservable;
108
- }
109
- /**
110
- * Fired when the touchpad values on this controller are modified
111
- */
112
- get onTouchpadValuesChangedObservable() {
113
- return this.onTrackpadValuesChangedObservable;
114
- }
115
- _updateTrackpad() {
116
- if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
117
- this.trackpad.x = this.browserGamepad["axes"][this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_X")];
118
- this.trackpad.y = this.browserGamepad["axes"][this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_Y")];
119
- this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
120
- }
121
- }
122
- /**
123
- * Called once per frame by the engine.
124
- */
125
- update() {
126
- super.update();
127
- if (this.browserGamepad.axes) {
128
- this._updateTrackpad();
129
- // Only need to animate axes if there is a loaded mesh
130
- if (this._loadedMeshInfo) {
131
- for (let axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
132
- this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
133
- }
134
- }
135
- }
136
- }
137
- /**
138
- * Called once for each button that changed state since the last frame
139
- * @param buttonIdx Which button index changed
140
- * @param state New state of the button
141
- */
142
- _handleButtonChange(buttonIdx, state) {
143
- const buttonName = this._mapping.buttons[buttonIdx];
144
- if (!buttonName) {
145
- return;
146
- }
147
- // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
148
- this._updateTrackpad();
149
- // Only emit events for buttons that we know how to map from index to name
150
- const observable = this[this._mapping.buttonObservableNames[buttonName]];
151
- if (observable) {
152
- observable.notifyObservers(state);
153
- }
154
- this._lerpButtonTransform(buttonName, state.value);
155
- }
156
- /**
157
- * Moves the buttons on the controller mesh based on their current state
158
- * @param buttonName the name of the button to move
159
- * @param buttonValue the value of the button which determines the buttons new position
160
- */
161
- _lerpButtonTransform(buttonName, buttonValue) {
162
- // If there is no loaded mesh, there is nothing to transform.
163
- if (!this._loadedMeshInfo) {
164
- return;
165
- }
166
- const meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
167
- if (!meshInfo || !meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
168
- return;
169
- }
170
- Quaternion.SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
171
- Vector3.LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
172
- }
173
- /**
174
- * Moves the axis on the controller mesh based on its current state
175
- * @param axis the index of the axis
176
- * @param axisValue the value of the axis which determines the meshes new position
177
- * @internal
178
- */
179
- _lerpAxisTransform(axis, axisValue) {
180
- if (!this._loadedMeshInfo) {
181
- return;
182
- }
183
- const meshInfo = this._loadedMeshInfo.axisMeshes[axis];
184
- if (!meshInfo) {
185
- return;
186
- }
187
- if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
188
- return;
189
- }
190
- // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
191
- const lerpValue = axisValue * 0.5 + 0.5;
192
- Quaternion.SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
193
- Vector3.LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
194
- }
195
- /**
196
- * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
197
- * @param scene scene in which to add meshes
198
- * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
199
- * @param forceDefault
200
- */
201
- initControllerMesh(scene, meshLoaded, forceDefault = false) {
202
- let path;
203
- let filename;
204
- // Checking if GLB loader is present
205
- if (SceneLoader.IsPluginForExtensionAvailable(".glb")) {
206
- // Determine the device specific folder based on the ID suffix
207
- let device = "default";
208
- if (this.id && !forceDefault) {
209
- const match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
210
- device = (match && match[0]) || device;
211
- }
212
- // Hand
213
- if (this.hand === "left") {
214
- filename = WindowsMotionController.MODEL_LEFT_FILENAME;
215
- }
216
- else {
217
- // Right is the default if no hand is specified
218
- filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
219
- }
220
- path = WindowsMotionController.MODEL_BASE_URL + device + "/";
221
- }
222
- else {
223
- Logger.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models");
224
- path = GenericController.MODEL_BASE_URL;
225
- filename = GenericController.MODEL_FILENAME;
226
- }
227
- SceneLoader.ImportMesh("", path, filename, scene, (meshes) => {
228
- // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
229
- this._loadedMeshInfo = this._processModel(scene, meshes);
230
- if (!this._loadedMeshInfo) {
231
- return;
232
- }
233
- this._defaultModel = this._loadedMeshInfo.rootNode;
234
- this.attachToMesh(this._defaultModel);
235
- if (meshLoaded) {
236
- meshLoaded(this._defaultModel);
237
- }
238
- }, null, (scene, message) => {
239
- Logger.Log(message);
240
- Logger.Warn("Failed to retrieve controller model from the remote server: " + path + filename);
241
- if (!forceDefault) {
242
- this.initControllerMesh(scene, meshLoaded, true);
243
- }
244
- });
245
- }
246
- /**
247
- * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
248
- * can be transformed by button presses and axes values, based on this._mapping.
249
- *
250
- * @param scene scene in which the meshes exist
251
- * @param meshes list of meshes that make up the controller model to process
252
- * @returns structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
253
- */
254
- _processModel(scene, meshes) {
255
- let loadedMeshInfo = null;
256
- // Create a new mesh to contain the glTF hierarchy
257
- const parentMesh = new Mesh(this.id + " " + this.hand, scene);
258
- // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
259
- let childMesh = null;
260
- for (let i = 0; i < meshes.length; i++) {
261
- const mesh = meshes[i];
262
- if (!mesh.parent) {
263
- // Exclude controller meshes from picking results
264
- mesh.isPickable = false;
265
- // Handle root node, attach to the new parentMesh
266
- childMesh = mesh;
267
- break;
268
- }
269
- }
270
- if (childMesh) {
271
- childMesh.setParent(parentMesh);
272
- // Create our mesh info. Note that this method will always return non-null.
273
- loadedMeshInfo = this._createMeshInfo(parentMesh);
274
- }
275
- else {
276
- Logger.Warn("Could not find root node in model file.");
277
- }
278
- return loadedMeshInfo;
279
- }
280
- _createMeshInfo(rootNode) {
281
- const loadedMeshInfo = new LoadedMeshInfo();
282
- let i;
283
- loadedMeshInfo.rootNode = rootNode;
284
- // Reset the caches
285
- loadedMeshInfo.buttonMeshes = {};
286
- loadedMeshInfo.axisMeshes = {};
287
- // Button Meshes
288
- for (i = 0; i < this._mapping.buttons.length; i++) {
289
- const buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
290
- if (!buttonMeshName) {
291
- Logger.Log("Skipping unknown button at index: " + i + " with mapped name: " + this._mapping.buttons[i]);
292
- continue;
293
- }
294
- const buttonMesh = getChildByName(rootNode, buttonMeshName);
295
- if (!buttonMesh) {
296
- Logger.Warn("Missing button mesh with name: " + buttonMeshName);
297
- continue;
298
- }
299
- const buttonMeshInfo = {
300
- index: i,
301
- value: getImmediateChildByName(buttonMesh, "VALUE"),
302
- pressed: getImmediateChildByName(buttonMesh, "PRESSED"),
303
- unpressed: getImmediateChildByName(buttonMesh, "UNPRESSED"),
304
- };
305
- if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
306
- loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
307
- }
308
- else {
309
- // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
310
- Logger.Warn("Missing button submesh under mesh with name: " +
311
- buttonMeshName +
312
- "(VALUE: " +
313
- !!buttonMeshInfo.value +
314
- ", PRESSED: " +
315
- !!buttonMeshInfo.pressed +
316
- ", UNPRESSED:" +
317
- !!buttonMeshInfo.unpressed +
318
- ")");
319
- }
320
- }
321
- // Axis Meshes
322
- for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
323
- const axisMeshName = this._mapping.axisMeshNames[i];
324
- if (!axisMeshName) {
325
- Logger.Log("Skipping unknown axis at index: " + i);
326
- continue;
327
- }
328
- const axisMesh = getChildByName(rootNode, axisMeshName);
329
- if (!axisMesh) {
330
- Logger.Warn("Missing axis mesh with name: " + axisMeshName);
331
- continue;
332
- }
333
- const axisMeshInfo = {
334
- index: i,
335
- value: getImmediateChildByName(axisMesh, "VALUE"),
336
- min: getImmediateChildByName(axisMesh, "MIN"),
337
- max: getImmediateChildByName(axisMesh, "MAX"),
338
- };
339
- if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
340
- loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
341
- }
342
- else {
343
- // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
344
- Logger.Warn("Missing axis submesh under mesh with name: " +
345
- axisMeshName +
346
- "(VALUE: " +
347
- !!axisMeshInfo.value +
348
- ", MIN: " +
349
- !!axisMeshInfo.min +
350
- ", MAX:" +
351
- !!axisMeshInfo.max +
352
- ")");
353
- }
354
- }
355
- // Pointing Ray
356
- loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
357
- if (!loadedMeshInfo.pointingPoseNode) {
358
- Logger.Warn("Missing pointing pose mesh with name: " + this._mapping.pointingPoseMeshName);
359
- }
360
- else {
361
- this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
362
- }
363
- return loadedMeshInfo;
364
- // Look through all children recursively. This will return null if no mesh exists with the given name.
365
- function getChildByName(node, name) {
366
- return node.getChildren((n) => n.name === name, false)[0];
367
- }
368
- // Look through only immediate children. This will return null if no mesh exists with the given name.
369
- function getImmediateChildByName(node, name) {
370
- return node.getChildren((n) => n.name == name, true)[0];
371
- }
372
- }
373
- /**
374
- * Gets the ray of the controller in the direction the controller is pointing
375
- * @param length the length the resulting ray should be
376
- * @returns a ray in the direction the controller is pointing
377
- */
378
- getForwardRay(length = 100) {
379
- if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
380
- return super.getForwardRay(length);
381
- }
382
- const m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
383
- const origin = m.getTranslation();
384
- const forward = new Vector3(0, 0, -1);
385
- const forwardWorld = Vector3.TransformNormal(forward, m);
386
- const direction = Vector3.Normalize(forwardWorld);
387
- return new Ray(origin, direction, length);
388
- }
389
- /**
390
- * Disposes of the controller
391
- */
392
- dispose() {
393
- super.dispose();
394
- this.onTrackpadChangedObservable.clear();
395
- this.onTrackpadValuesChangedObservable.clear();
396
- }
397
- }
398
- /**
399
- * The base url used to load the left and right controller models
400
- */
401
- WindowsMotionController.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/";
402
- /**
403
- * The name of the left controller model file
404
- */
405
- WindowsMotionController.MODEL_LEFT_FILENAME = "left.glb";
406
- /**
407
- * The name of the right controller model file
408
- */
409
- WindowsMotionController.MODEL_RIGHT_FILENAME = "right.glb";
410
- /**
411
- * The controller name prefix for this controller type
412
- */
413
- WindowsMotionController.GAMEPAD_ID_PREFIX = "Spatial Controller (Spatial Interaction Source) ";
414
- /**
415
- * The controller id pattern for this controller type
416
- */
417
- // eslint-disable-next-line @typescript-eslint/naming-convention
418
- WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
419
- /**
420
- * This class represents a new windows motion controller in XR.
421
- */
422
- export class XRWindowsMotionController extends WindowsMotionController {
423
- /**
424
- * Construct a new XR-Based windows motion controller
425
- *
426
- * @param gamepadInfo the gamepad object from the browser
427
- */
428
- constructor(gamepadInfo) {
429
- super(gamepadInfo);
430
- /**
431
- * Changing the original WIndowsMotionController mapping to fir the new mapping
432
- */
433
- this._mapping = {
434
- // Semantic button names
435
- buttons: ["trigger", "grip", "trackpad", "thumbstick", "menu"],
436
- // trigger, grip, trackpad, thumbstick, menu
437
- // A mapping of the button name to glTF model node name
438
- // that should be transformed by button value.
439
- buttonMeshNames: {
440
- trigger: "SELECT",
441
- menu: "MENU",
442
- grip: "GRASP",
443
- thumbstick: "THUMBSTICK_PRESS",
444
- trackpad: "TOUCHPAD_PRESS",
445
- },
446
- // This mapping is used to translate from the Motion Controller to Babylon semantics
447
- buttonObservableNames: {
448
- trigger: "onTriggerStateChangedObservable",
449
- menu: "onSecondaryButtonStateChangedObservable",
450
- grip: "onMainButtonStateChangedObservable",
451
- thumbstick: "onThumbstickStateChangedObservable",
452
- trackpad: "onTrackpadChangedObservable",
453
- },
454
- // A mapping of the axis name to glTF model node name
455
- // that should be transformed by axis value.
456
- // This array mirrors the browserGamepad.axes array, such that
457
- // the mesh corresponding to axis 0 is in this array index 0.
458
- axisMeshNames: ["TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y", "THUMBSTICK_X", "THUMBSTICK_Y"],
459
- // upside down in webxr
460
- pointingPoseMeshName: PoseEnabledController.POINTING_POSE,
461
- };
462
- /**
463
- * holds the thumbstick values (X,Y)
464
- */
465
- this.thumbstickValues = { x: 0, y: 0 };
466
- /**
467
- * Fired when the thumbstick on this controller is clicked
468
- */
469
- this.onThumbstickStateChangedObservable = new Observable();
470
- /**
471
- * Fired when the thumbstick on this controller is modified
472
- */
473
- this.onThumbstickValuesChangedObservable = new Observable();
474
- /**
475
- * Fired when the touchpad button on this controller is modified
476
- */
477
- this.onTrackpadChangedObservable = this.onPadStateChangedObservable;
478
- /**
479
- * Fired when the touchpad values on this controller are modified
480
- */
481
- this.onTrackpadValuesChangedObservable = this.onPadValuesChangedObservable;
482
- }
483
- /**
484
- * Fired when the thumbstick button on this controller is modified
485
- * here to prevent breaking changes
486
- */
487
- get onThumbstickButtonStateChangedObservable() {
488
- return this.onThumbstickStateChangedObservable;
489
- }
490
- /**
491
- * updating the thumbstick(!) and not the trackpad.
492
- * This is named this way due to the difference between WebVR and XR and to avoid
493
- * changing the parent class.
494
- */
495
- _updateTrackpad() {
496
- if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.thumbstickValues.x || this.browserGamepad.axes[3] != this.thumbstickValues.y)) {
497
- this.trackpad.x = this.browserGamepad["axes"][2];
498
- this.trackpad.y = this.browserGamepad["axes"][3];
499
- this.onThumbstickValuesChangedObservable.notifyObservers(this.trackpad);
500
- }
501
- }
502
- /**
503
- * Disposes the class with joy
504
- */
505
- dispose() {
506
- super.dispose();
507
- this.onThumbstickStateChangedObservable.clear();
508
- this.onThumbstickValuesChangedObservable.clear();
509
- }
510
- }
511
- PoseEnabledControllerHelper._ControllerFactories.push({
512
- canCreate: (gamepadInfo) => {
513
- return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
514
- },
515
- create: (gamepadInfo) => {
516
- return new WindowsMotionController(gamepadInfo);
517
- },
518
- });
519
- //# sourceMappingURL=windowsMotionController.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"windowsMotionController.js","sourceRoot":"","sources":["../../../../../dev/core/src/Gamepads/Controllers/windowsMotionController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAGxH;;GAEG;AACH,MAAM,cAAc;IAApB;QASI;;WAEG;QACI,iBAAY,GAAsC,EAAE,CAAC;QAC5D;;WAEG;QACI,eAAU,GAAoC,EAAE,CAAC;IAC5D,CAAC;CAAA;AA4CD;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,eAAe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GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,IAAI,CAAC,mCAAmC,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC3E;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,CAAC;QAChD,IAAI,CAAC,mCAAmC,CAAC,KAAK,EAAE,CAAC;IACrD,CAAC;CACJ;AAED,2BAA2B,CAAC,oBAAoB,CAAC,IAAI,CAAC;IAClD,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE;QACvB,OAAO,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE;QACpB,OAAO,IAAI,uBAAuB,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACJ,CAAC,CAAC","sourcesContent":["import { Logger } from \"../../Misc/logger\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Quaternion, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Node } from \"../../node\";\r\nimport { Mesh } from \"../../Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Ray } from \"../../Culling/ray\";\r\nimport { SceneLoader } from \"../../Loading/sceneLoader\";\r\nimport { WebVRController } from \"./webVRController\";\r\nimport { GenericController } from \"./genericController\";\r\nimport type { ExtendedGamepadButton } from \"./poseEnabledController\";\r\nimport { PoseEnabledController, PoseEnabledControllerType, PoseEnabledControllerHelper } from \"./poseEnabledController\";\r\nimport type { StickValues } from \"../../Gamepads/gamepad\";\r\n\r\n/**\r\n * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh\r\n */\r\nclass LoadedMeshInfo {\r\n /**\r\n * Root of the mesh\r\n */\r\n public rootNode: AbstractMesh;\r\n /**\r\n * Node of the mesh corresponding to the direction the ray should be cast from the controller\r\n */\r\n public pointingPoseNode: TransformNode;\r\n /**\r\n * Map of the button meshes contained in the controller\r\n */\r\n public buttonMeshes: { [id: string]: IButtonMeshInfo } = {};\r\n /**\r\n * Map of the axis meshes contained in the controller\r\n */\r\n public axisMeshes: { [id: number]: IAxisMeshInfo } = {};\r\n}\r\n\r\n/**\r\n * Defines the IMeshInfo object that describes information a webvr controller mesh\r\n */\r\ninterface IMeshInfo {\r\n /**\r\n * Index of the mesh inside the root mesh\r\n */\r\n index: number;\r\n /**\r\n * The mesh\r\n */\r\n value: TransformNode;\r\n}\r\n\r\n/**\r\n * Defines the IButtonMeshInfo object that describes a button mesh\r\n */\r\ninterface IButtonMeshInfo extends IMeshInfo {\r\n /**\r\n * The mesh that should be displayed when pressed\r\n */\r\n pressed: TransformNode;\r\n /**\r\n * The mesh that should be displayed when not pressed\r\n */\r\n unpressed: TransformNode;\r\n}\r\n\r\n/**\r\n * Defines the IAxisMeshInfo object that describes an axis mesh\r\n */\r\ninterface IAxisMeshInfo extends IMeshInfo {\r\n /**\r\n * The mesh that should be set when at its min\r\n */\r\n min: TransformNode;\r\n /**\r\n * The mesh that should be set when at its max\r\n */\r\n max: TransformNode;\r\n}\r\n\r\n/**\r\n * Defines the WindowsMotionController object that the state of the windows motion controller\r\n */\r\nexport class WindowsMotionController extends WebVRController {\r\n /**\r\n * The base url used to load the left and right controller models\r\n */\r\n public static MODEL_BASE_URL: string = \"https://controllers.babylonjs.com/microsoft/\";\r\n /**\r\n * The name of the left controller model file\r\n */\r\n public static MODEL_LEFT_FILENAME: string = \"left.glb\";\r\n /**\r\n * The name of the right controller model file\r\n */\r\n public static MODEL_RIGHT_FILENAME: string = \"right.glb\";\r\n\r\n /**\r\n * The controller name prefix for this controller type\r\n */\r\n public static readonly GAMEPAD_ID_PREFIX: string = \"Spatial Controller (Spatial Interaction Source) \";\r\n /**\r\n * The controller id pattern for this controller type\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private static readonly GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;\r\n\r\n private _loadedMeshInfo: Nullable<LoadedMeshInfo>;\r\n protected readonly _mapping = {\r\n // Semantic button names\r\n buttons: [\"thumbstick\", \"trigger\", \"grip\", \"menu\", \"trackpad\"],\r\n // trigger, grip, trackpad, thumbstick, menu\r\n\r\n // A mapping of the button name to glTF model node name\r\n // that should be transformed by button value.\r\n buttonMeshNames: {\r\n trigger: \"SELECT\",\r\n menu: \"MENU\",\r\n grip: \"GRASP\",\r\n thumbstick: \"THUMBSTICK_PRESS\",\r\n trackpad: \"TOUCHPAD_PRESS\",\r\n },\r\n // This mapping is used to translate from the Motion Controller to Babylon semantics\r\n buttonObservableNames: {\r\n trigger: \"onTriggerStateChangedObservable\",\r\n menu: \"onSecondaryButtonStateChangedObservable\",\r\n grip: \"onMainButtonStateChangedObservable\",\r\n thumbstick: \"onPadStateChangedObservable\",\r\n trackpad: \"onTrackpadChangedObservable\",\r\n },\r\n // A mapping of the axis name to glTF model node name\r\n // that should be transformed by axis value.\r\n // This array mirrors the browserGamepad.axes array, such that\r\n // the mesh corresponding to axis 0 is in this array index 0.\r\n axisMeshNames: [\"THUMBSTICK_X\", \"THUMBSTICK_Y\", \"TOUCHPAD_TOUCH_X\", \"TOUCHPAD_TOUCH_Y\"],\r\n // upside down in webxr\r\n pointingPoseMeshName: PoseEnabledController.POINTING_POSE,\r\n };\r\n\r\n /**\r\n * Fired when the trackpad on this controller is clicked\r\n */\r\n public onTrackpadChangedObservable = new Observable<ExtendedGamepadButton>();\r\n /**\r\n * Fired when the trackpad on this controller is modified\r\n */\r\n public onTrackpadValuesChangedObservable = new Observable<StickValues>();\r\n /**\r\n * The current x and y values of this controller's trackpad\r\n */\r\n public trackpad: StickValues = { x: 0, y: 0 };\r\n\r\n /**\r\n * Creates a new WindowsMotionController from a gamepad\r\n * @param vrGamepad the gamepad that the controller should be created from\r\n */\r\n constructor(vrGamepad: any) {\r\n super(vrGamepad);\r\n this.controllerType = PoseEnabledControllerType.WINDOWS;\r\n this._loadedMeshInfo = null;\r\n }\r\n\r\n /**\r\n * Fired when the trigger on this controller is modified\r\n */\r\n public get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {\r\n return this.onTriggerStateChangedObservable;\r\n }\r\n\r\n /**\r\n * Fired when the menu button on this controller is modified\r\n */\r\n public get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {\r\n return this.onSecondaryButtonStateChangedObservable;\r\n }\r\n\r\n /**\r\n * Fired when the grip button on this controller is modified\r\n */\r\n public get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {\r\n return this.onMainButtonStateChangedObservable;\r\n }\r\n\r\n /**\r\n * Fired when the thumbstick button on this controller is modified\r\n */\r\n public get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {\r\n return this.onPadStateChangedObservable;\r\n }\r\n\r\n /**\r\n * Fired when the touchpad button on this controller is modified\r\n */\r\n public get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {\r\n return this.onTrackpadChangedObservable;\r\n }\r\n\r\n /**\r\n * Fired when the touchpad values on this controller are modified\r\n */\r\n public get onTouchpadValuesChangedObservable(): Observable<StickValues> {\r\n return this.onTrackpadValuesChangedObservable;\r\n }\r\n\r\n protected _updateTrackpad() {\r\n if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {\r\n this.trackpad.x = this.browserGamepad[\"axes\"][this._mapping.axisMeshNames.indexOf(\"TOUCHPAD_TOUCH_X\")];\r\n this.trackpad.y = this.browserGamepad[\"axes\"][this._mapping.axisMeshNames.indexOf(\"TOUCHPAD_TOUCH_Y\")];\r\n this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);\r\n }\r\n }\r\n\r\n /**\r\n * Called once per frame by the engine.\r\n */\r\n public update() {\r\n super.update();\r\n if (this.browserGamepad.axes) {\r\n this._updateTrackpad();\r\n // Only need to animate axes if there is a loaded mesh\r\n if (this._loadedMeshInfo) {\r\n for (let axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {\r\n this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Called once for each button that changed state since the last frame\r\n * @param buttonIdx Which button index changed\r\n * @param state New state of the button\r\n */\r\n protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton) {\r\n const buttonName = this._mapping.buttons[buttonIdx];\r\n if (!buttonName) {\r\n return;\r\n }\r\n\r\n // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames\r\n this._updateTrackpad();\r\n\r\n // Only emit events for buttons that we know how to map from index to name\r\n const observable = (<any>this)[(<any>this._mapping.buttonObservableNames)[buttonName]];\r\n if (observable) {\r\n observable.notifyObservers(state);\r\n }\r\n\r\n this._lerpButtonTransform(buttonName, state.value);\r\n }\r\n\r\n /**\r\n * Moves the buttons on the controller mesh based on their current state\r\n * @param buttonName the name of the button to move\r\n * @param buttonValue the value of the button which determines the buttons new position\r\n */\r\n protected _lerpButtonTransform(buttonName: string, buttonValue: number) {\r\n // If there is no loaded mesh, there is nothing to transform.\r\n if (!this._loadedMeshInfo) {\r\n return;\r\n }\r\n\r\n const meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];\r\n\r\n if (!meshInfo || !meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {\r\n return;\r\n }\r\n\r\n Quaternion.SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);\r\n Vector3.LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);\r\n }\r\n\r\n /**\r\n * Moves the axis on the controller mesh based on its current state\r\n * @param axis the index of the axis\r\n * @param axisValue the value of the axis which determines the meshes new position\r\n * @internal\r\n */\r\n protected _lerpAxisTransform(axis: number, axisValue: number) {\r\n if (!this._loadedMeshInfo) {\r\n return;\r\n }\r\n\r\n const meshInfo = this._loadedMeshInfo.axisMeshes[axis];\r\n if (!meshInfo) {\r\n return;\r\n }\r\n\r\n if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {\r\n return;\r\n }\r\n\r\n // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)\r\n const lerpValue = axisValue * 0.5 + 0.5;\r\n Quaternion.SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);\r\n Vector3.LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);\r\n }\r\n\r\n /**\r\n * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.\r\n * @param scene scene in which to add meshes\r\n * @param meshLoaded optional callback function that will be called if the mesh loads successfully.\r\n * @param forceDefault\r\n */\r\n public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault = false) {\r\n let path: string;\r\n let filename: string;\r\n\r\n // Checking if GLB loader is present\r\n if (SceneLoader.IsPluginForExtensionAvailable(\".glb\")) {\r\n // Determine the device specific folder based on the ID suffix\r\n let device = \"default\";\r\n if (this.id && !forceDefault) {\r\n const match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);\r\n device = (match && match[0]) || device;\r\n }\r\n\r\n // Hand\r\n if (this.hand === \"left\") {\r\n filename = WindowsMotionController.MODEL_LEFT_FILENAME;\r\n } else {\r\n // Right is the default if no hand is specified\r\n filename = WindowsMotionController.MODEL_RIGHT_FILENAME;\r\n }\r\n\r\n path = WindowsMotionController.MODEL_BASE_URL + device + \"/\";\r\n } else {\r\n Logger.Warn(\"You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models\");\r\n path = GenericController.MODEL_BASE_URL;\r\n filename = GenericController.MODEL_FILENAME;\r\n }\r\n\r\n SceneLoader.ImportMesh(\r\n \"\",\r\n path,\r\n filename,\r\n scene,\r\n (meshes: AbstractMesh[]) => {\r\n // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.\r\n this._loadedMeshInfo = this._processModel(scene, meshes);\r\n\r\n if (!this._loadedMeshInfo) {\r\n return;\r\n }\r\n\r\n this._defaultModel = this._loadedMeshInfo.rootNode;\r\n this.attachToMesh(this._defaultModel);\r\n\r\n if (meshLoaded) {\r\n meshLoaded(this._defaultModel);\r\n }\r\n },\r\n null,\r\n (scene: Scene, message: string) => {\r\n Logger.Log(message);\r\n Logger.Warn(\"Failed to retrieve controller model from the remote server: \" + path + filename);\r\n if (!forceDefault) {\r\n this.initControllerMesh(scene, meshLoaded, true);\r\n }\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that\r\n * can be transformed by button presses and axes values, based on this._mapping.\r\n *\r\n * @param scene scene in which the meshes exist\r\n * @param meshes list of meshes that make up the controller model to process\r\n * @returns structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.\r\n */\r\n private _processModel(scene: Scene, meshes: AbstractMesh[]): Nullable<LoadedMeshInfo> {\r\n let loadedMeshInfo = null;\r\n\r\n // Create a new mesh to contain the glTF hierarchy\r\n const parentMesh = new Mesh(this.id + \" \" + this.hand, scene);\r\n\r\n // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'\r\n let childMesh: Nullable<AbstractMesh> = null;\r\n for (let i = 0; i < meshes.length; i++) {\r\n const mesh = meshes[i];\r\n\r\n if (!mesh.parent) {\r\n // Exclude controller meshes from picking results\r\n mesh.isPickable = false;\r\n\r\n // Handle root node, attach to the new parentMesh\r\n childMesh = mesh;\r\n break;\r\n }\r\n }\r\n\r\n if (childMesh) {\r\n childMesh.setParent(parentMesh);\r\n\r\n // Create our mesh info. Note that this method will always return non-null.\r\n loadedMeshInfo = this._createMeshInfo(parentMesh);\r\n } else {\r\n Logger.Warn(\"Could not find root node in model file.\");\r\n }\r\n\r\n return loadedMeshInfo;\r\n }\r\n\r\n private _createMeshInfo(rootNode: AbstractMesh): LoadedMeshInfo {\r\n const loadedMeshInfo = new LoadedMeshInfo();\r\n let i;\r\n loadedMeshInfo.rootNode = rootNode;\r\n\r\n // Reset the caches\r\n loadedMeshInfo.buttonMeshes = {};\r\n loadedMeshInfo.axisMeshes = {};\r\n\r\n // Button Meshes\r\n for (i = 0; i < this._mapping.buttons.length; i++) {\r\n const buttonMeshName = (<any>this._mapping.buttonMeshNames)[this._mapping.buttons[i]];\r\n if (!buttonMeshName) {\r\n Logger.Log(\"Skipping unknown button at index: \" + i + \" with mapped name: \" + this._mapping.buttons[i]);\r\n continue;\r\n }\r\n\r\n const buttonMesh = getChildByName(rootNode, buttonMeshName);\r\n if (!buttonMesh) {\r\n Logger.Warn(\"Missing button mesh with name: \" + buttonMeshName);\r\n continue;\r\n }\r\n\r\n const buttonMeshInfo = {\r\n index: i,\r\n value: getImmediateChildByName(buttonMesh, \"VALUE\"),\r\n pressed: getImmediateChildByName(buttonMesh, \"PRESSED\"),\r\n unpressed: getImmediateChildByName(buttonMesh, \"UNPRESSED\"),\r\n };\r\n if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {\r\n loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;\r\n } else {\r\n // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.\r\n Logger.Warn(\r\n \"Missing button submesh under mesh with name: \" +\r\n buttonMeshName +\r\n \"(VALUE: \" +\r\n !!buttonMeshInfo.value +\r\n \", PRESSED: \" +\r\n !!buttonMeshInfo.pressed +\r\n \", UNPRESSED:\" +\r\n !!buttonMeshInfo.unpressed +\r\n \")\"\r\n );\r\n }\r\n }\r\n\r\n // Axis Meshes\r\n for (i = 0; i < this._mapping.axisMeshNames.length; i++) {\r\n const axisMeshName = this._mapping.axisMeshNames[i];\r\n if (!axisMeshName) {\r\n Logger.Log(\"Skipping unknown axis at index: \" + i);\r\n continue;\r\n }\r\n\r\n const axisMesh = getChildByName(rootNode, axisMeshName);\r\n if (!axisMesh) {\r\n Logger.Warn(\"Missing axis mesh with name: \" + axisMeshName);\r\n continue;\r\n }\r\n\r\n const axisMeshInfo = {\r\n index: i,\r\n value: getImmediateChildByName(axisMesh, \"VALUE\"),\r\n min: getImmediateChildByName(axisMesh, \"MIN\"),\r\n max: getImmediateChildByName(axisMesh, \"MAX\"),\r\n };\r\n if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {\r\n loadedMeshInfo.axisMeshes[i] = axisMeshInfo;\r\n } else {\r\n // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.\r\n Logger.Warn(\r\n \"Missing axis submesh under mesh with name: \" +\r\n axisMeshName +\r\n \"(VALUE: \" +\r\n !!axisMeshInfo.value +\r\n \", MIN: \" +\r\n !!axisMeshInfo.min +\r\n \", MAX:\" +\r\n !!axisMeshInfo.max +\r\n \")\"\r\n );\r\n }\r\n }\r\n\r\n // Pointing Ray\r\n loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);\r\n if (!loadedMeshInfo.pointingPoseNode) {\r\n Logger.Warn(\"Missing pointing pose mesh with name: \" + this._mapping.pointingPoseMeshName);\r\n } else {\r\n this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;\r\n }\r\n\r\n return loadedMeshInfo;\r\n\r\n // Look through all children recursively. This will return null if no mesh exists with the given name.\r\n function getChildByName(node: Node, name: string) {\r\n return <TransformNode>node.getChildren((n) => n.name === name, false)[0];\r\n }\r\n // Look through only immediate children. This will return null if no mesh exists with the given name.\r\n function getImmediateChildByName(node: Node, name: string): TransformNode {\r\n return <TransformNode>node.getChildren((n) => n.name == name, true)[0];\r\n }\r\n }\r\n\r\n /**\r\n * Gets the ray of the controller in the direction the controller is pointing\r\n * @param length the length the resulting ray should be\r\n * @returns a ray in the direction the controller is pointing\r\n */\r\n public getForwardRay(length = 100): Ray {\r\n if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {\r\n return super.getForwardRay(length);\r\n }\r\n\r\n const m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();\r\n const origin = m.getTranslation();\r\n\r\n const forward = new Vector3(0, 0, -1);\r\n const forwardWorld = Vector3.TransformNormal(forward, m);\r\n\r\n const direction = Vector3.Normalize(forwardWorld);\r\n\r\n return new Ray(origin, direction, length);\r\n }\r\n\r\n /**\r\n * Disposes of the controller\r\n */\r\n public dispose(): void {\r\n super.dispose();\r\n\r\n this.onTrackpadChangedObservable.clear();\r\n this.onTrackpadValuesChangedObservable.clear();\r\n }\r\n}\r\n\r\n/**\r\n * This class represents a new windows motion controller in XR.\r\n */\r\nexport class XRWindowsMotionController extends WindowsMotionController {\r\n /**\r\n * Changing the original WIndowsMotionController mapping to fir the new mapping\r\n */\r\n protected readonly _mapping = {\r\n // Semantic button names\r\n buttons: [\"trigger\", \"grip\", \"trackpad\", \"thumbstick\", \"menu\"],\r\n // trigger, grip, trackpad, thumbstick, menu\r\n\r\n // A mapping of the button name to glTF model node name\r\n // that should be transformed by button value.\r\n buttonMeshNames: {\r\n trigger: \"SELECT\",\r\n menu: \"MENU\",\r\n grip: \"GRASP\",\r\n thumbstick: \"THUMBSTICK_PRESS\",\r\n trackpad: \"TOUCHPAD_PRESS\",\r\n },\r\n // This mapping is used to translate from the Motion Controller to Babylon semantics\r\n buttonObservableNames: {\r\n trigger: \"onTriggerStateChangedObservable\",\r\n menu: \"onSecondaryButtonStateChangedObservable\",\r\n grip: \"onMainButtonStateChangedObservable\",\r\n thumbstick: \"onThumbstickStateChangedObservable\",\r\n trackpad: \"onTrackpadChangedObservable\",\r\n },\r\n // A mapping of the axis name to glTF model node name\r\n // that should be transformed by axis value.\r\n // This array mirrors the browserGamepad.axes array, such that\r\n // the mesh corresponding to axis 0 is in this array index 0.\r\n axisMeshNames: [\"TOUCHPAD_TOUCH_X\", \"TOUCHPAD_TOUCH_Y\", \"THUMBSTICK_X\", \"THUMBSTICK_Y\"],\r\n // upside down in webxr\r\n pointingPoseMeshName: PoseEnabledController.POINTING_POSE,\r\n };\r\n\r\n /**\r\n * Construct a new XR-Based windows motion controller\r\n *\r\n * @param gamepadInfo the gamepad object from the browser\r\n */\r\n constructor(gamepadInfo: any) {\r\n super(gamepadInfo);\r\n }\r\n\r\n /**\r\n * holds the thumbstick values (X,Y)\r\n */\r\n public thumbstickValues: StickValues = { x: 0, y: 0 };\r\n\r\n /**\r\n * Fired when the thumbstick on this controller is clicked\r\n */\r\n public onThumbstickStateChangedObservable = new Observable<ExtendedGamepadButton>();\r\n /**\r\n * Fired when the thumbstick on this controller is modified\r\n */\r\n public onThumbstickValuesChangedObservable = new Observable<StickValues>();\r\n\r\n /**\r\n * Fired when the touchpad button on this controller is modified\r\n */\r\n public onTrackpadChangedObservable = this.onPadStateChangedObservable;\r\n\r\n /**\r\n * Fired when the touchpad values on this controller are modified\r\n */\r\n public onTrackpadValuesChangedObservable = this.onPadValuesChangedObservable;\r\n\r\n /**\r\n * Fired when the thumbstick button on this controller is modified\r\n * here to prevent breaking changes\r\n */\r\n public get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {\r\n return this.onThumbstickStateChangedObservable;\r\n }\r\n\r\n /**\r\n * updating the thumbstick(!) and not the trackpad.\r\n * This is named this way due to the difference between WebVR and XR and to avoid\r\n * changing the parent class.\r\n */\r\n protected _updateTrackpad() {\r\n if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.thumbstickValues.x || this.browserGamepad.axes[3] != this.thumbstickValues.y)) {\r\n this.trackpad.x = this.browserGamepad[\"axes\"][2];\r\n this.trackpad.y = this.browserGamepad[\"axes\"][3];\r\n this.onThumbstickValuesChangedObservable.notifyObservers(this.trackpad);\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the class with joy\r\n */\r\n public dispose() {\r\n super.dispose();\r\n this.onThumbstickStateChangedObservable.clear();\r\n this.onThumbstickValuesChangedObservable.clear();\r\n }\r\n}\r\n\r\nPoseEnabledControllerHelper._ControllerFactories.push({\r\n canCreate: (gamepadInfo) => {\r\n return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;\r\n },\r\n create: (gamepadInfo) => {\r\n return new WindowsMotionController(gamepadInfo);\r\n },\r\n});\r\n"]}