@babylonjs/core 8.3.1 → 8.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (336) hide show
  1. package/Animations/animation.d.ts +4 -0
  2. package/Animations/animation.js +22 -13
  3. package/Animations/animation.js.map +1 -1
  4. package/Animations/animation.optimizations.d.ts +31 -0
  5. package/Animations/animation.optimizations.js +41 -0
  6. package/Animations/animation.optimizations.js.map +1 -0
  7. package/Animations/index.d.ts +1 -0
  8. package/Animations/index.js +1 -0
  9. package/Animations/index.js.map +1 -1
  10. package/Animations/pathCursor.js +3 -1
  11. package/Animations/pathCursor.js.map +1 -1
  12. package/Animations/runtimeAnimation.d.ts +3 -1
  13. package/Animations/runtimeAnimation.js +127 -116
  14. package/Animations/runtimeAnimation.js.map +1 -1
  15. package/Audio/audioSceneComponent.js +4 -4
  16. package/Audio/audioSceneComponent.js.map +1 -1
  17. package/Behaviors/Meshes/attachToBoxBehavior.js +6 -6
  18. package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
  19. package/Behaviors/Meshes/fadeInOutBehavior.js +3 -2
  20. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  21. package/Behaviors/Meshes/multiPointerScaleBehavior.js +6 -4
  22. package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
  23. package/Behaviors/Meshes/sixDofDragBehavior.js +3 -2
  24. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  25. package/Bones/skeleton.js +6 -6
  26. package/Bones/skeleton.js.map +1 -1
  27. package/Cameras/Inputs/followCameraKeyboardMoveInput.js +2 -2
  28. package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
  29. package/Cameras/VR/vrExperienceHelper.js +2 -2
  30. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  31. package/Cameras/arcRotateCamera.js +6 -2
  32. package/Cameras/arcRotateCamera.js.map +1 -1
  33. package/Cameras/camera.js +2 -2
  34. package/Cameras/camera.js.map +1 -1
  35. package/Cameras/deviceOrientationCamera.js +3 -2
  36. package/Cameras/deviceOrientationCamera.js.map +1 -1
  37. package/Collisions/gpuPicker.d.ts +1 -0
  38. package/Collisions/gpuPicker.js +14 -4
  39. package/Collisions/gpuPicker.js.map +1 -1
  40. package/Debug/axesViewer.js +3 -2
  41. package/Debug/axesViewer.js.map +1 -1
  42. package/Debug/directionalLightFrustumViewer.js +4 -4
  43. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  44. package/Debug/physicsViewer.js +7 -6
  45. package/Debug/physicsViewer.js.map +1 -1
  46. package/Debug/skeletonViewer.js +4 -4
  47. package/Debug/skeletonViewer.js.map +1 -1
  48. package/Engines/Processors/shaderCodeNode.js +2 -2
  49. package/Engines/Processors/shaderCodeNode.js.map +1 -1
  50. package/Engines/abstractEngine.d.ts +1 -0
  51. package/Engines/abstractEngine.js +14 -8
  52. package/Engines/abstractEngine.js.map +1 -1
  53. package/Engines/constants.d.ts +27 -5
  54. package/Engines/constants.js +27 -5
  55. package/Engines/constants.js.map +1 -1
  56. package/Engines/engine.js +8 -8
  57. package/Engines/engine.js.map +1 -1
  58. package/Engines/webgpuEngine.js +6 -2
  59. package/Engines/webgpuEngine.js.map +1 -1
  60. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +2 -2
  61. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -1
  62. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js +3 -2
  63. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js.map +1 -1
  64. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +3 -2
  65. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  66. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js +2 -2
  67. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js.map +1 -1
  68. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +3 -2
  69. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
  70. package/FlowGraph/flowGraphAsyncExecutionBlock.js +5 -3
  71. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -1
  72. package/FlowGraph/flowGraphBlock.js +3 -2
  73. package/FlowGraph/flowGraphBlock.js.map +1 -1
  74. package/FlowGraph/flowGraphCoordinator.js +10 -6
  75. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  76. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +2 -2
  77. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  78. package/FrameGraph/Node/nodeRenderGraphBlock.js +5 -4
  79. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  80. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +4 -3
  81. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
  82. package/Gamepads/gamepadManager.js +2 -2
  83. package/Gamepads/gamepadManager.js.map +1 -1
  84. package/Gizmos/axisDragGizmo.js +3 -2
  85. package/Gizmos/axisDragGizmo.js.map +1 -1
  86. package/Gizmos/axisScaleGizmo.js +6 -4
  87. package/Gizmos/axisScaleGizmo.js.map +1 -1
  88. package/Gizmos/boundingBoxGizmo.js +28 -26
  89. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  90. package/Gizmos/cameraGizmo.js +6 -3
  91. package/Gizmos/cameraGizmo.js.map +1 -1
  92. package/Gizmos/gizmo.js +11 -10
  93. package/Gizmos/gizmo.js.map +1 -1
  94. package/Gizmos/gizmoManager.js +16 -12
  95. package/Gizmos/gizmoManager.js.map +1 -1
  96. package/Gizmos/lightGizmo.js +3 -2
  97. package/Gizmos/lightGizmo.js.map +1 -1
  98. package/Gizmos/planeDragGizmo.js +3 -2
  99. package/Gizmos/planeDragGizmo.js.map +1 -1
  100. package/Gizmos/planeRotationGizmo.js +3 -2
  101. package/Gizmos/planeRotationGizmo.js.map +1 -1
  102. package/Gizmos/positionGizmo.js +41 -28
  103. package/Gizmos/positionGizmo.js.map +1 -1
  104. package/Gizmos/rotationGizmo.js +26 -18
  105. package/Gizmos/rotationGizmo.js.map +1 -1
  106. package/Gizmos/scaleGizmo.js +47 -32
  107. package/Gizmos/scaleGizmo.js.map +1 -1
  108. package/Layers/effectLayerSceneComponent.js +4 -4
  109. package/Layers/effectLayerSceneComponent.js.map +1 -1
  110. package/Layers/layerSceneComponent.js +4 -4
  111. package/Layers/layerSceneComponent.js.map +1 -1
  112. package/LensFlares/lensFlareSystemSceneComponent.js +4 -4
  113. package/LensFlares/lensFlareSystemSceneComponent.js.map +1 -1
  114. package/Lights/Shadows/shadowGenerator.js +3 -3
  115. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  116. package/Lights/light.js +4 -4
  117. package/Lights/light.js.map +1 -1
  118. package/Loading/Plugins/babylonFileLoader.js +54 -46
  119. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  120. package/Loading/loadingScreen.js +4 -3
  121. package/Loading/loadingScreen.js.map +1 -1
  122. package/Loading/sceneLoader.js +15 -12
  123. package/Loading/sceneLoader.js.map +1 -1
  124. package/Materials/Node/Blocks/Dual/currentScreenBlock.js +9 -3
  125. package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
  126. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +11 -0
  127. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  128. package/Materials/Node/Blocks/Input/inputBlock.js +18 -31
  129. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  130. package/Materials/Node/Blocks/baseMathBlock.js +3 -1
  131. package/Materials/Node/Blocks/baseMathBlock.js.map +1 -1
  132. package/Materials/Node/Blocks/customBlock.js +53 -43
  133. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  134. package/Materials/Node/Enums/nodeMaterialModes.d.ts +3 -1
  135. package/Materials/Node/Enums/nodeMaterialModes.js +2 -0
  136. package/Materials/Node/Enums/nodeMaterialModes.js.map +1 -1
  137. package/Materials/Node/nodeMaterial.d.ts +5 -0
  138. package/Materials/Node/nodeMaterial.js +33 -20
  139. package/Materials/Node/nodeMaterial.js.map +1 -1
  140. package/Materials/Node/nodeMaterialBlock.js +7 -4
  141. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  142. package/Materials/Node/nodeMaterialBuildState.d.ts +13 -2
  143. package/Materials/Node/nodeMaterialBuildState.js +72 -7
  144. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  145. package/Materials/Node/nodeMaterialDefault.d.ts +5 -0
  146. package/Materials/Node/nodeMaterialDefault.js +28 -0
  147. package/Materials/Node/nodeMaterialDefault.js.map +1 -1
  148. package/Materials/Textures/cubeTexture.js +3 -1
  149. package/Materials/Textures/cubeTexture.js.map +1 -1
  150. package/Materials/Textures/videoTexture.js +5 -4
  151. package/Materials/Textures/videoTexture.js.map +1 -1
  152. package/Materials/materialDefines.js +3 -1
  153. package/Materials/materialDefines.js.map +1 -1
  154. package/Materials/multiMaterial.js +3 -1
  155. package/Materials/multiMaterial.js.map +1 -1
  156. package/Materials/shaderMaterial.js +3 -2
  157. package/Materials/shaderMaterial.js.map +1 -1
  158. package/Materials/shadowDepthWrapper.js +6 -0
  159. package/Materials/shadowDepthWrapper.js.map +1 -1
  160. package/Materials/uniformBuffer.js +4 -0
  161. package/Materials/uniformBuffer.js.map +1 -1
  162. package/Meshes/Compression/dracoEncoder.js +2 -2
  163. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  164. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +32 -15
  165. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  166. package/Meshes/GreasedLine/greasedLineMesh.js +6 -6
  167. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  168. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +4 -3
  169. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  170. package/Meshes/Node/Blocks/mathBlock.js +3 -1
  171. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  172. package/Meshes/Node/nodeGeometryBlock.js +8 -5
  173. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  174. package/Meshes/abstractMesh.js +2 -2
  175. package/Meshes/abstractMesh.js.map +1 -1
  176. package/Meshes/geodesicMesh.js +2 -2
  177. package/Meshes/geodesicMesh.js.map +1 -1
  178. package/Meshes/mesh.js +6 -6
  179. package/Meshes/mesh.js.map +1 -1
  180. package/Meshes/mesh.vertexData.functions.js +11 -10
  181. package/Meshes/mesh.vertexData.functions.js.map +1 -1
  182. package/Meshes/mesh.vertexData.subdivide.js +10 -10
  183. package/Meshes/mesh.vertexData.subdivide.js.map +1 -1
  184. package/Meshes/meshSimplification.js +10 -10
  185. package/Meshes/meshSimplification.js.map +1 -1
  186. package/Meshes/meshUtils.js +6 -3
  187. package/Meshes/meshUtils.js.map +1 -1
  188. package/Meshes/polygonMesh.js +10 -10
  189. package/Meshes/polygonMesh.js.map +1 -1
  190. package/Misc/PerformanceViewer/performanceViewerCollector.js +4 -4
  191. package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
  192. package/Misc/arrayTools.js +2 -2
  193. package/Misc/arrayTools.js.map +1 -1
  194. package/Misc/asyncLock.js +9 -9
  195. package/Misc/asyncLock.js.map +1 -1
  196. package/Misc/basis.js +4 -2
  197. package/Misc/basis.js.map +1 -1
  198. package/Misc/deepCopier.js +3 -2
  199. package/Misc/deepCopier.js.map +1 -1
  200. package/Misc/deepMerger.js +3 -2
  201. package/Misc/deepMerger.js.map +1 -1
  202. package/Misc/fileTools.js +4 -4
  203. package/Misc/fileTools.js.map +1 -1
  204. package/Misc/greasedLineTools.js +14 -13
  205. package/Misc/greasedLineTools.js.map +1 -1
  206. package/Misc/logger.js +3 -2
  207. package/Misc/logger.js.map +1 -1
  208. package/Misc/observable.d.ts +3 -2
  209. package/Misc/observable.extensions.js +4 -4
  210. package/Misc/observable.extensions.js.map +1 -1
  211. package/Misc/observable.js +5 -4
  212. package/Misc/observable.js.map +1 -1
  213. package/Misc/sceneSerializer.js +5 -4
  214. package/Misc/sceneSerializer.js.map +1 -1
  215. package/Misc/snapshotRenderingHelper.js +3 -1
  216. package/Misc/snapshotRenderingHelper.js.map +1 -1
  217. package/Misc/tags.js +2 -2
  218. package/Misc/tags.js.map +1 -1
  219. package/Misc/trajectoryClassifier.js +8 -8
  220. package/Misc/trajectoryClassifier.js.map +1 -1
  221. package/Particles/IParticleSystem.d.ts +1 -1
  222. package/Particles/IParticleSystem.js.map +1 -1
  223. package/Particles/baseParticleSystem.d.ts +11 -3
  224. package/Particles/baseParticleSystem.js +37 -3
  225. package/Particles/baseParticleSystem.js.map +1 -1
  226. package/Particles/gpuParticleSystem.js +1 -14
  227. package/Particles/gpuParticleSystem.js.map +1 -1
  228. package/Particles/particle.js +2 -2
  229. package/Particles/particle.js.map +1 -1
  230. package/Particles/particleSystem.js +15 -13
  231. package/Particles/particleSystem.js.map +1 -1
  232. package/Particles/thinParticleSystem.js +3 -16
  233. package/Particles/thinParticleSystem.js.map +1 -1
  234. package/Physics/physicsHelper.js +18 -14
  235. package/Physics/physicsHelper.js.map +1 -1
  236. package/Physics/v1/Plugins/ammoJSPlugin.js +10 -8
  237. package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
  238. package/Physics/v1/Plugins/cannonJSPlugin.js +13 -8
  239. package/Physics/v1/Plugins/cannonJSPlugin.js.map +1 -1
  240. package/Physics/v1/Plugins/oimoJSPlugin.js +9 -8
  241. package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -1
  242. package/Physics/v1/physicsEngine.js +4 -4
  243. package/Physics/v1/physicsEngine.js.map +1 -1
  244. package/Physics/v1/physicsImpostor.js +10 -21
  245. package/Physics/v1/physicsImpostor.js.map +1 -1
  246. package/Physics/v2/Plugins/havokPlugin.js +12 -10
  247. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  248. package/Physics/v2/ragdoll.js +4 -4
  249. package/Physics/v2/ragdoll.js.map +1 -1
  250. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +3 -2
  251. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  252. package/PostProcesses/RenderPipeline/postProcessRenderEffect.js +8 -6
  253. package/PostProcesses/RenderPipeline/postProcessRenderEffect.js.map +1 -1
  254. package/PostProcesses/depthOfFieldMergePostProcess.js +4 -3
  255. package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
  256. package/Rendering/GlobalIllumination/giRSMManager.js +6 -6
  257. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  258. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +14 -14
  259. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  260. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +14 -12
  261. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  262. package/Rendering/iblCdfGenerator.js +4 -4
  263. package/Rendering/iblCdfGenerator.js.map +1 -1
  264. package/Rendering/objectRenderer.js +2 -2
  265. package/Rendering/objectRenderer.js.map +1 -1
  266. package/Rendering/reflectiveShadowMap.js +7 -5
  267. package/Rendering/reflectiveShadowMap.js.map +1 -1
  268. package/ShadersWGSL/gaussianSplatting.vertex.js +1 -1
  269. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  270. package/Sprites/spriteMap.js +2 -2
  271. package/Sprites/spriteMap.js.map +1 -1
  272. package/XR/features/WebXRAbstractFeature.js +2 -2
  273. package/XR/features/WebXRAbstractFeature.js.map +1 -1
  274. package/XR/features/WebXRAnchorSystem.js +4 -4
  275. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  276. package/XR/features/WebXRBackgroundRemover.js +3 -1
  277. package/XR/features/WebXRBackgroundRemover.js.map +1 -1
  278. package/XR/features/WebXRControllerMovement.js +6 -3
  279. package/XR/features/WebXRControllerMovement.js.map +1 -1
  280. package/XR/features/WebXRControllerPhysics.js +12 -7
  281. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  282. package/XR/features/WebXRControllerPointerSelection.js +12 -7
  283. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  284. package/XR/features/WebXRControllerTeleportation.js +11 -7
  285. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  286. package/XR/features/WebXRDepthSensing.js +6 -6
  287. package/XR/features/WebXRDepthSensing.js.map +1 -1
  288. package/XR/features/WebXRHandTracking.js +60 -24
  289. package/XR/features/WebXRHandTracking.js.map +1 -1
  290. package/XR/features/WebXRHitTest.js +4 -4
  291. package/XR/features/WebXRHitTest.js.map +1 -1
  292. package/XR/features/WebXRImageTracking.js +2 -2
  293. package/XR/features/WebXRImageTracking.js.map +1 -1
  294. package/XR/features/WebXRLayers.js +2 -2
  295. package/XR/features/WebXRLayers.js.map +1 -1
  296. package/XR/features/WebXRNearInteraction.js +12 -7
  297. package/XR/features/WebXRNearInteraction.js.map +1 -1
  298. package/XR/features/WebXRRawCameraAccess.js +9 -4
  299. package/XR/features/WebXRRawCameraAccess.js.map +1 -1
  300. package/XR/features/WebXRSpaceWarp.js +2 -2
  301. package/XR/features/WebXRSpaceWarp.js.map +1 -1
  302. package/XR/motionController/webXRAbstractMotionController.js +19 -8
  303. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  304. package/XR/motionController/webXRGenericMotionController.js +2 -2
  305. package/XR/motionController/webXRGenericMotionController.js.map +1 -1
  306. package/XR/motionController/webXRHTCViveMotionController.js +5 -4
  307. package/XR/motionController/webXRHTCViveMotionController.js.map +1 -1
  308. package/XR/motionController/webXRMicrosoftMixedRealityController.js +9 -6
  309. package/XR/motionController/webXRMicrosoftMixedRealityController.js.map +1 -1
  310. package/XR/motionController/webXRMotionControllerManager.js +4 -4
  311. package/XR/motionController/webXRMotionControllerManager.js.map +1 -1
  312. package/XR/motionController/webXROculusTouchMotionController.js +5 -4
  313. package/XR/motionController/webXROculusTouchMotionController.js.map +1 -1
  314. package/XR/motionController/webXRProfiledMotionController.js +15 -10
  315. package/XR/motionController/webXRProfiledMotionController.js.map +1 -1
  316. package/XR/webXRCamera.js +3 -2
  317. package/XR/webXRCamera.js.map +1 -1
  318. package/XR/webXREnterExitUI.js +5 -4
  319. package/XR/webXREnterExitUI.js.map +1 -1
  320. package/XR/webXRExperienceHelper.js +2 -2
  321. package/XR/webXRExperienceHelper.js.map +1 -1
  322. package/XR/webXRFeaturesManager.js +10 -7
  323. package/XR/webXRFeaturesManager.js.map +1 -1
  324. package/XR/webXRInput.js +8 -8
  325. package/XR/webXRInput.js.map +1 -1
  326. package/XR/webXRInputSource.js +4 -1
  327. package/XR/webXRInputSource.js.map +1 -1
  328. package/XR/webXRRenderTargetTextureProvider.js +3 -1
  329. package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
  330. package/assetContainer.js +156 -135
  331. package/assetContainer.js.map +1 -1
  332. package/node.js +2 -2
  333. package/node.js.map +1 -1
  334. package/package.json +1 -1
  335. package/scene.js +18 -11
  336. package/scene.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"trajectoryClassifier.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/trajectoryClassifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvD,8EAA8E;AAC9E,0CAA0C;AAE1C;;GAEG;AACH,IAAU,WAAW,CA+NpB;AA/ND,WAAU,WAAW;IACjB;;;OAGG;IACH,MAAa,QAAQ;QAMjB;;;WAGG;QACI,SAAS;YACZ,MAAM,UAAU,GAAQ,EAAE,CAAC;YAE3B,MAAM,UAAU,GAAG,IAAI,KAAK,CAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAC3D,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,E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;QACD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type { DeepImmutable, Nullable } from \"../types\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\n\r\n// This implementation was based on the original MIT-licensed TRACE repository\r\n// from https://github.com/septagon/TRACE.\r\n\r\n/**\r\n * Generic implementation of Levenshtein distance.\r\n */\r\nnamespace Levenshtein {\r\n /**\r\n * Alphabet from which to construct sequences to be compared using Levenshtein\r\n * distance.\r\n */\r\n export class Alphabet<T> {\r\n private _characterToIdx: Map<T, number>;\r\n private _insertionCosts: number[];\r\n private _deletionCosts: number[];\r\n private _substitutionCosts: number[][];\r\n\r\n /**\r\n * Serialize the Alphabet to JSON string.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n const jsonObject: any = {};\r\n\r\n const characters = new Array<T>(this._characterToIdx.size);\r\n this._characterToIdx.forEach((v, k) => {\r\n characters[v] = k;\r\n });\r\n jsonObject[\"characters\"] = characters;\r\n\r\n jsonObject[\"insertionCosts\"] = this._insertionCosts;\r\n jsonObject[\"deletionCosts\"] = this._deletionCosts;\r\n jsonObject[\"substitutionCosts\"] = this._substitutionCosts;\r\n\r\n return JSON.stringify(jsonObject);\r\n }\r\n\r\n /**\r\n * Parse an Alphabet from a JSON serialization.\r\n * @param json JSON string to deserialize\r\n * @returns deserialized Alphabet\r\n */\r\n public static Deserialize<T>(json: string): Alphabet<T> {\r\n const jsonObject = JSON.parse(json);\r\n const alphabet = new Alphabet(jsonObject[\"characters\"] as T[]);\r\n alphabet._insertionCosts = jsonObject[\"insertionCosts\"];\r\n alphabet._deletionCosts = jsonObject[\"deletionCosts\"];\r\n alphabet._substitutionCosts = jsonObject[\"substitutionCosts\"];\r\n return alphabet;\r\n }\r\n\r\n /**\r\n * Create a new Alphabet.\r\n * @param characters characters of the alphabet\r\n * @param charToInsertionCost function mapping characters to insertion costs\r\n * @param charToDeletionCost function mapping characters to deletion costs\r\n * @param charsToSubstitutionCost function mapping character pairs to substitution costs\r\n */\r\n public constructor(\r\n characters: Array<T>,\r\n charToInsertionCost: Nullable<(char: T) => number> = null,\r\n charToDeletionCost: Nullable<(char: T) => number> = null,\r\n charsToSubstitutionCost: Nullable<(outChar: T, inChar: T) => number> = null\r\n ) {\r\n charToInsertionCost = charToInsertionCost ?? (() => 1);\r\n charToDeletionCost = charToDeletionCost ?? (() => 1);\r\n charsToSubstitutionCost = charsToSubstitutionCost ?? ((a: T, b: T) => (a === b ? 0 : 1));\r\n\r\n this._characterToIdx = new Map<T, number>();\r\n this._insertionCosts = new Array<number>(characters.length);\r\n this._deletionCosts = new Array<number>(characters.length);\r\n this._substitutionCosts = new Array<Array<number>>(characters.length);\r\n\r\n let c: T;\r\n for (let outerIdx = 0; outerIdx < characters.length; ++outerIdx) {\r\n c = characters[outerIdx];\r\n this._characterToIdx.set(c, outerIdx);\r\n this._insertionCosts[outerIdx] = charToInsertionCost(c);\r\n this._deletionCosts[outerIdx] = charToDeletionCost(c);\r\n\r\n this._substitutionCosts[outerIdx] = new Array<number>(characters.length);\r\n for (let innerIdx = outerIdx; innerIdx < characters.length; ++innerIdx) {\r\n this._substitutionCosts[outerIdx][innerIdx] = charsToSubstitutionCost(c, characters[innerIdx]);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Get the index (internally-assigned number) for a character.\r\n * @param char character\r\n * @returns index\r\n */\r\n public getCharacterIdx(char: T): number {\r\n return this._characterToIdx.get(char)!;\r\n }\r\n\r\n /**\r\n * Get the insertion cost of a character from its index.\r\n * @param idx character index\r\n * @returns insertion cost\r\n */\r\n public getInsertionCost(idx: number): number {\r\n return this._insertionCosts[idx];\r\n }\r\n\r\n /**\r\n * Get the deletion cost of a character from its index.\r\n * @param idx character index\r\n * @returns deletion cost\r\n */\r\n public getDeletionCost(idx: number): number {\r\n return this._deletionCosts[idx];\r\n }\r\n\r\n /**\r\n * Gets the cost to substitute two characters. NOTE: this cost is\r\n * required to be bi-directional, meaning it cannot matter which of\r\n * the provided characters is being removed and which is being inserted.\r\n * @param idx1 the first character index\r\n * @param idx2 the second character index\r\n * @returns substitution cost\r\n */\r\n public getSubstitutionCost(idx1: number, idx2: number): number {\r\n const min = Math.min(idx1, idx2);\r\n const max = Math.max(idx1, idx2);\r\n\r\n return this._substitutionCosts[min][max];\r\n }\r\n }\r\n\r\n /**\r\n * Character sequence intended to be compared against other Sequences created\r\n * with the same Alphabet in order to compute Levenshtein distance.\r\n */\r\n export class Sequence<T> {\r\n private _alphabet: Alphabet<T>;\r\n private _characters: number[];\r\n\r\n // Scratch values\r\n private static readonly _MAX_SEQUENCE_LENGTH = 256;\r\n private static _CostMatrix = [...Array(Sequence._MAX_SEQUENCE_LENGTH + 1)].map(() => new Array<number>(Sequence._MAX_SEQUENCE_LENGTH + 1));\r\n private static _InsertionCost: number;\r\n private static _DeletionCost: number;\r\n private static _SubstitutionCost: number;\r\n\r\n /**\r\n * Serialize to JSON string. JSON representation does NOT include the Alphabet\r\n * from which this Sequence was created; Alphabet must be independently\r\n * serialized.\r\n * @returns JSON string\r\n */\r\n public serialize(): string {\r\n return JSON.stringify(this._characters);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON string and Alphabet. This should be the same Alphabet\r\n * from which the Sequence was originally created, which must be serialized and\r\n * deserialized independently so that it can be passed in here.\r\n * @param json JSON string representation of Sequence\r\n * @param alphabet Alphabet from which Sequence was originally created\r\n * @returns Sequence\r\n */\r\n public static Deserialize<T>(json: string, alphabet: Alphabet<T>): Sequence<T> {\r\n const sequence = new Sequence([], alphabet);\r\n sequence._characters = JSON.parse(json);\r\n return sequence;\r\n }\r\n\r\n /**\r\n * Create a new Sequence.\r\n * @param characters characters in the new Sequence\r\n * @param alphabet Alphabet, which must include all used characters\r\n */\r\n public constructor(characters: T[], alphabet: Alphabet<T>) {\r\n if (characters.length > Sequence._MAX_SEQUENCE_LENGTH) {\r\n throw new Error(\"Sequences longer than \" + Sequence._MAX_SEQUENCE_LENGTH + \" not supported.\");\r\n }\r\n this._alphabet = alphabet;\r\n this._characters = characters.map((c) => this._alphabet.getCharacterIdx(c));\r\n }\r\n\r\n /**\r\n * Get the distance between this Sequence and another.\r\n * @param other sequence to compare to\r\n * @returns Levenshtein distance\r\n */\r\n public distance(other: Sequence<T>): number {\r\n return Sequence._Distance<T>(this, other);\r\n }\r\n\r\n /**\r\n * Compute the Levenshtein distance between two Sequences.\r\n * @param a first Sequence\r\n * @param b second Sequence\r\n * @returns Levenshtein distance\r\n */\r\n private static _Distance<T>(a: Sequence<T>, b: Sequence<T>): number {\r\n const alphabet = a._alphabet;\r\n if (alphabet !== b._alphabet) {\r\n throw new Error(\"Cannot Levenshtein compare Sequences built from different alphabets.\");\r\n }\r\n const aChars = a._characters;\r\n const bChars = b._characters;\r\n const aLength = aChars.length;\r\n const bLength = bChars.length;\r\n\r\n const costMatrix = Sequence._CostMatrix;\r\n costMatrix[0][0] = 0;\r\n for (let idx = 0; idx < aLength; ++idx) {\r\n costMatrix[idx + 1][0] = costMatrix[idx][0] + alphabet.getInsertionCost(aChars[idx]);\r\n }\r\n for (let idx = 0; idx < bLength; ++idx) {\r\n costMatrix[0][idx + 1] = costMatrix[0][idx] + alphabet.getInsertionCost(bChars[idx]);\r\n }\r\n\r\n for (let aIdx = 0; aIdx < aLength; ++aIdx) {\r\n for (let bIdx = 0; bIdx < bLength; ++bIdx) {\r\n Sequence._InsertionCost = costMatrix[aIdx + 1][bIdx] + alphabet.getInsertionCost(bChars[bIdx]);\r\n Sequence._DeletionCost = costMatrix[aIdx][bIdx + 1] + alphabet.getDeletionCost(aChars[aIdx]);\r\n Sequence._SubstitutionCost = costMatrix[aIdx][bIdx] + alphabet.getSubstitutionCost(aChars[aIdx], bChars[bIdx]);\r\n\r\n costMatrix[aIdx + 1][bIdx + 1] = Math.min(Sequence._InsertionCost, Sequence._DeletionCost, Sequence._SubstitutionCost);\r\n }\r\n }\r\n\r\n return costMatrix[aLength][bLength];\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A 3D trajectory consisting of an order list of vectors describing a\r\n * path of motion through 3D space.\r\n */\r\nexport class Trajectory {\r\n private _points: Vector3[];\r\n private readonly _segmentLength: number;\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns serialized JSON string\r\n */\r\n public serialize(): string {\r\n return JSON.stringify(this);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON.\r\n * @param json serialized JSON string\r\n * @returns deserialized Trajectory\r\n */\r\n public static Deserialize(json: string): Trajectory {\r\n const jsonObject = JSON.parse(json);\r\n const trajectory = new Trajectory(jsonObject[\"_segmentLength\"]);\r\n trajectory._points = jsonObject[\"_points\"].map((pt: any) => {\r\n return new Vector3(pt[\"_x\"], pt[\"_y\"], pt[\"_z\"]);\r\n });\r\n return trajectory;\r\n }\r\n\r\n /**\r\n * Create a new empty Trajectory.\r\n * @param segmentLength radius of discretization for Trajectory points\r\n */\r\n public constructor(segmentLength: number = 0.01) {\r\n this._points = [];\r\n this._segmentLength = segmentLength;\r\n }\r\n\r\n /**\r\n * Get the length of the Trajectory.\r\n * @returns length of the Trajectory\r\n */\r\n public getLength(): number {\r\n return this._points.length * this._segmentLength;\r\n }\r\n\r\n /**\r\n * Append a new point to the Trajectory.\r\n * NOTE: This implementation has many allocations.\r\n * @param point point to append to the Trajectory\r\n */\r\n public add(point: DeepImmutable<Vector3>): void {\r\n let numPoints = this._points.length;\r\n if (numPoints === 0) {\r\n this._points.push(point.clone());\r\n } else {\r\n const getT = () => this._segmentLength / Vector3.Distance(this._points[numPoints - 1], point);\r\n for (let t = getT(); t <= 1.0; t = getT()) {\r\n const newPoint = this._points[numPoints - 1].scale(1.0 - t);\r\n point.scaleAndAddToRef(t, newPoint);\r\n this._points.push(newPoint);\r\n ++numPoints;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Create a new Trajectory with a segment length chosen to make it\r\n * probable that the new Trajectory will have a specified number of\r\n * segments. This operation is imprecise.\r\n * @param targetResolution number of segments desired\r\n * @returns new Trajectory with approximately the requested number of segments\r\n */\r\n public resampleAtTargetResolution(targetResolution: number): Trajectory {\r\n const resampled = new Trajectory(this.getLength() / targetResolution);\r\n this._points.forEach((pt) => {\r\n resampled.add(pt);\r\n });\r\n return resampled;\r\n }\r\n\r\n /**\r\n * Convert Trajectory segments into tokenized representation. This\r\n * representation is an array of numbers where each nth number is the\r\n * index of the token which is most similar to the nth segment of the\r\n * Trajectory.\r\n * @param tokens list of vectors which serve as discrete tokens\r\n * @returns list of indices of most similar token per segment\r\n */\r\n public tokenize(tokens: DeepImmutable<Vector3[]>): number[] {\r\n const tokenization: number[] = [];\r\n\r\n const segmentDir = new Vector3();\r\n for (let idx = 2; idx < this._points.length; ++idx) {\r\n if (Trajectory._TransformSegmentDirToRef(this._points[idx - 2], this._points[idx - 1], this._points[idx], segmentDir)) {\r\n tokenization.push(Trajectory._TokenizeSegment(segmentDir, tokens));\r\n }\r\n }\r\n\r\n return tokenization;\r\n }\r\n\r\n private static _ForwardDir = new Vector3();\r\n private static _InverseFromVec = new Vector3();\r\n private static _UpDir = new Vector3();\r\n private static _FromToVec = new Vector3();\r\n private static _LookMatrix = new Matrix();\r\n\r\n /**\r\n * Transform the rotation (i.e., direction) of a segment to isolate\r\n * the relative transformation represented by the segment. This operation\r\n * may or may not succeed due to singularities in the equations that define\r\n * motion relativity in this context.\r\n * @param priorVec the origin of the prior segment\r\n * @param fromVec the origin of the current segment\r\n * @param toVec the destination of the current segment\r\n * @param result reference to output variable\r\n * @returns whether or not transformation was successful\r\n */\r\n private static _TransformSegmentDirToRef(priorVec: DeepImmutable<Vector3>, fromVec: DeepImmutable<Vector3>, toVec: DeepImmutable<Vector3>, result: Vector3): boolean {\r\n const DOT_PRODUCT_SAMPLE_REJECTION_THRESHOLD = 0.98;\r\n\r\n fromVec.subtractToRef(priorVec, Trajectory._ForwardDir);\r\n Trajectory._ForwardDir.normalize();\r\n fromVec.scaleToRef(-1, Trajectory._InverseFromVec);\r\n Trajectory._InverseFromVec.normalize();\r\n\r\n if (Math.abs(Vector3.Dot(Trajectory._ForwardDir, Trajectory._InverseFromVec)) > DOT_PRODUCT_SAMPLE_REJECTION_THRESHOLD) {\r\n return false;\r\n }\r\n\r\n Vector3.CrossToRef(Trajectory._ForwardDir, Trajectory._InverseFromVec, Trajectory._UpDir);\r\n Trajectory._UpDir.normalize();\r\n Matrix.LookAtLHToRef(priorVec, fromVec, Trajectory._UpDir, Trajectory._LookMatrix);\r\n toVec.subtractToRef(fromVec, Trajectory._FromToVec);\r\n Trajectory._FromToVec.normalize();\r\n Vector3.TransformNormalToRef(Trajectory._FromToVec, Trajectory._LookMatrix, result);\r\n return true;\r\n }\r\n\r\n private static _BestMatch: number;\r\n private static _Score: number;\r\n private static _BestScore: number;\r\n\r\n /**\r\n * Determine which token vector is most similar to the\r\n * segment vector.\r\n * @param segment segment vector\r\n * @param tokens token vector list\r\n * @returns index of the most similar token to the segment\r\n */\r\n private static _TokenizeSegment(segment: DeepImmutable<Vector3>, tokens: DeepImmutable<Vector3[]>): number {\r\n Trajectory._BestMatch = 0;\r\n Trajectory._Score = Vector3.Dot(segment, tokens[0]);\r\n Trajectory._BestScore = Trajectory._Score;\r\n for (let idx = 1; idx < tokens.length; ++idx) {\r\n Trajectory._Score = Vector3.Dot(segment, tokens[idx]);\r\n if (Trajectory._Score > Trajectory._BestScore) {\r\n Trajectory._BestMatch = idx;\r\n Trajectory._BestScore = Trajectory._Score;\r\n }\r\n }\r\n\r\n return Trajectory._BestMatch;\r\n }\r\n}\r\n\r\n/**\r\n * Collection of vectors intended to be used as the basis of Trajectory\r\n * tokenization for Levenshtein distance comparison. Canonically, a\r\n * Vector3Alphabet will resemble a \"spikeball\" of vectors distributed\r\n * roughly evenly over the surface of the unit sphere.\r\n */\r\nclass Vector3Alphabet {\r\n /**\r\n * Characters in the alphabet.\r\n * NOTE: There is no reason for this property to exist and this class should just extend\r\n * Array<Vector3>, except that doing so produces bizarre build-time errors indicating that\r\n * the ES5 library itself fails its own TypeDoc validation.\r\n */\r\n public chars: Vector3[];\r\n\r\n /**\r\n * Helper method to create new \"spikeball\" Vector3Alphabets. Uses a naive\r\n * optimize-from-random strategy to space points around the unit sphere\r\n * surface as a simple alternative to really doing the math to tile the\r\n * sphere.\r\n * @param alphabetSize size of the desired alphabet\r\n * @param iterations number of iterations over which to optimize the \"spikeball\"\r\n * @param startingStepSize distance factor to move points in early optimization iterations\r\n * @param endingStepSize distance factor to move points in late optimization iterations\r\n * @param fixedValues alphabet \"characters\" that are required and cannot be moved by optimization\r\n * @returns a new randomly generated and optimized Vector3Alphabet of the specified size\r\n */\r\n public static Generate(\r\n alphabetSize: number = 64,\r\n iterations: number = 256,\r\n startingStepSize: number = 0.1,\r\n endingStepSize: number = 0.001,\r\n fixedValues: DeepImmutable<Vector3[]> = []\r\n ): Vector3Alphabet {\r\n const EPSILON = 0.001;\r\n const EPSILON_SQUARED = EPSILON * EPSILON;\r\n\r\n const alphabet = new Vector3Alphabet(alphabetSize);\r\n for (let idx = 0; idx < alphabetSize; ++idx) {\r\n alphabet.chars[idx] = new Vector3(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);\r\n alphabet.chars[idx].normalize();\r\n }\r\n\r\n for (let idx = 0; idx < fixedValues.length; ++idx) {\r\n alphabet.chars[idx].copyFrom(fixedValues[idx]);\r\n }\r\n\r\n let stepSize: number;\r\n let distSq: number;\r\n const force = new Vector3();\r\n const scratch = new Vector3();\r\n const lerp = (l: number, r: number, t: number) => (1.0 - t) * l + t * r;\r\n for (let iteration = 0; iteration < iterations; ++iteration) {\r\n stepSize = lerp(startingStepSize, endingStepSize, iteration / (iterations - 1));\r\n for (let idx = fixedValues.length; idx < alphabet.chars.length; ++idx) {\r\n force.copyFromFloats(0, 0, 0);\r\n alphabet.chars.forEach((pt) => {\r\n alphabet.chars[idx].subtractToRef(pt, scratch);\r\n distSq = scratch.lengthSquared();\r\n if (distSq > EPSILON_SQUARED) {\r\n scratch.scaleAndAddToRef(1 / (scratch.lengthSquared() * distSq), force);\r\n }\r\n });\r\n force.scaleInPlace(stepSize);\r\n alphabet.chars[idx].addInPlace(force);\r\n alphabet.chars[idx].normalize();\r\n }\r\n }\r\n\r\n return alphabet;\r\n }\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n return JSON.stringify(this.chars);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON.\r\n * @param json JSON serialization\r\n * @returns deserialized Vector3Alphabet\r\n */\r\n public static Deserialize(json: string): Vector3Alphabet {\r\n const jsonObject = JSON.parse(json);\r\n const alphabet = new Vector3Alphabet(jsonObject.length);\r\n for (let idx = 0; idx < jsonObject.length; ++idx) {\r\n alphabet.chars[idx] = new Vector3(jsonObject[idx][\"_x\"], jsonObject[idx][\"_y\"], jsonObject[idx][\"_z\"]);\r\n }\r\n return alphabet;\r\n }\r\n\r\n private constructor(size: number) {\r\n this.chars = new Array(size);\r\n }\r\n}\r\n\r\n/**\r\n * Class which formalizes the manner in which a Vector3Alphabet is used to tokenize and\r\n * describe a Trajectory. This class houses the functionality which determines what\r\n * attributes of Trajectories are and are not considered important, such as scale.\r\n */\r\nclass TrajectoryDescriptor {\r\n private static readonly _FINEST_DESCRIPTOR_RESOLUTION = 32;\r\n\r\n private _sequences: Levenshtein.Sequence<number>[];\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n return JSON.stringify(this._sequences.map((sequence) => sequence.serialize()));\r\n }\r\n\r\n /**\r\n * Deserialize from JSON string and Alphabet. This should be the same Alphabet\r\n * from which the descriptor was originally created, which must be serialized and\r\n * deserialized independently so that it can be passed in here.\r\n * @param json JSON serialization\r\n * @param alphabet Alphabet from which descriptor was originally created\r\n * @returns deserialized TrajectoryDescriptor\r\n */\r\n public static Deserialize(json: string, alphabet: Levenshtein.Alphabet<number>): TrajectoryDescriptor {\r\n const descriptor = new TrajectoryDescriptor();\r\n descriptor._sequences = (JSON.parse(json) as string[]).map((s) => Levenshtein.Sequence.Deserialize(s, alphabet));\r\n return descriptor;\r\n }\r\n\r\n /**\r\n * Create a new TrajectoryDescriptor to describe a provided Trajectory according\r\n * to the provided alphabets.\r\n * @param trajectory Trajectory to be described\r\n * @param vector3Alphabet Vector3Alphabet to be used to tokenize the Trajectory\r\n * @param levenshteinAlphabet Levenshtein.Alphabet to be used as basis for comparison with other descriptors\r\n * @returns TrajectoryDescriptor describing provided Trajectory\r\n */\r\n public static CreateFromTrajectory(trajectory: Trajectory, vector3Alphabet: Vector3Alphabet, levenshteinAlphabet: Levenshtein.Alphabet<number>): TrajectoryDescriptor {\r\n return TrajectoryDescriptor.CreateFromTokenizationPyramid(TrajectoryDescriptor._GetTokenizationPyramid(trajectory, vector3Alphabet), levenshteinAlphabet);\r\n }\r\n\r\n /**\r\n * Create a new TrajectoryDescriptor from a pre-existing pyramid of tokens.\r\n * NOTE: This function exists to support an outdated serialization mechanism and should\r\n * be deleted if it is no longer useful.\r\n * @param pyramid tokenization pyramid\r\n * @param levenshteinAlphabet Levenshtein.Alphabet to be uses as basis for comparison with other descriptors\r\n * @returns TrajectoryDescriptor describing the Trajectory from which the pyramid was built\r\n */\r\n public static CreateFromTokenizationPyramid(pyramid: number[][], levenshteinAlphabet: Levenshtein.Alphabet<number>): TrajectoryDescriptor {\r\n const descriptor = new TrajectoryDescriptor();\r\n descriptor._sequences = pyramid.map((tokens) => new Levenshtein.Sequence<number>(tokens, levenshteinAlphabet));\r\n return descriptor;\r\n }\r\n\r\n private constructor() {\r\n this._sequences = [];\r\n }\r\n\r\n /**\r\n * Create the tokenization pyramid for the provided Trajectory according to the given\r\n * Vector3Alphabet.\r\n * @param trajectory Trajectory to be tokenized\r\n * @param alphabet Vector3Alphabet containing tokens\r\n * @param targetResolution finest resolution of descriptor\r\n * @returns tokenization pyramid for Trajectory\r\n */\r\n private static _GetTokenizationPyramid(\r\n trajectory: Trajectory,\r\n alphabet: Vector3Alphabet,\r\n targetResolution: number = TrajectoryDescriptor._FINEST_DESCRIPTOR_RESOLUTION\r\n ): number[][] {\r\n const pyramid: number[][] = [];\r\n for (let res = targetResolution; res > 4; res = Math.floor(res / 2)) {\r\n pyramid.push(trajectory.resampleAtTargetResolution(res).tokenize(alphabet.chars));\r\n }\r\n return pyramid;\r\n }\r\n\r\n /**\r\n * Calculate a distance metric between this TrajectoryDescriptor and another. This is\r\n * essentially a similarity score and does not directly represent Euclidean distance,\r\n * edit distance, or any other formal distance metric.\r\n * @param other TrajectoryDescriptor from which to determine distance\r\n * @returns distance, a nonnegative similarity score where larger values indicate dissimilarity\r\n */\r\n public distance(other: TrajectoryDescriptor): number {\r\n let totalDistance = 0;\r\n let weight: number;\r\n for (let idx = 0; idx < this._sequences.length; ++idx) {\r\n weight = Math.pow(2, idx);\r\n totalDistance += weight * this._sequences[idx].distance(other._sequences[idx]);\r\n }\r\n return totalDistance;\r\n }\r\n}\r\n\r\n/**\r\n * A set of TrajectoryDescriptors defined to be \"the same.\" This is essentially a helper\r\n * class to facilitate methods of Trajectory clustering.\r\n */\r\nclass TrajectoryClass {\r\n private static readonly _MIN_AVERAGE_DISTANCE = 1;\r\n\r\n private _descriptors: TrajectoryDescriptor[];\r\n private _centroidIdx: number;\r\n private _averageDistance: number;\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n const jsonObject: any = {};\r\n jsonObject.descriptors = this._descriptors.map((desc) => desc.serialize());\r\n jsonObject.centroidIdx = this._centroidIdx;\r\n jsonObject.averageDistance = this._averageDistance;\r\n return JSON.stringify(jsonObject);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON string and Alphabet. This should be the same Alphabet\r\n * from which the descriptors were originally created, which must be serialized and\r\n * deserialized independently so that it can be passed in here.\r\n * @param json JSON string representation\r\n * @param alphabet Alphabet from which TrajectoryDescriptors were originally created\r\n * @returns deserialized TrajectoryDescriptor\r\n */\r\n public static Deserialize(json: string, alphabet: Levenshtein.Alphabet<number>): TrajectoryClass {\r\n const jsonObject = JSON.parse(json);\r\n const described = new TrajectoryClass();\r\n described._descriptors = jsonObject.descriptors.map((s: string) => TrajectoryDescriptor.Deserialize(s, alphabet));\r\n described._centroidIdx = jsonObject.centroidIdx;\r\n described._averageDistance = jsonObject.averageDistance;\r\n return described;\r\n }\r\n\r\n /**\r\n * Create a new DescribedTrajectory.\r\n * @param descriptors currently-known TrajectoryDescriptors, if any\r\n */\r\n public constructor(descriptors: TrajectoryDescriptor[] = []) {\r\n this._descriptors = descriptors;\r\n this._centroidIdx = -1;\r\n this._averageDistance = 0;\r\n\r\n this._refreshDescription();\r\n }\r\n\r\n /**\r\n * Add a new TrajectoryDescriptor to the list of descriptors known to describe\r\n * this same DescribedTrajectory.\r\n * @param descriptor descriptor to be added\r\n */\r\n public add(descriptor: TrajectoryDescriptor): void {\r\n this._descriptors.push(descriptor);\r\n this._refreshDescription();\r\n }\r\n\r\n /**\r\n * Compute the cost, which is inversely related to the likelihood that the provided\r\n * TrajectoryDescriptor describes a Trajectory that is considered to be the same as\r\n * the class represented by this DescribedTrajectory.\r\n * @param descriptor the descriptor to be costed\r\n * @returns cost of the match, which is a nonnegative similarity metric where larger values indicate dissimilarity\r\n */\r\n public getMatchCost(descriptor: TrajectoryDescriptor): number {\r\n return descriptor.distance(this._descriptors[this._centroidIdx]) / this._averageDistance;\r\n }\r\n\r\n /**\r\n * Compute the minimum distance between the queried TrajectoryDescriptor and a\r\n * descriptor which is a member of this collection. This is an alternative way of\r\n * conceptualizing match cost from getMatchCost(), and it serves a different function.\r\n * @param descriptor the descriptor to find the minimum distance to\r\n * @returns minimum descriptor distance to a member descriptor of this DescribedTrajectory\r\n */\r\n public getMatchMinimumDistance(descriptor: TrajectoryDescriptor): number {\r\n return Math.min(...this._descriptors.map((desc) => desc.distance(descriptor)));\r\n }\r\n\r\n /**\r\n * Refreshes the internal representation of this DescribedTrajectory.\r\n */\r\n private _refreshDescription(): void {\r\n this._centroidIdx = -1;\r\n let sum: number;\r\n const distances = this._descriptors.map((a) => {\r\n sum = 0;\r\n this._descriptors.forEach((b) => {\r\n sum += a.distance(b);\r\n });\r\n return sum;\r\n });\r\n for (let idx = 0; idx < distances.length; ++idx) {\r\n if (this._centroidIdx < 0 || distances[idx] < distances[this._centroidIdx]) {\r\n this._centroidIdx = idx;\r\n }\r\n }\r\n\r\n this._averageDistance = 0;\r\n this._descriptors.forEach((desc) => {\r\n this._averageDistance += desc.distance(this._descriptors[this._centroidIdx]);\r\n });\r\n if (this._descriptors.length > 0) {\r\n this._averageDistance = Math.max(this._averageDistance / this._descriptors.length, TrajectoryClass._MIN_AVERAGE_DISTANCE);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Class representing a set of known, named trajectories to which Trajectories can be\r\n * added and using which Trajectories can be recognized.\r\n */\r\nexport class TrajectoryClassifier {\r\n private _maximumAllowableMatchCost: number = 4;\r\n private _vector3Alphabet: Vector3Alphabet;\r\n private _levenshteinAlphabet: Levenshtein.Alphabet<number>;\r\n private _nameToDescribedTrajectory: Map<string, TrajectoryClass>;\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n const jsonObject: any = {};\r\n jsonObject.maximumAllowableMatchCost = this._maximumAllowableMatchCost;\r\n jsonObject.vector3Alphabet = this._vector3Alphabet.serialize();\r\n jsonObject.levenshteinAlphabet = this._levenshteinAlphabet.serialize();\r\n jsonObject.nameToDescribedTrajectory = [];\r\n this._nameToDescribedTrajectory.forEach((described, name) => {\r\n jsonObject.nameToDescribedTrajectory.push(name);\r\n jsonObject.nameToDescribedTrajectory.push(described.serialize());\r\n });\r\n return JSON.stringify(jsonObject);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON.\r\n * @param json JSON serialization\r\n * @returns deserialized TrajectorySet\r\n */\r\n public static Deserialize(json: string): TrajectoryClassifier {\r\n const jsonObject = JSON.parse(json);\r\n const classifier = new TrajectoryClassifier();\r\n classifier._maximumAllowableMatchCost = jsonObject.maximumAllowableMatchCost;\r\n classifier._vector3Alphabet = Vector3Alphabet.Deserialize(jsonObject.vector3Alphabet);\r\n classifier._levenshteinAlphabet = Levenshtein.Alphabet.Deserialize<number>(jsonObject.levenshteinAlphabet);\r\n for (let idx = 0; idx < jsonObject.nameToDescribedTrajectory.length; idx += 2) {\r\n classifier._nameToDescribedTrajectory.set(\r\n jsonObject.nameToDescribedTrajectory[idx],\r\n TrajectoryClass.Deserialize(jsonObject.nameToDescribedTrajectory[idx + 1], classifier._levenshteinAlphabet)\r\n );\r\n }\r\n return classifier;\r\n }\r\n\r\n /**\r\n * Initialize a new empty TrajectorySet with auto-generated Alphabets.\r\n * VERY naive, need to be generating these things from known\r\n * sets. Better version later, probably eliminating this one.\r\n * @returns auto-generated TrajectorySet\r\n */\r\n public static Generate(): TrajectoryClassifier {\r\n const vecs = Vector3Alphabet.Generate(64, 256, 0.1, 0.001, [Vector3.Forward()]);\r\n\r\n const charIdxs = new Array(vecs.chars.length);\r\n for (let idx = 0; idx < charIdxs.length; ++idx) {\r\n charIdxs[idx] = idx;\r\n }\r\n\r\n const alphabet = new Levenshtein.Alphabet<number>(\r\n charIdxs,\r\n (idx) => (idx === 0 ? 0 : 1),\r\n (idx) => (idx === 0 ? 0 : 1),\r\n (a, b) => Math.min(1 - Vector3.Dot(vecs.chars[a], vecs.chars[b]), 1)\r\n );\r\n\r\n const trajectorySet = new TrajectoryClassifier();\r\n trajectorySet._vector3Alphabet = vecs;\r\n trajectorySet._levenshteinAlphabet = alphabet;\r\n return trajectorySet;\r\n }\r\n\r\n private constructor() {\r\n this._nameToDescribedTrajectory = new Map<string, TrajectoryClass>();\r\n }\r\n\r\n /**\r\n * Add a new Trajectory to the set with a given name.\r\n * @param trajectory new Trajectory to be added\r\n * @param classification name to which to add the Trajectory\r\n */\r\n public addTrajectoryToClassification(trajectory: Trajectory, classification: string): void {\r\n if (!this._nameToDescribedTrajectory.has(classification)) {\r\n this._nameToDescribedTrajectory.set(classification, new TrajectoryClass());\r\n }\r\n\r\n this._nameToDescribedTrajectory.get(classification)!.add(TrajectoryDescriptor.CreateFromTrajectory(trajectory, this._vector3Alphabet, this._levenshteinAlphabet));\r\n }\r\n\r\n /**\r\n * Remove a known named trajectory and all Trajectories associated with it.\r\n * @param classification name to remove\r\n * @returns whether anything was removed\r\n */\r\n public deleteClassification(classification: string): boolean {\r\n return this._nameToDescribedTrajectory.delete(classification);\r\n }\r\n\r\n /**\r\n * Attempt to recognize a Trajectory from among all the classifications\r\n * already known to the classifier.\r\n * @param trajectory Trajectory to be recognized\r\n * @returns classification of Trajectory if recognized, null otherwise\r\n */\r\n public classifyTrajectory(trajectory: Trajectory): Nullable<string> {\r\n const descriptor = TrajectoryDescriptor.CreateFromTrajectory(trajectory, this._vector3Alphabet, this._levenshteinAlphabet);\r\n\r\n const allowableMatches: string[] = [];\r\n this._nameToDescribedTrajectory.forEach((trajectoryClass, classification) => {\r\n if (trajectoryClass.getMatchCost(descriptor) < this._maximumAllowableMatchCost) {\r\n allowableMatches.push(classification);\r\n }\r\n });\r\n\r\n if (allowableMatches.length === 0) {\r\n return null;\r\n }\r\n\r\n let bestIdx = 0;\r\n let bestMatch = this._nameToDescribedTrajectory.get(allowableMatches[bestIdx])!.getMatchMinimumDistance(descriptor);\r\n let match: number;\r\n for (let idx = 0; idx < allowableMatches.length; ++idx) {\r\n match = this._nameToDescribedTrajectory.get(allowableMatches[idx])!.getMatchMinimumDistance(descriptor);\r\n if (match < bestMatch) {\r\n bestMatch = match;\r\n bestIdx = idx;\r\n }\r\n }\r\n return allowableMatches[bestIdx];\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"trajectoryClassifier.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/trajectoryClassifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvD,8EAA8E;AAC9E,0CAA0C;AAE1C;;GAEG;AACH,IAAU,WAAW,CA+NpB;AA/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gB,CAAC,GAAG,CAAC,CAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;YACxG,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;gBACpB,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO,GAAG,GAAG,CAAC;YAClB,CAAC;QACL,CAAC;QACD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type { DeepImmutable, Nullable } from \"../types\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\n\r\n// This implementation was based on the original MIT-licensed TRACE repository\r\n// from https://github.com/septagon/TRACE.\r\n\r\n/**\r\n * Generic implementation of Levenshtein distance.\r\n */\r\nnamespace Levenshtein {\r\n /**\r\n * Alphabet from which to construct sequences to be compared using Levenshtein\r\n * distance.\r\n */\r\n export class Alphabet<T> {\r\n private _characterToIdx: Map<T, number>;\r\n private _insertionCosts: number[];\r\n private _deletionCosts: number[];\r\n private _substitutionCosts: number[][];\r\n\r\n /**\r\n * Serialize the Alphabet to JSON string.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n const jsonObject: any = {};\r\n\r\n const characters = new Array<T>(this._characterToIdx.size);\r\n this._characterToIdx.forEach((v, k) => {\r\n characters[v] = k;\r\n });\r\n jsonObject[\"characters\"] = characters;\r\n\r\n jsonObject[\"insertionCosts\"] = this._insertionCosts;\r\n jsonObject[\"deletionCosts\"] = this._deletionCosts;\r\n jsonObject[\"substitutionCosts\"] = this._substitutionCosts;\r\n\r\n return JSON.stringify(jsonObject);\r\n }\r\n\r\n /**\r\n * Parse an Alphabet from a JSON serialization.\r\n * @param json JSON string to deserialize\r\n * @returns deserialized Alphabet\r\n */\r\n public static Deserialize<T>(json: string): Alphabet<T> {\r\n const jsonObject = JSON.parse(json);\r\n const alphabet = new Alphabet(jsonObject[\"characters\"] as T[]);\r\n alphabet._insertionCosts = jsonObject[\"insertionCosts\"];\r\n alphabet._deletionCosts = jsonObject[\"deletionCosts\"];\r\n alphabet._substitutionCosts = jsonObject[\"substitutionCosts\"];\r\n return alphabet;\r\n }\r\n\r\n /**\r\n * Create a new Alphabet.\r\n * @param characters characters of the alphabet\r\n * @param charToInsertionCost function mapping characters to insertion costs\r\n * @param charToDeletionCost function mapping characters to deletion costs\r\n * @param charsToSubstitutionCost function mapping character pairs to substitution costs\r\n */\r\n public constructor(\r\n characters: Array<T>,\r\n charToInsertionCost: Nullable<(char: T) => number> = null,\r\n charToDeletionCost: Nullable<(char: T) => number> = null,\r\n charsToSubstitutionCost: Nullable<(outChar: T, inChar: T) => number> = null\r\n ) {\r\n charToInsertionCost = charToInsertionCost ?? (() => 1);\r\n charToDeletionCost = charToDeletionCost ?? (() => 1);\r\n charsToSubstitutionCost = charsToSubstitutionCost ?? ((a: T, b: T) => (a === b ? 0 : 1));\r\n\r\n this._characterToIdx = new Map<T, number>();\r\n this._insertionCosts = new Array<number>(characters.length);\r\n this._deletionCosts = new Array<number>(characters.length);\r\n this._substitutionCosts = new Array<Array<number>>(characters.length);\r\n\r\n let c: T;\r\n for (let outerIdx = 0; outerIdx < characters.length; ++outerIdx) {\r\n c = characters[outerIdx];\r\n this._characterToIdx.set(c, outerIdx);\r\n this._insertionCosts[outerIdx] = charToInsertionCost(c);\r\n this._deletionCosts[outerIdx] = charToDeletionCost(c);\r\n\r\n this._substitutionCosts[outerIdx] = new Array<number>(characters.length);\r\n for (let innerIdx = outerIdx; innerIdx < characters.length; ++innerIdx) {\r\n this._substitutionCosts[outerIdx][innerIdx] = charsToSubstitutionCost(c, characters[innerIdx]);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Get the index (internally-assigned number) for a character.\r\n * @param char character\r\n * @returns index\r\n */\r\n public getCharacterIdx(char: T): number {\r\n return this._characterToIdx.get(char)!;\r\n }\r\n\r\n /**\r\n * Get the insertion cost of a character from its index.\r\n * @param idx character index\r\n * @returns insertion cost\r\n */\r\n public getInsertionCost(idx: number): number {\r\n return this._insertionCosts[idx];\r\n }\r\n\r\n /**\r\n * Get the deletion cost of a character from its index.\r\n * @param idx character index\r\n * @returns deletion cost\r\n */\r\n public getDeletionCost(idx: number): number {\r\n return this._deletionCosts[idx];\r\n }\r\n\r\n /**\r\n * Gets the cost to substitute two characters. NOTE: this cost is\r\n * required to be bi-directional, meaning it cannot matter which of\r\n * the provided characters is being removed and which is being inserted.\r\n * @param idx1 the first character index\r\n * @param idx2 the second character index\r\n * @returns substitution cost\r\n */\r\n public getSubstitutionCost(idx1: number, idx2: number): number {\r\n const min = Math.min(idx1, idx2);\r\n const max = Math.max(idx1, idx2);\r\n\r\n return this._substitutionCosts[min][max];\r\n }\r\n }\r\n\r\n /**\r\n * Character sequence intended to be compared against other Sequences created\r\n * with the same Alphabet in order to compute Levenshtein distance.\r\n */\r\n export class Sequence<T> {\r\n private _alphabet: Alphabet<T>;\r\n private _characters: number[];\r\n\r\n // Scratch values\r\n private static readonly _MAX_SEQUENCE_LENGTH = 256;\r\n private static _CostMatrix = [...Array(Sequence._MAX_SEQUENCE_LENGTH + 1)].map(() => new Array<number>(Sequence._MAX_SEQUENCE_LENGTH + 1));\r\n private static _InsertionCost: number;\r\n private static _DeletionCost: number;\r\n private static _SubstitutionCost: number;\r\n\r\n /**\r\n * Serialize to JSON string. JSON representation does NOT include the Alphabet\r\n * from which this Sequence was created; Alphabet must be independently\r\n * serialized.\r\n * @returns JSON string\r\n */\r\n public serialize(): string {\r\n return JSON.stringify(this._characters);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON string and Alphabet. This should be the same Alphabet\r\n * from which the Sequence was originally created, which must be serialized and\r\n * deserialized independently so that it can be passed in here.\r\n * @param json JSON string representation of Sequence\r\n * @param alphabet Alphabet from which Sequence was originally created\r\n * @returns Sequence\r\n */\r\n public static Deserialize<T>(json: string, alphabet: Alphabet<T>): Sequence<T> {\r\n const sequence = new Sequence([], alphabet);\r\n sequence._characters = JSON.parse(json);\r\n return sequence;\r\n }\r\n\r\n /**\r\n * Create a new Sequence.\r\n * @param characters characters in the new Sequence\r\n * @param alphabet Alphabet, which must include all used characters\r\n */\r\n public constructor(characters: T[], alphabet: Alphabet<T>) {\r\n if (characters.length > Sequence._MAX_SEQUENCE_LENGTH) {\r\n throw new Error(\"Sequences longer than \" + Sequence._MAX_SEQUENCE_LENGTH + \" not supported.\");\r\n }\r\n this._alphabet = alphabet;\r\n this._characters = characters.map((c) => this._alphabet.getCharacterIdx(c));\r\n }\r\n\r\n /**\r\n * Get the distance between this Sequence and another.\r\n * @param other sequence to compare to\r\n * @returns Levenshtein distance\r\n */\r\n public distance(other: Sequence<T>): number {\r\n return Sequence._Distance<T>(this, other);\r\n }\r\n\r\n /**\r\n * Compute the Levenshtein distance between two Sequences.\r\n * @param a first Sequence\r\n * @param b second Sequence\r\n * @returns Levenshtein distance\r\n */\r\n private static _Distance<T>(a: Sequence<T>, b: Sequence<T>): number {\r\n const alphabet = a._alphabet;\r\n if (alphabet !== b._alphabet) {\r\n throw new Error(\"Cannot Levenshtein compare Sequences built from different alphabets.\");\r\n }\r\n const aChars = a._characters;\r\n const bChars = b._characters;\r\n const aLength = aChars.length;\r\n const bLength = bChars.length;\r\n\r\n const costMatrix = Sequence._CostMatrix;\r\n costMatrix[0][0] = 0;\r\n for (let idx = 0; idx < aLength; ++idx) {\r\n costMatrix[idx + 1][0] = costMatrix[idx][0] + alphabet.getInsertionCost(aChars[idx]);\r\n }\r\n for (let idx = 0; idx < bLength; ++idx) {\r\n costMatrix[0][idx + 1] = costMatrix[0][idx] + alphabet.getInsertionCost(bChars[idx]);\r\n }\r\n\r\n for (let aIdx = 0; aIdx < aLength; ++aIdx) {\r\n for (let bIdx = 0; bIdx < bLength; ++bIdx) {\r\n Sequence._InsertionCost = costMatrix[aIdx + 1][bIdx] + alphabet.getInsertionCost(bChars[bIdx]);\r\n Sequence._DeletionCost = costMatrix[aIdx][bIdx + 1] + alphabet.getDeletionCost(aChars[aIdx]);\r\n Sequence._SubstitutionCost = costMatrix[aIdx][bIdx] + alphabet.getSubstitutionCost(aChars[aIdx], bChars[bIdx]);\r\n\r\n costMatrix[aIdx + 1][bIdx + 1] = Math.min(Sequence._InsertionCost, Sequence._DeletionCost, Sequence._SubstitutionCost);\r\n }\r\n }\r\n\r\n return costMatrix[aLength][bLength];\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A 3D trajectory consisting of an order list of vectors describing a\r\n * path of motion through 3D space.\r\n */\r\nexport class Trajectory {\r\n private _points: Vector3[];\r\n private readonly _segmentLength: number;\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns serialized JSON string\r\n */\r\n public serialize(): string {\r\n return JSON.stringify(this);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON.\r\n * @param json serialized JSON string\r\n * @returns deserialized Trajectory\r\n */\r\n public static Deserialize(json: string): Trajectory {\r\n const jsonObject = JSON.parse(json);\r\n const trajectory = new Trajectory(jsonObject[\"_segmentLength\"]);\r\n trajectory._points = jsonObject[\"_points\"].map((pt: any) => {\r\n return new Vector3(pt[\"_x\"], pt[\"_y\"], pt[\"_z\"]);\r\n });\r\n return trajectory;\r\n }\r\n\r\n /**\r\n * Create a new empty Trajectory.\r\n * @param segmentLength radius of discretization for Trajectory points\r\n */\r\n public constructor(segmentLength: number = 0.01) {\r\n this._points = [];\r\n this._segmentLength = segmentLength;\r\n }\r\n\r\n /**\r\n * Get the length of the Trajectory.\r\n * @returns length of the Trajectory\r\n */\r\n public getLength(): number {\r\n return this._points.length * this._segmentLength;\r\n }\r\n\r\n /**\r\n * Append a new point to the Trajectory.\r\n * NOTE: This implementation has many allocations.\r\n * @param point point to append to the Trajectory\r\n */\r\n public add(point: DeepImmutable<Vector3>): void {\r\n let numPoints = this._points.length;\r\n if (numPoints === 0) {\r\n this._points.push(point.clone());\r\n } else {\r\n const getT = () => this._segmentLength / Vector3.Distance(this._points[numPoints - 1], point);\r\n for (let t = getT(); t <= 1.0; t = getT()) {\r\n const newPoint = this._points[numPoints - 1].scale(1.0 - t);\r\n point.scaleAndAddToRef(t, newPoint);\r\n this._points.push(newPoint);\r\n ++numPoints;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Create a new Trajectory with a segment length chosen to make it\r\n * probable that the new Trajectory will have a specified number of\r\n * segments. This operation is imprecise.\r\n * @param targetResolution number of segments desired\r\n * @returns new Trajectory with approximately the requested number of segments\r\n */\r\n public resampleAtTargetResolution(targetResolution: number): Trajectory {\r\n const resampled = new Trajectory(this.getLength() / targetResolution);\r\n for (const pt of this._points) {\r\n resampled.add(pt);\r\n }\r\n return resampled;\r\n }\r\n\r\n /**\r\n * Convert Trajectory segments into tokenized representation. This\r\n * representation is an array of numbers where each nth number is the\r\n * index of the token which is most similar to the nth segment of the\r\n * Trajectory.\r\n * @param tokens list of vectors which serve as discrete tokens\r\n * @returns list of indices of most similar token per segment\r\n */\r\n public tokenize(tokens: DeepImmutable<Vector3[]>): number[] {\r\n const tokenization: number[] = [];\r\n\r\n const segmentDir = new Vector3();\r\n for (let idx = 2; idx < this._points.length; ++idx) {\r\n if (Trajectory._TransformSegmentDirToRef(this._points[idx - 2], this._points[idx - 1], this._points[idx], segmentDir)) {\r\n tokenization.push(Trajectory._TokenizeSegment(segmentDir, tokens));\r\n }\r\n }\r\n\r\n return tokenization;\r\n }\r\n\r\n private static _ForwardDir = new Vector3();\r\n private static _InverseFromVec = new Vector3();\r\n private static _UpDir = new Vector3();\r\n private static _FromToVec = new Vector3();\r\n private static _LookMatrix = new Matrix();\r\n\r\n /**\r\n * Transform the rotation (i.e., direction) of a segment to isolate\r\n * the relative transformation represented by the segment. This operation\r\n * may or may not succeed due to singularities in the equations that define\r\n * motion relativity in this context.\r\n * @param priorVec the origin of the prior segment\r\n * @param fromVec the origin of the current segment\r\n * @param toVec the destination of the current segment\r\n * @param result reference to output variable\r\n * @returns whether or not transformation was successful\r\n */\r\n private static _TransformSegmentDirToRef(priorVec: DeepImmutable<Vector3>, fromVec: DeepImmutable<Vector3>, toVec: DeepImmutable<Vector3>, result: Vector3): boolean {\r\n const DOT_PRODUCT_SAMPLE_REJECTION_THRESHOLD = 0.98;\r\n\r\n fromVec.subtractToRef(priorVec, Trajectory._ForwardDir);\r\n Trajectory._ForwardDir.normalize();\r\n fromVec.scaleToRef(-1, Trajectory._InverseFromVec);\r\n Trajectory._InverseFromVec.normalize();\r\n\r\n if (Math.abs(Vector3.Dot(Trajectory._ForwardDir, Trajectory._InverseFromVec)) > DOT_PRODUCT_SAMPLE_REJECTION_THRESHOLD) {\r\n return false;\r\n }\r\n\r\n Vector3.CrossToRef(Trajectory._ForwardDir, Trajectory._InverseFromVec, Trajectory._UpDir);\r\n Trajectory._UpDir.normalize();\r\n Matrix.LookAtLHToRef(priorVec, fromVec, Trajectory._UpDir, Trajectory._LookMatrix);\r\n toVec.subtractToRef(fromVec, Trajectory._FromToVec);\r\n Trajectory._FromToVec.normalize();\r\n Vector3.TransformNormalToRef(Trajectory._FromToVec, Trajectory._LookMatrix, result);\r\n return true;\r\n }\r\n\r\n private static _BestMatch: number;\r\n private static _Score: number;\r\n private static _BestScore: number;\r\n\r\n /**\r\n * Determine which token vector is most similar to the\r\n * segment vector.\r\n * @param segment segment vector\r\n * @param tokens token vector list\r\n * @returns index of the most similar token to the segment\r\n */\r\n private static _TokenizeSegment(segment: DeepImmutable<Vector3>, tokens: DeepImmutable<Vector3[]>): number {\r\n Trajectory._BestMatch = 0;\r\n Trajectory._Score = Vector3.Dot(segment, tokens[0]);\r\n Trajectory._BestScore = Trajectory._Score;\r\n for (let idx = 1; idx < tokens.length; ++idx) {\r\n Trajectory._Score = Vector3.Dot(segment, tokens[idx]);\r\n if (Trajectory._Score > Trajectory._BestScore) {\r\n Trajectory._BestMatch = idx;\r\n Trajectory._BestScore = Trajectory._Score;\r\n }\r\n }\r\n\r\n return Trajectory._BestMatch;\r\n }\r\n}\r\n\r\n/**\r\n * Collection of vectors intended to be used as the basis of Trajectory\r\n * tokenization for Levenshtein distance comparison. Canonically, a\r\n * Vector3Alphabet will resemble a \"spikeball\" of vectors distributed\r\n * roughly evenly over the surface of the unit sphere.\r\n */\r\nclass Vector3Alphabet {\r\n /**\r\n * Characters in the alphabet.\r\n * NOTE: There is no reason for this property to exist and this class should just extend\r\n * Array<Vector3>, except that doing so produces bizarre build-time errors indicating that\r\n * the ES5 library itself fails its own TypeDoc validation.\r\n */\r\n public chars: Vector3[];\r\n\r\n /**\r\n * Helper method to create new \"spikeball\" Vector3Alphabets. Uses a naive\r\n * optimize-from-random strategy to space points around the unit sphere\r\n * surface as a simple alternative to really doing the math to tile the\r\n * sphere.\r\n * @param alphabetSize size of the desired alphabet\r\n * @param iterations number of iterations over which to optimize the \"spikeball\"\r\n * @param startingStepSize distance factor to move points in early optimization iterations\r\n * @param endingStepSize distance factor to move points in late optimization iterations\r\n * @param fixedValues alphabet \"characters\" that are required and cannot be moved by optimization\r\n * @returns a new randomly generated and optimized Vector3Alphabet of the specified size\r\n */\r\n public static Generate(\r\n alphabetSize: number = 64,\r\n iterations: number = 256,\r\n startingStepSize: number = 0.1,\r\n endingStepSize: number = 0.001,\r\n fixedValues: DeepImmutable<Vector3[]> = []\r\n ): Vector3Alphabet {\r\n const EPSILON = 0.001;\r\n const EPSILON_SQUARED = EPSILON * EPSILON;\r\n\r\n const alphabet = new Vector3Alphabet(alphabetSize);\r\n for (let idx = 0; idx < alphabetSize; ++idx) {\r\n alphabet.chars[idx] = new Vector3(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);\r\n alphabet.chars[idx].normalize();\r\n }\r\n\r\n for (let idx = 0; idx < fixedValues.length; ++idx) {\r\n alphabet.chars[idx].copyFrom(fixedValues[idx]);\r\n }\r\n\r\n let stepSize: number;\r\n let distSq: number;\r\n const force = new Vector3();\r\n const scratch = new Vector3();\r\n const lerp = (l: number, r: number, t: number) => (1.0 - t) * l + t * r;\r\n for (let iteration = 0; iteration < iterations; ++iteration) {\r\n stepSize = lerp(startingStepSize, endingStepSize, iteration / (iterations - 1));\r\n for (let idx = fixedValues.length; idx < alphabet.chars.length; ++idx) {\r\n force.copyFromFloats(0, 0, 0);\r\n for (const pt of alphabet.chars) {\r\n alphabet.chars[idx].subtractToRef(pt, scratch);\r\n distSq = scratch.lengthSquared();\r\n if (distSq > EPSILON_SQUARED) {\r\n scratch.scaleAndAddToRef(1 / (scratch.lengthSquared() * distSq), force);\r\n }\r\n }\r\n force.scaleInPlace(stepSize);\r\n alphabet.chars[idx].addInPlace(force);\r\n alphabet.chars[idx].normalize();\r\n }\r\n }\r\n\r\n return alphabet;\r\n }\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n return JSON.stringify(this.chars);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON.\r\n * @param json JSON serialization\r\n * @returns deserialized Vector3Alphabet\r\n */\r\n public static Deserialize(json: string): Vector3Alphabet {\r\n const jsonObject = JSON.parse(json);\r\n const alphabet = new Vector3Alphabet(jsonObject.length);\r\n for (let idx = 0; idx < jsonObject.length; ++idx) {\r\n alphabet.chars[idx] = new Vector3(jsonObject[idx][\"_x\"], jsonObject[idx][\"_y\"], jsonObject[idx][\"_z\"]);\r\n }\r\n return alphabet;\r\n }\r\n\r\n private constructor(size: number) {\r\n this.chars = new Array(size);\r\n }\r\n}\r\n\r\n/**\r\n * Class which formalizes the manner in which a Vector3Alphabet is used to tokenize and\r\n * describe a Trajectory. This class houses the functionality which determines what\r\n * attributes of Trajectories are and are not considered important, such as scale.\r\n */\r\nclass TrajectoryDescriptor {\r\n private static readonly _FINEST_DESCRIPTOR_RESOLUTION = 32;\r\n\r\n private _sequences: Levenshtein.Sequence<number>[];\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n return JSON.stringify(this._sequences.map((sequence) => sequence.serialize()));\r\n }\r\n\r\n /**\r\n * Deserialize from JSON string and Alphabet. This should be the same Alphabet\r\n * from which the descriptor was originally created, which must be serialized and\r\n * deserialized independently so that it can be passed in here.\r\n * @param json JSON serialization\r\n * @param alphabet Alphabet from which descriptor was originally created\r\n * @returns deserialized TrajectoryDescriptor\r\n */\r\n public static Deserialize(json: string, alphabet: Levenshtein.Alphabet<number>): TrajectoryDescriptor {\r\n const descriptor = new TrajectoryDescriptor();\r\n descriptor._sequences = (JSON.parse(json) as string[]).map((s) => Levenshtein.Sequence.Deserialize(s, alphabet));\r\n return descriptor;\r\n }\r\n\r\n /**\r\n * Create a new TrajectoryDescriptor to describe a provided Trajectory according\r\n * to the provided alphabets.\r\n * @param trajectory Trajectory to be described\r\n * @param vector3Alphabet Vector3Alphabet to be used to tokenize the Trajectory\r\n * @param levenshteinAlphabet Levenshtein.Alphabet to be used as basis for comparison with other descriptors\r\n * @returns TrajectoryDescriptor describing provided Trajectory\r\n */\r\n public static CreateFromTrajectory(trajectory: Trajectory, vector3Alphabet: Vector3Alphabet, levenshteinAlphabet: Levenshtein.Alphabet<number>): TrajectoryDescriptor {\r\n return TrajectoryDescriptor.CreateFromTokenizationPyramid(TrajectoryDescriptor._GetTokenizationPyramid(trajectory, vector3Alphabet), levenshteinAlphabet);\r\n }\r\n\r\n /**\r\n * Create a new TrajectoryDescriptor from a pre-existing pyramid of tokens.\r\n * NOTE: This function exists to support an outdated serialization mechanism and should\r\n * be deleted if it is no longer useful.\r\n * @param pyramid tokenization pyramid\r\n * @param levenshteinAlphabet Levenshtein.Alphabet to be uses as basis for comparison with other descriptors\r\n * @returns TrajectoryDescriptor describing the Trajectory from which the pyramid was built\r\n */\r\n public static CreateFromTokenizationPyramid(pyramid: number[][], levenshteinAlphabet: Levenshtein.Alphabet<number>): TrajectoryDescriptor {\r\n const descriptor = new TrajectoryDescriptor();\r\n descriptor._sequences = pyramid.map((tokens) => new Levenshtein.Sequence<number>(tokens, levenshteinAlphabet));\r\n return descriptor;\r\n }\r\n\r\n private constructor() {\r\n this._sequences = [];\r\n }\r\n\r\n /**\r\n * Create the tokenization pyramid for the provided Trajectory according to the given\r\n * Vector3Alphabet.\r\n * @param trajectory Trajectory to be tokenized\r\n * @param alphabet Vector3Alphabet containing tokens\r\n * @param targetResolution finest resolution of descriptor\r\n * @returns tokenization pyramid for Trajectory\r\n */\r\n private static _GetTokenizationPyramid(\r\n trajectory: Trajectory,\r\n alphabet: Vector3Alphabet,\r\n targetResolution: number = TrajectoryDescriptor._FINEST_DESCRIPTOR_RESOLUTION\r\n ): number[][] {\r\n const pyramid: number[][] = [];\r\n for (let res = targetResolution; res > 4; res = Math.floor(res / 2)) {\r\n pyramid.push(trajectory.resampleAtTargetResolution(res).tokenize(alphabet.chars));\r\n }\r\n return pyramid;\r\n }\r\n\r\n /**\r\n * Calculate a distance metric between this TrajectoryDescriptor and another. This is\r\n * essentially a similarity score and does not directly represent Euclidean distance,\r\n * edit distance, or any other formal distance metric.\r\n * @param other TrajectoryDescriptor from which to determine distance\r\n * @returns distance, a nonnegative similarity score where larger values indicate dissimilarity\r\n */\r\n public distance(other: TrajectoryDescriptor): number {\r\n let totalDistance = 0;\r\n let weight: number;\r\n for (let idx = 0; idx < this._sequences.length; ++idx) {\r\n weight = Math.pow(2, idx);\r\n totalDistance += weight * this._sequences[idx].distance(other._sequences[idx]);\r\n }\r\n return totalDistance;\r\n }\r\n}\r\n\r\n/**\r\n * A set of TrajectoryDescriptors defined to be \"the same.\" This is essentially a helper\r\n * class to facilitate methods of Trajectory clustering.\r\n */\r\nclass TrajectoryClass {\r\n private static readonly _MIN_AVERAGE_DISTANCE = 1;\r\n\r\n private _descriptors: TrajectoryDescriptor[];\r\n private _centroidIdx: number;\r\n private _averageDistance: number;\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n const jsonObject: any = {};\r\n jsonObject.descriptors = this._descriptors.map((desc) => desc.serialize());\r\n jsonObject.centroidIdx = this._centroidIdx;\r\n jsonObject.averageDistance = this._averageDistance;\r\n return JSON.stringify(jsonObject);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON string and Alphabet. This should be the same Alphabet\r\n * from which the descriptors were originally created, which must be serialized and\r\n * deserialized independently so that it can be passed in here.\r\n * @param json JSON string representation\r\n * @param alphabet Alphabet from which TrajectoryDescriptors were originally created\r\n * @returns deserialized TrajectoryDescriptor\r\n */\r\n public static Deserialize(json: string, alphabet: Levenshtein.Alphabet<number>): TrajectoryClass {\r\n const jsonObject = JSON.parse(json);\r\n const described = new TrajectoryClass();\r\n described._descriptors = jsonObject.descriptors.map((s: string) => TrajectoryDescriptor.Deserialize(s, alphabet));\r\n described._centroidIdx = jsonObject.centroidIdx;\r\n described._averageDistance = jsonObject.averageDistance;\r\n return described;\r\n }\r\n\r\n /**\r\n * Create a new DescribedTrajectory.\r\n * @param descriptors currently-known TrajectoryDescriptors, if any\r\n */\r\n public constructor(descriptors: TrajectoryDescriptor[] = []) {\r\n this._descriptors = descriptors;\r\n this._centroidIdx = -1;\r\n this._averageDistance = 0;\r\n\r\n this._refreshDescription();\r\n }\r\n\r\n /**\r\n * Add a new TrajectoryDescriptor to the list of descriptors known to describe\r\n * this same DescribedTrajectory.\r\n * @param descriptor descriptor to be added\r\n */\r\n public add(descriptor: TrajectoryDescriptor): void {\r\n this._descriptors.push(descriptor);\r\n this._refreshDescription();\r\n }\r\n\r\n /**\r\n * Compute the cost, which is inversely related to the likelihood that the provided\r\n * TrajectoryDescriptor describes a Trajectory that is considered to be the same as\r\n * the class represented by this DescribedTrajectory.\r\n * @param descriptor the descriptor to be costed\r\n * @returns cost of the match, which is a nonnegative similarity metric where larger values indicate dissimilarity\r\n */\r\n public getMatchCost(descriptor: TrajectoryDescriptor): number {\r\n return descriptor.distance(this._descriptors[this._centroidIdx]) / this._averageDistance;\r\n }\r\n\r\n /**\r\n * Compute the minimum distance between the queried TrajectoryDescriptor and a\r\n * descriptor which is a member of this collection. This is an alternative way of\r\n * conceptualizing match cost from getMatchCost(), and it serves a different function.\r\n * @param descriptor the descriptor to find the minimum distance to\r\n * @returns minimum descriptor distance to a member descriptor of this DescribedTrajectory\r\n */\r\n public getMatchMinimumDistance(descriptor: TrajectoryDescriptor): number {\r\n return Math.min(...this._descriptors.map((desc) => desc.distance(descriptor)));\r\n }\r\n\r\n /**\r\n * Refreshes the internal representation of this DescribedTrajectory.\r\n */\r\n private _refreshDescription(): void {\r\n this._centroidIdx = -1;\r\n let sum: number;\r\n const distances = this._descriptors.map((a) => {\r\n sum = 0;\r\n for (const b of this._descriptors) {\r\n sum += a.distance(b);\r\n }\r\n return sum;\r\n });\r\n for (let idx = 0; idx < distances.length; ++idx) {\r\n if (this._centroidIdx < 0 || distances[idx] < distances[this._centroidIdx]) {\r\n this._centroidIdx = idx;\r\n }\r\n }\r\n\r\n this._averageDistance = 0;\r\n for (const desc of this._descriptors) {\r\n this._averageDistance += desc.distance(this._descriptors[this._centroidIdx]);\r\n }\r\n if (this._descriptors.length > 0) {\r\n this._averageDistance = Math.max(this._averageDistance / this._descriptors.length, TrajectoryClass._MIN_AVERAGE_DISTANCE);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Class representing a set of known, named trajectories to which Trajectories can be\r\n * added and using which Trajectories can be recognized.\r\n */\r\nexport class TrajectoryClassifier {\r\n private _maximumAllowableMatchCost: number = 4;\r\n private _vector3Alphabet: Vector3Alphabet;\r\n private _levenshteinAlphabet: Levenshtein.Alphabet<number>;\r\n private _nameToDescribedTrajectory: Map<string, TrajectoryClass>;\r\n\r\n /**\r\n * Serialize to JSON.\r\n * @returns JSON serialization\r\n */\r\n public serialize(): string {\r\n const jsonObject: any = {};\r\n jsonObject.maximumAllowableMatchCost = this._maximumAllowableMatchCost;\r\n jsonObject.vector3Alphabet = this._vector3Alphabet.serialize();\r\n jsonObject.levenshteinAlphabet = this._levenshteinAlphabet.serialize();\r\n jsonObject.nameToDescribedTrajectory = [];\r\n this._nameToDescribedTrajectory.forEach((described, name) => {\r\n jsonObject.nameToDescribedTrajectory.push(name);\r\n jsonObject.nameToDescribedTrajectory.push(described.serialize());\r\n });\r\n return JSON.stringify(jsonObject);\r\n }\r\n\r\n /**\r\n * Deserialize from JSON.\r\n * @param json JSON serialization\r\n * @returns deserialized TrajectorySet\r\n */\r\n public static Deserialize(json: string): TrajectoryClassifier {\r\n const jsonObject = JSON.parse(json);\r\n const classifier = new TrajectoryClassifier();\r\n classifier._maximumAllowableMatchCost = jsonObject.maximumAllowableMatchCost;\r\n classifier._vector3Alphabet = Vector3Alphabet.Deserialize(jsonObject.vector3Alphabet);\r\n classifier._levenshteinAlphabet = Levenshtein.Alphabet.Deserialize<number>(jsonObject.levenshteinAlphabet);\r\n for (let idx = 0; idx < jsonObject.nameToDescribedTrajectory.length; idx += 2) {\r\n classifier._nameToDescribedTrajectory.set(\r\n jsonObject.nameToDescribedTrajectory[idx],\r\n TrajectoryClass.Deserialize(jsonObject.nameToDescribedTrajectory[idx + 1], classifier._levenshteinAlphabet)\r\n );\r\n }\r\n return classifier;\r\n }\r\n\r\n /**\r\n * Initialize a new empty TrajectorySet with auto-generated Alphabets.\r\n * VERY naive, need to be generating these things from known\r\n * sets. Better version later, probably eliminating this one.\r\n * @returns auto-generated TrajectorySet\r\n */\r\n public static Generate(): TrajectoryClassifier {\r\n const vecs = Vector3Alphabet.Generate(64, 256, 0.1, 0.001, [Vector3.Forward()]);\r\n\r\n const charIdxs = new Array(vecs.chars.length);\r\n for (let idx = 0; idx < charIdxs.length; ++idx) {\r\n charIdxs[idx] = idx;\r\n }\r\n\r\n const alphabet = new Levenshtein.Alphabet<number>(\r\n charIdxs,\r\n (idx) => (idx === 0 ? 0 : 1),\r\n (idx) => (idx === 0 ? 0 : 1),\r\n (a, b) => Math.min(1 - Vector3.Dot(vecs.chars[a], vecs.chars[b]), 1)\r\n );\r\n\r\n const trajectorySet = new TrajectoryClassifier();\r\n trajectorySet._vector3Alphabet = vecs;\r\n trajectorySet._levenshteinAlphabet = alphabet;\r\n return trajectorySet;\r\n }\r\n\r\n private constructor() {\r\n this._nameToDescribedTrajectory = new Map<string, TrajectoryClass>();\r\n }\r\n\r\n /**\r\n * Add a new Trajectory to the set with a given name.\r\n * @param trajectory new Trajectory to be added\r\n * @param classification name to which to add the Trajectory\r\n */\r\n public addTrajectoryToClassification(trajectory: Trajectory, classification: string): void {\r\n if (!this._nameToDescribedTrajectory.has(classification)) {\r\n this._nameToDescribedTrajectory.set(classification, new TrajectoryClass());\r\n }\r\n\r\n this._nameToDescribedTrajectory.get(classification)!.add(TrajectoryDescriptor.CreateFromTrajectory(trajectory, this._vector3Alphabet, this._levenshteinAlphabet));\r\n }\r\n\r\n /**\r\n * Remove a known named trajectory and all Trajectories associated with it.\r\n * @param classification name to remove\r\n * @returns whether anything was removed\r\n */\r\n public deleteClassification(classification: string): boolean {\r\n return this._nameToDescribedTrajectory.delete(classification);\r\n }\r\n\r\n /**\r\n * Attempt to recognize a Trajectory from among all the classifications\r\n * already known to the classifier.\r\n * @param trajectory Trajectory to be recognized\r\n * @returns classification of Trajectory if recognized, null otherwise\r\n */\r\n public classifyTrajectory(trajectory: Trajectory): Nullable<string> {\r\n const descriptor = TrajectoryDescriptor.CreateFromTrajectory(trajectory, this._vector3Alphabet, this._levenshteinAlphabet);\r\n\r\n const allowableMatches: string[] = [];\r\n this._nameToDescribedTrajectory.forEach((trajectoryClass, classification) => {\r\n if (trajectoryClass.getMatchCost(descriptor) < this._maximumAllowableMatchCost) {\r\n allowableMatches.push(classification);\r\n }\r\n });\r\n\r\n if (allowableMatches.length === 0) {\r\n return null;\r\n }\r\n\r\n let bestIdx = 0;\r\n let bestMatch = this._nameToDescribedTrajectory.get(allowableMatches[bestIdx])!.getMatchMinimumDistance(descriptor);\r\n let match: number;\r\n for (let idx = 0; idx < allowableMatches.length; ++idx) {\r\n match = this._nameToDescribedTrajectory.get(allowableMatches[idx])!.getMatchMinimumDistance(descriptor);\r\n if (match < bestMatch) {\r\n bestMatch = match;\r\n bestIdx = idx;\r\n }\r\n }\r\n return allowableMatches[bestIdx];\r\n }\r\n}\r\n"]}
