@babylonjs/core 6.41.0 → 6.41.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 (650) hide show
  1. package/Animations/animatable.js +1 -2
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/animation.js +4 -6
  4. package/Animations/animation.js.map +1 -1
  5. package/Animations/animationGroup.js +3 -3
  6. package/Animations/animationGroup.js.map +1 -1
  7. package/Animations/runtimeAnimation.js +1 -1
  8. package/Animations/runtimeAnimation.js.map +1 -1
  9. package/Audio/audioEngine.js +3 -5
  10. package/Audio/audioEngine.js.map +1 -1
  11. package/Audio/audioSceneComponent.js +1 -2
  12. package/Audio/audioSceneComponent.js.map +1 -1
  13. package/Audio/sound.js +48 -74
  14. package/Audio/sound.js.map +1 -1
  15. package/Audio/soundTrack.js +6 -12
  16. package/Audio/soundTrack.js.map +1 -1
  17. package/BakedVertexAnimation/bakedVertexAnimationManager.js +1 -2
  18. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  19. package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
  20. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  21. package/Behaviors/Meshes/fadeInOutBehavior.js +2 -4
  22. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  23. package/Behaviors/Meshes/followBehavior.js +1 -2
  24. package/Behaviors/Meshes/followBehavior.js.map +1 -1
  25. package/Behaviors/Meshes/handConstraintBehavior.js +2 -2
  26. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  27. package/Bones/bone.js +4 -6
  28. package/Bones/bone.js.map +1 -1
  29. package/Bones/skeleton.js +2 -3
  30. package/Bones/skeleton.js.map +1 -1
  31. package/Buffers/buffer.align.js +5 -8
  32. package/Buffers/buffer.align.js.map +1 -1
  33. package/Buffers/buffer.js +6 -8
  34. package/Buffers/buffer.js.map +1 -1
  35. package/Cameras/Inputs/BaseCameraPointersInput.js +3 -4
  36. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  37. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +3 -5
  38. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  39. package/Cameras/Inputs/flyCameraMouseInput.js +2 -2
  40. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  41. package/Cameras/Inputs/freeCameraMouseInput.js +2 -2
  42. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  43. package/Cameras/arcRotateCamera.js +1 -2
  44. package/Cameras/arcRotateCamera.js.map +1 -1
  45. package/Cameras/camera.d.ts +5 -0
  46. package/Cameras/camera.js +18 -11
  47. package/Cameras/camera.js.map +1 -1
  48. package/Collisions/pickingInfo.js +1 -1
  49. package/Collisions/pickingInfo.js.map +1 -1
  50. package/Compute/computeEffect.js +5 -8
  51. package/Compute/computeEffect.js.map +1 -1
  52. package/Compute/computeShader.js +12 -9
  53. package/Compute/computeShader.js.map +1 -1
  54. package/Culling/Octrees/octreeSceneComponent.js +1 -2
  55. package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
  56. package/Culling/boundingBox.js +2 -3
  57. package/Culling/boundingBox.js.map +1 -1
  58. package/Culling/ray.d.ts +6 -1
  59. package/Culling/ray.js +9 -4
  60. package/Culling/ray.js.map +1 -1
  61. package/Debug/debugLayer.js +4 -1
  62. package/Debug/debugLayer.js.map +1 -1
  63. package/Debug/directionalLightFrustumViewer.js +7 -9
  64. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  65. package/Debug/physicsViewer.js +5 -7
  66. package/Debug/physicsViewer.js.map +1 -1
  67. package/Debug/rayHelper.js +1 -2
  68. package/Debug/rayHelper.js.map +1 -1
  69. package/Debug/skeletonViewer.js +26 -31
  70. package/Debug/skeletonViewer.js.map +1 -1
  71. package/Decorators/nodeDecorator.js +1 -1
  72. package/Decorators/nodeDecorator.js.map +1 -1
  73. package/DeviceInput/InputDevices/deviceSourceManager.js +3 -5
  74. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  75. package/DeviceInput/eventFactory.js +1 -1
  76. package/DeviceInput/eventFactory.js.map +1 -1
  77. package/DeviceInput/internalDeviceSourceManager.js +1 -2
  78. package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
  79. package/DeviceInput/webDeviceInputSystem.js +9 -12
  80. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  81. package/Engines/Extensions/engine.cubeTexture.js +6 -1
  82. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  83. package/Engines/Extensions/engine.multiRender.js +3 -4
  84. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  85. package/Engines/Extensions/engine.rawTexture.js +4 -4
  86. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  87. package/Engines/Extensions/engine.readTexture.js +2 -3
  88. package/Engines/Extensions/engine.readTexture.js.map +1 -1
  89. package/Engines/Extensions/engine.renderTarget.js +9 -5
  90. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  91. package/Engines/Extensions/engine.renderTargetCube.js +9 -1
  92. package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
  93. package/Engines/Extensions/engine.views.js +1 -2
  94. package/Engines/Extensions/engine.views.js.map +1 -1
  95. package/Engines/Processors/shaderCodeNode.js +6 -7
  96. package/Engines/Processors/shaderCodeNode.js.map +1 -1
  97. package/Engines/Processors/shaderProcessor.js +6 -11
  98. package/Engines/Processors/shaderProcessor.js.map +1 -1
  99. package/Engines/WebGL/webGLHardwareTexture.js +1 -2
  100. package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
  101. package/Engines/WebGL/webGLRenderTargetWrapper.js +3 -5
  102. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  103. package/Engines/WebGPU/Extensions/engine.cubeTexture.js +9 -2
  104. package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
  105. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +1 -2
  106. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
  107. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -6
  108. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  109. package/Engines/WebGPU/Extensions/engine.query.js +2 -4
  110. package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
  111. package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -4
  112. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  113. package/Engines/WebGPU/Extensions/engine.renderTarget.js +11 -5
  114. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  115. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js +11 -3
  116. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
  117. package/Engines/WebGPU/Extensions/engine.storageBuffer.js +2 -3
  118. package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
  119. package/Engines/WebGPU/Extensions/engine.textureSampler.js +1 -2
  120. package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
  121. package/Engines/WebGPU/Extensions/engine.videoTexture.js +1 -2
  122. package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
  123. package/Engines/WebGPU/webgpuBufferManager.js +1 -1
  124. package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
  125. package/Engines/WebGPU/webgpuCacheBindGroups.js +6 -7
  126. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  127. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +15 -20
  128. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  129. package/Engines/WebGPU/webgpuCacheSampler.js +10 -5
  130. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  131. package/Engines/WebGPU/webgpuClearQuad.js +2 -3
  132. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  133. package/Engines/WebGPU/webgpuComputePipelineContext.js +1 -2
  134. package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
  135. package/Engines/WebGPU/webgpuDepthCullingState.js +2 -2
  136. package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
  137. package/Engines/WebGPU/webgpuDrawContext.js +1 -2
  138. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  139. package/Engines/WebGPU/webgpuHardwareTexture.js +4 -6
  140. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  141. package/Engines/WebGPU/webgpuMaterialContext.js +2 -3
  142. package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
  143. package/Engines/WebGPU/webgpuOcclusionQuery.js +3 -5
  144. package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
  145. package/Engines/WebGPU/webgpuPipelineContext.js +2 -4
  146. package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
  147. package/Engines/WebGPU/webgpuQuerySet.js +1 -1
  148. package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
  149. package/Engines/WebGPU/webgpuShaderProcessingContext.js +2 -4
  150. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  151. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -4
  152. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  153. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +5 -4
  154. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  155. package/Engines/WebGPU/webgpuStencilStateComposer.js +1 -2
  156. package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
  157. package/Engines/WebGPU/webgpuTextureManager.js +40 -43
  158. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  159. package/Engines/WebGPU/webgpuTimestampQuery.js +12 -7
  160. package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
  161. package/Engines/WebGPU/webgpuTintWASM.js +4 -1
  162. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  163. package/Engines/engine.js +4 -7
  164. package/Engines/engine.js.map +1 -1
  165. package/Engines/nativeEngine.js +16 -22
  166. package/Engines/nativeEngine.js.map +1 -1
  167. package/Engines/nullEngine.js +9 -1
  168. package/Engines/nullEngine.js.map +1 -1
  169. package/Engines/renderTargetWrapper.js +11 -16
  170. package/Engines/renderTargetWrapper.js.map +1 -1
  171. package/Engines/thinEngine.js +32 -44
  172. package/Engines/thinEngine.js.map +1 -1
  173. package/Engines/webgpuEngine.js +77 -95
  174. package/Engines/webgpuEngine.js.map +1 -1
  175. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +2 -3
  176. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  177. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +3 -6
  178. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  179. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +1 -2
  180. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
  181. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +1 -2
  182. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
  183. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +2 -4
  184. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
  185. package/FlowGraph/flowGraph.js +1 -2
  186. package/FlowGraph/flowGraph.js.map +1 -1
  187. package/FlowGraph/flowGraphBlock.js +2 -4
  188. package/FlowGraph/flowGraphBlock.js.map +1 -1
  189. package/FlowGraph/flowGraphContext.js +1 -2
  190. package/FlowGraph/flowGraphContext.js.map +1 -1
  191. package/FlowGraph/flowGraphCoordinator.js +4 -7
  192. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  193. package/FlowGraph/flowGraphSignalConnection.js +1 -2
  194. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  195. package/FlowGraph/serialization.js +2 -3
  196. package/FlowGraph/serialization.js.map +1 -1
  197. package/Gamepads/gamepadManager.js +1 -1
  198. package/Gamepads/gamepadManager.js.map +1 -1
  199. package/Gizmos/axisDragGizmo.js +2 -4
  200. package/Gizmos/axisDragGizmo.js.map +1 -1
  201. package/Gizmos/axisScaleGizmo.js +5 -8
  202. package/Gizmos/axisScaleGizmo.js.map +1 -1
  203. package/Gizmos/boundingBoxGizmo.js +1 -1
  204. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  205. package/Gizmos/cameraGizmo.js +2 -3
  206. package/Gizmos/cameraGizmo.js.map +1 -1
  207. package/Gizmos/gizmo.js +4 -7
  208. package/Gizmos/gizmo.js.map +1 -1
  209. package/Gizmos/gizmoManager.js +3 -4
  210. package/Gizmos/gizmoManager.js.map +1 -1
  211. package/Gizmos/planeDragGizmo.js +2 -4
  212. package/Gizmos/planeDragGizmo.js.map +1 -1
  213. package/Gizmos/planeRotationGizmo.js +2 -4
  214. package/Gizmos/planeRotationGizmo.js.map +1 -1
  215. package/Helpers/environmentHelper.js +8 -2
  216. package/Helpers/environmentHelper.js.map +1 -1
  217. package/Helpers/videoDome.js +1 -2
  218. package/Helpers/videoDome.js.map +1 -1
  219. package/Inputs/scene.inputManager.js +8 -10
  220. package/Inputs/scene.inputManager.js.map +1 -1
  221. package/Layers/effectLayer.js +16 -10
  222. package/Layers/effectLayer.js.map +1 -1
  223. package/Layers/glowLayer.js +16 -6
  224. package/Layers/glowLayer.js.map +1 -1
  225. package/Layers/highlightLayer.js +12 -3
  226. package/Layers/highlightLayer.js.map +1 -1
  227. package/Layers/layer.js +1 -2
  228. package/Layers/layer.js.map +1 -1
  229. package/LensFlares/lensFlareSystem.js +1 -2
  230. package/LensFlares/lensFlareSystem.js.map +1 -1
  231. package/Lights/Shadows/cascadedShadowGenerator.js +21 -25
  232. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  233. package/Lights/Shadows/shadowGenerator.js +18 -21
  234. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  235. package/Lights/light.js +2 -4
  236. package/Lights/light.js.map +1 -1
  237. package/Lights/shadowLight.js +1 -1
  238. package/Lights/shadowLight.js.map +1 -1
  239. package/Loading/Plugins/babylonFileLoader.js +1 -2
  240. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  241. package/Loading/sceneLoader.js +1 -1
  242. package/Loading/sceneLoader.js.map +1 -1
  243. package/Materials/GreasedLine/greasedLinePluginMaterial.js +26 -32
  244. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
  245. package/Materials/GreasedLine/greasedLineSimpleMaterial.js +22 -27
  246. package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
  247. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +6 -7
  248. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
  249. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +1 -2
  250. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  251. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +1 -2
  252. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  253. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +1 -1
  254. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
  255. package/Materials/Node/Blocks/Dual/textureBlock.js +10 -16
  256. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  257. package/Materials/Node/Blocks/Fragment/TBNBlock.js +2 -3
  258. package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
  259. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -2
  260. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  261. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +2 -4
  262. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  263. package/Materials/Node/Blocks/Input/inputBlock.js +1 -2
  264. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  265. package/Materials/Node/Blocks/PBR/clearCoatBlock.js +24 -26
  266. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  267. package/Materials/Node/Blocks/PBR/iridescenceBlock.js +3 -3
  268. package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
  269. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +45 -49
  270. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  271. package/Materials/Node/Blocks/PBR/reflectionBlock.js +1 -2
  272. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  273. package/Materials/Node/Blocks/PBR/refractionBlock.js +1 -2
  274. package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
  275. package/Materials/Node/Blocks/PBR/sheenBlock.js +13 -13
  276. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  277. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +27 -28
  278. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
  279. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +1 -2
  280. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  281. package/Materials/Node/Blocks/Vertex/instancesBlock.js +2 -2
  282. package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
  283. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +43 -33
  284. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  285. package/Materials/Node/Blocks/biPlanarBlock.js +1 -2
  286. package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
  287. package/Materials/Node/Blocks/cloudBlock.js +2 -3
  288. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  289. package/Materials/Node/Blocks/colorMergerBlock.js +4 -5
  290. package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
  291. package/Materials/Node/Blocks/customBlock.js +4 -6
  292. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  293. package/Materials/Node/Blocks/meshAttributeExistsBlock.js +2 -4
  294. package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
  295. package/Materials/Node/Blocks/triPlanarBlock.js +14 -23
  296. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  297. package/Materials/Node/Blocks/vectorMergerBlock.js +4 -5
  298. package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
  299. package/Materials/Node/nodeMaterial.js +16 -11
  300. package/Materials/Node/nodeMaterial.js.map +1 -1
  301. package/Materials/Node/nodeMaterialBlock.js +3 -4
  302. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  303. package/Materials/Node/nodeMaterialBuildState.js +1 -1
  304. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  305. package/Materials/PBR/pbrBaseMaterial.js +25 -28
  306. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  307. package/Materials/PBR/pbrClearCoatConfiguration.js +6 -9
  308. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  309. package/Materials/PBR/pbrIridescenceConfiguration.js +4 -7
  310. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  311. package/Materials/PBR/pbrSheenConfiguration.js +4 -7
  312. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  313. package/Materials/Textures/Loaders/envTextureLoader.js +2 -2
  314. package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
  315. package/Materials/Textures/Packer/packer.js +13 -14
  316. package/Materials/Textures/Packer/packer.js.map +1 -1
  317. package/Materials/Textures/Procedurals/noiseProceduralTexture.js +1 -2
  318. package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
  319. package/Materials/Textures/Procedurals/proceduralTexture.js +19 -11
  320. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  321. package/Materials/Textures/baseTexture.js +2 -4
  322. package/Materials/Textures/baseTexture.js.map +1 -1
  323. package/Materials/Textures/cubeTexture.js +7 -13
  324. package/Materials/Textures/cubeTexture.js.map +1 -1
  325. package/Materials/Textures/dynamicTexture.js +1 -2
  326. package/Materials/Textures/dynamicTexture.js.map +1 -1
  327. package/Materials/Textures/hdrCubeTexture.js +2 -4
  328. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  329. package/Materials/Textures/htmlElementTexture.js +5 -3
  330. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  331. package/Materials/Textures/internalTexture.js +3 -5
  332. package/Materials/Textures/internalTexture.js.map +1 -1
  333. package/Materials/Textures/mirrorTexture.js +3 -6
  334. package/Materials/Textures/mirrorTexture.js.map +1 -1
  335. package/Materials/Textures/multiRenderTarget.js +5 -8
  336. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  337. package/Materials/Textures/rawTexture.js +1 -1
  338. package/Materials/Textures/rawTexture.js.map +1 -1
  339. package/Materials/Textures/renderTargetTexture.js +22 -34
  340. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  341. package/Materials/Textures/texture.js +16 -21
  342. package/Materials/Textures/texture.js.map +1 -1
  343. package/Materials/Textures/thinRenderTargetTexture.js +2 -4
  344. package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
  345. package/Materials/Textures/thinTexture.js +1 -1
  346. package/Materials/Textures/thinTexture.js.map +1 -1
  347. package/Materials/Textures/videoTexture.js +12 -10
  348. package/Materials/Textures/videoTexture.js.map +1 -1
  349. package/Materials/clipPlaneMaterialHelper.js +18 -21
  350. package/Materials/clipPlaneMaterialHelper.js.map +1 -1
  351. package/Materials/drawWrapper.js +2 -4
  352. package/Materials/drawWrapper.js.map +1 -1
  353. package/Materials/effect.d.ts +4 -0
  354. package/Materials/effect.js +18 -18
  355. package/Materials/effect.js.map +1 -1
  356. package/Materials/effectRenderer.js +2 -3
  357. package/Materials/effectRenderer.js.map +1 -1
  358. package/Materials/material.decalMapConfiguration.js +3 -3
  359. package/Materials/material.decalMapConfiguration.js.map +1 -1
  360. package/Materials/material.detailMapConfiguration.js +1 -2
  361. package/Materials/material.detailMapConfiguration.js.map +1 -1
  362. package/Materials/material.js +7 -4
  363. package/Materials/material.js.map +1 -1
  364. package/Materials/materialDefines.js +5 -6
  365. package/Materials/materialDefines.js.map +1 -1
  366. package/Materials/materialHelper.d.ts +1 -1
  367. package/Materials/materialHelper.js +3 -4
  368. package/Materials/materialHelper.js.map +1 -1
  369. package/Materials/materialPluginManager.js +3 -5
  370. package/Materials/materialPluginManager.js.map +1 -1
  371. package/Materials/meshDebugPluginMaterial.js +13 -14
  372. package/Materials/meshDebugPluginMaterial.js.map +1 -1
  373. package/Materials/multiMaterial.js +1 -2
  374. package/Materials/multiMaterial.js.map +1 -1
  375. package/Materials/shaderMaterial.d.ts +1 -1
  376. package/Materials/shaderMaterial.js +64 -32
  377. package/Materials/shaderMaterial.js.map +1 -1
  378. package/Materials/shadowDepthWrapper.js +24 -23
  379. package/Materials/shadowDepthWrapper.js.map +1 -1
  380. package/Materials/standardMaterial.js +10 -12
  381. package/Materials/standardMaterial.js.map +1 -1
  382. package/Materials/uniformBuffer.js +1 -1
  383. package/Materials/uniformBuffer.js.map +1 -1
  384. package/Maths/math.vector.js +1 -2
  385. package/Maths/math.vector.js.map +1 -1
  386. package/Meshes/Builders/decalBuilder.js +26 -29
  387. package/Meshes/Builders/decalBuilder.js.map +1 -1
  388. package/Meshes/Builders/greasedLineBuilder.js +16 -16
  389. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  390. package/Meshes/Builders/groundBuilder.d.ts +5 -1
  391. package/Meshes/Builders/groundBuilder.js +13 -2
  392. package/Meshes/Builders/groundBuilder.js.map +1 -1
  393. package/Meshes/Builders/textBuilder.js +2 -3
  394. package/Meshes/Builders/textBuilder.js.map +1 -1
  395. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +9 -1
  396. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +141 -12
  397. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  398. package/Meshes/GreasedLine/greasedLineBaseMesh.js +8 -11
  399. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  400. package/Meshes/GreasedLine/greasedLineMesh.js +3 -5
  401. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  402. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +13 -18
  403. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  404. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +1 -2
  405. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  406. package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +18 -18
  407. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +18 -18
  408. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
  409. package/Meshes/Node/nodeGeometry.js +6 -3
  410. package/Meshes/Node/nodeGeometry.js.map +1 -1
  411. package/Meshes/Node/nodeGeometryBlock.js +1 -1
  412. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  413. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +1 -2
  414. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  415. package/Meshes/Node/nodeGeometryBuildState.js +1 -2
  416. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  417. package/Meshes/abstractMesh.js +6 -10
  418. package/Meshes/abstractMesh.js.map +1 -1
  419. package/Meshes/csg.js +1 -2
  420. package/Meshes/csg.js.map +1 -1
  421. package/Meshes/geometry.js +1 -1
  422. package/Meshes/geometry.js.map +1 -1
  423. package/Meshes/instancedMesh.js +5 -10
  424. package/Meshes/instancedMesh.js.map +1 -1
  425. package/Meshes/mesh.js +13 -22
  426. package/Meshes/mesh.js.map +1 -1
  427. package/Meshes/mesh.vertexData.js +3 -4
  428. package/Meshes/mesh.vertexData.js.map +1 -1
  429. package/Meshes/meshUVSpaceRenderer.js +18 -15
  430. package/Meshes/meshUVSpaceRenderer.js.map +1 -1
  431. package/Meshes/subMesh.js +8 -14
  432. package/Meshes/subMesh.js.map +1 -1
  433. package/Meshes/thinInstanceMesh.js +12 -18
  434. package/Meshes/thinInstanceMesh.js.map +1 -1
  435. package/Meshes/trailMesh.js +2 -3
  436. package/Meshes/trailMesh.js.map +1 -1
  437. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -2
  438. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  439. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +9 -14
  440. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  441. package/Misc/PerformanceViewer/performanceViewerCollector.js +2 -3
  442. package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
  443. package/Misc/arrayTools.js +1 -1
  444. package/Misc/arrayTools.js.map +1 -1
  445. package/Misc/basis.js +2 -3
  446. package/Misc/basis.js.map +1 -1
  447. package/Misc/dataStorage.js +1 -1
  448. package/Misc/dataStorage.js.map +1 -1
  449. package/Misc/deepCopier.js +1 -1
  450. package/Misc/deepCopier.js.map +1 -1
  451. package/Misc/environmentTextureTools.js +3 -4
  452. package/Misc/environmentTextureTools.js.map +1 -1
  453. package/Misc/equirectangularCapture.js +2 -3
  454. package/Misc/equirectangularCapture.js.map +1 -1
  455. package/Misc/fileTools.js +4 -4
  456. package/Misc/fileTools.js.map +1 -1
  457. package/Misc/greasedLineTools.js +3 -5
  458. package/Misc/greasedLineTools.js.map +1 -1
  459. package/Misc/logger.js +1 -2
  460. package/Misc/logger.js.map +1 -1
  461. package/Misc/minMaxReducer.js +2 -3
  462. package/Misc/minMaxReducer.js.map +1 -1
  463. package/Misc/pressureObserverWrapper.js +5 -8
  464. package/Misc/pressureObserverWrapper.js.map +1 -1
  465. package/Misc/sceneRecorder.js +1 -1
  466. package/Misc/sceneRecorder.js.map +1 -1
  467. package/Misc/screenshotTools.js +1 -1
  468. package/Misc/screenshotTools.js.map +1 -1
  469. package/Misc/textureTools.js +5 -5
  470. package/Misc/textureTools.js.map +1 -1
  471. package/Misc/timer.js +3 -5
  472. package/Misc/timer.js.map +1 -1
  473. package/Misc/tools.d.ts +3 -2
  474. package/Misc/tools.js +6 -5
  475. package/Misc/tools.js.map +1 -1
  476. package/Misc/trajectoryClassifier.js +3 -3
  477. package/Misc/trajectoryClassifier.js.map +1 -1
  478. package/Misc/videoRecorder.js +6 -4
  479. package/Misc/videoRecorder.js.map +1 -1
  480. package/Misc/virtualJoystick.js +4 -1
  481. package/Misc/virtualJoystick.js.map +1 -1
  482. package/Morph/morphTargetManager.js +1 -2
  483. package/Morph/morphTargetManager.js.map +1 -1
  484. package/Particles/EmitterTypes/meshParticleEmitter.js +1 -2
  485. package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
  486. package/Particles/baseParticleSystem.d.ts +4 -0
  487. package/Particles/baseParticleSystem.js +4 -0
  488. package/Particles/baseParticleSystem.js.map +1 -1
  489. package/Particles/computeShaderParticleSystem.js +3 -6
  490. package/Particles/computeShaderParticleSystem.js.map +1 -1
  491. package/Particles/gpuParticleSystem.d.ts +2 -2
  492. package/Particles/gpuParticleSystem.js +30 -20
  493. package/Particles/gpuParticleSystem.js.map +1 -1
  494. package/Particles/particleSystem.d.ts +3 -2
  495. package/Particles/particleSystem.js +33 -30
  496. package/Particles/particleSystem.js.map +1 -1
  497. package/Particles/particleSystemComponent.js +2 -3
  498. package/Particles/particleSystemComponent.js.map +1 -1
  499. package/Particles/pointsCloudSystem.js +5 -8
  500. package/Particles/pointsCloudSystem.js.map +1 -1
  501. package/Particles/solidParticleSystem.js +5 -7
  502. package/Particles/solidParticleSystem.js.map +1 -1
  503. package/Particles/webgl2ParticleSystem.js +1 -2
  504. package/Particles/webgl2ParticleSystem.js.map +1 -1
  505. package/Physics/castingResult.js +1 -1
  506. package/Physics/castingResult.js.map +1 -1
  507. package/Physics/joinedPhysicsEngineComponent.js +2 -2
  508. package/Physics/joinedPhysicsEngineComponent.js.map +1 -1
  509. package/Physics/physicsHelper.js +19 -21
  510. package/Physics/physicsHelper.js.map +1 -1
  511. package/Physics/v2/IPhysicsEnginePlugin.d.ts +20 -0
  512. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  513. package/Physics/v2/Plugins/havokPlugin.js +48 -35
  514. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  515. package/Physics/v2/physicsAggregate.js +10 -12
  516. package/Physics/v2/physicsAggregate.js.map +1 -1
  517. package/Physics/v2/physicsBody.js +2 -4
  518. package/Physics/v2/physicsBody.js.map +1 -1
  519. package/Physics/v2/physicsShape.js +1 -2
  520. package/Physics/v2/physicsShape.js.map +1 -1
  521. package/Physics/v2/ragdoll.js +6 -8
  522. package/Physics/v2/ragdoll.js.map +1 -1
  523. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +6 -8
  524. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  525. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +14 -22
  526. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  527. package/PostProcesses/colorCorrectionPostProcess.js +1 -1
  528. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  529. package/PostProcesses/postProcess.js +28 -34
  530. package/PostProcesses/postProcess.js.map +1 -1
  531. package/PostProcesses/postProcessManager.js +4 -6
  532. package/PostProcesses/postProcessManager.js.map +1 -1
  533. package/PostProcesses/screenSpaceReflectionPostProcess.js +2 -2
  534. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  535. package/PostProcesses/volumetricLightScatteringPostProcess.js +4 -7
  536. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  537. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +1 -1
  538. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
  539. package/Probes/reflectionProbe.js +2 -4
  540. package/Probes/reflectionProbe.js.map +1 -1
  541. package/Rendering/GlobalIllumination/giRSMManager.js +22 -19
  542. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  543. package/Rendering/boundingBoxRenderer.js +2 -3
  544. package/Rendering/boundingBoxRenderer.js.map +1 -1
  545. package/Rendering/depthPeelingRenderer.js +2 -4
  546. package/Rendering/depthPeelingRenderer.js.map +1 -1
  547. package/Rendering/depthPeelingSceneComponent.js +2 -4
  548. package/Rendering/depthPeelingSceneComponent.js.map +1 -1
  549. package/Rendering/depthRenderer.js +10 -13
  550. package/Rendering/depthRenderer.js.map +1 -1
  551. package/Rendering/edgesRenderer.js +8 -11
  552. package/Rendering/edgesRenderer.js.map +1 -1
  553. package/Rendering/fluidRenderer/fluidRenderer.js +6 -11
  554. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  555. package/Rendering/fluidRenderer/fluidRenderingObject.js +3 -5
  556. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
  557. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +2 -4
  558. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
  559. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +30 -36
  560. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
  561. package/Rendering/fluidRenderer/fluidRenderingTextures.js +5 -7
  562. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
  563. package/Rendering/geometryBufferRenderer.js +3 -2
  564. package/Rendering/geometryBufferRenderer.js.map +1 -1
  565. package/Rendering/outlineRenderer.js +5 -4
  566. package/Rendering/outlineRenderer.js.map +1 -1
  567. package/Rendering/prePassRenderer.js +3 -6
  568. package/Rendering/prePassRenderer.js.map +1 -1
  569. package/Rendering/reflectiveShadowMap.d.ts +1 -0
  570. package/Rendering/reflectiveShadowMap.js +5 -5
  571. package/Rendering/reflectiveShadowMap.js.map +1 -1
  572. package/Shaders/color.fragment.d.ts +2 -0
  573. package/Shaders/color.fragment.js +4 -0
  574. package/Shaders/color.fragment.js.map +1 -1
  575. package/Shaders/color.vertex.d.ts +2 -0
  576. package/Shaders/color.vertex.js +7 -0
  577. package/Shaders/color.vertex.js.map +1 -1
  578. package/Shaders/gpuRenderParticles.fragment.d.ts +2 -0
  579. package/Shaders/gpuRenderParticles.fragment.js +4 -0
  580. package/Shaders/gpuRenderParticles.fragment.js.map +1 -1
  581. package/Shaders/gpuRenderParticles.vertex.d.ts +2 -0
  582. package/Shaders/gpuRenderParticles.vertex.js +5 -1
  583. package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
  584. package/Shaders/particles.fragment.d.ts +2 -0
  585. package/Shaders/particles.fragment.js +4 -0
  586. package/Shaders/particles.fragment.js.map +1 -1
  587. package/Shaders/particles.vertex.d.ts +2 -0
  588. package/Shaders/particles.vertex.js +5 -1
  589. package/Shaders/particles.vertex.js.map +1 -1
  590. package/Sprites/spriteManager.js +1 -2
  591. package/Sprites/spriteManager.js.map +1 -1
  592. package/Sprites/spriteRenderer.js +5 -7
  593. package/Sprites/spriteRenderer.js.map +1 -1
  594. package/States/stencilStateComposer.js +2 -4
  595. package/States/stencilStateComposer.js.map +1 -1
  596. package/XR/features/WebXRAbstractFeature.js +6 -2
  597. package/XR/features/WebXRAbstractFeature.js.map +1 -1
  598. package/XR/features/WebXRAnchorSystem.js +1 -2
  599. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  600. package/XR/features/WebXRControllerMovement.js +6 -7
  601. package/XR/features/WebXRControllerMovement.js.map +1 -1
  602. package/XR/features/WebXRControllerPhysics.js +17 -10
  603. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  604. package/XR/features/WebXRControllerPointerSelection.js +1 -2
  605. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  606. package/XR/features/WebXRControllerTeleportation.d.ts +1 -0
  607. package/XR/features/WebXRControllerTeleportation.js +6 -3
  608. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  609. package/XR/features/WebXRDepthSensing.js +3 -5
  610. package/XR/features/WebXRDepthSensing.js.map +1 -1
  611. package/XR/features/WebXRHandTracking.d.ts +1 -0
  612. package/XR/features/WebXRHandTracking.js +31 -28
  613. package/XR/features/WebXRHandTracking.js.map +1 -1
  614. package/XR/features/WebXRLayers.js +9 -11
  615. package/XR/features/WebXRLayers.js.map +1 -1
  616. package/XR/features/WebXRLightEstimation.js +3 -6
  617. package/XR/features/WebXRLightEstimation.js.map +1 -1
  618. package/XR/features/WebXRMeshDetector.js +2 -4
  619. package/XR/features/WebXRMeshDetector.js.map +1 -1
  620. package/XR/features/WebXRNearInteraction.js +21 -18
  621. package/XR/features/WebXRNearInteraction.js.map +1 -1
  622. package/XR/features/WebXRPlaneDetector.js +1 -2
  623. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  624. package/XR/features/WebXRRawCameraAccess.js +2 -3
  625. package/XR/features/WebXRRawCameraAccess.js.map +1 -1
  626. package/XR/features/WebXRSpaceWarp.js +1 -1
  627. package/XR/features/WebXRSpaceWarp.js.map +1 -1
  628. package/XR/motionController/webXRAbstractMotionController.js +4 -1
  629. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  630. package/XR/native/nativeXRFrame.js +1 -2
  631. package/XR/native/nativeXRFrame.js.map +1 -1
  632. package/XR/webXRCamera.js +1 -2
  633. package/XR/webXRCamera.js.map +1 -1
  634. package/XR/webXRDefaultExperience.js +28 -6
  635. package/XR/webXRDefaultExperience.js.map +1 -1
  636. package/XR/webXRExperienceHelper.js +5 -7
  637. package/XR/webXRExperienceHelper.js.map +1 -1
  638. package/XR/webXRFeaturesManager.js +4 -1
  639. package/XR/webXRFeaturesManager.js.map +1 -1
  640. package/XR/webXRInput.js +6 -1
  641. package/XR/webXRInput.js.map +1 -1
  642. package/XR/webXRInputSource.js +1 -2
  643. package/XR/webXRInputSource.js.map +1 -1
  644. package/XR/webXRSessionManager.js +16 -29
  645. package/XR/webXRSessionManager.js.map +1 -1
  646. package/assetContainer.js +4 -1
  647. package/assetContainer.js.map +1 -1
  648. package/package.json +1 -1
  649. package/scene.js +18 -17
  650. package/scene.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"deviceSourceManager.js","sourceRoot":"","sources":["../../../../../dev/core/src/DeviceInput/InputDevices/deviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAK7E;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAkB5B,mBAAmB;IACnB;;;;;OAKG;IACI,eAAe,CAAuB,UAAa,EAAE,UAAmB;QAC3E,IAAI,UAAU,KAAK,SAAS,EAAE;YAC1B,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;gBAC7C,OAAO,IAAI,CAAC;aACf;YAED,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;SAC9C;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;YACnF,OAAO,IAAI,CAAC;SACf;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAoB,CAAC;IACpE,CAAC;IACD;;;;OAIG;IACI,gBAAgB,CAAuB,UAAa;QACvD,2EAA2E;QAC3E,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC5B,OAAO,EAAE,CAAC;SACb;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAC/C,OAAO,CAAC,CAAC,MAAM,CAAC;QACpB,CAAC,CAA2B,CAAC;IACjC,CAAC;I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AAC,CAAC,CAAC,EAAE;4BACZ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;4BAC5B,MAAM;yBACT;qBACJ;iBACJ;gBACD,MAAM;aACT;SACJ;IACL,CAAC;CACJ","sourcesContent":["import type { Engine } from \"../../Engines/engine\";\r\nimport { DeviceType } from \"./deviceEnums\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { DeviceSource } from \"./deviceSource\";\r\nimport type { IObservableManager, DeviceSourceType } from \"../internalDeviceSourceManager\";\r\nimport { InternalDeviceSourceManager } from \"../internalDeviceSourceManager\";\r\nimport type { IDisposable } from \"../../scene\";\r\nimport type { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport type { IKeyboardEvent, IPointerEvent, IUIEvent, IWheelEvent } from \"../../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Class to keep track of devices\r\n */\r\nexport class DeviceSourceManager implements IDisposable, IObservableManager {\r\n // Public Members\r\n /**\r\n * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices\r\n */\r\n public readonly onDeviceConnectedObservable: Observable<DeviceSourceType>;\r\n\r\n /**\r\n * Observable to be triggered when after a device is disconnected\r\n */\r\n public readonly onDeviceDisconnectedObservable: Observable<DeviceSourceType>;\r\n\r\n // Private Members\r\n private _engine: Engine;\r\n private _onDisposeObserver: Nullable<Observer<ThinEngine>>;\r\n private readonly _devices: Array<Array<DeviceSource<DeviceType>>>;\r\n private readonly _firstDevice: Array<number>;\r\n\r\n // Public Functions\r\n /**\r\n * Gets a DeviceSource, given a type and slot\r\n * @param deviceType - Type of Device\r\n * @param deviceSlot - Slot or ID of device\r\n * @returns DeviceSource\r\n */\r\n public getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>> {\r\n if (deviceSlot === undefined) {\r\n if (this._firstDevice[deviceType] === undefined) {\r\n return null;\r\n }\r\n\r\n deviceSlot = this._firstDevice[deviceType];\r\n }\r\n\r\n if (!this._devices[deviceType] || this._devices[deviceType][deviceSlot] === undefined) {\r\n return null;\r\n }\r\n\r\n return this._devices[deviceType][deviceSlot] as DeviceSource<T>;\r\n }\r\n /**\r\n * Gets an array of DeviceSource objects for a given device type\r\n * @param deviceType - Type of Device\r\n * @returns All available DeviceSources of a given type\r\n */\r\n public getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>> {\r\n // If device type hasn't had any devices connected yet, return empty array.\r\n if (!this._devices[deviceType]) {\r\n return [];\r\n }\r\n return this._devices[deviceType].filter((source) => {\r\n return !!source;\r\n }) as Array<DeviceSource<T>>;\r\n }\r\n\r\n /**\r\n * Default constructor\r\n * @param engine - Used to get canvas (if applicable)\r\n */\r\n constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array(numberOfDeviceTypes);\r\n this._firstDevice = new Array(numberOfDeviceTypes);\r\n this._engine = engine;\r\n\r\n if (!this._engine._deviceSourceManager) {\r\n this._engine._deviceSourceManager = new InternalDeviceSourceManager(engine);\r\n }\r\n this._engine._deviceSourceManager._refCount++;\r\n\r\n // Observables\r\n this.onDeviceConnectedObservable = new Observable((observer) => {\r\n for (const devices of this._devices) {\r\n if (devices) {\r\n for (const device of devices) {\r\n if (device) {\r\n this.onDeviceConnectedObservable.notifyObserver(observer, device as DeviceSourceType);\r\n }\r\n }\r\n }\r\n }\r\n });\r\n this.onDeviceDisconnectedObservable = new Observable();\r\n\r\n this._engine._deviceSourceManager.registerManager(this);\r\n\r\n this._onDisposeObserver = engine.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Dispose of DeviceSourceManager\r\n */\r\n public dispose(): void {\r\n // Null out observable refs\r\n this.onDeviceConnectedObservable.clear();\r\n this.onDeviceDisconnectedObservable.clear();\r\n\r\n if (this._engine._deviceSourceManager) {\r\n this._engine._deviceSourceManager.unregisterManager(this);\r\n if (--this._engine._deviceSourceManager._refCount < 1) {\r\n this._engine._deviceSourceManager.dispose();\r\n delete this._engine._deviceSourceManager;\r\n }\r\n }\r\n this._engine.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n\r\n // Hidden Functions\r\n /**\r\n * @param deviceSource - Source to add\r\n * @internal\r\n */\r\n public _addDevice(deviceSource: DeviceSourceType): void {\r\n if (!this._devices[deviceSource.deviceType]) {\r\n this._devices[deviceSource.deviceType] = new Array();\r\n }\r\n\r\n if (!this._devices[deviceSource.deviceType][deviceSource.deviceSlot]) {\r\n this._devices[deviceSource.deviceType][deviceSource.deviceSlot] = deviceSource;\r\n this._updateFirstDevices(deviceSource.deviceType);\r\n }\r\n\r\n this.onDeviceConnectedObservable.notifyObservers(deviceSource);\r\n }\r\n\r\n /**\r\n * @param deviceType - DeviceType\r\n * @param deviceSlot - DeviceSlot\r\n * @internal\r\n */\r\n public _removeDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n const deviceSource = this._devices[deviceType]?.[deviceSlot]; // Grab local reference to use before removing from devices\r\n this.onDeviceDisconnectedObservable.notifyObservers(deviceSource as DeviceSourceType);\r\n if (this._devices[deviceType]?.[deviceSlot]) {\r\n delete this._devices[deviceType][deviceSlot];\r\n }\r\n // Even if we don't delete a device, we should still check for the first device as things may have gotten out of sync.\r\n this._updateFirstDevices(deviceType);\r\n }\r\n\r\n /**\r\n * @param deviceType - DeviceType\r\n * @param deviceSlot - DeviceSlot\r\n * @param eventData - Event\r\n * @internal\r\n */\r\n public _onInputChanged<T extends DeviceType>(deviceType: T, deviceSlot: number, eventData: IUIEvent): void {\r\n this._devices[deviceType]?.[deviceSlot]?.onInputChangedObservable.notifyObservers(eventData as IKeyboardEvent | IWheelEvent | IPointerEvent);\r\n }\r\n\r\n // Private Functions\r\n private _updateFirstDevices(type: DeviceType): void {\r\n switch (type) {\r\n case DeviceType.Keyboard:\r\n case DeviceType.Mouse:\r\n this._firstDevice[type] = 0;\r\n break;\r\n case DeviceType.Touch:\r\n case DeviceType.DualSense:\r\n case DeviceType.DualShock:\r\n case DeviceType.Xbox:\r\n case DeviceType.Switch:\r\n case DeviceType.Generic: {\r\n delete this._firstDevice[type];\r\n // eslint-disable-next-line no-case-declarations\r\n const devices = this._devices[type];\r\n if (devices) {\r\n for (let i = 0; i < devices.length; i++) {\r\n if (devices[i]) {\r\n this._firstDevice[type] = i;\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"deviceSourceManager.js","sourceRoot":"","sources":["../../../../../dev/core/src/DeviceInput/InputDevices/deviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAK7E;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAkB5B,mBAAmB;IACnB;;;;;OAKG;IACI,eAAe,CAAuB,UAAa,EAAE,UAAmB;QAC3E,IAAI,UAAU,KAAK,SAAS,EAAE;YAC1B,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;gBAC7C,OAAO,IAAI,CAAC;aACf;YAED,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;SAC9C;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;YACnF,OAAO,IAAI,CAAC;SACf;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAoB,CAAC;IACpE,CAAC;IACD;;;;OAIG;IACI,gBAAgB,CAAuB,UAAa;QACvD,2EAA2E;QAC3E,IAAI,CAAC,IAAI,C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gDAAgD;gBAChD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACpC,IAAI,OAAO,EAAE;oBACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACrC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;4BACZ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;4BAC5B,MAAM;yBACT;qBACJ;iBACJ;gBACD,MAAM;aACT;SACJ;IACL,CAAC;CACJ","sourcesContent":["import type { Engine } from \"../../Engines/engine\";\r\nimport { DeviceType } from \"./deviceEnums\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { DeviceSource } from \"./deviceSource\";\r\nimport type { IObservableManager, DeviceSourceType } from \"../internalDeviceSourceManager\";\r\nimport { InternalDeviceSourceManager } from \"../internalDeviceSourceManager\";\r\nimport type { IDisposable } from \"../../scene\";\r\nimport type { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport type { IKeyboardEvent, IPointerEvent, IUIEvent, IWheelEvent } from \"../../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Class to keep track of devices\r\n */\r\nexport class DeviceSourceManager implements IDisposable, IObservableManager {\r\n // Public Members\r\n /**\r\n * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices\r\n */\r\n public readonly onDeviceConnectedObservable: Observable<DeviceSourceType>;\r\n\r\n /**\r\n * Observable to be triggered when after a device is disconnected\r\n */\r\n public readonly onDeviceDisconnectedObservable: Observable<DeviceSourceType>;\r\n\r\n // Private Members\r\n private _engine: Engine;\r\n private _onDisposeObserver: Nullable<Observer<ThinEngine>>;\r\n private readonly _devices: Array<Array<DeviceSource<DeviceType>>>;\r\n private readonly _firstDevice: Array<number>;\r\n\r\n // Public Functions\r\n /**\r\n * Gets a DeviceSource, given a type and slot\r\n * @param deviceType - Type of Device\r\n * @param deviceSlot - Slot or ID of device\r\n * @returns DeviceSource\r\n */\r\n public getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>> {\r\n if (deviceSlot === undefined) {\r\n if (this._firstDevice[deviceType] === undefined) {\r\n return null;\r\n }\r\n\r\n deviceSlot = this._firstDevice[deviceType];\r\n }\r\n\r\n if (!this._devices[deviceType] || this._devices[deviceType][deviceSlot] === undefined) {\r\n return null;\r\n }\r\n\r\n return this._devices[deviceType][deviceSlot] as DeviceSource<T>;\r\n }\r\n /**\r\n * Gets an array of DeviceSource objects for a given device type\r\n * @param deviceType - Type of Device\r\n * @returns All available DeviceSources of a given type\r\n */\r\n public getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>> {\r\n // If device type hasn't had any devices connected yet, return empty array.\r\n if (!this._devices[deviceType]) {\r\n return [];\r\n }\r\n return this._devices[deviceType].filter((source) => {\r\n return !!source;\r\n }) as Array<DeviceSource<T>>;\r\n }\r\n\r\n /**\r\n * Default constructor\r\n * @param engine - Used to get canvas (if applicable)\r\n */\r\n constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array(numberOfDeviceTypes);\r\n this._firstDevice = new Array(numberOfDeviceTypes);\r\n this._engine = engine;\r\n\r\n if (!this._engine._deviceSourceManager) {\r\n this._engine._deviceSourceManager = new InternalDeviceSourceManager(engine);\r\n }\r\n this._engine._deviceSourceManager._refCount++;\r\n\r\n // Observables\r\n this.onDeviceConnectedObservable = new Observable((observer) => {\r\n for (const devices of this._devices) {\r\n if (devices) {\r\n for (const device of devices) {\r\n if (device) {\r\n this.onDeviceConnectedObservable.notifyObserver(observer, device as DeviceSourceType);\r\n }\r\n }\r\n }\r\n }\r\n });\r\n this.onDeviceDisconnectedObservable = new Observable();\r\n\r\n this._engine._deviceSourceManager.registerManager(this);\r\n\r\n this._onDisposeObserver = engine.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Dispose of DeviceSourceManager\r\n */\r\n public dispose(): void {\r\n // Null out observable refs\r\n this.onDeviceConnectedObservable.clear();\r\n this.onDeviceDisconnectedObservable.clear();\r\n\r\n if (this._engine._deviceSourceManager) {\r\n this._engine._deviceSourceManager.unregisterManager(this);\r\n if (--this._engine._deviceSourceManager._refCount < 1) {\r\n this._engine._deviceSourceManager.dispose();\r\n delete this._engine._deviceSourceManager;\r\n }\r\n }\r\n this._engine.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n\r\n // Hidden Functions\r\n /**\r\n * @param deviceSource - Source to add\r\n * @internal\r\n */\r\n public _addDevice(deviceSource: DeviceSourceType): void {\r\n if (!this._devices[deviceSource.deviceType]) {\r\n this._devices[deviceSource.deviceType] = new Array();\r\n }\r\n\r\n if (!this._devices[deviceSource.deviceType][deviceSource.deviceSlot]) {\r\n this._devices[deviceSource.deviceType][deviceSource.deviceSlot] = deviceSource;\r\n this._updateFirstDevices(deviceSource.deviceType);\r\n }\r\n\r\n this.onDeviceConnectedObservable.notifyObservers(deviceSource);\r\n }\r\n\r\n /**\r\n * @param deviceType - DeviceType\r\n * @param deviceSlot - DeviceSlot\r\n * @internal\r\n */\r\n public _removeDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n const deviceSource = this._devices[deviceType]?.[deviceSlot]; // Grab local reference to use before removing from devices\r\n this.onDeviceDisconnectedObservable.notifyObservers(deviceSource as DeviceSourceType);\r\n if (this._devices[deviceType]?.[deviceSlot]) {\r\n delete this._devices[deviceType][deviceSlot];\r\n }\r\n // Even if we don't delete a device, we should still check for the first device as things may have gotten out of sync.\r\n this._updateFirstDevices(deviceType);\r\n }\r\n\r\n /**\r\n * @param deviceType - DeviceType\r\n * @param deviceSlot - DeviceSlot\r\n * @param eventData - Event\r\n * @internal\r\n */\r\n public _onInputChanged<T extends DeviceType>(deviceType: T, deviceSlot: number, eventData: IUIEvent): void {\r\n this._devices[deviceType]?.[deviceSlot]?.onInputChangedObservable.notifyObservers(eventData as IKeyboardEvent | IWheelEvent | IPointerEvent);\r\n }\r\n\r\n // Private Functions\r\n private _updateFirstDevices(type: DeviceType): void {\r\n switch (type) {\r\n case DeviceType.Keyboard:\r\n case DeviceType.Mouse:\r\n this._firstDevice[type] = 0;\r\n break;\r\n case DeviceType.Touch:\r\n case DeviceType.DualSense:\r\n case DeviceType.DualShock:\r\n case DeviceType.Xbox:\r\n case DeviceType.Switch:\r\n case DeviceType.Generic: {\r\n delete this._firstDevice[type];\r\n // eslint-disable-next-line no-case-declarations\r\n const devices = this._devices[type];\r\n if (devices) {\r\n for (let i = 0; i < devices.length; i++) {\r\n if (devices[i]) {\r\n this._firstDevice[type] = i;\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -54,7 +54,7 @@ export class DeviceEventFactory {
54
54
  }
55
55
  else {
56
56
  evt.deviceType = DeviceType.Touch;
57
- evt.pointerId = pointerId !== null && pointerId !== void 0 ? pointerId : deviceSlot;
57
+ evt.pointerId = pointerId ?? deviceSlot;
58
58
  evt.pointerType = "touch";
59
59
  }
60
60
  let buttons = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"eventFactory.js","sourceRoot":"","sources":["../../../../dev/core/src/DeviceInput/eventFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1F;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC3B;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,iBAAiB,CAC3B,UAAsB,EACtB,UAAkB,EAClB,UAAkB,EAClB,YAA8B,EAC9B,iBAAqC,EACrC,iBAAuB,EACvB,SAA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AAC,KAAK,CAAC,CAAC;QAE1H,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QACpB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,YAAY,CAAC,iBAAsB;QAC9C,MAAM,GAAG,GAAyB,EAAE,CAAC;QACrC,GAAG,CAAC,cAAc,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAC9B,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;CACJ","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport type { IUIEvent } from \"../Events/deviceInputEvents\";\r\nimport { EventConstants } from \"../Events/deviceInputEvents\";\r\nimport type { Nullable } from \"../types\";\r\nimport { DeviceType, NativePointerInput, PointerInput } from \"./InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\n/**\r\n * Class to wrap DeviceInputSystem data into an event object\r\n */\r\nexport class DeviceEventFactory {\r\n /**\r\n * Create device input events based on provided type and slot\r\n *\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @param pointerId PointerId to use for pointer events\r\n * @returns IUIEvent object\r\n */\r\n public static CreateDeviceEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any,\r\n pointerId?: number\r\n ): IUIEvent {\r\n switch (deviceType) {\r\n case DeviceType.Keyboard:\r\n return this._CreateKeyboardEvent(inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n case DeviceType.Mouse:\r\n if (inputIndex === PointerInput.MouseWheelX || inputIndex === PointerInput.MouseWheelY || inputIndex === PointerInput.MouseWheelZ) {\r\n return this._CreateWheelEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n }\r\n // eslint-disable-next-line no-fallthrough\r\n case DeviceType.Touch:\r\n return this._CreatePointerEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo, pointerId);\r\n default:\r\n // eslint-disable-next-line no-throw-literal\r\n throw `Unable to generate event for device ${DeviceType[deviceType]}`;\r\n }\r\n }\r\n\r\n /**\r\n * Creates pointer event\r\n *\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @param pointerId PointerId to use for pointer events\r\n * @returns IUIEvent object (Pointer)\r\n */\r\n private static _CreatePointerEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any,\r\n pointerId?: number\r\n ): any {\r\n const evt = this._CreateMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n if (deviceType === DeviceType.Mouse) {\r\n evt.deviceType = DeviceType.Mouse;\r\n evt.pointerId = 1;\r\n evt.pointerType = \"mouse\";\r\n } else {\r\n evt.deviceType = DeviceType.Touch;\r\n evt.pointerId = pointerId ?? deviceSlot;\r\n evt.pointerType = \"touch\";\r\n }\r\n\r\n let buttons = 0;\r\n\r\n // Populate buttons property with current state of all mouse buttons\r\n // Uses values found on: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.LeftClick);\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.RightClick) * 2;\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MiddleClick) * 4;\r\n evt.buttons = buttons;\r\n\r\n if (inputIndex === PointerInput.Move) {\r\n evt.type = \"pointermove\";\r\n } else if (inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick) {\r\n evt.type = currentState === 1 ? \"pointerdown\" : \"pointerup\";\r\n evt.button = inputIndex - 2;\r\n }\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Wheel Event\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IUIEvent object (Wheel)\r\n */\r\n private static _CreateWheelEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo: any\r\n ): any {\r\n const evt = this._CreateMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n // While WheelEvents don't generally have a pointerId, we used to add one in the InputManager\r\n // This line has been added to make the InputManager more platform-agnostic\r\n // Similar code exists in the WebDeviceInputSystem to handle browser created events\r\n evt.pointerId = 1;\r\n evt.type = \"wheel\";\r\n evt.deltaMode = EventConstants.DOM_DELTA_PIXEL;\r\n evt.deltaX = 0;\r\n evt.deltaY = 0;\r\n evt.deltaZ = 0;\r\n\r\n switch (inputIndex) {\r\n case PointerInput.MouseWheelX:\r\n evt.deltaX = currentState;\r\n break;\r\n case PointerInput.MouseWheelY:\r\n evt.deltaY = currentState;\r\n break;\r\n case PointerInput.MouseWheelZ:\r\n evt.deltaZ = currentState;\r\n break;\r\n }\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Event\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IUIEvent object (Mouse)\r\n */\r\n private static _CreateMouseEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any\r\n ): any {\r\n const evt = this._CreateEvent(elementToAttachTo);\r\n const pointerX = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Horizontal);\r\n const pointerY = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Vertical);\r\n\r\n // Handle offsets/deltas based on existence of HTMLElement\r\n if (elementToAttachTo) {\r\n evt.movementX = 0;\r\n evt.movementY = 0;\r\n evt.offsetX = evt.movementX - elementToAttachTo.getBoundingClientRect().x;\r\n evt.offsetY = evt.movementY - elementToAttachTo.getBoundingClientRect().y;\r\n } else {\r\n evt.movementX = deviceInputSystem.pollInput(deviceType, deviceSlot, NativePointerInput.DeltaHorizontal); // DeltaHorizontal\r\n evt.movementY = deviceInputSystem.pollInput(deviceType, deviceSlot, NativePointerInput.DeltaVertical); // DeltaVertical\r\n evt.offsetX = 0;\r\n evt.offsetY = 0;\r\n }\r\n this._CheckNonCharacterKeys(evt, deviceInputSystem);\r\n\r\n evt.clientX = pointerX;\r\n evt.clientY = pointerY;\r\n evt.x = pointerX;\r\n evt.y = pointerY;\r\n\r\n evt.deviceType = deviceType;\r\n evt.deviceSlot = deviceSlot;\r\n evt.inputIndex = inputIndex;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Keyboard Event\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Keyboard)\r\n */\r\n private static _CreateKeyboardEvent(inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._CreateEvent(elementToAttachTo);\r\n this._CheckNonCharacterKeys(evt, deviceInputSystem);\r\n evt.deviceType = DeviceType.Keyboard;\r\n evt.deviceSlot = 0;\r\n evt.inputIndex = inputIndex;\r\n\r\n evt.type = currentState === 1 ? \"keydown\" : \"keyup\";\r\n evt.key = String.fromCharCode(inputIndex);\r\n evt.keyCode = inputIndex;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Add parameters for non-character keys (Ctrl, Alt, Meta, Shift)\r\n * @param evt Event object to add parameters to\r\n * @param deviceInputSystem DeviceInputSystem to pull values from\r\n */\r\n private static _CheckNonCharacterKeys(evt: any, deviceInputSystem: IDeviceInputSystem): void {\r\n const isKeyboardActive = deviceInputSystem.isDeviceAvailable(DeviceType.Keyboard);\r\n const altKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_ALT_KEY) === 1;\r\n const ctrlKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_CTRL_KEY) === 1;\r\n const metaKey =\r\n isKeyboardActive &&\r\n (deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY1) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY2) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY3) === 1);\r\n const shiftKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_SHIFT_KEY) === 1;\r\n\r\n evt.altKey = altKey;\r\n evt.ctrlKey = ctrlKey;\r\n evt.metaKey = metaKey;\r\n evt.shiftKey = shiftKey;\r\n }\r\n\r\n /**\r\n * Create base event object\r\n * @param elementToAttachTo Value to use as event target\r\n * @returns\r\n */\r\n private static _CreateEvent(elementToAttachTo: any): any {\r\n const evt: { [k: string]: any } = {};\r\n evt.preventDefault = () => {};\r\n evt.target = elementToAttachTo;\r\n\r\n return evt;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"eventFactory.js","sourceRoot":"","sources":["../../../../dev/core/src/DeviceInput/eventFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1F;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC3B;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,iBAAiB,CAC3B,UAAsB,EACtB,UAAkB,EAClB,UAAkB,EAClB,YAA8B,EAC9B,iBAAqC,EACrC,iBAAuB,EACvB,SAAkB;QAElB,QAAQ,UAAU,EAAE;YAChB,KAAK,UAAU,CAAC,QAAQ;gBACpB,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;YACrG,KAAK,UAAU,CAAC,KAAK;gBACjB,IAAI,UAAU,KAAK,YAAY,CAAC,WAAW,IAAI,UAAU,KAAK,YAAY,CAAC,WAAW,IAAI,UAAU,KAAK,YAAY,CAAC,WAAW,EAAE;oBAC/H,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;iBACzH;YACL,0CAA0C;YAC1C,KAAK,UAAU,CAAC,KAAK;gBACjB,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,SAAS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,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACxH,MAAM,OAAO,GACT,gBAAgB;YAChB,CAAC,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC;gBACjF,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC;gBACpF,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9F,MAAM,QAAQ,GAAG,gBAAgB,IAAI,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAE1H,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QACpB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,YAAY,CAAC,iBAAsB;QAC9C,MAAM,GAAG,GAAyB,EAAE,CAAC;QACrC,GAAG,CAAC,cAAc,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAC9B,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;CACJ","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport type { IUIEvent } from \"../Events/deviceInputEvents\";\r\nimport { EventConstants } from \"../Events/deviceInputEvents\";\r\nimport type { Nullable } from \"../types\";\r\nimport { DeviceType, NativePointerInput, PointerInput } from \"./InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\n/**\r\n * Class to wrap DeviceInputSystem data into an event object\r\n */\r\nexport class DeviceEventFactory {\r\n /**\r\n * Create device input events based on provided type and slot\r\n *\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @param pointerId PointerId to use for pointer events\r\n * @returns IUIEvent object\r\n */\r\n public static CreateDeviceEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any,\r\n pointerId?: number\r\n ): IUIEvent {\r\n switch (deviceType) {\r\n case DeviceType.Keyboard:\r\n return this._CreateKeyboardEvent(inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n case DeviceType.Mouse:\r\n if (inputIndex === PointerInput.MouseWheelX || inputIndex === PointerInput.MouseWheelY || inputIndex === PointerInput.MouseWheelZ) {\r\n return this._CreateWheelEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n }\r\n // eslint-disable-next-line no-fallthrough\r\n case DeviceType.Touch:\r\n return this._CreatePointerEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo, pointerId);\r\n default:\r\n // eslint-disable-next-line no-throw-literal\r\n throw `Unable to generate event for device ${DeviceType[deviceType]}`;\r\n }\r\n }\r\n\r\n /**\r\n * Creates pointer event\r\n *\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @param pointerId PointerId to use for pointer events\r\n * @returns IUIEvent object (Pointer)\r\n */\r\n private static _CreatePointerEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any,\r\n pointerId?: number\r\n ): any {\r\n const evt = this._CreateMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n if (deviceType === DeviceType.Mouse) {\r\n evt.deviceType = DeviceType.Mouse;\r\n evt.pointerId = 1;\r\n evt.pointerType = \"mouse\";\r\n } else {\r\n evt.deviceType = DeviceType.Touch;\r\n evt.pointerId = pointerId ?? deviceSlot;\r\n evt.pointerType = \"touch\";\r\n }\r\n\r\n let buttons = 0;\r\n\r\n // Populate buttons property with current state of all mouse buttons\r\n // Uses values found on: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.LeftClick);\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.RightClick) * 2;\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MiddleClick) * 4;\r\n evt.buttons = buttons;\r\n\r\n if (inputIndex === PointerInput.Move) {\r\n evt.type = \"pointermove\";\r\n } else if (inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick) {\r\n evt.type = currentState === 1 ? \"pointerdown\" : \"pointerup\";\r\n evt.button = inputIndex - 2;\r\n }\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Wheel Event\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IUIEvent object (Wheel)\r\n */\r\n private static _CreateWheelEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo: any\r\n ): any {\r\n const evt = this._CreateMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n // While WheelEvents don't generally have a pointerId, we used to add one in the InputManager\r\n // This line has been added to make the InputManager more platform-agnostic\r\n // Similar code exists in the WebDeviceInputSystem to handle browser created events\r\n evt.pointerId = 1;\r\n evt.type = \"wheel\";\r\n evt.deltaMode = EventConstants.DOM_DELTA_PIXEL;\r\n evt.deltaX = 0;\r\n evt.deltaY = 0;\r\n evt.deltaZ = 0;\r\n\r\n switch (inputIndex) {\r\n case PointerInput.MouseWheelX:\r\n evt.deltaX = currentState;\r\n break;\r\n case PointerInput.MouseWheelY:\r\n evt.deltaY = currentState;\r\n break;\r\n case PointerInput.MouseWheelZ:\r\n evt.deltaZ = currentState;\r\n break;\r\n }\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Event\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IUIEvent object (Mouse)\r\n */\r\n private static _CreateMouseEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any\r\n ): any {\r\n const evt = this._CreateEvent(elementToAttachTo);\r\n const pointerX = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Horizontal);\r\n const pointerY = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Vertical);\r\n\r\n // Handle offsets/deltas based on existence of HTMLElement\r\n if (elementToAttachTo) {\r\n evt.movementX = 0;\r\n evt.movementY = 0;\r\n evt.offsetX = evt.movementX - elementToAttachTo.getBoundingClientRect().x;\r\n evt.offsetY = evt.movementY - elementToAttachTo.getBoundingClientRect().y;\r\n } else {\r\n evt.movementX = deviceInputSystem.pollInput(deviceType, deviceSlot, NativePointerInput.DeltaHorizontal); // DeltaHorizontal\r\n evt.movementY = deviceInputSystem.pollInput(deviceType, deviceSlot, NativePointerInput.DeltaVertical); // DeltaVertical\r\n evt.offsetX = 0;\r\n evt.offsetY = 0;\r\n }\r\n this._CheckNonCharacterKeys(evt, deviceInputSystem);\r\n\r\n evt.clientX = pointerX;\r\n evt.clientY = pointerY;\r\n evt.x = pointerX;\r\n evt.y = pointerY;\r\n\r\n evt.deviceType = deviceType;\r\n evt.deviceSlot = deviceSlot;\r\n evt.inputIndex = inputIndex;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Keyboard Event\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Keyboard)\r\n */\r\n private static _CreateKeyboardEvent(inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._CreateEvent(elementToAttachTo);\r\n this._CheckNonCharacterKeys(evt, deviceInputSystem);\r\n evt.deviceType = DeviceType.Keyboard;\r\n evt.deviceSlot = 0;\r\n evt.inputIndex = inputIndex;\r\n\r\n evt.type = currentState === 1 ? \"keydown\" : \"keyup\";\r\n evt.key = String.fromCharCode(inputIndex);\r\n evt.keyCode = inputIndex;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Add parameters for non-character keys (Ctrl, Alt, Meta, Shift)\r\n * @param evt Event object to add parameters to\r\n * @param deviceInputSystem DeviceInputSystem to pull values from\r\n */\r\n private static _CheckNonCharacterKeys(evt: any, deviceInputSystem: IDeviceInputSystem): void {\r\n const isKeyboardActive = deviceInputSystem.isDeviceAvailable(DeviceType.Keyboard);\r\n const altKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_ALT_KEY) === 1;\r\n const ctrlKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_CTRL_KEY) === 1;\r\n const metaKey =\r\n isKeyboardActive &&\r\n (deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY1) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY2) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY3) === 1);\r\n const shiftKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_SHIFT_KEY) === 1;\r\n\r\n evt.altKey = altKey;\r\n evt.ctrlKey = ctrlKey;\r\n evt.metaKey = metaKey;\r\n evt.shiftKey = shiftKey;\r\n }\r\n\r\n /**\r\n * Create base event object\r\n * @param elementToAttachTo Value to use as event target\r\n * @returns\r\n */\r\n private static _CreateEvent(elementToAttachTo: any): any {\r\n const evt: { [k: string]: any } = {};\r\n evt.preventDefault = () => {};\r\n evt.target = elementToAttachTo;\r\n\r\n return evt;\r\n }\r\n}\r\n"]}