@@ -58,7 +58,7 @@ export interface IParticleSystem {
58
58
  */
59
59
  particleTexture: Nullable<BaseTexture>;
60
60
  /**
61
- * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
61
+ * Blend mode use to render the particle. It can be any of the ParticleSystem.BLENDMODE_* constants
62
62
  */
63
63
  blendMode: number;
64
64
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"IParticleSystem.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/IParticleSystem.ts"],"names":[],"mappings":"","sourcesContent":["import type { Immutable, Nullable } from \"../types\";\r\nimport type { Vector2, Vector3, Matrix } from \"../Maths/math.vector\";\r\nimport type { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type {\r\n BoxParticleEmitter,\r\n IParticleEmitterType,\r\n PointParticleEmitter,\r\n HemisphericParticleEmitter,\r\n SphereParticleEmitter,\r\n SphereDirectedParticleEmitter,\r\n CylinderParticleEmitter,\r\n CylinderDirectedParticleEmitter,\r\n ConeParticleEmitter,\r\n ConeDirectedParticleEmitter,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"../Particles/EmitterTypes/index\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ColorGradient, FactorGradient, Color3Gradient } from \"../Misc/gradients\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { Observable } from \"../Misc/observable\";\r\nimport type { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\n\r\nimport type { Animation } from \"../Animations/animation\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\n\r\n/**\r\n * Interface representing a particle system in Babylon.js.\r\n * This groups the common functionalities that needs to be implemented in order to create a particle system.\r\n * A particle system represents a way to manage particles from their emission to their animation and rendering.\r\n */\r\nexport interface IParticleSystem {\r\n /**\r\n * List of animations used by the particle system.\r\n */\r\n animations: Animation[];\r\n /**\r\n * The id of the Particle system.\r\n */\r\n id: string;\r\n /**\r\n * The name of the Particle system.\r\n */\r\n name: string;\r\n /**\r\n * The emitter represents the Mesh or position we are attaching the particle system to.\r\n */\r\n emitter: Nullable<AbstractMesh | Vector3>;\r\n /**\r\n * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction\r\n */\r\n isBillboardBased: boolean;\r\n /**\r\n * The rendering group used by the Particle system to chose when to render.\r\n */\r\n renderingGroupId: number;\r\n /**\r\n * The layer mask we are rendering the particles through.\r\n */\r\n layerMask: number;\r\n\r\n /**\r\n * The overall motion speed (0.01 is default update speed, faster updates = faster animation)\r\n */\r\n updateSpeed: number;\r\n\r\n /**\r\n * The amount of time the particle system is running (depends of the overall update speed).\r\n */\r\n targetStopDuration: number;\r\n\r\n /**\r\n * The texture used to render each particle. (this can be a spritesheet)\r\n */\r\n particleTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.\r\n */\r\n blendMode: number;\r\n\r\n /**\r\n * Minimum life time of emitting particles.\r\n */\r\n minLifeTime: number;\r\n /**\r\n * Maximum life time of emitting particles.\r\n */\r\n maxLifeTime: number;\r\n\r\n /**\r\n * Minimum Size of emitting particles.\r\n */\r\n minSize: number;\r\n /**\r\n * Maximum Size of emitting particles.\r\n */\r\n maxSize: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on X axis.\r\n */\r\n minScaleX: number;\r\n /**\r\n * Maximum scale of emitting particles on X axis.\r\n */\r\n maxScaleX: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on Y axis.\r\n */\r\n minScaleY: number;\r\n /**\r\n * Maximum scale of emitting particles on Y axis.\r\n */\r\n maxScaleY: number;\r\n\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color1: Color4;\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color2: Color4;\r\n\r\n /**\r\n * Color the particle will have at the end of its lifetime.\r\n */\r\n colorDead: Color4;\r\n\r\n /**\r\n * The maximum number of particles to emit per frame until we reach the activeParticleCount value\r\n */\r\n emitRate: number;\r\n\r\n /**\r\n * You can use gravity if you want to give an orientation to your particles.\r\n */\r\n gravity: Vector3;\r\n\r\n /**\r\n * Minimum power of emitting particles.\r\n */\r\n minEmitPower: number;\r\n /**\r\n * Maximum power of emitting particles.\r\n */\r\n maxEmitPower: number;\r\n /**\r\n * Minimum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n minAngularSpeed: number;\r\n /**\r\n * Maximum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n maxAngularSpeed: number;\r\n /**\r\n * Gets or sets the minimal initial rotation in radians.\r\n */\r\n minInitialRotation: number;\r\n /**\r\n * Gets or sets the maximal initial rotation in radians.\r\n */\r\n maxInitialRotation: number;\r\n /**\r\n * The particle emitter type defines the emitter used by the particle system.\r\n * It can be for example box, sphere, or cone...\r\n */\r\n particleEmitterType: Nullable<IParticleEmitterType>;\r\n /**\r\n * Defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n startDelay: number;\r\n /**\r\n * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0\r\n */\r\n preWarmCycles: number;\r\n /**\r\n * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)\r\n */\r\n preWarmStepOffset: number;\r\n\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)\r\n */\r\n spriteCellChangeSpeed: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display\r\n */\r\n startSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display\r\n */\r\n endSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines whether the sprite animation is looping\r\n */\r\n spriteCellLoop: boolean;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use\r\n */\r\n spriteCellWidth: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use\r\n */\r\n spriteCellHeight: number;\r\n /**\r\n * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID\r\n */\r\n spriteRandomStartCell: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture\r\n */\r\n isAnimationSheetEnabled: boolean;\r\n\r\n /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */\r\n translationPivot: Vector2;\r\n\r\n /**\r\n * Gets or sets a texture used to add random noise to particle positions\r\n */\r\n noiseTexture: Nullable<BaseTexture>;\r\n\r\n /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */\r\n noiseStrength: Vector3;\r\n\r\n /**\r\n * Gets or sets the billboard mode to use when isBillboardBased = true.\r\n * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED\r\n */\r\n billboardMode: number;\r\n\r\n /**\r\n * Gets or sets a boolean enabling the use of logarithmic depth buffers, which is good for wide depth buffers.\r\n */\r\n useLogarithmicDepth: boolean;\r\n\r\n /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */\r\n limitVelocityDamping: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called\r\n */\r\n beginAnimationOnStart: boolean;\r\n\r\n /**\r\n * Gets or sets the frame to start the animation from when beginAnimationOnStart is true\r\n */\r\n beginAnimationFrom: number;\r\n\r\n /**\r\n * Gets or sets the frame to end the animation on when beginAnimationOnStart is true\r\n */\r\n beginAnimationTo: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true\r\n */\r\n beginAnimationLoop: boolean;\r\n\r\n /**\r\n * Specifies whether the particle system will be disposed once it reaches the end of the animation.\r\n */\r\n disposeOnStop: boolean;\r\n\r\n /**\r\n * If you want to launch only a few particles at once, that can be done, as well.\r\n */\r\n manualEmitCount: number;\r\n\r\n /**\r\n * Specifies if the particles are updated in emitter local space or world space\r\n */\r\n isLocal: boolean;\r\n\r\n /** Snippet ID if the particle system was created from the snippet server */\r\n snippetId: string;\r\n\r\n /** Gets or sets a matrix to use to compute projection */\r\n defaultProjectionMatrix: Matrix;\r\n\r\n /** Indicates that the update of particles is done in the animate function (and not in render) */\r\n updateInAnimate: boolean;\r\n\r\n /** @internal */\r\n _wasDispatched: boolean;\r\n\r\n /**\r\n * Gets the maximum number of particles active at the same time.\r\n * @returns The max number of active particles.\r\n */\r\n getCapacity(): number;\r\n\r\n /**\r\n * Gets the number of particles active at the same time.\r\n * @returns The number of active particles.\r\n */\r\n getActiveCount(): number;\r\n\r\n /**\r\n * Gets if the system has been started. (Note: this will still be true after stop is called)\r\n * @returns True if it has been started, otherwise false.\r\n */\r\n isStarted(): boolean;\r\n\r\n /**\r\n * Animates the particle system for this frame.\r\n */\r\n animate(): void;\r\n /**\r\n * Renders the particle system in its current state.\r\n * @returns the current number of particles\r\n */\r\n render(): number;\r\n /**\r\n * Dispose the particle system and frees its associated resources.\r\n * @param disposeTexture defines if the particle texture must be disposed as well (true by default)\r\n * @param disposeAttachedSubEmitters defines if the attached sub-emitters must be disposed as well (false by default)\r\n * @param disposeEndSubEmitters defines if the end type sub-emitters must be disposed as well (false by default)\r\n */\r\n dispose(disposeTexture?: boolean, disposeAttachedSubEmitters?: boolean, disposeEndSubEmitters?: boolean): void;\r\n /**\r\n * An event triggered when the system is disposed\r\n */\r\n onDisposeObservable: Observable<IParticleSystem>;\r\n /**\r\n * An event triggered when the system is stopped\r\n */\r\n onStoppedObservable: Observable<IParticleSystem>;\r\n /**\r\n * Clones the particle system.\r\n * @param name The name of the cloned object\r\n * @param newEmitter The new emitter to use\r\n * @returns the cloned particle system\r\n */\r\n clone(name: string, newEmitter: any): Nullable<IParticleSystem>;\r\n /**\r\n * Serializes the particle system to a JSON object\r\n * @param serializeTexture defines if the texture must be serialized as well\r\n * @returns the JSON object\r\n */\r\n serialize(serializeTexture: boolean): any;\r\n /**\r\n * Rebuild the particle system\r\n */\r\n rebuild(): void;\r\n\r\n /** Force the system to rebuild all gradients that need to be resync */\r\n forceRefreshGradients(): void;\r\n\r\n /**\r\n * Starts the particle system and begins to emit\r\n * @param delay defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n start(delay?: number): void;\r\n\r\n /**\r\n * Stops the particle system.\r\n */\r\n stop(): void;\r\n\r\n /**\r\n * Remove all active particles\r\n */\r\n reset(): void;\r\n\r\n /**\r\n * Gets a boolean indicating that the system is stopping\r\n * @returns true if the system is currently stopping\r\n */\r\n isStopping(): boolean;\r\n\r\n /**\r\n * Is this system ready to be used/rendered\r\n * @returns true if the system is ready\r\n */\r\n isReady(): boolean;\r\n /**\r\n * Returns the string \"ParticleSystem\"\r\n * @returns a string containing the class name\r\n */\r\n getClassName(): string;\r\n /**\r\n * Gets the custom effect used to render the particles\r\n * @param blendMode Blend mode for which the effect should be retrieved\r\n * @returns The effect\r\n */\r\n getCustomEffect(blendMode: number): Nullable<Effect>;\r\n /**\r\n * Sets the custom effect used to render the particles\r\n * @param effect The effect to set\r\n * @param blendMode Blend mode for which the effect should be set\r\n */\r\n setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;\r\n\r\n /**\r\n * Fill the defines array according to the current settings of the particle system\r\n * @param defines Array to be updated\r\n * @param blendMode blend mode to take into account when updating the array\r\n * @param fillImageProcessing fills the image processing defines\r\n */\r\n fillDefines(defines: Array<string>, blendMode: number, fillImageProcessing?: boolean): void;\r\n /**\r\n * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system\r\n * @param uniforms Uniforms array to fill\r\n * @param attributes Attributes array to fill\r\n * @param samplers Samplers array to fill\r\n */\r\n fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;\r\n /**\r\n * Observable that will be called just before the particles are drawn\r\n */\r\n onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;\r\n /**\r\n * Gets the name of the particle vertex shader\r\n */\r\n vertexShaderName: string;\r\n\r\n /**\r\n * Gets the vertex buffers used by the particle system\r\n */\r\n vertexBuffers: Immutable<{ [key: string]: VertexBuffer }>;\r\n /**\r\n * Gets the index buffer used by the particle system (or null if no index buffer is used)\r\n */\r\n indexBuffer: Nullable<DataBuffer>;\r\n\r\n /**\r\n * Adds a new color gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color1 defines the color to affect to the specified gradient\r\n * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from\r\n * @returns the current particle system\r\n */\r\n addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;\r\n /**\r\n * Remove a specific color gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeColorGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new size gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the size factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n /**\r\n * Gets the current list of size gradients.\r\n * You must use addSizeGradient and removeSizeGradient to update this list\r\n * @returns the list of size gradients\r\n */\r\n getSizeGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Gets the current list of angular speed gradients.\r\n * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list\r\n * @returns the list of angular speed gradients\r\n */\r\n getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new angular speed gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the angular speed to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific angular speed gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeAngularSpeedGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of velocity gradients.\r\n * You must use addVelocityGradient and removeVelocityGradient to update this list\r\n * @returns the list of velocity gradients\r\n */\r\n getVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of limit velocity gradients.\r\n * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list\r\n * @returns the list of limit velocity gradients\r\n */\r\n getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new limit velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the limit velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific limit velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLimitVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new drag gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the drag to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific drag gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeDragGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of drag gradients.\r\n * You must use addDragGradient and removeDragGradient to update this list\r\n * @returns the list of drag gradients\r\n */\r\n getDragGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the emit rate to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific emit rate gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeEmitRateGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of emit rate gradients.\r\n * You must use addEmitRateGradient and removeEmitRateGradient to update this list\r\n * @returns the list of emit rate gradients\r\n */\r\n getEmitRateGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the start size to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific start size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeStartSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of start size gradients.\r\n * You must use addStartSizeGradient and removeStartSizeGradient to update this list\r\n * @returns the list of start size gradients\r\n */\r\n getStartSizeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new life time gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the life time factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific life time gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLifeTimeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of life time gradients.\r\n * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list\r\n * @returns the list of life time gradients\r\n */\r\n getLifeTimeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n\r\n /**\r\n * Adds a new ramp gradient used to remap particle colors\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color defines the color to affect to the specified gradient\r\n * @returns the current particle system\r\n */\r\n addRampGradient(gradient: number, color: Color3): IParticleSystem;\r\n /**\r\n * Gets the current list of ramp gradients.\r\n * You must use addRampGradient and removeRampGradient to update this list\r\n * @returns the list of ramp gradients\r\n */\r\n getRampGradients(): Nullable<Array<Color3Gradient>>;\r\n\r\n /** Gets or sets a boolean indicating that ramp gradients must be used\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/ramps_and_blends\r\n */\r\n useRampGradients: boolean;\r\n\r\n /**\r\n * Adds a new color remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the color remap minimal range\r\n * @param max defines the color remap maximal range\r\n * @returns the current particle system\r\n */\r\n addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color remap gradients.\r\n * You must use addColorRemapGradient and removeColorRemapGradient to update this list\r\n * @returns the list of color remap gradients\r\n */\r\n getColorRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new alpha remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the alpha remap minimal range\r\n * @param max defines the alpha remap maximal range\r\n * @returns the current particle system\r\n */\r\n addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of alpha remap gradients.\r\n * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list\r\n * @returns the list of alpha remap gradients\r\n */\r\n getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Creates a Point Emitter for the particle system (emits directly from the emitter position)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @returns the emitter\r\n */\r\n createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;\r\n\r\n /**\r\n * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)\r\n * @param radius The radius of the hemisphere to emit from\r\n * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;\r\n\r\n /**\r\n * Creates a Sphere Emitter for the particle system (emits along the sphere radius)\r\n * @param radius The radius of the sphere to emit from\r\n * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the sphere to emit from\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @returns the emitter\r\n */\r\n createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)\r\n * @param radius The radius of the emission cylinder\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius\r\n * @param directionRandomizer How much to randomize the particle direction [0-1]\r\n * @returns the emitter\r\n */\r\n createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the cylinder to emit from\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @returns the emitter\r\n */\r\n createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): CylinderDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)\r\n * @param radius The radius of the cone to emit from\r\n * @param angle The base angle of the cone\r\n * @returns the emitter\r\n */\r\n createConeEmitter(radius: number, angle: number): ConeParticleEmitter;\r\n\r\n createDirectedConeEmitter(radius: number, angle: number, direction1: Vector3, direction2: Vector3): ConeDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @returns the emitter\r\n */\r\n createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;\r\n\r\n /**\r\n * Get hosting scene\r\n * @returns the scene\r\n */\r\n getScene(): Nullable<Scene>;\r\n}\r\n"]}
1
+ {"version":3,"file":"IParticleSystem.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/IParticleSystem.ts"],"names":[],"mappings":"","sourcesContent":["import type { Immutable, Nullable } from \"../types\";\r\nimport type { Vector2, Vector3, Matrix } from \"../Maths/math.vector\";\r\nimport type { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type {\r\n BoxParticleEmitter,\r\n IParticleEmitterType,\r\n PointParticleEmitter,\r\n HemisphericParticleEmitter,\r\n SphereParticleEmitter,\r\n SphereDirectedParticleEmitter,\r\n CylinderParticleEmitter,\r\n CylinderDirectedParticleEmitter,\r\n ConeParticleEmitter,\r\n ConeDirectedParticleEmitter,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"../Particles/EmitterTypes/index\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ColorGradient, FactorGradient, Color3Gradient } from \"../Misc/gradients\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { Observable } from \"../Misc/observable\";\r\nimport type { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\n\r\nimport type { Animation } from \"../Animations/animation\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\n\r\n/**\r\n * Interface representing a particle system in Babylon.js.\r\n * This groups the common functionalities that needs to be implemented in order to create a particle system.\r\n * A particle system represents a way to manage particles from their emission to their animation and rendering.\r\n */\r\nexport interface IParticleSystem {\r\n /**\r\n * List of animations used by the particle system.\r\n */\r\n animations: Animation[];\r\n /**\r\n * The id of the Particle system.\r\n */\r\n id: string;\r\n /**\r\n * The name of the Particle system.\r\n */\r\n name: string;\r\n /**\r\n * The emitter represents the Mesh or position we are attaching the particle system to.\r\n */\r\n emitter: Nullable<AbstractMesh | Vector3>;\r\n /**\r\n * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction\r\n */\r\n isBillboardBased: boolean;\r\n /**\r\n * The rendering group used by the Particle system to chose when to render.\r\n */\r\n renderingGroupId: number;\r\n /**\r\n * The layer mask we are rendering the particles through.\r\n */\r\n layerMask: number;\r\n\r\n /**\r\n * The overall motion speed (0.01 is default update speed, faster updates = faster animation)\r\n */\r\n updateSpeed: number;\r\n\r\n /**\r\n * The amount of time the particle system is running (depends of the overall update speed).\r\n */\r\n targetStopDuration: number;\r\n\r\n /**\r\n * The texture used to render each particle. (this can be a spritesheet)\r\n */\r\n particleTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Blend mode use to render the particle. It can be any of the ParticleSystem.BLENDMODE_* constants\r\n */\r\n blendMode: number;\r\n\r\n /**\r\n * Minimum life time of emitting particles.\r\n */\r\n minLifeTime: number;\r\n /**\r\n * Maximum life time of emitting particles.\r\n */\r\n maxLifeTime: number;\r\n\r\n /**\r\n * Minimum Size of emitting particles.\r\n */\r\n minSize: number;\r\n /**\r\n * Maximum Size of emitting particles.\r\n */\r\n maxSize: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on X axis.\r\n */\r\n minScaleX: number;\r\n /**\r\n * Maximum scale of emitting particles on X axis.\r\n */\r\n maxScaleX: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on Y axis.\r\n */\r\n minScaleY: number;\r\n /**\r\n * Maximum scale of emitting particles on Y axis.\r\n */\r\n maxScaleY: number;\r\n\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color1: Color4;\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color2: Color4;\r\n\r\n /**\r\n * Color the particle will have at the end of its lifetime.\r\n */\r\n colorDead: Color4;\r\n\r\n /**\r\n * The maximum number of particles to emit per frame until we reach the activeParticleCount value\r\n */\r\n emitRate: number;\r\n\r\n /**\r\n * You can use gravity if you want to give an orientation to your particles.\r\n */\r\n gravity: Vector3;\r\n\r\n /**\r\n * Minimum power of emitting particles.\r\n */\r\n minEmitPower: number;\r\n /**\r\n * Maximum power of emitting particles.\r\n */\r\n maxEmitPower: number;\r\n /**\r\n * Minimum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n minAngularSpeed: number;\r\n /**\r\n * Maximum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n maxAngularSpeed: number;\r\n /**\r\n * Gets or sets the minimal initial rotation in radians.\r\n */\r\n minInitialRotation: number;\r\n /**\r\n * Gets or sets the maximal initial rotation in radians.\r\n */\r\n maxInitialRotation: number;\r\n /**\r\n * The particle emitter type defines the emitter used by the particle system.\r\n * It can be for example box, sphere, or cone...\r\n */\r\n particleEmitterType: Nullable<IParticleEmitterType>;\r\n /**\r\n * Defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n startDelay: number;\r\n /**\r\n * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0\r\n */\r\n preWarmCycles: number;\r\n /**\r\n * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)\r\n */\r\n preWarmStepOffset: number;\r\n\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)\r\n */\r\n spriteCellChangeSpeed: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display\r\n */\r\n startSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display\r\n */\r\n endSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines whether the sprite animation is looping\r\n */\r\n spriteCellLoop: boolean;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use\r\n */\r\n spriteCellWidth: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use\r\n */\r\n spriteCellHeight: number;\r\n /**\r\n * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID\r\n */\r\n spriteRandomStartCell: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture\r\n */\r\n isAnimationSheetEnabled: boolean;\r\n\r\n /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */\r\n translationPivot: Vector2;\r\n\r\n /**\r\n * Gets or sets a texture used to add random noise to particle positions\r\n */\r\n noiseTexture: Nullable<BaseTexture>;\r\n\r\n /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */\r\n noiseStrength: Vector3;\r\n\r\n /**\r\n * Gets or sets the billboard mode to use when isBillboardBased = true.\r\n * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED\r\n */\r\n billboardMode: number;\r\n\r\n /**\r\n * Gets or sets a boolean enabling the use of logarithmic depth buffers, which is good for wide depth buffers.\r\n */\r\n useLogarithmicDepth: boolean;\r\n\r\n /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */\r\n limitVelocityDamping: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called\r\n */\r\n beginAnimationOnStart: boolean;\r\n\r\n /**\r\n * Gets or sets the frame to start the animation from when beginAnimationOnStart is true\r\n */\r\n beginAnimationFrom: number;\r\n\r\n /**\r\n * Gets or sets the frame to end the animation on when beginAnimationOnStart is true\r\n */\r\n beginAnimationTo: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true\r\n */\r\n beginAnimationLoop: boolean;\r\n\r\n /**\r\n * Specifies whether the particle system will be disposed once it reaches the end of the animation.\r\n */\r\n disposeOnStop: boolean;\r\n\r\n /**\r\n * If you want to launch only a few particles at once, that can be done, as well.\r\n */\r\n manualEmitCount: number;\r\n\r\n /**\r\n * Specifies if the particles are updated in emitter local space or world space\r\n */\r\n isLocal: boolean;\r\n\r\n /** Snippet ID if the particle system was created from the snippet server */\r\n snippetId: string;\r\n\r\n /** Gets or sets a matrix to use to compute projection */\r\n defaultProjectionMatrix: Matrix;\r\n\r\n /** Indicates that the update of particles is done in the animate function (and not in render) */\r\n updateInAnimate: boolean;\r\n\r\n /** @internal */\r\n _wasDispatched: boolean;\r\n\r\n /**\r\n * Gets the maximum number of particles active at the same time.\r\n * @returns The max number of active particles.\r\n */\r\n getCapacity(): number;\r\n\r\n /**\r\n * Gets the number of particles active at the same time.\r\n * @returns The number of active particles.\r\n */\r\n getActiveCount(): number;\r\n\r\n /**\r\n * Gets if the system has been started. (Note: this will still be true after stop is called)\r\n * @returns True if it has been started, otherwise false.\r\n */\r\n isStarted(): boolean;\r\n\r\n /**\r\n * Animates the particle system for this frame.\r\n */\r\n animate(): void;\r\n /**\r\n * Renders the particle system in its current state.\r\n * @returns the current number of particles\r\n */\r\n render(): number;\r\n /**\r\n * Dispose the particle system and frees its associated resources.\r\n * @param disposeTexture defines if the particle texture must be disposed as well (true by default)\r\n * @param disposeAttachedSubEmitters defines if the attached sub-emitters must be disposed as well (false by default)\r\n * @param disposeEndSubEmitters defines if the end type sub-emitters must be disposed as well (false by default)\r\n */\r\n dispose(disposeTexture?: boolean, disposeAttachedSubEmitters?: boolean, disposeEndSubEmitters?: boolean): void;\r\n /**\r\n * An event triggered when the system is disposed\r\n */\r\n onDisposeObservable: Observable<IParticleSystem>;\r\n /**\r\n * An event triggered when the system is stopped\r\n */\r\n onStoppedObservable: Observable<IParticleSystem>;\r\n /**\r\n * Clones the particle system.\r\n * @param name The name of the cloned object\r\n * @param newEmitter The new emitter to use\r\n * @returns the cloned particle system\r\n */\r\n clone(name: string, newEmitter: any): Nullable<IParticleSystem>;\r\n /**\r\n * Serializes the particle system to a JSON object\r\n * @param serializeTexture defines if the texture must be serialized as well\r\n * @returns the JSON object\r\n */\r\n serialize(serializeTexture: boolean): any;\r\n /**\r\n * Rebuild the particle system\r\n */\r\n rebuild(): void;\r\n\r\n /** Force the system to rebuild all gradients that need to be resync */\r\n forceRefreshGradients(): void;\r\n\r\n /**\r\n * Starts the particle system and begins to emit\r\n * @param delay defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n start(delay?: number): void;\r\n\r\n /**\r\n * Stops the particle system.\r\n */\r\n stop(): void;\r\n\r\n /**\r\n * Remove all active particles\r\n */\r\n reset(): void;\r\n\r\n /**\r\n * Gets a boolean indicating that the system is stopping\r\n * @returns true if the system is currently stopping\r\n */\r\n isStopping(): boolean;\r\n\r\n /**\r\n * Is this system ready to be used/rendered\r\n * @returns true if the system is ready\r\n */\r\n isReady(): boolean;\r\n /**\r\n * Returns the string \"ParticleSystem\"\r\n * @returns a string containing the class name\r\n */\r\n getClassName(): string;\r\n /**\r\n * Gets the custom effect used to render the particles\r\n * @param blendMode Blend mode for which the effect should be retrieved\r\n * @returns The effect\r\n */\r\n getCustomEffect(blendMode: number): Nullable<Effect>;\r\n /**\r\n * Sets the custom effect used to render the particles\r\n * @param effect The effect to set\r\n * @param blendMode Blend mode for which the effect should be set\r\n */\r\n setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;\r\n\r\n /**\r\n * Fill the defines array according to the current settings of the particle system\r\n * @param defines Array to be updated\r\n * @param blendMode blend mode to take into account when updating the array\r\n * @param fillImageProcessing fills the image processing defines\r\n */\r\n fillDefines(defines: Array<string>, blendMode: number, fillImageProcessing?: boolean): void;\r\n /**\r\n * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system\r\n * @param uniforms Uniforms array to fill\r\n * @param attributes Attributes array to fill\r\n * @param samplers Samplers array to fill\r\n */\r\n fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;\r\n /**\r\n * Observable that will be called just before the particles are drawn\r\n */\r\n onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;\r\n /**\r\n * Gets the name of the particle vertex shader\r\n */\r\n vertexShaderName: string;\r\n\r\n /**\r\n * Gets the vertex buffers used by the particle system\r\n */\r\n vertexBuffers: Immutable<{ [key: string]: VertexBuffer }>;\r\n /**\r\n * Gets the index buffer used by the particle system (or null if no index buffer is used)\r\n */\r\n indexBuffer: Nullable<DataBuffer>;\r\n\r\n /**\r\n * Adds a new color gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color1 defines the color to affect to the specified gradient\r\n * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from\r\n * @returns the current particle system\r\n */\r\n addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;\r\n /**\r\n * Remove a specific color gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeColorGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new size gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the size factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n /**\r\n * Gets the current list of size gradients.\r\n * You must use addSizeGradient and removeSizeGradient to update this list\r\n * @returns the list of size gradients\r\n */\r\n getSizeGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Gets the current list of angular speed gradients.\r\n * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list\r\n * @returns the list of angular speed gradients\r\n */\r\n getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new angular speed gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the angular speed to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific angular speed gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeAngularSpeedGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of velocity gradients.\r\n * You must use addVelocityGradient and removeVelocityGradient to update this list\r\n * @returns the list of velocity gradients\r\n */\r\n getVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of limit velocity gradients.\r\n * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list\r\n * @returns the list of limit velocity gradients\r\n */\r\n getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new limit velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the limit velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific limit velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLimitVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new drag gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the drag to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific drag gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeDragGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of drag gradients.\r\n * You must use addDragGradient and removeDragGradient to update this list\r\n * @returns the list of drag gradients\r\n */\r\n getDragGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the emit rate to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific emit rate gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeEmitRateGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of emit rate gradients.\r\n * You must use addEmitRateGradient and removeEmitRateGradient to update this list\r\n * @returns the list of emit rate gradients\r\n */\r\n getEmitRateGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the start size to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific start size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeStartSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of start size gradients.\r\n * You must use addStartSizeGradient and removeStartSizeGradient to update this list\r\n * @returns the list of start size gradients\r\n */\r\n getStartSizeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new life time gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the life time factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific life time gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLifeTimeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of life time gradients.\r\n * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list\r\n * @returns the list of life time gradients\r\n */\r\n getLifeTimeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n\r\n /**\r\n * Adds a new ramp gradient used to remap particle colors\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color defines the color to affect to the specified gradient\r\n * @returns the current particle system\r\n */\r\n addRampGradient(gradient: number, color: Color3): IParticleSystem;\r\n /**\r\n * Gets the current list of ramp gradients.\r\n * You must use addRampGradient and removeRampGradient to update this list\r\n * @returns the list of ramp gradients\r\n */\r\n getRampGradients(): Nullable<Array<Color3Gradient>>;\r\n\r\n /** Gets or sets a boolean indicating that ramp gradients must be used\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/ramps_and_blends\r\n */\r\n useRampGradients: boolean;\r\n\r\n /**\r\n * Adds a new color remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the color remap minimal range\r\n * @param max defines the color remap maximal range\r\n * @returns the current particle system\r\n */\r\n addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color remap gradients.\r\n * You must use addColorRemapGradient and removeColorRemapGradient to update this list\r\n * @returns the list of color remap gradients\r\n */\r\n getColorRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new alpha remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the alpha remap minimal range\r\n * @param max defines the alpha remap maximal range\r\n * @returns the current particle system\r\n */\r\n addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of alpha remap gradients.\r\n * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list\r\n * @returns the list of alpha remap gradients\r\n */\r\n getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Creates a Point Emitter for the particle system (emits directly from the emitter position)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @returns the emitter\r\n */\r\n createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;\r\n\r\n /**\r\n * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)\r\n * @param radius The radius of the hemisphere to emit from\r\n * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;\r\n\r\n /**\r\n * Creates a Sphere Emitter for the particle system (emits along the sphere radius)\r\n * @param radius The radius of the sphere to emit from\r\n * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the sphere to emit from\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @returns the emitter\r\n */\r\n createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)\r\n * @param radius The radius of the emission cylinder\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius\r\n * @param directionRandomizer How much to randomize the particle direction [0-1]\r\n * @returns the emitter\r\n */\r\n createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the cylinder to emit from\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @returns the emitter\r\n */\r\n createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): CylinderDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)\r\n * @param radius The radius of the cone to emit from\r\n * @param angle The base angle of the cone\r\n * @returns the emitter\r\n */\r\n createConeEmitter(radius: number, angle: number): ConeParticleEmitter;\r\n\r\n createDirectedConeEmitter(radius: number, angle: number, direction1: Vector3, direction2: Vector3): ConeDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @returns the emitter\r\n */\r\n createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;\r\n\r\n /**\r\n * Get hosting scene\r\n * @returns the scene\r\n */\r\n getScene(): Nullable<Scene>;\r\n}\r\n"]}
@@ -29,11 +29,11 @@ import type { ConeDirectedParticleEmitter, ConeParticleEmitter } from "./Emitter
29
29
  */