@@ -39,8 +39,7 @@ export class InternalDeviceSourceManager {
39
39
  }
40
40
  };
41
41
  const onDeviceDisconnected = (deviceType, deviceSlot) => {
42
- var _a;
43
- if ((_a = this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot]) {
42
+ if (this._devices[deviceType]?.[deviceSlot]) {
44
43
  delete this._devices[deviceType][deviceSlot];
45
44
  }
46
45
  for (const manager of this._registeredManagers) {
@@ -1 +1 @@
1
- {"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../dev/core/src/DeviceInput/internalDeviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAE,uBAAuB,EA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,CAAC;QAEF,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YAChC,IAAI,CAAC,kBAAkB,GAAG,IAAI,uBAAuB,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,CAAC,CAAC;SAClH;aAAM;YACH,IAAI,CAAC,kBAAkB,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,CAAC,CAAC;SACvH;IACL,CAAC;IAsBM,OAAO;QACV,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;CACJ","sourcesContent":["import type { IDisposable } from \"../scene\";\r\nimport { DeviceType } from \"./InputDevices/deviceEnums\";\r\nimport type { Observable } from \"../Misc/observable\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\nimport { NativeDeviceInputSystem } from \"./nativeDeviceInputSystem\";\r\nimport { WebDeviceInputSystem } from \"./webDeviceInputSystem\";\r\nimport { DeviceSource } from \"./InputDevices/deviceSource\";\r\nimport type { INative } from \"../Engines/Native/nativeInterfaces\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { IUIEvent } from \"../Events/deviceInputEvents\";\r\n\r\ntype Distribute<T> = T extends DeviceType ? DeviceSource<T> : never;\r\n\r\nexport type DeviceSourceType = Distribute<DeviceType>;\r\n\r\ndeclare const _native: INative;\r\n\r\ndeclare module \"../Engines/engine\" {\r\n interface Engine {\r\n /** @internal */\r\n _deviceSourceManager?: InternalDeviceSourceManager;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface IObservableManager {\r\n onDeviceConnectedObservable: Observable<DeviceSourceType>;\r\n onDeviceDisconnectedObservable: Observable<DeviceSourceType>;\r\n\r\n // Functions\r\n _onInputChanged(deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent): void;\r\n _addDevice(deviceSource: DeviceSource<DeviceType>): void;\r\n _removeDevice(deviceType: DeviceType, deviceSlot: number): void;\r\n}\r\n\r\n/** @internal */\r\nexport class InternalDeviceSourceManager implements IDisposable {\r\n // Public Members\r\n public readonly _deviceInputSystem: IDeviceInputSystem;\r\n\r\n // Private Members\r\n // This is a master list of all device type/slot combos\r\n private readonly _devices: Array<Array<number>>;\r\n\r\n private readonly _registeredManagers = new Array<IObservableManager>();\r\n\r\n public _refCount = 0;\r\n\r\n public constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array<Array<number>>(numberOfDeviceTypes);\r\n\r\n const onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => {\r\n if (!this._devices[deviceType]) {\r\n this._devices[deviceType] = new Array<number>();\r\n }\r\n\r\n if (!this._devices[deviceType][deviceSlot]) {\r\n this._devices[deviceType][deviceSlot] = deviceSlot;\r\n }\r\n for (const manager of this._registeredManagers) {\r\n const deviceSource = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);\r\n manager._addDevice(deviceSource);\r\n }\r\n };\r\n\r\n const onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => {\r\n if (this._devices[deviceType]?.[deviceSlot]) {\r\n delete this._devices[deviceType][deviceSlot];\r\n }\r\n for (const manager of this._registeredManagers) {\r\n manager._removeDevice(deviceType, deviceSlot);\r\n }\r\n };\r\n\r\n const onInputChanged = (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => {\r\n if (eventData) {\r\n for (const manager of this._registeredManagers) {\r\n manager._onInputChanged(deviceType, deviceSlot, eventData);\r\n }\r\n }\r\n };\r\n\r\n if (typeof _native !== \"undefined\") {\r\n this._deviceInputSystem = new NativeDeviceInputSystem(onDeviceConnected, onDeviceDisconnected, onInputChanged);\r\n } else {\r\n this._deviceInputSystem = new WebDeviceInputSystem(engine, onDeviceConnected, onDeviceDisconnected, onInputChanged);\r\n }\r\n }\r\n\r\n // Public Functions\r\n public readonly registerManager = (manager: IObservableManager): void => {\r\n for (let deviceType = 0; deviceType < this._devices.length; deviceType++) {\r\n const device = this._devices[deviceType];\r\n for (const deviceSlotKey in device) {\r\n const deviceSlot = +deviceSlotKey;\r\n manager._addDevice(new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot));\r\n }\r\n }\r\n this._registeredManagers.push(manager);\r\n };\r\n\r\n public readonly unregisterManager = (manager: IObservableManager): void => {\r\n const idx = this._registeredManagers.indexOf(manager);\r\n\r\n if (idx > -1) {\r\n this._registeredManagers.splice(idx, 1);\r\n }\r\n };\r\n\r\n public dispose(): void {\r\n this._deviceInputSystem.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../dev/core/src/DeviceInput/internalDeviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA6B3D,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAYpC,YAAmB,MAAc;QAJhB,wBAAmB,GAAG,IAAI,KAAK,EAAsB,CAAC;QAEhE,cAAS,GAAG,CAAC,CAAC;QA4CrB,mBAAmB;QACH,oBAAe,GAAG,CAAC,OAA2B,EAAQ,EAAE;YACpE,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;gBACtE,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACzC,KAAK,MAAM,aAAa,IAAI,MAAM,EAAE;oBAChC,MAAM,UAAU,GAAG,CAAC,aAAa,CAAC;oBAClC,OAAO,CAAC,UAAU,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;iBACzF;aACJ;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,EAAE,CAAC,UAAU,CAAC,EAAE;gBACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC;aAChD;YACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAC5C,OAAO,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;aACjD;QACL,CAAC,CAAC;QAEF,MAAM,cAAc,GAAG,CAAC,UAAsB,EAAE,UAAkB,EAAE,SAAmB,EAAE,EAAE;YACvF,IAAI,SAAS,EAAE;gBACX,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,mBAAmB,EAAE;oBAC5C,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;iBAC9D;aACJ;QACL,CAAC,CAAC;QAEF,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YAChC,IAAI,CAAC,kBAAkB,GAAG,IAAI,uBAAuB,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,CAAC,CAAC;SAClH;aAAM;YACH,IAAI,CAAC,kBAAkB,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,CAAC,CAAC;SACvH;IACL,CAAC;IAsBM,OAAO;QACV,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;CACJ","sourcesContent":["import type { IDisposable } from \"../scene\";\r\nimport { DeviceType } from \"./InputDevices/deviceEnums\";\r\nimport type { Observable } from \"../Misc/observable\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\nimport { NativeDeviceInputSystem } from \"./nativeDeviceInputSystem\";\r\nimport { WebDeviceInputSystem } from \"./webDeviceInputSystem\";\r\nimport { DeviceSource } from \"./InputDevices/deviceSource\";\r\nimport type { INative } from \"../Engines/Native/nativeInterfaces\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { IUIEvent } from \"../Events/deviceInputEvents\";\r\n\r\ntype Distribute<T> = T extends DeviceType ? DeviceSource<T> : never;\r\n\r\nexport type DeviceSourceType = Distribute<DeviceType>;\r\n\r\ndeclare const _native: INative;\r\n\r\ndeclare module \"../Engines/engine\" {\r\n interface Engine {\r\n /** @internal */\r\n _deviceSourceManager?: InternalDeviceSourceManager;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface IObservableManager {\r\n onDeviceConnectedObservable: Observable<DeviceSourceType>;\r\n onDeviceDisconnectedObservable: Observable<DeviceSourceType>;\r\n\r\n // Functions\r\n _onInputChanged(deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent): void;\r\n _addDevice(deviceSource: DeviceSource<DeviceType>): void;\r\n _removeDevice(deviceType: DeviceType, deviceSlot: number): void;\r\n}\r\n\r\n/** @internal */\r\nexport class InternalDeviceSourceManager implements IDisposable {\r\n // Public Members\r\n public readonly _deviceInputSystem: IDeviceInputSystem;\r\n\r\n // Private Members\r\n // This is a master list of all device type/slot combos\r\n private readonly _devices: Array<Array<number>>;\r\n\r\n private readonly _registeredManagers = new Array<IObservableManager>();\r\n\r\n public _refCount = 0;\r\n\r\n public constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array<Array<number>>(numberOfDeviceTypes);\r\n\r\n const onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => {\r\n if (!this._devices[deviceType]) {\r\n this._devices[deviceType] = new Array<number>();\r\n }\r\n\r\n if (!this._devices[deviceType][deviceSlot]) {\r\n this._devices[deviceType][deviceSlot] = deviceSlot;\r\n }\r\n for (const manager of this._registeredManagers) {\r\n const deviceSource = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);\r\n manager._addDevice(deviceSource);\r\n }\r\n };\r\n\r\n const onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => {\r\n if (this._devices[deviceType]?.[deviceSlot]) {\r\n delete this._devices[deviceType][deviceSlot];\r\n }\r\n for (const manager of this._registeredManagers) {\r\n manager._removeDevice(deviceType, deviceSlot);\r\n }\r\n };\r\n\r\n const onInputChanged = (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => {\r\n if (eventData) {\r\n for (const manager of this._registeredManagers) {\r\n manager._onInputChanged(deviceType, deviceSlot, eventData);\r\n }\r\n }\r\n };\r\n\r\n if (typeof _native !== \"undefined\") {\r\n this._deviceInputSystem = new NativeDeviceInputSystem(onDeviceConnected, onDeviceDisconnected, onInputChanged);\r\n } else {\r\n this._deviceInputSystem = new WebDeviceInputSystem(engine, onDeviceConnected, onDeviceDisconnected, onInputChanged);\r\n }\r\n }\r\n\r\n // Public Functions\r\n public readonly registerManager = (manager: IObservableManager): void => {\r\n for (let deviceType = 0; deviceType < this._devices.length; deviceType++) {\r\n const device = this._devices[deviceType];\r\n for (const deviceSlotKey in device) {\r\n const deviceSlot = +deviceSlotKey;\r\n manager._addDevice(new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot));\r\n }\r\n }\r\n this._registeredManagers.push(manager);\r\n };\r\n\r\n public readonly unregisterManager = (manager: IObservableManager): void => {\r\n const idx = this._registeredManagers.indexOf(manager);\r\n\r\n if (idx > -1) {\r\n this._registeredManagers.splice(idx, 1);\r\n }\r\n };\r\n\r\n public dispose(): void {\r\n this._deviceInputSystem.dispose();\r\n }\r\n}\r\n"]}
@@ -124,7 +124,7 @@ export class WebDeviceInputSystem {
124
124
  * Enable listening for user input events
125
125
  */
126
126
  _enableEvents() {
127
- const inputElement = this === null || this === void 0 ? void 0 : this._engine.getInputElement();
127
+ const inputElement = this?._engine.getInputElement();
128
128
  if (inputElement && (!this._eventsAttached || this._elementToAttachTo !== inputElement)) {
129
129
  // Remove events before adding to avoid double events or simultaneous events on multiple canvases
130
130
  this._disableEvents();
@@ -454,7 +454,6 @@ export class WebDeviceInputSystem {
454
454
  }
455
455
  };
456
456
  this._pointerUpEvent = (evt) => {
457
- var _a, _b, _c, _d, _e;
458
457
  const deviceType = this._getPointerType(evt);
459
458
  const deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);
460
459
  if (deviceType === DeviceType.Touch) {
@@ -466,7 +465,7 @@ export class WebDeviceInputSystem {
466
465
  this._activeTouchIds[deviceSlot] = -1;
467
466
  }
468
467
  }
469
- const pointer = (_a = this._inputs[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot];
468
+ const pointer = this._inputs[deviceType]?.[deviceSlot];
470
469
  if (pointer && pointer[evt.button + 2] !== 0) {
471
470
  const previousHorizontal = pointer[PointerInput.Horizontal];
472
471
  const previousVertical = pointer[PointerInput.Vertical];
@@ -485,10 +484,10 @@ export class WebDeviceInputSystem {
485
484
  // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression
486
485
  // EG. ([X, Y, Left-click], Middle-click, etc...)
487
486
  deviceEvent.inputIndex = evt.button + 2;
488
- if (deviceType === DeviceType.Mouse && this._mouseId >= 0 && ((_c = (_b = this._elementToAttachTo).hasPointerCapture) === null || _c === void 0 ? void 0 : _c.call(_b, this._mouseId))) {
487
+ if (deviceType === DeviceType.Mouse && this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {
489
488
  this._elementToAttachTo.releasePointerCapture(this._mouseId);
490
489
  }
491
- else if (evt.pointerId && ((_e = (_d = this._elementToAttachTo).hasPointerCapture) === null || _e === void 0 ? void 0 : _e.call(_d, evt.pointerId))) {
490
+ else if (evt.pointerId && this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {
492
491
  this._elementToAttachTo.releasePointerCapture(evt.pointerId);
493
492
  }
494
493
  this._onInputChanged(deviceType, deviceSlot, deviceEvent);
@@ -498,10 +497,9 @@ export class WebDeviceInputSystem {
498
497
  }
499
498
  };
500
499
  this._pointerCancelEvent = (evt) => {
501
- var _a, _b, _c, _d;
502
500
  if (evt.pointerType === "mouse") {
503
501
  const pointer = this._inputs[DeviceType.Mouse][0];
504
- if (this._mouseId >= 0 && ((_b = (_a = this._elementToAttachTo).hasPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, this._mouseId))) {
502
+ if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {
505
503
  this._elementToAttachTo.releasePointerCapture(this._mouseId);
506
504
  }
507
505
  for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {
@@ -518,7 +516,7 @@ export class WebDeviceInputSystem {
518
516
  if (deviceSlot === -1) {
519
517
  return;
520
518
  }
521
- if ((_d = (_c = this._elementToAttachTo).hasPointerCapture) === null || _d === void 0 ? void 0 : _d.call(_c, evt.pointerId)) {
519
+ if (this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {
522
520
  this._elementToAttachTo.releasePointerCapture(evt.pointerId);
523
521
  }
524
522
  this._inputs[DeviceType.Touch][deviceSlot][PointerInput.LeftClick] = 0;
@@ -554,11 +552,10 @@ export class WebDeviceInputSystem {
554
552
  /* */
555
553
  }
556
554
  this._pointerBlurEvent = () => {
557
- var _a, _b, _c, _d, _e;
558
555
  // Handle mouse buttons
559
556
  if (this.isDeviceAvailable(DeviceType.Mouse)) {
560
557
  const pointer = this._inputs[DeviceType.Mouse][0];
561
- if (this._mouseId >= 0 && ((_b = (_a = this._elementToAttachTo).hasPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, this._mouseId))) {
558
+ if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {
562
559
  this._elementToAttachTo.releasePointerCapture(this._mouseId);
563
560
  }
564
561
  for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {
@@ -574,10 +571,10 @@ export class WebDeviceInputSystem {
574
571
  const pointer = this._inputs[DeviceType.Touch];
575
572
  for (let deviceSlot = 0; deviceSlot < this._activeTouchIds.length; deviceSlot++) {
576
573
  const pointerId = this._activeTouchIds[deviceSlot];
577
- if ((_d = (_c = this._elementToAttachTo).hasPointerCapture) === null || _d === void 0 ? void 0 : _d.call(_c, pointerId)) {
574
+ if (this._elementToAttachTo.hasPointerCapture?.(pointerId)) {
578
575
  this._elementToAttachTo.releasePointerCapture(pointerId);
579
576
  }
580
- if (pointerId !== -1 && ((_e = pointer[deviceSlot]) === null || _e === void 0 ? void 0 : _e[PointerInput.LeftClick]) === 1) {
577
+ if (pointerId !== -1 && pointer[deviceSlot]?.[PointerInput.LeftClick] === 1) {
581
578
  pointer[deviceSlot][PointerInput.LeftClick] = 0;
582
579
  const deviceEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 0, this, this._elementToAttachTo, pointerId);
583
580
  this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);