30
30
  export declare class BaseParticleSystem implements IClipPlanesHolder {
31
31
  /**
32
- * Source color is added to the destination color without alpha affecting the result
32
+ * Source color is added to the destination color without alpha affecting the result. Great for additive glow effects (fire, magic, lasers)
33
33
  */
34
34
  static BLENDMODE_ONEONE: number;
35
35
  /**
36
- * Blend current color and particle color using particle’s alpha
36
+ * Blend current color and particle color using particle’s alpha. Same as Constants.ALPHA_COMBINE, the go-to for transparency. 100% alpha means source, 0% alpha means background. Glass, UI fade, smoke
37
37
  */
38
38
  static BLENDMODE_STANDARD: number;
39
39
  /**
@@ -48,6 +48,11 @@ export declare class BaseParticleSystem implements IClipPlanesHolder {
48
48
  * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
49
49
  */
50
50
  static BLENDMODE_MULTIPLYADD: number;
51
+ /**
52
+ * Subtracts source (particle) from destination (current color), leading to darker results
53
+ * - NOTE: Init as -1 so we can properly map all modes to Engine Const's (otherwise ALPHA_SUBTRACT will conflict with BLENDMODE_MULTIPLY since both use 3)
54
+ */
55
+ static BLENDMODE_SUBTRACT: number;
51
56
  /**
52
57
  * List of animations used by the particle system.
53
58
  */
@@ -190,7 +195,9 @@ export declare class BaseParticleSystem implements IClipPlanesHolder {
190
195
  */
191
196
  onAnimationEnd: Nullable<() => void>;
192
197
  /**
193
- * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
198
+ * Blend mode use to render the particle
199
+ * For original blend modes which are exposed from ParticleSystem (OneOne, Standard, Add, Multiply, MultiplyAdd, and Subtract), use ParticleSystem.BLENDMODE_FOO
200
+ * For all other blend modes, use Engine Constants.ALPHA_FOO blend modes
194
201
  */
195
202
  blendMode: number;
196
203
  /**
@@ -311,6 +318,7 @@ export declare class BaseParticleSystem implements IClipPlanesHolder {
311
318
  protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
312
319
  protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
313
320
  protected _hasTargetStopDurationDependantGradient(): boolean | null;
321
+ protected _setEngineBasedOnBlendMode(blendMode: number): void;
314
322
  /**
315
323
  * Defines the delay in milliseconds before starting the system (0 by default)
316
324
  */
@@ -58,6 +58,33 @@ export class BaseParticleSystem {
58
58
  (this._emitRateGradients && this._emitRateGradients.length > 0) ||
59
59
  (this._lifeTimeGradients && this._lifeTimeGradients.length > 0));
60
60
  }
61
+ _setEngineBasedOnBlendMode(blendMode) {
62
+ switch (blendMode) {
63
+ case BaseParticleSystem.BLENDMODE_MULTIPLYADD:
64
+ // Don't want to update engine since there is no equivalent engine alpha mode, instead it gets handled within particleSystem
65
+ return;
66
+ case BaseParticleSystem.BLENDMODE_ADD:
67
+ blendMode = 1;
68
+ break;
69
+ case BaseParticleSystem.BLENDMODE_ONEONE:
70
+ blendMode = 6;
71
+ break;
72
+ case BaseParticleSystem.BLENDMODE_STANDARD:
73
+ blendMode = 2;
74
+ break;
75
+ case BaseParticleSystem.BLENDMODE_MULTIPLY:
76
+ blendMode = 4;
77
+ break;
78
+ case BaseParticleSystem.BLENDMODE_SUBTRACT:
79
+ blendMode = 3;
80
+ break;
81
+ default:
82
+ // For all other blend modes that were added after the initial particleSystem implementation,
83
+ // the ParticleSystem.BLENDMODE_FOO are already mapped to the underlying undefined
84
+ break;
85
+ }
86
+ this._engine.setAlphaMode(blendMode);
87
+ }
61
88
  /**
62
89
  * Gets the current list of drag gradients.
63
90
  * You must use addDragGradient and removeDragGradient to update this list
@@ -407,7 +434,9 @@ export class BaseParticleSystem {
407
434
  */
408
435
  this.onAnimationEnd = null;
409
436
  /**
410
- * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
437
+ * Blend mode use to render the particle
438
+ * For original blend modes which are exposed from ParticleSystem (OneOne, Standard, Add, Multiply, MultiplyAdd, and Subtract), use ParticleSystem.BLENDMODE_FOO
439
+ * For all other blend modes, use Engine undefined blend modes
411
440
  */
412
441
  this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
413
442
  /**
@@ -598,11 +627,11 @@ export class BaseParticleSystem {
598
627
  }
599
628
  }
600
629
  /**
601
- * Source color is added to the destination color without alpha affecting the result
630
+ * Source color is added to the destination color without alpha affecting the result. Great for additive glow effects (fire, magic, lasers)
602
631
  */
603
632
  BaseParticleSystem.BLENDMODE_ONEONE = 0;
604
633
  /**
605
- * Blend current color and particle color using particle’s alpha
634
+ * Blend current color and particle color using particle’s alpha. Same as 2, the go-to for transparency. 100% alpha means source, 0% alpha means background. Glass, UI fade, smoke
606
635
  */
607
636
  BaseParticleSystem.BLENDMODE_STANDARD = 1;
608
637
  /**
@@ -617,6 +646,11 @@ BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
617
646
  * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
618
647
  */
619
648
  BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
649
+ /**
650
+ * Subtracts source (particle) from destination (current color), leading to darker results
651
+ * - NOTE: Init as -1 so we can properly map all modes to Engine Const's (otherwise ALPHA_SUBTRACT will conflict with BLENDMODE_MULTIPLY since both use 3)
652
+ */
653
+ BaseParticleSystem.BLENDMODE_SUBTRACT = -1;
620
654
  // Register Class Name
621
655
  RegisterClass("BABYLON.BaseParticleSystem", BaseParticleSystem);
622
656
  //# sourceMappingURL=baseParticleSystem.js.map