@needle-tools/engine 3.28.6-beta → 3.28.7-beta.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 (848) hide show
  1. package/CHANGELOG.md +2259 -2253
  2. package/LICENSE.md +10 -10
  3. package/README.md +52 -52
  4. package/dist/needle-engine.js +7 -10
  5. package/dist/needle-engine.light.js +7 -10
  6. package/dist/needle-engine.light.min.js +7 -10
  7. package/dist/needle-engine.light.umd.cjs +7 -10
  8. package/dist/needle-engine.min.js +7 -10
  9. package/dist/needle-engine.umd.cjs +7 -10
  10. package/lib/engine/api.d.ts +52 -52
  11. package/lib/engine/api.js +51 -51
  12. package/lib/engine/assets/index.d.ts +1 -1
  13. package/lib/engine/assets/index.js +4 -4
  14. package/lib/engine/codegen/register_types.d.ts +1 -1
  15. package/lib/engine/codegen/register_types.js +439 -439
  16. package/lib/engine/debug/debug.d.ts +12 -12
  17. package/lib/engine/debug/debug.js +26 -26
  18. package/lib/engine/debug/debug_console.d.ts +2 -2
  19. package/lib/engine/debug/debug_console.js +204 -204
  20. package/lib/engine/debug/debug_overlay.d.ts +10 -10
  21. package/lib/engine/debug/debug_overlay.js +277 -277
  22. package/lib/engine/debug/index.d.ts +1 -1
  23. package/lib/engine/debug/index.js +1 -1
  24. package/lib/engine/engine_addressables.d.ts +75 -75
  25. package/lib/engine/engine_addressables.js +441 -441
  26. package/lib/engine/engine_application.d.ts +19 -19
  27. package/lib/engine/engine_application.js +45 -45
  28. package/lib/engine/engine_assetdatabase.d.ts +25 -25
  29. package/lib/engine/engine_assetdatabase.js +341 -341
  30. package/lib/engine/engine_camera.d.ts +6 -6
  31. package/lib/engine/engine_camera.js +23 -23
  32. package/lib/engine/engine_components.d.ts +17 -17
  33. package/lib/engine/engine_components.js +273 -273
  34. package/lib/engine/engine_components_internal.d.ts +11 -11
  35. package/lib/engine/engine_components_internal.js +41 -41
  36. package/lib/engine/engine_constants.d.ts +5 -5
  37. package/lib/engine/engine_constants.js +32 -32
  38. package/lib/engine/engine_context.d.ts +269 -269
  39. package/lib/engine/engine_context.js +1242 -1242
  40. package/lib/engine/engine_context_registry.d.ts +50 -50
  41. package/lib/engine/engine_context_registry.js +89 -89
  42. package/lib/engine/engine_coroutine.d.ts +4 -4
  43. package/lib/engine/engine_coroutine.js +21 -21
  44. package/lib/engine/engine_create_objects.d.ts +13 -13
  45. package/lib/engine/engine_create_objects.js +33 -33
  46. package/lib/engine/engine_default_parameters.d.ts +2 -2
  47. package/lib/engine/engine_default_parameters.js +3 -3
  48. package/lib/engine/engine_editor-sync.d.ts +17 -17
  49. package/lib/engine/engine_editor-sync.js +7 -7
  50. package/lib/engine/engine_element.d.ts +55 -55
  51. package/lib/engine/engine_element.js +559 -559
  52. package/lib/engine/engine_element_attributes.d.ts +49 -49
  53. package/lib/engine/engine_element_attributes.js +1 -1
  54. package/lib/engine/engine_element_extras.d.ts +6 -6
  55. package/lib/engine/engine_element_extras.js +13 -13
  56. package/lib/engine/engine_element_loading.d.ts +40 -40
  57. package/lib/engine/engine_element_loading.js +312 -312
  58. package/lib/engine/engine_element_overlay.d.ts +19 -19
  59. package/lib/engine/engine_element_overlay.js +143 -143
  60. package/lib/engine/engine_fileloader.d.ts +3 -3
  61. package/lib/engine/engine_fileloader.js +7 -7
  62. package/lib/engine/engine_gameobject.d.ts +39 -39
  63. package/lib/engine/engine_gameobject.js +559 -559
  64. package/lib/engine/engine_generic_utils.d.ts +1 -1
  65. package/lib/engine/engine_generic_utils.js +13 -13
  66. package/lib/engine/engine_gizmos.d.ts +26 -26
  67. package/lib/engine/engine_gizmos.js +282 -282
  68. package/lib/engine/engine_gltf.d.ts +13 -13
  69. package/lib/engine/engine_gltf.js +15 -15
  70. package/lib/engine/engine_gltf_builtin_components.d.ts +7 -7
  71. package/lib/engine/engine_gltf_builtin_components.js +298 -298
  72. package/lib/engine/engine_hot_reload.d.ts +5 -5
  73. package/lib/engine/engine_hot_reload.js +182 -182
  74. package/lib/engine/engine_input.d.ts +129 -129
  75. package/lib/engine/engine_input.js +799 -799
  76. package/lib/engine/engine_input_utils.d.ts +2 -2
  77. package/lib/engine/engine_input_utils.js +22 -22
  78. package/lib/engine/engine_instancing.d.ts +16 -16
  79. package/lib/engine/engine_instancing.js +36 -36
  80. package/lib/engine/engine_license.d.ts +4 -4
  81. package/lib/engine/engine_license.js +398 -398
  82. package/lib/engine/engine_lifecycle_api.d.ts +14 -14
  83. package/lib/engine/engine_lifecycle_api.js +24 -24
  84. package/lib/engine/engine_lifecycle_functions_internal.d.ts +6 -6
  85. package/lib/engine/engine_lifecycle_functions_internal.js +28 -28
  86. package/lib/engine/engine_lightdata.d.ts +23 -23
  87. package/lib/engine/engine_lightdata.js +86 -86
  88. package/lib/engine/engine_loaders.d.ts +7 -7
  89. package/lib/engine/engine_loaders.js +69 -69
  90. package/lib/engine/engine_mainloop_utils.d.ts +13 -13
  91. package/lib/engine/engine_mainloop_utils.js +426 -426
  92. package/lib/engine/engine_math.d.ts +43 -43
  93. package/lib/engine/engine_math.js +147 -147
  94. package/lib/engine/engine_networking.d.ts +176 -176
  95. package/lib/engine/engine_networking.js +649 -649
  96. package/lib/engine/engine_networking_auto.d.ts +24 -24
  97. package/lib/engine/engine_networking_auto.js +324 -324
  98. package/lib/engine/engine_networking_files.d.ts +23 -23
  99. package/lib/engine/engine_networking_files.js +176 -176
  100. package/lib/engine/engine_networking_files_default_components.d.ts +3 -3
  101. package/lib/engine/engine_networking_files_default_components.js +39 -39
  102. package/lib/engine/engine_networking_instantiate.d.ts +39 -39
  103. package/lib/engine/engine_networking_instantiate.js +302 -302
  104. package/lib/engine/engine_networking_peer.d.ts +15 -15
  105. package/lib/engine/engine_networking_peer.js +132 -132
  106. package/lib/engine/engine_networking_streams.d.ts +90 -90
  107. package/lib/engine/engine_networking_streams.js +428 -428
  108. package/lib/engine/engine_networking_types.d.ts +14 -14
  109. package/lib/engine/engine_networking_types.js +7 -7
  110. package/lib/engine/engine_networking_utils.d.ts +2 -2
  111. package/lib/engine/engine_networking_utils.js +20 -20
  112. package/lib/engine/engine_patcher.d.ts +10 -10
  113. package/lib/engine/engine_patcher.js +142 -142
  114. package/lib/engine/engine_physics.d.ts +115 -115
  115. package/lib/engine/engine_physics.js +228 -228
  116. package/lib/engine/engine_physics.types.d.ts +37 -37
  117. package/lib/engine/engine_physics.types.js +33 -33
  118. package/lib/engine/engine_physics_rapier.d.ts +112 -112
  119. package/lib/engine/engine_physics_rapier.js +1266 -1266
  120. package/lib/engine/engine_playerview.d.ts +26 -26
  121. package/lib/engine/engine_playerview.js +64 -64
  122. package/lib/engine/engine_scenelighting.d.ts +74 -74
  123. package/lib/engine/engine_scenelighting.js +285 -285
  124. package/lib/engine/engine_scenetools.d.ts +35 -35
  125. package/lib/engine/engine_scenetools.js +212 -212
  126. package/lib/engine/engine_serialization.d.ts +4 -4
  127. package/lib/engine/engine_serialization.js +4 -4
  128. package/lib/engine/engine_serialization_builtin_serializer.d.ts +62 -62
  129. package/lib/engine/engine_serialization_builtin_serializer.js +369 -369
  130. package/lib/engine/engine_serialization_core.d.ts +84 -84
  131. package/lib/engine/engine_serialization_core.js +576 -576
  132. package/lib/engine/engine_serialization_decorator.d.ts +15 -15
  133. package/lib/engine/engine_serialization_decorator.js +54 -54
  134. package/lib/engine/engine_setup.d.ts +1 -1
  135. package/lib/engine/engine_setup.js +2 -2
  136. package/lib/engine/engine_shaders.d.ts +31 -31
  137. package/lib/engine/engine_shaders.js +229 -229
  138. package/lib/engine/engine_shims.d.ts +3 -3
  139. package/lib/engine/engine_shims.js +22 -22
  140. package/lib/engine/engine_texture.d.ts +20 -20
  141. package/lib/engine/engine_texture.js +57 -57
  142. package/lib/engine/engine_three_utils.d.ts +51 -51
  143. package/lib/engine/engine_three_utils.js +342 -342
  144. package/lib/engine/engine_time.d.ts +19 -19
  145. package/lib/engine/engine_time.js +47 -47
  146. package/lib/engine/engine_types.d.ts +358 -358
  147. package/lib/engine/engine_types.js +72 -72
  148. package/lib/engine/engine_typestore.d.ts +16 -16
  149. package/lib/engine/engine_typestore.js +35 -35
  150. package/lib/engine/engine_util_decorator.d.ts +12 -12
  151. package/lib/engine/engine_util_decorator.js +115 -115
  152. package/lib/engine/engine_utils.d.ts +104 -104
  153. package/lib/engine/engine_utils.js +518 -518
  154. package/lib/engine/engine_utils_screenshot.d.ts +10 -10
  155. package/lib/engine/engine_utils_screenshot.js +70 -70
  156. package/lib/engine/engine_web_api.d.ts +12 -12
  157. package/lib/engine/engine_web_api.js +112 -112
  158. package/lib/engine/extensions/EXT_texture_exr.d.ts +8 -8
  159. package/lib/engine/extensions/EXT_texture_exr.js +32 -32
  160. package/lib/engine/extensions/NEEDLE_animator_controller_model.d.ts +116 -116
  161. package/lib/engine/extensions/NEEDLE_animator_controller_model.js +91 -91
  162. package/lib/engine/extensions/NEEDLE_components.d.ts +33 -33
  163. package/lib/engine/extensions/NEEDLE_components.js +206 -206
  164. package/lib/engine/extensions/NEEDLE_gameobject_data.d.ts +10 -10
  165. package/lib/engine/extensions/NEEDLE_gameobject_data.js +57 -57
  166. package/lib/engine/extensions/NEEDLE_lighting_settings.d.ts +38 -38
  167. package/lib/engine/extensions/NEEDLE_lighting_settings.js +183 -183
  168. package/lib/engine/extensions/NEEDLE_lightmaps.d.ts +18 -18
  169. package/lib/engine/extensions/NEEDLE_lightmaps.js +108 -108
  170. package/lib/engine/extensions/NEEDLE_persistent_assets.d.ts +11 -11
  171. package/lib/engine/extensions/NEEDLE_persistent_assets.js +63 -63
  172. package/lib/engine/extensions/NEEDLE_progressive.d.ts +41 -41
  173. package/lib/engine/extensions/NEEDLE_progressive.js +366 -366
  174. package/lib/engine/extensions/NEEDLE_render_objects.d.ts +13 -13
  175. package/lib/engine/extensions/NEEDLE_render_objects.js +159 -159
  176. package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +39 -39
  177. package/lib/engine/extensions/NEEDLE_techniques_webgl.js +544 -544
  178. package/lib/engine/extensions/extension_resolver.d.ts +4 -4
  179. package/lib/engine/extensions/extension_resolver.js +1 -1
  180. package/lib/engine/extensions/extension_utils.d.ts +2 -2
  181. package/lib/engine/extensions/extension_utils.js +140 -140
  182. package/lib/engine/extensions/extensions.d.ts +21 -21
  183. package/lib/engine/extensions/extensions.js +94 -94
  184. package/lib/engine/extensions/index.d.ts +5 -5
  185. package/lib/engine/extensions/index.js +5 -5
  186. package/lib/engine/extensions/usage_tracker.d.ts +13 -13
  187. package/lib/engine/extensions/usage_tracker.js +61 -61
  188. package/lib/engine/js-extensions/Camera.d.ts +1 -1
  189. package/lib/engine/js-extensions/Camera.js +36 -36
  190. package/lib/engine/js-extensions/Layers.d.ts +3 -3
  191. package/lib/engine/js-extensions/Layers.js +19 -19
  192. package/lib/engine/js-extensions/index.d.ts +2 -2
  193. package/lib/engine/js-extensions/index.js +2 -2
  194. package/lib/engine/shaders/shaderData.d.ts +55 -55
  195. package/lib/engine/shaders/shaderData.js +58 -58
  196. package/lib/engine/tests/test_utils.d.ts +2 -2
  197. package/lib/engine/tests/test_utils.js +53 -53
  198. package/lib/engine-components/AlignmentConstraint.d.ts +10 -10
  199. package/lib/engine-components/AlignmentConstraint.js +39 -39
  200. package/lib/engine-components/Animation.d.ts +53 -53
  201. package/lib/engine-components/Animation.js +333 -333
  202. package/lib/engine-components/AnimationCurve.d.ts +16 -16
  203. package/lib/engine-components/AnimationCurve.js +97 -97
  204. package/lib/engine-components/AnimationUtils.d.ts +8 -8
  205. package/lib/engine-components/AnimationUtils.js +110 -110
  206. package/lib/engine-components/Animator.d.ts +81 -81
  207. package/lib/engine-components/Animator.js +229 -229
  208. package/lib/engine-components/AnimatorController.d.ts +57 -57
  209. package/lib/engine-components/AnimatorController.js +887 -887
  210. package/lib/engine-components/AudioListener.d.ts +7 -7
  211. package/lib/engine-components/AudioListener.js +30 -30
  212. package/lib/engine-components/AudioSource.d.ts +61 -61
  213. package/lib/engine-components/AudioSource.js +422 -422
  214. package/lib/engine-components/AvatarLoader.d.ts +19 -19
  215. package/lib/engine-components/AvatarLoader.js +173 -173
  216. package/lib/engine-components/AxesHelper.d.ts +9 -9
  217. package/lib/engine-components/AxesHelper.js +44 -44
  218. package/lib/engine-components/BasicIKConstraint.d.ts +9 -9
  219. package/lib/engine-components/BasicIKConstraint.js +43 -43
  220. package/lib/engine-components/BoxHelperComponent.d.ts +16 -16
  221. package/lib/engine-components/BoxHelperComponent.js +89 -89
  222. package/lib/engine-components/Camera.d.ts +70 -70
  223. package/lib/engine-components/Camera.js +450 -450
  224. package/lib/engine-components/CameraUtils.d.ts +1 -1
  225. package/lib/engine-components/CameraUtils.js +77 -77
  226. package/lib/engine-components/CharacterController.d.ts +46 -46
  227. package/lib/engine-components/CharacterController.js +227 -227
  228. package/lib/engine-components/Collider.d.ts +46 -46
  229. package/lib/engine-components/Collider.js +153 -153
  230. package/lib/engine-components/Component.d.ts +228 -228
  231. package/lib/engine-components/Component.js +541 -541
  232. package/lib/engine-components/ContactShadows.d.ts +23 -23
  233. package/lib/engine-components/ContactShadows.js +233 -233
  234. package/lib/engine-components/DeleteBox.d.ts +9 -9
  235. package/lib/engine-components/DeleteBox.js +30 -30
  236. package/lib/engine-components/DeviceFlag.d.ts +12 -12
  237. package/lib/engine-components/DeviceFlag.js +43 -43
  238. package/lib/engine-components/DragControls.d.ts +51 -51
  239. package/lib/engine-components/DragControls.js +516 -516
  240. package/lib/engine-components/DropListener.d.ts +15 -15
  241. package/lib/engine-components/DropListener.js +120 -120
  242. package/lib/engine-components/Duplicatable.d.ts +16 -16
  243. package/lib/engine-components/Duplicatable.js +150 -150
  244. package/lib/engine-components/EventList.d.ts +28 -28
  245. package/lib/engine-components/EventList.js +105 -105
  246. package/lib/engine-components/EventTrigger.d.ts +12 -12
  247. package/lib/engine-components/EventTrigger.js +50 -50
  248. package/lib/engine-components/EventType.d.ts +19 -19
  249. package/lib/engine-components/EventType.js +71 -71
  250. package/lib/engine-components/FlyControls.d.ts +7 -7
  251. package/lib/engine-components/FlyControls.js +25 -25
  252. package/lib/engine-components/Fog.d.ts +20 -20
  253. package/lib/engine-components/Fog.js +60 -60
  254. package/lib/engine-components/Gizmos.d.ts +12 -12
  255. package/lib/engine-components/Gizmos.js +60 -60
  256. package/lib/engine-components/GridHelper.d.ts +12 -12
  257. package/lib/engine-components/GridHelper.js +47 -47
  258. package/lib/engine-components/GroundProjection.d.ts +21 -21
  259. package/lib/engine-components/GroundProjection.js +97 -97
  260. package/lib/engine-components/Interactable.d.ts +10 -10
  261. package/lib/engine-components/Interactable.js +11 -11
  262. package/lib/engine-components/Joints.d.ts +19 -19
  263. package/lib/engine-components/Joints.js +51 -51
  264. package/lib/engine-components/LODGroup.d.ts +30 -30
  265. package/lib/engine-components/LODGroup.js +145 -145
  266. package/lib/engine-components/Light.d.ts +75 -75
  267. package/lib/engine-components/Light.js +475 -475
  268. package/lib/engine-components/LookAtConstraint.d.ts +7 -7
  269. package/lib/engine-components/LookAtConstraint.js +17 -17
  270. package/lib/engine-components/NestedGltf.d.ts +11 -11
  271. package/lib/engine-components/NestedGltf.js +74 -74
  272. package/lib/engine-components/Networking.d.ts +11 -11
  273. package/lib/engine-components/Networking.js +70 -70
  274. package/lib/engine-components/OffsetConstraint.d.ts +14 -14
  275. package/lib/engine-components/OffsetConstraint.js +65 -65
  276. package/lib/engine-components/OrbitControls.d.ts +111 -111
  277. package/lib/engine-components/OrbitControls.js +646 -646
  278. package/lib/engine-components/ParticleSystem.d.ts +145 -145
  279. package/lib/engine-components/ParticleSystem.js +1077 -1077
  280. package/lib/engine-components/ParticleSystemModules.d.ts +489 -489
  281. package/lib/engine-components/ParticleSystemModules.js +1667 -1667
  282. package/lib/engine-components/ParticleSystemSubEmitter.d.ts +25 -25
  283. package/lib/engine-components/ParticleSystemSubEmitter.js +86 -86
  284. package/lib/engine-components/PlayerColor.d.ts +13 -13
  285. package/lib/engine-components/PlayerColor.js +83 -83
  286. package/lib/engine-components/ReflectionProbe.d.ts +22 -22
  287. package/lib/engine-components/ReflectionProbe.js +181 -181
  288. package/lib/engine-components/Renderer.d.ts +112 -112
  289. package/lib/engine-components/Renderer.js +1029 -1029
  290. package/lib/engine-components/RendererLightmap.d.ts +19 -19
  291. package/lib/engine-components/RendererLightmap.js +127 -127
  292. package/lib/engine-components/RigidBody.d.ts +120 -120
  293. package/lib/engine-components/RigidBody.js +452 -452
  294. package/lib/engine-components/SceneSwitcher.d.ts +72 -72
  295. package/lib/engine-components/SceneSwitcher.js +583 -583
  296. package/lib/engine-components/ScreenCapture.d.ts +64 -64
  297. package/lib/engine-components/ScreenCapture.js +405 -405
  298. package/lib/engine-components/ShadowCatcher.d.ts +18 -18
  299. package/lib/engine-components/ShadowCatcher.js +144 -144
  300. package/lib/engine-components/Skybox.d.ts +23 -23
  301. package/lib/engine-components/Skybox.js +287 -287
  302. package/lib/engine-components/SmoothFollow.d.ts +14 -14
  303. package/lib/engine-components/SmoothFollow.js +63 -63
  304. package/lib/engine-components/SpatialTrigger.d.ts +27 -27
  305. package/lib/engine-components/SpatialTrigger.js +144 -144
  306. package/lib/engine-components/SpectatorCamera.d.ts +45 -45
  307. package/lib/engine-components/SpectatorCamera.js +593 -593
  308. package/lib/engine-components/SpriteRenderer.d.ts +48 -48
  309. package/lib/engine-components/SpriteRenderer.js +257 -257
  310. package/lib/engine-components/SyncedCamera.d.ts +27 -27
  311. package/lib/engine-components/SyncedCamera.js +187 -187
  312. package/lib/engine-components/SyncedRoom.d.ts +24 -24
  313. package/lib/engine-components/SyncedRoom.js +162 -162
  314. package/lib/engine-components/SyncedTransform.d.ts +35 -35
  315. package/lib/engine-components/SyncedTransform.js +265 -265
  316. package/lib/engine-components/TestRunner.d.ts +13 -13
  317. package/lib/engine-components/TestRunner.js +99 -99
  318. package/lib/engine-components/TransformGizmo.d.ts +16 -16
  319. package/lib/engine-components/TransformGizmo.js +148 -148
  320. package/lib/engine-components/VideoPlayer.d.ts +86 -86
  321. package/lib/engine-components/VideoPlayer.js +792 -792
  322. package/lib/engine-components/Voip.d.ts +29 -29
  323. package/lib/engine-components/Voip.js +203 -203
  324. package/lib/engine-components/XRFlag.d.ts +33 -33
  325. package/lib/engine-components/XRFlag.js +128 -128
  326. package/lib/engine-components/api.d.ts +15 -15
  327. package/lib/engine-components/api.js +15 -15
  328. package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +10 -10
  329. package/lib/engine-components/avatar/AvatarBlink_Simple.js +75 -75
  330. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +13 -13
  331. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +74 -74
  332. package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +27 -27
  333. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +119 -119
  334. package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +13 -13
  335. package/lib/engine-components/avatar/Avatar_MouthShapes.js +78 -78
  336. package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +8 -8
  337. package/lib/engine-components/avatar/Avatar_MustacheShake.js +28 -28
  338. package/lib/engine-components/codegen/components.d.ts +216 -216
  339. package/lib/engine-components/codegen/components.js +217 -217
  340. package/lib/engine-components/debug/LogStats.d.ts +5 -5
  341. package/lib/engine-components/debug/LogStats.js +18 -18
  342. package/lib/engine-components/export/gltf/GltfExport.d.ts +25 -25
  343. package/lib/engine-components/export/gltf/GltfExport.js +215 -215
  344. package/lib/engine-components/export/index.d.ts +1 -1
  345. package/lib/engine-components/export/index.js +1 -1
  346. package/lib/engine-components/export/usdz/Extension.d.ts +10 -10
  347. package/lib/engine-components/export/usdz/Extension.js +1 -1
  348. package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +114 -114
  349. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +1211 -1211
  350. package/lib/engine-components/export/usdz/USDZExporter.d.ts +59 -59
  351. package/lib/engine-components/export/usdz/USDZExporter.js +450 -450
  352. package/lib/engine-components/export/usdz/extensions/Animation.d.ts +69 -69
  353. package/lib/engine-components/export/usdz/extensions/Animation.js +650 -650
  354. package/lib/engine-components/export/usdz/extensions/DocumentExtension.d.ts +5 -5
  355. package/lib/engine-components/export/usdz/extensions/DocumentExtension.js +6 -6
  356. package/lib/engine-components/export/usdz/extensions/USDZText.d.ts +55 -55
  357. package/lib/engine-components/export/usdz/extensions/USDZText.js +246 -246
  358. package/lib/engine-components/export/usdz/extensions/USDZUI.d.ts +8 -8
  359. package/lib/engine-components/export/usdz/extensions/USDZUI.js +100 -100
  360. package/lib/engine-components/export/usdz/extensions/behavior/Actions.d.ts +30 -30
  361. package/lib/engine-components/export/usdz/extensions/behavior/Actions.js +88 -88
  362. package/lib/engine-components/export/usdz/extensions/behavior/AudioExtension.d.ts +9 -9
  363. package/lib/engine-components/export/usdz/extensions/behavior/AudioExtension.js +52 -52
  364. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +22 -22
  365. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +134 -134
  366. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +126 -126
  367. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +824 -824
  368. package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.d.ts +133 -133
  369. package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js +464 -464
  370. package/lib/engine-components/export/usdz/index.d.ts +3 -3
  371. package/lib/engine-components/export/usdz/index.js +2 -2
  372. package/lib/engine-components/export/usdz/utils/animationutils.d.ts +3 -3
  373. package/lib/engine-components/export/usdz/utils/animationutils.js +85 -85
  374. package/lib/engine-components/export/usdz/utils/quicklook.d.ts +2 -2
  375. package/lib/engine-components/export/usdz/utils/quicklook.js +35 -35
  376. package/lib/engine-components/export/usdz/utils/timeutils.d.ts +1 -1
  377. package/lib/engine-components/export/usdz/utils/timeutils.js +14 -14
  378. package/lib/engine-components/js-extensions/ExtensionUtils.d.ts +6 -6
  379. package/lib/engine-components/js-extensions/ExtensionUtils.js +65 -65
  380. package/lib/engine-components/js-extensions/Object3D.d.ts +2 -2
  381. package/lib/engine-components/js-extensions/Object3D.js +140 -140
  382. package/lib/engine-components/js-extensions/RGBAColor.d.ts +14 -14
  383. package/lib/engine-components/js-extensions/RGBAColor.js +49 -49
  384. package/lib/engine-components/js-extensions/index.d.ts +3 -3
  385. package/lib/engine-components/js-extensions/index.js +3 -3
  386. package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +13 -13
  387. package/lib/engine-components/postprocessing/Effects/Antialiasing.js +45 -45
  388. package/lib/engine-components/postprocessing/Effects/Bloom.d.ts +12 -12
  389. package/lib/engine-components/postprocessing/Effects/Bloom.js +77 -77
  390. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +8 -8
  391. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +38 -38
  392. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +12 -12
  393. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +81 -81
  394. package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +21 -21
  395. package/lib/engine-components/postprocessing/Effects/DepthOfField.js +97 -97
  396. package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +7 -7
  397. package/lib/engine-components/postprocessing/Effects/Pixelation.js +28 -28
  398. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +13 -13
  399. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +86 -86
  400. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +24 -24
  401. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +94 -94
  402. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +13 -13
  403. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +62 -62
  404. package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +16 -16
  405. package/lib/engine-components/postprocessing/Effects/Tonemapping.js +51 -51
  406. package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +11 -11
  407. package/lib/engine-components/postprocessing/Effects/Vignette.js +56 -56
  408. package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +33 -33
  409. package/lib/engine-components/postprocessing/PostProcessingEffect.js +126 -126
  410. package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +22 -22
  411. package/lib/engine-components/postprocessing/PostProcessingHandler.js +201 -201
  412. package/lib/engine-components/postprocessing/Volume.d.ts +25 -25
  413. package/lib/engine-components/postprocessing/Volume.js +193 -193
  414. package/lib/engine-components/postprocessing/VolumeParameter.d.ts +22 -22
  415. package/lib/engine-components/postprocessing/VolumeParameter.js +80 -80
  416. package/lib/engine-components/postprocessing/VolumeProfile.d.ts +7 -7
  417. package/lib/engine-components/postprocessing/VolumeProfile.js +41 -41
  418. package/lib/engine-components/postprocessing/index.d.ts +4 -4
  419. package/lib/engine-components/postprocessing/index.js +4 -4
  420. package/lib/engine-components/timeline/PlayableDirector.d.ts +107 -107
  421. package/lib/engine-components/timeline/PlayableDirector.js +624 -624
  422. package/lib/engine-components/timeline/SignalAsset.d.ts +18 -18
  423. package/lib/engine-components/timeline/SignalAsset.js +124 -124
  424. package/lib/engine-components/timeline/TimelineModels.d.ts +88 -88
  425. package/lib/engine-components/timeline/TimelineModels.js +22 -22
  426. package/lib/engine-components/timeline/TimelineTracks.d.ts +90 -90
  427. package/lib/engine-components/timeline/TimelineTracks.js +825 -825
  428. package/lib/engine-components/timeline/index.d.ts +4 -4
  429. package/lib/engine-components/timeline/index.js +3 -3
  430. package/lib/engine-components/ui/BaseUIComponent.d.ts +31 -31
  431. package/lib/engine-components/ui/BaseUIComponent.js +161 -161
  432. package/lib/engine-components/ui/Button.d.ts +56 -56
  433. package/lib/engine-components/ui/Button.js +282 -282
  434. package/lib/engine-components/ui/Canvas.d.ts +67 -67
  435. package/lib/engine-components/ui/Canvas.js +382 -382
  436. package/lib/engine-components/ui/CanvasGroup.d.ts +15 -15
  437. package/lib/engine-components/ui/CanvasGroup.js +53 -53
  438. package/lib/engine-components/ui/EventSystem.d.ts +102 -102
  439. package/lib/engine-components/ui/EventSystem.js +641 -641
  440. package/lib/engine-components/ui/Graphic.d.ts +45 -45
  441. package/lib/engine-components/ui/Graphic.js +236 -236
  442. package/lib/engine-components/ui/Image.d.ts +27 -27
  443. package/lib/engine-components/ui/Image.js +107 -107
  444. package/lib/engine-components/ui/InputField.d.ts +34 -34
  445. package/lib/engine-components/ui/InputField.js +234 -234
  446. package/lib/engine-components/ui/Interfaces.d.ts +38 -38
  447. package/lib/engine-components/ui/Interfaces.js +12 -12
  448. package/lib/engine-components/ui/Layout.d.ts +72 -72
  449. package/lib/engine-components/ui/Layout.js +318 -318
  450. package/lib/engine-components/ui/Outline.d.ts +7 -7
  451. package/lib/engine-components/ui/Outline.js +20 -20
  452. package/lib/engine-components/ui/PointerEvents.d.ts +64 -64
  453. package/lib/engine-components/ui/PointerEvents.js +68 -68
  454. package/lib/engine-components/ui/RaycastUtils.d.ts +11 -11
  455. package/lib/engine-components/ui/RaycastUtils.js +67 -67
  456. package/lib/engine-components/ui/Raycaster.d.ts +18 -18
  457. package/lib/engine-components/ui/Raycaster.js +69 -69
  458. package/lib/engine-components/ui/RectTransform.d.ts +61 -61
  459. package/lib/engine-components/ui/RectTransform.js +343 -343
  460. package/lib/engine-components/ui/SpatialHtml.d.ts +6 -6
  461. package/lib/engine-components/ui/SpatialHtml.js +57 -57
  462. package/lib/engine-components/ui/Text.d.ts +74 -74
  463. package/lib/engine-components/ui/Text.js +534 -534
  464. package/lib/engine-components/ui/Utils.d.ts +23 -23
  465. package/lib/engine-components/ui/Utils.js +90 -90
  466. package/lib/engine-components/ui/index.d.ts +1 -1
  467. package/lib/engine-components/ui/index.js +1 -1
  468. package/lib/engine-components/utils/LookAt.d.ts +13 -13
  469. package/lib/engine-components/utils/LookAt.js +59 -59
  470. package/lib/engine-components/utils/OpenURL.d.ts +21 -21
  471. package/lib/engine-components/utils/OpenURL.js +124 -124
  472. package/lib/engine-components/webxr/WebARCameraBackground.d.ts +19 -19
  473. package/lib/engine-components/webxr/WebARCameraBackground.js +193 -193
  474. package/lib/engine-components/webxr/WebARSessionRoot.d.ts +38 -38
  475. package/lib/engine-components/webxr/WebARSessionRoot.js +407 -407
  476. package/lib/engine-components/webxr/WebXR.d.ts +110 -110
  477. package/lib/engine-components/webxr/WebXR.js +672 -672
  478. package/lib/engine-components/webxr/WebXRAvatar.d.ts +61 -61
  479. package/lib/engine-components/webxr/WebXRAvatar.js +289 -289
  480. package/lib/engine-components/webxr/WebXRController.d.ts +154 -154
  481. package/lib/engine-components/webxr/WebXRController.js +1028 -1028
  482. package/lib/engine-components/webxr/WebXRGrabRendering.d.ts +42 -42
  483. package/lib/engine-components/webxr/WebXRGrabRendering.js +137 -137
  484. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +49 -49
  485. package/lib/engine-components/webxr/WebXRImageTracking.js +336 -336
  486. package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +49 -49
  487. package/lib/engine-components/webxr/WebXRPlaneTracking.js +372 -372
  488. package/lib/engine-components/webxr/WebXRRig.d.ts +4 -4
  489. package/lib/engine-components/webxr/WebXRRig.js +19 -19
  490. package/lib/engine-components/webxr/WebXRSync.d.ts +54 -54
  491. package/lib/engine-components/webxr/WebXRSync.js +410 -410
  492. package/lib/engine-components/webxr/index.d.ts +4 -4
  493. package/lib/engine-components/webxr/index.js +4 -4
  494. package/lib/engine-components-experimental/Presentation.d.ts +6 -6
  495. package/lib/engine-components-experimental/Presentation.js +9 -9
  496. package/lib/engine-components-experimental/api.d.ts +1 -1
  497. package/lib/engine-components-experimental/api.js +1 -1
  498. package/lib/engine-components-experimental/networking/PlayerSync.d.ts +50 -50
  499. package/lib/engine-components-experimental/networking/PlayerSync.js +200 -200
  500. package/lib/engine-schemes/api.d.ts +1 -1
  501. package/lib/engine-schemes/api.js +1 -1
  502. package/lib/engine-schemes/schemes.d.ts +7 -7
  503. package/lib/engine-schemes/schemes.js +19 -19
  504. package/lib/engine-schemes/synced-camera-model.d.ts +25 -25
  505. package/lib/engine-schemes/synced-camera-model.js +67 -67
  506. package/lib/engine-schemes/synced-transform-model.d.ts +31 -31
  507. package/lib/engine-schemes/synced-transform-model.js +66 -66
  508. package/lib/engine-schemes/transform.d.ts +12 -12
  509. package/lib/engine-schemes/transform.js +39 -39
  510. package/lib/engine-schemes/vec3.d.ts +11 -11
  511. package/lib/engine-schemes/vec3.js +29 -29
  512. package/lib/engine-schemes/vec4.d.ts +12 -12
  513. package/lib/engine-schemes/vec4.js +33 -33
  514. package/lib/engine-schemes/vr-user-state-buffer.d.ts +36 -36
  515. package/lib/engine-schemes/vr-user-state-buffer.js +103 -103
  516. package/lib/include/three/ARButton.d.ts +3 -3
  517. package/lib/include/three/ARButton.js +151 -151
  518. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -6
  519. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +45 -45
  520. package/lib/include/three/VRButton.d.ts +5 -5
  521. package/lib/include/three/VRButton.js +118 -118
  522. package/lib/needle-engine.d.ts +6 -6
  523. package/lib/needle-engine.js +49 -49
  524. package/package.json +1 -1
  525. package/plugins/common/config.cjs +14 -14
  526. package/plugins/common/config.js +19 -19
  527. package/plugins/common/generator.js +10 -10
  528. package/plugins/common/license.cjs +30 -30
  529. package/plugins/common/version.js +11 -11
  530. package/plugins/next/license.cjs +4 -4
  531. package/plugins/next/next.js +70 -70
  532. package/plugins/types/index.d.ts +1 -1
  533. package/plugins/types/needleConfig.d.ts +21 -21
  534. package/plugins/types/userconfig.d.ts +42 -42
  535. package/plugins/vite/alias.js +70 -70
  536. package/plugins/vite/build.js +19 -19
  537. package/plugins/vite/config.js +73 -73
  538. package/plugins/vite/copyfiles.js +134 -134
  539. package/plugins/vite/defines.js +45 -45
  540. package/plugins/vite/dependency-watcher.js +224 -224
  541. package/plugins/vite/drop-client.js +76 -76
  542. package/plugins/vite/drop.js +82 -82
  543. package/plugins/vite/editor-connection.js +121 -121
  544. package/plugins/vite/facebook-instant-games.js +99 -99
  545. package/plugins/vite/gzip.js +5 -5
  546. package/plugins/vite/imports-logger.js +143 -143
  547. package/plugins/vite/index.js +81 -81
  548. package/plugins/vite/license.js +42 -42
  549. package/plugins/vite/meta.js +149 -149
  550. package/plugins/vite/peer.js +31 -31
  551. package/plugins/vite/poster-client.js +59 -59
  552. package/plugins/vite/poster.js +73 -73
  553. package/plugins/vite/reload-client.js +15 -15
  554. package/plugins/vite/reload.js +363 -363
  555. package/plugins/vite/transform-codegen.js +55 -55
  556. package/plugins/vite/vite-4.4-hack.js +31 -31
  557. package/src/engine/api.ts +54 -54
  558. package/src/engine/assets/index.ts +4 -4
  559. package/src/engine/codegen/register_types.ts +441 -441
  560. package/src/engine/debug/debug.ts +29 -29
  561. package/src/engine/debug/debug_console.ts +213 -213
  562. package/src/engine/debug/debug_overlay.ts +283 -283
  563. package/src/engine/engine.ts +13 -13
  564. package/src/engine/engine_addressables.ts +494 -494
  565. package/src/engine/engine_application.ts +53 -53
  566. package/src/engine/engine_assetdatabase.ts +383 -383
  567. package/src/engine/engine_camera.ts +32 -32
  568. package/src/engine/engine_components.ts +266 -266
  569. package/src/engine/engine_components_internal.ts +42 -42
  570. package/src/engine/engine_constants.ts +42 -42
  571. package/src/engine/engine_context.ts +1386 -1386
  572. package/src/engine/engine_context_registry.ts +103 -103
  573. package/src/engine/engine_coroutine.ts +24 -24
  574. package/src/engine/engine_create_objects.ts +39 -39
  575. package/src/engine/engine_default_parameters.ts +3 -3
  576. package/src/engine/engine_editor-sync.ts +29 -29
  577. package/src/engine/engine_element.ts +592 -592
  578. package/src/engine/engine_element_attributes.ts +61 -61
  579. package/src/engine/engine_element_extras.ts +16 -16
  580. package/src/engine/engine_element_loading.ts +341 -341
  581. package/src/engine/engine_element_overlay.ts +160 -160
  582. package/src/engine/engine_fileloader.js +8 -8
  583. package/src/engine/engine_gameobject.ts +621 -621
  584. package/src/engine/engine_generic_utils.js +13 -13
  585. package/src/engine/engine_gizmos.ts +321 -321
  586. package/src/engine/engine_gltf.ts +30 -30
  587. package/src/engine/engine_gltf_builtin_components.ts +350 -350
  588. package/src/engine/engine_hot_reload.ts +196 -196
  589. package/src/engine/engine_input.ts +879 -879
  590. package/src/engine/engine_input_utils.ts +23 -23
  591. package/src/engine/engine_instancing.ts +42 -42
  592. package/src/engine/engine_license.ts +413 -413
  593. package/src/engine/engine_lifecycle_api.ts +29 -29
  594. package/src/engine/engine_lifecycle_functions_internal.ts +36 -36
  595. package/src/engine/engine_lightdata.ts +113 -113
  596. package/src/engine/engine_loaders.ts +77 -77
  597. package/src/engine/engine_mainloop_utils.ts +431 -431
  598. package/src/engine/engine_math.ts +174 -174
  599. package/src/engine/engine_networking.ts +742 -742
  600. package/src/engine/engine_networking_auto.ts +373 -373
  601. package/src/engine/engine_networking_files.ts +206 -206
  602. package/src/engine/engine_networking_files_default_components.ts +54 -54
  603. package/src/engine/engine_networking_instantiate.ts +362 -362
  604. package/src/engine/engine_networking_peer.ts +158 -158
  605. package/src/engine/engine_networking_streams.ts +489 -489
  606. package/src/engine/engine_networking_types.ts +18 -18
  607. package/src/engine/engine_networking_utils.ts +23 -23
  608. package/src/engine/engine_networking_websocket.ts +2 -2
  609. package/src/engine/engine_patcher.ts +199 -199
  610. package/src/engine/engine_physics.ts +287 -287
  611. package/src/engine/engine_physics.types.ts +43 -43
  612. package/src/engine/engine_physics_rapier.ts +1385 -1385
  613. package/src/engine/engine_playerview.ts +79 -79
  614. package/src/engine/engine_scenelighting.ts +313 -313
  615. package/src/engine/engine_scenetools.ts +242 -242
  616. package/src/engine/engine_serialization.ts +6 -6
  617. package/src/engine/engine_serialization_builtin_serializer.ts +415 -415
  618. package/src/engine/engine_serialization_core.ts +680 -680
  619. package/src/engine/engine_serialization_decorator.ts +68 -68
  620. package/src/engine/engine_setup.ts +1 -1
  621. package/src/engine/engine_shaders.ts +242 -242
  622. package/src/engine/engine_shims.ts +28 -28
  623. package/src/engine/engine_texture.ts +70 -70
  624. package/src/engine/engine_three_utils.ts +382 -382
  625. package/src/engine/engine_time.ts +55 -55
  626. package/src/engine/engine_types.ts +489 -489
  627. package/src/engine/engine_typestore.ts +41 -41
  628. package/src/engine/engine_util_decorator.ts +134 -134
  629. package/src/engine/engine_utils.ts +605 -605
  630. package/src/engine/engine_utils_screenshot.ts +84 -84
  631. package/src/engine/engine_web_api.ts +119 -119
  632. package/src/engine/extensions/EXT_texture_exr.ts +49 -49
  633. package/src/engine/extensions/NEEDLE_animator_controller_model.ts +193 -193
  634. package/src/engine/extensions/NEEDLE_components.ts +250 -250
  635. package/src/engine/extensions/NEEDLE_gameobject_data.ts +82 -82
  636. package/src/engine/extensions/NEEDLE_lighting_settings.ts +210 -210
  637. package/src/engine/extensions/NEEDLE_lightmaps.ts +130 -130
  638. package/src/engine/extensions/NEEDLE_persistent_assets.ts +75 -75
  639. package/src/engine/extensions/NEEDLE_progressive.ts +412 -412
  640. package/src/engine/extensions/NEEDLE_render_objects.ts +209 -209
  641. package/src/engine/extensions/NEEDLE_techniques_webgl.ts +618 -618
  642. package/src/engine/extensions/extension_resolver.ts +4 -4
  643. package/src/engine/extensions/extension_utils.ts +149 -149
  644. package/src/engine/extensions/extensions.ts +118 -118
  645. package/src/engine/extensions/index.ts +4 -4
  646. package/src/engine/extensions/usage_tracker.ts +95 -95
  647. package/src/engine/js-extensions/Camera.ts +34 -34
  648. package/src/engine/js-extensions/Layers.ts +19 -19
  649. package/src/engine/js-extensions/index.ts +1 -1
  650. package/src/engine/shaders/shaderData.ts +67 -67
  651. package/src/engine/tests/test_utils.ts +63 -63
  652. package/src/engine-components/AlignmentConstraint.ts +35 -35
  653. package/src/engine-components/Animation.ts +345 -345
  654. package/src/engine-components/AnimationCurve.ts +83 -83
  655. package/src/engine-components/AnimationUtils.ts +117 -117
  656. package/src/engine-components/Animator.ts +243 -243
  657. package/src/engine-components/AnimatorController.ts +1020 -1020
  658. package/src/engine-components/AudioListener.ts +32 -32
  659. package/src/engine-components/AudioSource.ts +419 -419
  660. package/src/engine-components/AvatarLoader.ts +204 -204
  661. package/src/engine-components/AxesHelper.ts +33 -33
  662. package/src/engine-components/BasicIKConstraint.ts +53 -53
  663. package/src/engine-components/BoxCollider.ts +1 -1
  664. package/src/engine-components/BoxHelperComponent.ts +100 -100
  665. package/src/engine-components/Camera.ts +454 -454
  666. package/src/engine-components/CameraUtils.ts +89 -89
  667. package/src/engine-components/CharacterController.ts +243 -243
  668. package/src/engine-components/Collider.ts +160 -160
  669. package/src/engine-components/Component.ts +670 -670
  670. package/src/engine-components/ContactShadows.ts +265 -265
  671. package/src/engine-components/DeleteBox.ts +35 -35
  672. package/src/engine-components/DeviceFlag.ts +42 -42
  673. package/src/engine-components/DragControls.ts +574 -574
  674. package/src/engine-components/DropListener.ts +112 -112
  675. package/src/engine-components/Duplicatable.ts +146 -146
  676. package/src/engine-components/EventList.ts +125 -125
  677. package/src/engine-components/EventTrigger.ts +47 -47
  678. package/src/engine-components/EventType.ts +87 -87
  679. package/src/engine-components/FlyControls.ts +31 -31
  680. package/src/engine-components/Fog.ts +59 -59
  681. package/src/engine-components/Gizmos.ts +52 -52
  682. package/src/engine-components/GridHelper.ts +40 -40
  683. package/src/engine-components/GroundProjection.ts +97 -97
  684. package/src/engine-components/Interactable.ts +18 -18
  685. package/src/engine-components/Joints.ts +51 -51
  686. package/src/engine-components/LODGroup.ts +145 -145
  687. package/src/engine-components/Light.ts +493 -493
  688. package/src/engine-components/LookAtConstraint.ts +11 -11
  689. package/src/engine-components/NestedGltf.ts +70 -70
  690. package/src/engine-components/Networking.ts +72 -72
  691. package/src/engine-components/OffsetConstraint.ts +59 -59
  692. package/src/engine-components/OrbitControls.ts +653 -653
  693. package/src/engine-components/ParticleSystem.ts +1192 -1192
  694. package/src/engine-components/ParticleSystemModules.ts +1481 -1481
  695. package/src/engine-components/ParticleSystemSubEmitter.ts +110 -110
  696. package/src/engine-components/PlayerColor.ts +93 -93
  697. package/src/engine-components/ReflectionProbe.ts +192 -192
  698. package/src/engine-components/Renderer.ts +1125 -1125
  699. package/src/engine-components/RendererLightmap.ts +145 -145
  700. package/src/engine-components/RigidBody.ts +453 -453
  701. package/src/engine-components/SceneSwitcher.ts +594 -594
  702. package/src/engine-components/ScreenCapture.ts +437 -437
  703. package/src/engine-components/ShadowCatcher.ts +149 -149
  704. package/src/engine-components/Skybox.ts +281 -281
  705. package/src/engine-components/SmoothFollow.ts +57 -57
  706. package/src/engine-components/SpatialTrigger.ts +142 -142
  707. package/src/engine-components/SpectatorCamera.ts +675 -675
  708. package/src/engine-components/SphereCollider.ts +1 -1
  709. package/src/engine-components/SpriteRenderer.ts +244 -244
  710. package/src/engine-components/SyncedCamera.ts +208 -208
  711. package/src/engine-components/SyncedRoom.ts +166 -166
  712. package/src/engine-components/SyncedTransform.ts +336 -336
  713. package/src/engine-components/TestRunner.ts +114 -114
  714. package/src/engine-components/TransformGizmo.ts +157 -157
  715. package/src/engine-components/VideoPlayer.ts +831 -831
  716. package/src/engine-components/Voip.ts +214 -214
  717. package/src/engine-components/XRFlag.ts +138 -138
  718. package/src/engine-components/api.ts +22 -22
  719. package/src/engine-components/avatar/AvatarBlink_Simple.ts +67 -67
  720. package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +68 -68
  721. package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +136 -136
  722. package/src/engine-components/avatar/Avatar_MouthShapes.ts +81 -81
  723. package/src/engine-components/avatar/Avatar_MustacheShake.ts +28 -28
  724. package/src/engine-components/codegen/components.ts +216 -216
  725. package/src/engine-components/debug/LogStats.ts +21 -21
  726. package/src/engine-components/export/gltf/GltfExport.ts +231 -231
  727. package/src/engine-components/export/usdz/Extension.ts +11 -11
  728. package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +1773 -1773
  729. package/src/engine-components/export/usdz/USDZExporter.ts +477 -477
  730. package/src/engine-components/export/usdz/extensions/Animation.ts +774 -774
  731. package/src/engine-components/export/usdz/extensions/DocumentExtension.ts +9 -9
  732. package/src/engine-components/export/usdz/extensions/USDZText.ts +287 -287
  733. package/src/engine-components/export/usdz/extensions/USDZUI.ts +119 -119
  734. package/src/engine-components/export/usdz/extensions/behavior/Actions.ts +98 -98
  735. package/src/engine-components/export/usdz/extensions/behavior/AudioExtension.ts +67 -67
  736. package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +202 -202
  737. package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +963 -963
  738. package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +517 -517
  739. package/src/engine-components/export/usdz/index.ts +2 -2
  740. package/src/engine-components/export/usdz/utils/animationutils.ts +100 -100
  741. package/src/engine-components/export/usdz/utils/quicklook.ts +42 -42
  742. package/src/engine-components/export/usdz/utils/timeutils.ts +19 -19
  743. package/src/engine-components/js-extensions/ExtensionUtils.ts +81 -81
  744. package/src/engine-components/js-extensions/Object3D.ts +181 -181
  745. package/src/engine-components/js-extensions/RGBAColor.ts +54 -54
  746. package/src/engine-components/js-extensions/Vector.ts +16 -16
  747. package/src/engine-components/js-extensions/index.ts +2 -2
  748. package/src/engine-components/postprocessing/Effects/Antialiasing.ts +51 -51
  749. package/src/engine-components/postprocessing/Effects/Bloom.ts +76 -76
  750. package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +35 -35
  751. package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +96 -96
  752. package/src/engine-components/postprocessing/Effects/DepthOfField.ts +93 -93
  753. package/src/engine-components/postprocessing/Effects/Pixelation.ts +26 -26
  754. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +84 -84
  755. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +98 -98
  756. package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +55 -55
  757. package/src/engine-components/postprocessing/Effects/Tonemapping.ts +54 -54
  758. package/src/engine-components/postprocessing/Effects/Vignette.ts +54 -54
  759. package/src/engine-components/postprocessing/PostProcessingEffect.ts +148 -148
  760. package/src/engine-components/postprocessing/PostProcessingHandler.ts +232 -232
  761. package/src/engine-components/postprocessing/Volume.ts +216 -216
  762. package/src/engine-components/postprocessing/VolumeParameter.ts +92 -92
  763. package/src/engine-components/postprocessing/VolumeProfile.ts +40 -40
  764. package/src/engine-components/postprocessing/index.ts +3 -3
  765. package/src/engine-components/timeline/PlayableDirector.ts +666 -666
  766. package/src/engine-components/timeline/SignalAsset.ts +138 -138
  767. package/src/engine-components/timeline/TimelineModels.ts +93 -93
  768. package/src/engine-components/timeline/TimelineTracks.ts +906 -906
  769. package/src/engine-components/timeline/index.ts +3 -3
  770. package/src/engine-components/ui/BaseUIComponent.ts +195 -195
  771. package/src/engine-components/ui/Button.ts +283 -283
  772. package/src/engine-components/ui/Canvas.ts +390 -390
  773. package/src/engine-components/ui/CanvasGroup.ts +49 -49
  774. package/src/engine-components/ui/EventSystem.ts +736 -736
  775. package/src/engine-components/ui/Graphic.ts +255 -255
  776. package/src/engine-components/ui/Image.ts +102 -102
  777. package/src/engine-components/ui/InputField.ts +290 -290
  778. package/src/engine-components/ui/Interfaces.ts +57 -57
  779. package/src/engine-components/ui/Layout.ts +322 -322
  780. package/src/engine-components/ui/Outline.ts +12 -12
  781. package/src/engine-components/ui/PointerEvents.ts +118 -118
  782. package/src/engine-components/ui/RaycastUtils.ts +68 -68
  783. package/src/engine-components/ui/Raycaster.ts +73 -73
  784. package/src/engine-components/ui/RectTransform.ts +364 -364
  785. package/src/engine-components/ui/SpatialHtml.ts +63 -63
  786. package/src/engine-components/ui/Text.ts +572 -572
  787. package/src/engine-components/ui/Utils.ts +110 -110
  788. package/src/engine-components/utils/LookAt.ts +65 -65
  789. package/src/engine-components/utils/OpenURL.ts +118 -118
  790. package/src/engine-components/webxr/WebARCameraBackground.ts +224 -224
  791. package/src/engine-components/webxr/WebARSessionRoot.ts +446 -446
  792. package/src/engine-components/webxr/WebXR.ts +761 -761
  793. package/src/engine-components/webxr/WebXRAvatar.ts +356 -356
  794. package/src/engine-components/webxr/WebXRController.ts +1168 -1168
  795. package/src/engine-components/webxr/WebXRGrabRendering.ts +150 -150
  796. package/src/engine-components/webxr/WebXRImageTracking.ts +371 -371
  797. package/src/engine-components/webxr/WebXRPlaneTracking.ts +429 -429
  798. package/src/engine-components/webxr/WebXRRig.ts +21 -21
  799. package/src/engine-components/webxr/WebXRSync.ts +463 -463
  800. package/src/engine-components/webxr/index.ts +3 -3
  801. package/src/engine-components-experimental/Presentation.ts +12 -12
  802. package/src/engine-components-experimental/networking/PlayerSync.ts +217 -217
  803. package/src/engine-schemes/COMPILE_SCHEMES.bat +3 -3
  804. package/src/engine-schemes/COMPILE_TS.bat +11 -11
  805. package/src/engine-schemes/schemes.ts +27 -27
  806. package/src/engine-schemes/synced-camera-model.ts +92 -92
  807. package/src/engine-schemes/synced-transform-model.ts +90 -90
  808. package/src/engine-schemes/syncedCamera.fbs +10 -10
  809. package/src/engine-schemes/transform.ts +50 -50
  810. package/src/engine-schemes/transforms.fbs +25 -25
  811. package/src/engine-schemes/vec.fbs +19 -19
  812. package/src/engine-schemes/vec2.ts +33 -33
  813. package/src/engine-schemes/vec3.ts +38 -38
  814. package/src/engine-schemes/vec4.ts +43 -43
  815. package/src/engine-schemes/vr-user-state-buffer.ts +138 -138
  816. package/src/engine-schemes/vrUserStateBuffer.fbs +16 -16
  817. package/src/include/draco/draco_decoder.js +34 -34
  818. package/src/include/draco/draco_wasm_wrapper.js +117 -117
  819. package/src/include/ktx2/basis_transcoder.js +21 -21
  820. package/src/include/needle/arial-msdf.json +1471 -1471
  821. package/src/include/three/ARButton.js +231 -231
  822. package/src/include/three/DragControls.js +231 -231
  823. package/src/include/three/EXT_mesh_gpu_instancing_exporter.js +66 -66
  824. package/src/include/three/VRButton.js +194 -194
  825. package/src/needle-engine.ts +55 -55
  826. package/src/engine/dist/api.js +0 -73
  827. package/src/engine/dist/api.js.meta +0 -7
  828. package/src/engine/dist/engine_networking_streams.js +0 -474
  829. package/src/engine/dist/engine_networking_streams.js.meta +0 -7
  830. package/src/engine-schemes/dist/api.js +0 -17
  831. package/src/engine-schemes/dist/api.js.meta +0 -7
  832. package/src/engine-schemes/dist/schemes.js +0 -25
  833. package/src/engine-schemes/dist/schemes.js.meta +0 -7
  834. package/src/engine-schemes/dist/synced-camera-model.js +0 -74
  835. package/src/engine-schemes/dist/synced-camera-model.js.meta +0 -7
  836. package/src/engine-schemes/dist/synced-transform-model.js +0 -73
  837. package/src/engine-schemes/dist/synced-transform-model.js.meta +0 -7
  838. package/src/engine-schemes/dist/transform.js +0 -46
  839. package/src/engine-schemes/dist/transform.js.meta +0 -7
  840. package/src/engine-schemes/dist/vec2.js +0 -32
  841. package/src/engine-schemes/dist/vec2.js.meta +0 -7
  842. package/src/engine-schemes/dist/vec3.js +0 -36
  843. package/src/engine-schemes/dist/vec3.js.meta +0 -7
  844. package/src/engine-schemes/dist/vec4.js +0 -40
  845. package/src/engine-schemes/dist/vec4.js.meta +0 -7
  846. package/src/engine-schemes/dist/vr-user-state-buffer.js +0 -110
  847. package/src/engine-schemes/dist/vr-user-state-buffer.js.meta +0 -7
  848. package/src/engine-schemes/flatc.exe +0 -0
@@ -1,1668 +1,1668 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Matrix4, Quaternion, Vector3, Vector2, Euler } from "three";
8
- import { Mathf } from "../engine/engine_math.js";
9
- import { serializable } from "../engine/engine_serialization.js";
10
- import { RGBAColor } from "./js-extensions/RGBAColor.js";
11
- import { AnimationCurve } from "./AnimationCurve.js";
12
- import { createNoise4D } from 'simplex-noise';
13
- import { Gizmos } from "../engine/engine_gizmos.js";
14
- import { getParam } from "../engine/engine_utils.js";
15
- const debug = getParam("debugparticles");
16
- export var ParticleSystemRenderMode;
17
- (function (ParticleSystemRenderMode) {
18
- ParticleSystemRenderMode[ParticleSystemRenderMode["Billboard"] = 0] = "Billboard";
19
- ParticleSystemRenderMode[ParticleSystemRenderMode["Stretch"] = 1] = "Stretch";
20
- ParticleSystemRenderMode[ParticleSystemRenderMode["HorizontalBillboard"] = 2] = "HorizontalBillboard";
21
- ParticleSystemRenderMode[ParticleSystemRenderMode["VerticalBillboard"] = 3] = "VerticalBillboard";
22
- ParticleSystemRenderMode[ParticleSystemRenderMode["Mesh"] = 4] = "Mesh";
23
- // None = 5,
24
- })(ParticleSystemRenderMode || (ParticleSystemRenderMode = {}));
25
- export class Gradient {
26
- alphaKeys;
27
- colorKeys;
28
- get duration() {
29
- return 1;
30
- }
31
- evaluate(time, target) {
32
- // target.r = this.colorKeys[0].color.r;
33
- // target.g = this.colorKeys[0].color.g;
34
- // target.b = this.colorKeys[0].color.b;
35
- // target.alpha = this.alphaKeys[0].alpha;
36
- // return;
37
- let closestAlpha = undefined;
38
- let closestAlphaIndex = 0;
39
- let closestColor = null;
40
- let closestColorIndex = 0;
41
- for (let i = 0; i < this.alphaKeys.length; i++) {
42
- const key = this.alphaKeys[i];
43
- if (key.time < time || !closestAlpha) {
44
- closestAlpha = key;
45
- closestAlphaIndex = i;
46
- }
47
- }
48
- for (let i = 0; i < this.colorKeys.length; i++) {
49
- const key = this.colorKeys[i];
50
- if (key.time < time || !closestColor) {
51
- closestColor = key;
52
- closestColorIndex = i;
53
- }
54
- }
55
- if (closestColor) {
56
- const hasNextColor = closestColorIndex + 1 < this.colorKeys.length;
57
- if (hasNextColor) {
58
- const nextColor = this.colorKeys[closestColorIndex + 1];
59
- const t = Mathf.remap(time, closestColor.time, nextColor.time, 0, 1);
60
- target.r = Mathf.lerp(closestColor.color.r, nextColor.color.r, t);
61
- target.g = Mathf.lerp(closestColor.color.g, nextColor.color.g, t);
62
- target.b = Mathf.lerp(closestColor.color.b, nextColor.color.b, t);
63
- }
64
- else {
65
- target.r = closestColor.color.r;
66
- target.g = closestColor.color.g;
67
- target.b = closestColor.color.b;
68
- }
69
- }
70
- if (closestAlpha) {
71
- const hasNextAlpha = closestAlphaIndex + 1 < this.alphaKeys.length;
72
- if (hasNextAlpha) {
73
- const nextAlpha = this.alphaKeys[closestAlphaIndex + 1];
74
- const t = Mathf.remap(time, closestAlpha.time, nextAlpha.time, 0, 1);
75
- target.alpha = Mathf.lerp(closestAlpha.alpha, nextAlpha.alpha, t);
76
- }
77
- else {
78
- target.alpha = closestAlpha.alpha;
79
- }
80
- }
81
- return target;
82
- }
83
- }
84
- __decorate([
85
- serializable()
86
- ], Gradient.prototype, "alphaKeys", void 0);
87
- __decorate([
88
- serializable()
89
- ], Gradient.prototype, "colorKeys", void 0);
90
- export var ParticleSystemCurveMode;
91
- (function (ParticleSystemCurveMode) {
92
- ParticleSystemCurveMode[ParticleSystemCurveMode["Constant"] = 0] = "Constant";
93
- ParticleSystemCurveMode[ParticleSystemCurveMode["Curve"] = 1] = "Curve";
94
- ParticleSystemCurveMode[ParticleSystemCurveMode["TwoCurves"] = 2] = "TwoCurves";
95
- ParticleSystemCurveMode[ParticleSystemCurveMode["TwoConstants"] = 3] = "TwoConstants";
96
- })(ParticleSystemCurveMode || (ParticleSystemCurveMode = {}));
97
- export var ParticleSystemGradientMode;
98
- (function (ParticleSystemGradientMode) {
99
- ParticleSystemGradientMode[ParticleSystemGradientMode["Color"] = 0] = "Color";
100
- ParticleSystemGradientMode[ParticleSystemGradientMode["Gradient"] = 1] = "Gradient";
101
- ParticleSystemGradientMode[ParticleSystemGradientMode["TwoColors"] = 2] = "TwoColors";
102
- ParticleSystemGradientMode[ParticleSystemGradientMode["TwoGradients"] = 3] = "TwoGradients";
103
- ParticleSystemGradientMode[ParticleSystemGradientMode["RandomColor"] = 4] = "RandomColor";
104
- })(ParticleSystemGradientMode || (ParticleSystemGradientMode = {}));
105
- export var ParticleSystemSimulationSpace;
106
- (function (ParticleSystemSimulationSpace) {
107
- ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["Local"] = 0] = "Local";
108
- ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["World"] = 1] = "World";
109
- ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["Custom"] = 2] = "Custom";
110
- })(ParticleSystemSimulationSpace || (ParticleSystemSimulationSpace = {}));
111
- export var ParticleSystemShapeType;
112
- (function (ParticleSystemShapeType) {
113
- ParticleSystemShapeType[ParticleSystemShapeType["Sphere"] = 0] = "Sphere";
114
- ParticleSystemShapeType[ParticleSystemShapeType["SphereShell"] = 1] = "SphereShell";
115
- ParticleSystemShapeType[ParticleSystemShapeType["Hemisphere"] = 2] = "Hemisphere";
116
- ParticleSystemShapeType[ParticleSystemShapeType["HemisphereShell"] = 3] = "HemisphereShell";
117
- ParticleSystemShapeType[ParticleSystemShapeType["Cone"] = 4] = "Cone";
118
- ParticleSystemShapeType[ParticleSystemShapeType["Box"] = 5] = "Box";
119
- ParticleSystemShapeType[ParticleSystemShapeType["Mesh"] = 6] = "Mesh";
120
- ParticleSystemShapeType[ParticleSystemShapeType["ConeShell"] = 7] = "ConeShell";
121
- ParticleSystemShapeType[ParticleSystemShapeType["ConeVolume"] = 8] = "ConeVolume";
122
- ParticleSystemShapeType[ParticleSystemShapeType["ConeVolumeShell"] = 9] = "ConeVolumeShell";
123
- ParticleSystemShapeType[ParticleSystemShapeType["Circle"] = 10] = "Circle";
124
- ParticleSystemShapeType[ParticleSystemShapeType["CircleEdge"] = 11] = "CircleEdge";
125
- ParticleSystemShapeType[ParticleSystemShapeType["SingleSidedEdge"] = 12] = "SingleSidedEdge";
126
- ParticleSystemShapeType[ParticleSystemShapeType["MeshRenderer"] = 13] = "MeshRenderer";
127
- ParticleSystemShapeType[ParticleSystemShapeType["SkinnedMeshRenderer"] = 14] = "SkinnedMeshRenderer";
128
- ParticleSystemShapeType[ParticleSystemShapeType["BoxShell"] = 15] = "BoxShell";
129
- ParticleSystemShapeType[ParticleSystemShapeType["BoxEdge"] = 16] = "BoxEdge";
130
- ParticleSystemShapeType[ParticleSystemShapeType["Donut"] = 17] = "Donut";
131
- ParticleSystemShapeType[ParticleSystemShapeType["Rectangle"] = 18] = "Rectangle";
132
- ParticleSystemShapeType[ParticleSystemShapeType["Sprite"] = 19] = "Sprite";
133
- ParticleSystemShapeType[ParticleSystemShapeType["SpriteRenderer"] = 20] = "SpriteRenderer";
134
- })(ParticleSystemShapeType || (ParticleSystemShapeType = {}));
135
- export var ParticleSystemShapeMultiModeValue;
136
- (function (ParticleSystemShapeMultiModeValue) {
137
- ParticleSystemShapeMultiModeValue[ParticleSystemShapeMultiModeValue["Random"] = 0] = "Random";
138
- ParticleSystemShapeMultiModeValue[ParticleSystemShapeMultiModeValue["Loop"] = 1] = "Loop";
139
- ParticleSystemShapeMultiModeValue[ParticleSystemShapeMultiModeValue["PingPong"] = 2] = "PingPong";
140
- ParticleSystemShapeMultiModeValue[ParticleSystemShapeMultiModeValue["BurstSpread"] = 3] = "BurstSpread";
141
- })(ParticleSystemShapeMultiModeValue || (ParticleSystemShapeMultiModeValue = {}));
142
- export class MinMaxCurve {
143
- mode;
144
- constant;
145
- constantMin;
146
- constantMax;
147
- curve;
148
- curveMin;
149
- curveMax;
150
- curveMultiplier;
151
- evaluate(t01, lerpFactor) {
152
- const t = lerpFactor === undefined ? Math.random() : lerpFactor;
153
- switch (this.mode) {
154
- case ParticleSystemCurveMode.Constant:
155
- return this.constant;
156
- case ParticleSystemCurveMode.Curve:
157
- t01 = Mathf.clamp01(t01);
158
- return this.curve.evaluate(t01) * this.curveMultiplier;
159
- case ParticleSystemCurveMode.TwoCurves:
160
- const t1 = t01 * this.curveMin.duration;
161
- const t2 = t01 * this.curveMax.duration;
162
- return Mathf.lerp(this.curveMin.evaluate(t1), this.curveMax.evaluate(t2), t % 1) * this.curveMultiplier;
163
- case ParticleSystemCurveMode.TwoConstants:
164
- return Mathf.lerp(this.constantMin, this.constantMax, t % 1);
165
- default:
166
- this.curveMax.evaluate(t01) * this.curveMultiplier;
167
- break;
168
- }
169
- return 0;
170
- }
171
- getMax() {
172
- switch (this.mode) {
173
- case ParticleSystemCurveMode.Constant:
174
- return this.constant;
175
- case ParticleSystemCurveMode.Curve:
176
- return this.getMaxFromCurve(this.curve) * this.curveMultiplier;
177
- case ParticleSystemCurveMode.TwoCurves:
178
- return Math.max(this.getMaxFromCurve(this.curveMin), this.getMaxFromCurve(this.curveMax)) * this.curveMultiplier;
179
- case ParticleSystemCurveMode.TwoConstants:
180
- return Math.max(this.constantMin, this.constantMax);
181
- default:
182
- return 0;
183
- }
184
- }
185
- getMaxFromCurve(curve) {
186
- if (!curve)
187
- return 0;
188
- let maxNumber = Number.MIN_VALUE;
189
- for (let i = 0; i < curve.keys.length; i++) {
190
- const key = curve.keys[i];
191
- if (key.value > maxNumber) {
192
- maxNumber = key.value;
193
- }
194
- }
195
- return maxNumber;
196
- }
197
- }
198
- __decorate([
199
- serializable()
200
- ], MinMaxCurve.prototype, "mode", void 0);
201
- __decorate([
202
- serializable()
203
- ], MinMaxCurve.prototype, "constant", void 0);
204
- __decorate([
205
- serializable()
206
- ], MinMaxCurve.prototype, "constantMin", void 0);
207
- __decorate([
208
- serializable()
209
- ], MinMaxCurve.prototype, "constantMax", void 0);
210
- __decorate([
211
- serializable(AnimationCurve)
212
- ], MinMaxCurve.prototype, "curve", void 0);
213
- __decorate([
214
- serializable(AnimationCurve)
215
- ], MinMaxCurve.prototype, "curveMin", void 0);
216
- __decorate([
217
- serializable(AnimationCurve)
218
- ], MinMaxCurve.prototype, "curveMax", void 0);
219
- __decorate([
220
- serializable()
221
- ], MinMaxCurve.prototype, "curveMultiplier", void 0);
222
- export class MinMaxGradient {
223
- mode;
224
- color;
225
- colorMin;
226
- colorMax;
227
- gradient;
228
- gradientMin;
229
- gradientMax;
230
- static _temp = new RGBAColor(0, 0, 0, 1);
231
- static _temp2 = new RGBAColor(0, 0, 0, 1);
232
- evaluate(t01, lerpFactor) {
233
- const t = lerpFactor === undefined ? Math.random() : lerpFactor;
234
- switch (this.mode) {
235
- case ParticleSystemGradientMode.Color:
236
- return this.color;
237
- case ParticleSystemGradientMode.Gradient:
238
- this.gradient.evaluate(t01, MinMaxGradient._temp);
239
- return MinMaxGradient._temp;
240
- case ParticleSystemGradientMode.TwoColors:
241
- const col1 = MinMaxGradient._temp.lerpColors(this.colorMin, this.colorMax, t);
242
- return col1;
243
- case ParticleSystemGradientMode.TwoGradients:
244
- this.gradientMin.evaluate(t01, MinMaxGradient._temp);
245
- this.gradientMax.evaluate(t01, MinMaxGradient._temp2);
246
- return MinMaxGradient._temp.lerp(MinMaxGradient._temp2, t);
247
- }
248
- // console.warn("Not implemented", ParticleSystemGradientMode[this.mode]);
249
- MinMaxGradient._temp.set(0xff00ff);
250
- MinMaxGradient._temp.alpha = 1;
251
- return MinMaxGradient._temp;
252
- }
253
- }
254
- __decorate([
255
- serializable(RGBAColor)
256
- ], MinMaxGradient.prototype, "color", void 0);
257
- __decorate([
258
- serializable(RGBAColor)
259
- ], MinMaxGradient.prototype, "colorMin", void 0);
260
- __decorate([
261
- serializable(RGBAColor)
262
- ], MinMaxGradient.prototype, "colorMax", void 0);
263
- __decorate([
264
- serializable(Gradient)
265
- ], MinMaxGradient.prototype, "gradient", void 0);
266
- __decorate([
267
- serializable(Gradient)
268
- ], MinMaxGradient.prototype, "gradientMin", void 0);
269
- __decorate([
270
- serializable(Gradient)
271
- ], MinMaxGradient.prototype, "gradientMax", void 0);
272
- export var ParticleSystemScalingMode;
273
- (function (ParticleSystemScalingMode) {
274
- ParticleSystemScalingMode[ParticleSystemScalingMode["Hierarchy"] = 0] = "Hierarchy";
275
- ParticleSystemScalingMode[ParticleSystemScalingMode["Local"] = 1] = "Local";
276
- ParticleSystemScalingMode[ParticleSystemScalingMode["Shape"] = 2] = "Shape";
277
- })(ParticleSystemScalingMode || (ParticleSystemScalingMode = {}));
278
- export class MainModule {
279
- cullingMode;
280
- duration;
281
- emitterVelocityMode;
282
- flipRotation;
283
- gravityModifier;
284
- gravityModifierMultiplier;
285
- loop;
286
- maxParticles;
287
- playOnAwake;
288
- prewarm;
289
- ringBufferLoopRange;
290
- ringBufferMode;
291
- scalingMode;
292
- simulationSpace;
293
- simulationSpeed;
294
- startColor;
295
- startDelay;
296
- startDelayMultiplier;
297
- startLifetime;
298
- startLifetimeMultiplier;
299
- startRotation;
300
- startRotationMultiplier;
301
- startRotation3D;
302
- startRotationX;
303
- startRotationXMultiplier;
304
- startRotationY;
305
- startRotationYMultiplier;
306
- startRotationZ;
307
- startRotationZMultiplier;
308
- startSize;
309
- startSize3D;
310
- startSizeMultiplier;
311
- startSizeX;
312
- startSizeXMultiplier;
313
- startSizeY;
314
- startSizeYMultiplier;
315
- startSizeZ;
316
- startSizeZMultiplier;
317
- startSpeed;
318
- startSpeedMultiplier;
319
- stopAction;
320
- useUnscaledTime;
321
- }
322
- __decorate([
323
- serializable(MinMaxCurve)
324
- ], MainModule.prototype, "gravityModifier", void 0);
325
- __decorate([
326
- serializable(MinMaxGradient)
327
- ], MainModule.prototype, "startColor", void 0);
328
- __decorate([
329
- serializable(MinMaxCurve)
330
- ], MainModule.prototype, "startDelay", void 0);
331
- __decorate([
332
- serializable(MinMaxCurve)
333
- ], MainModule.prototype, "startLifetime", void 0);
334
- __decorate([
335
- serializable(MinMaxCurve)
336
- ], MainModule.prototype, "startRotation", void 0);
337
- __decorate([
338
- serializable(MinMaxCurve)
339
- ], MainModule.prototype, "startRotationX", void 0);
340
- __decorate([
341
- serializable(MinMaxCurve)
342
- ], MainModule.prototype, "startRotationY", void 0);
343
- __decorate([
344
- serializable(MinMaxCurve)
345
- ], MainModule.prototype, "startRotationZ", void 0);
346
- __decorate([
347
- serializable(MinMaxCurve)
348
- ], MainModule.prototype, "startSize", void 0);
349
- __decorate([
350
- serializable(MinMaxCurve)
351
- ], MainModule.prototype, "startSizeX", void 0);
352
- __decorate([
353
- serializable(MinMaxCurve)
354
- ], MainModule.prototype, "startSizeY", void 0);
355
- __decorate([
356
- serializable(MinMaxCurve)
357
- ], MainModule.prototype, "startSizeZ", void 0);
358
- __decorate([
359
- serializable(MinMaxCurve)
360
- ], MainModule.prototype, "startSpeed", void 0);
361
- export class ParticleBurst {
362
- cycleCount;
363
- maxCount;
364
- minCount;
365
- probability;
366
- repeatInterval;
367
- time;
368
- count;
369
- _performed = 0;
370
- reset() {
371
- this._performed = 0;
372
- }
373
- run(time) {
374
- if (time <= this.time) {
375
- return 0;
376
- }
377
- let amount = 0;
378
- if (this.cycleCount === 0 || this._performed < this.cycleCount) {
379
- const nextTime = this.time + this.repeatInterval * this._performed;
380
- if (time >= nextTime) {
381
- this._performed += 1;
382
- if (Math.random() < this.probability) {
383
- switch (this.count.mode) {
384
- case ParticleSystemCurveMode.Constant:
385
- amount = this.count.constant;
386
- break;
387
- case ParticleSystemCurveMode.TwoConstants:
388
- amount = Mathf.lerp(this.count.constantMin, this.count.constantMax, Math.random());
389
- break;
390
- case ParticleSystemCurveMode.Curve:
391
- amount = this.count.curve.evaluate(Math.random());
392
- break;
393
- case ParticleSystemCurveMode.TwoCurves:
394
- const t = Math.random();
395
- amount = Mathf.lerp(this.count.curveMin.evaluate(t), this.count.curveMax.evaluate(t), Math.random());
396
- break;
397
- }
398
- }
399
- }
400
- }
401
- return amount;
402
- }
403
- }
404
- export class EmissionModule {
405
- enabled;
406
- get burstCount() {
407
- return this.bursts?.length ?? 0;
408
- }
409
- bursts;
410
- rateOverTime;
411
- rateOverTimeMultiplier;
412
- rateOverDistance;
413
- rateOverDistanceMultiplier;
414
- /** set from system */
415
- system;
416
- reset() {
417
- this.bursts?.forEach(b => b.reset());
418
- }
419
- getBurst() {
420
- let amount = 0;
421
- if (this.burstCount > 0) {
422
- for (let i = 0; i < this.burstCount; i++) {
423
- const burst = this.bursts[i];
424
- if (this.system.main.loop && burst.time >= this.system.time) {
425
- burst.reset();
426
- }
427
- amount += Math.round(burst.run(this.system.time));
428
- }
429
- }
430
- return amount;
431
- }
432
- }
433
- __decorate([
434
- serializable()
435
- ], EmissionModule.prototype, "enabled", void 0);
436
- __decorate([
437
- serializable()
438
- ], EmissionModule.prototype, "bursts", void 0);
439
- __decorate([
440
- serializable(MinMaxCurve)
441
- ], EmissionModule.prototype, "rateOverTime", void 0);
442
- __decorate([
443
- serializable()
444
- ], EmissionModule.prototype, "rateOverTimeMultiplier", void 0);
445
- __decorate([
446
- serializable(MinMaxCurve)
447
- ], EmissionModule.prototype, "rateOverDistance", void 0);
448
- __decorate([
449
- serializable()
450
- ], EmissionModule.prototype, "rateOverDistanceMultiplier", void 0);
451
- export class ColorOverLifetimeModule {
452
- enabled;
453
- color;
454
- }
455
- __decorate([
456
- serializable(MinMaxGradient)
457
- ], ColorOverLifetimeModule.prototype, "color", void 0);
458
- export class SizeOverLifetimeModule {
459
- enabled;
460
- separateAxes;
461
- size;
462
- sizeMultiplier;
463
- x;
464
- xMultiplier;
465
- y;
466
- yMultiplier;
467
- z;
468
- zMultiplier;
469
- _time = 0;
470
- _temp = new Vector3();
471
- evaluate(t01, target, lerpFactor) {
472
- if (!target)
473
- target = this._temp;
474
- if (!this.enabled) {
475
- target.x = target.y = target.z = 1;
476
- return target;
477
- }
478
- if (!this.separateAxes) {
479
- const scale = this.size.evaluate(t01, lerpFactor) * this.sizeMultiplier;
480
- target.x = scale;
481
- // target.y = scale;
482
- // target.z = scale;
483
- }
484
- else {
485
- target.x = this.x.evaluate(t01, lerpFactor) * this.xMultiplier;
486
- target.y = this.y.evaluate(t01, lerpFactor) * this.yMultiplier;
487
- target.z = this.z.evaluate(t01, lerpFactor) * this.zMultiplier;
488
- }
489
- return target;
490
- }
491
- }
492
- __decorate([
493
- serializable(MinMaxCurve)
494
- ], SizeOverLifetimeModule.prototype, "size", void 0);
495
- __decorate([
496
- serializable(MinMaxCurve)
497
- ], SizeOverLifetimeModule.prototype, "x", void 0);
498
- __decorate([
499
- serializable(MinMaxCurve)
500
- ], SizeOverLifetimeModule.prototype, "y", void 0);
501
- __decorate([
502
- serializable(MinMaxCurve)
503
- ], SizeOverLifetimeModule.prototype, "z", void 0);
504
- export class ShapeModule {
505
- // Emittershape start
506
- get type() {
507
- return ParticleSystemShapeType[this.shapeType];
508
- }
509
- initialize(particle) {
510
- this.getPosition();
511
- particle.position.copy(this._vector);
512
- }
513
- toJSON() {
514
- return this;
515
- }
516
- clone() {
517
- return new ShapeModule();
518
- }
519
- // EmitterShape end
520
- shapeType = ParticleSystemShapeType.Box;
521
- enabled = true;
522
- alignToDirection = false;
523
- angle = 0;
524
- arc = 360;
525
- arcSpread;
526
- arcSpeedMultiplier;
527
- arcMode;
528
- boxThickness;
529
- position;
530
- rotation;
531
- _rotation = new Euler();
532
- scale;
533
- radius;
534
- radiusThickness;
535
- sphericalDirectionAmount;
536
- randomDirectionAmount;
537
- randomPositionAmount;
538
- system;
539
- _space;
540
- _worldSpaceMatrix = new Matrix4();
541
- _worldSpaceMatrixInverse = new Matrix4();
542
- constructor() {
543
- if (debug)
544
- console.log(this);
545
- }
546
- update(system, _context, simulationSpace, obj) {
547
- this.system = system;
548
- this._space = simulationSpace;
549
- if (simulationSpace === ParticleSystemSimulationSpace.World) {
550
- this._worldSpaceMatrix.copy(obj.matrixWorld);
551
- // set scale to 1
552
- this._worldSpaceMatrix.elements[0] = 1;
553
- this._worldSpaceMatrix.elements[5] = 1;
554
- this._worldSpaceMatrix.elements[10] = 1;
555
- this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert();
556
- }
557
- }
558
- applyRotation(vector) {
559
- const isRotated = this.rotation.x !== 0 || this.rotation.y !== 0 || this.rotation.z !== 0;
560
- if (isRotated) {
561
- // console.log(this._rotation);
562
- // TODO: we need to convert this to threejs euler
563
- this._rotation.x = Mathf.toRadians(this.rotation.x);
564
- this._rotation.y = Mathf.toRadians(this.rotation.y);
565
- this._rotation.z = Mathf.toRadians(this.rotation.z);
566
- this._rotation.order = 'ZYX';
567
- vector.applyEuler(this._rotation);
568
- // this._quat.setFromEuler(this._rotation);
569
- // // this._quat.invert();
570
- // this._quat.x *= -1;
571
- // // this._quat.y *= -1;
572
- // // this._quat.z *= -1;
573
- // this._quat.w *= -1;
574
- // vector.applyQuaternion(this._quat);
575
- }
576
- return isRotated;
577
- }
578
- /** nebula implementations: */
579
- /** initializer implementation */
580
- _vector = new Vector3(0, 0, 0);
581
- _temp = new Vector3(0, 0, 0);
582
- /** called by nebula on initialize */
583
- get vector() {
584
- return this._vector;
585
- }
586
- getPosition() {
587
- this._vector.set(0, 0, 0);
588
- const pos = this._temp.copy(this.position);
589
- const isWorldSpace = this._space === ParticleSystemSimulationSpace.World;
590
- if (isWorldSpace) {
591
- pos.applyQuaternion(this.system.worldQuaternion);
592
- }
593
- let radius = this.radius;
594
- if (isWorldSpace)
595
- radius *= this.system.worldScale.x;
596
- if (this.enabled) {
597
- switch (this.shapeType) {
598
- case ParticleSystemShapeType.Box:
599
- if (debug)
600
- Gizmos.DrawWireBox(this.position, this.scale, 0xdddddd, 1);
601
- this._vector.x = Math.random() * this.scale.x - this.scale.x / 2;
602
- this._vector.y = Math.random() * this.scale.y - this.scale.y / 2;
603
- this._vector.z = Math.random() * this.scale.z - this.scale.z / 2;
604
- this._vector.add(pos);
605
- break;
606
- case ParticleSystemShapeType.Cone:
607
- this.randomConePoint(this.position, this.angle, radius, this.radiusThickness, this.arc, this.arcMode, this._vector);
608
- break;
609
- case ParticleSystemShapeType.Sphere:
610
- this.randomSpherePoint(this.position, radius, this.radiusThickness, this.arc, this._vector);
611
- break;
612
- case ParticleSystemShapeType.Circle:
613
- this.randomCirclePoint(this.position, radius, this.radiusThickness, this.arc, this._vector);
614
- break;
615
- default:
616
- this._vector.set(0, 0, 0);
617
- break;
618
- // case ParticleSystemShapeType.Hemisphere:
619
- // randomSpherePoint(this.position.x, this.position.y, this.position.z, this.radius, this.radiusThickness, 180, this._vector);
620
- // break;
621
- }
622
- this.randomizePosition(this._vector, this.randomPositionAmount);
623
- }
624
- this.applyRotation(this._vector);
625
- if (isWorldSpace) {
626
- this._vector.applyQuaternion(this.system.worldQuaternion);
627
- this._vector.add(this.system.worldPos);
628
- }
629
- if (debug) {
630
- Gizmos.DrawSphere(this._vector, .03, 0xff0000, .5, true);
631
- }
632
- }
633
- _dir = new Vector3();
634
- getDirection(pos) {
635
- if (!this.enabled) {
636
- this._dir.set(0, 0, 1);
637
- return this._dir;
638
- }
639
- switch (this.shapeType) {
640
- case ParticleSystemShapeType.Box:
641
- this._dir.set(0, 0, 1);
642
- break;
643
- case ParticleSystemShapeType.Cone:
644
- this._dir.set(0, 0, 1);
645
- // apply cone angle
646
- // this._dir.applyAxisAngle(new Vector3(0, 1, 0), Mathf.toRadians(this.angle));
647
- break;
648
- case ParticleSystemShapeType.Circle:
649
- case ParticleSystemShapeType.Sphere:
650
- const rx = pos.x;
651
- const ry = pos.y;
652
- const rz = pos.z;
653
- this._dir.set(rx, ry, rz);
654
- if (this.system?.worldspace)
655
- this._dir.sub(this.system.worldPos);
656
- else
657
- this._dir.sub(this.position);
658
- break;
659
- default:
660
- this._dir.set(0, 0, 1);
661
- break;
662
- }
663
- if (this._space === ParticleSystemSimulationSpace.World) {
664
- this._dir.applyQuaternion(this.system.worldQuaternion);
665
- }
666
- this.applyRotation(this._dir);
667
- this._dir.normalize();
668
- this.spherizeDirection(this._dir, this.sphericalDirectionAmount);
669
- this.randomizeDirection(this._dir, this.randomDirectionAmount);
670
- if (debug) {
671
- Gizmos.DrawSphere(pos, .01, 0x883300, .5, true);
672
- Gizmos.DrawDirection(pos, this._dir, 0x883300, .5, true);
673
- }
674
- return this._dir;
675
- }
676
- static _randomQuat = new Quaternion();
677
- static _tempVec = new Vector3();
678
- randomizePosition(pos, amount) {
679
- if (amount <= 0)
680
- return;
681
- const rp = ShapeModule._tempVec;
682
- rp.set(Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1);
683
- rp.x *= amount * this.scale.x;
684
- rp.y *= amount * this.scale.y;
685
- rp.z *= amount * this.scale.z;
686
- pos.add(rp);
687
- }
688
- randomizeDirection(direction, amount) {
689
- if (amount === 0)
690
- return;
691
- const randomQuat = ShapeModule._randomQuat;
692
- const tempVec = ShapeModule._tempVec;
693
- tempVec.set(Math.random() - .5, Math.random() - .5, Math.random() - .5).normalize();
694
- randomQuat.setFromAxisAngle(tempVec, amount * Math.random() * Math.PI);
695
- direction.applyQuaternion(randomQuat);
696
- }
697
- spherizeDirection(dir, amount) {
698
- if (amount === 0)
699
- return;
700
- const theta = Math.random() * Math.PI * 2;
701
- const phi = Math.acos(1 - Math.random() * 2);
702
- const x = Math.sin(phi) * Math.cos(theta);
703
- const y = Math.sin(phi) * Math.sin(theta);
704
- const z = Math.cos(phi);
705
- const v = new Vector3(x, y, z);
706
- dir.lerp(v, amount);
707
- }
708
- randomSpherePoint(pos, radius, thickness, arc, vec) {
709
- const u = Math.random();
710
- const v = Math.random();
711
- const theta = 2 * Math.PI * u * (arc / 360);
712
- const phi = Math.acos(2 * v - 1);
713
- const r = Mathf.lerp(1, 1 - (Math.pow(1 - Math.random(), Math.PI)), thickness) * (radius);
714
- const x = pos.x + this.scale.x * (-r * Math.sin(phi) * Math.cos(theta));
715
- const y = pos.y + this.scale.y * (r * Math.sin(phi) * Math.sin(theta));
716
- const z = pos.z + this.scale.z * (r * Math.cos(phi));
717
- vec.x = x;
718
- vec.y = y;
719
- vec.z = z;
720
- }
721
- randomCirclePoint(pos, radius, thickness, arg, vec) {
722
- const u = Math.random();
723
- const theta = 2 * Math.PI * u * (arg / 360);
724
- const r = Mathf.lerp(1, 1 - (Math.pow(1 - Math.random(), Math.PI)), thickness) * (radius);
725
- const x = pos.x + this.scale.x * r * Math.cos(theta);
726
- const y = pos.y + this.scale.y * r * Math.sin(theta);
727
- const z = pos.z;
728
- vec.x = x;
729
- vec.y = y;
730
- vec.z = z;
731
- }
732
- _loopTime = 0;
733
- _loopDirection = 1;
734
- randomConePoint(pos, _angle, radius, thickness, arc, arcMode, vec) {
735
- let u = 0;
736
- let v = 0;
737
- switch (arcMode) {
738
- case ParticleSystemShapeMultiModeValue.Random:
739
- u = Math.random();
740
- v = Math.random();
741
- break;
742
- case ParticleSystemShapeMultiModeValue.PingPong:
743
- if (this._loopTime > 1)
744
- this._loopDirection = -1;
745
- if (this._loopTime < 0)
746
- this._loopDirection = 1;
747
- // continue with loop
748
- case ParticleSystemShapeMultiModeValue.Loop:
749
- u = .5;
750
- v = Math.random();
751
- this._loopTime += this.system.deltaTime * this._loopDirection;
752
- break;
753
- }
754
- let theta = 2 * Math.PI * u * (arc / 360);
755
- switch (arcMode) {
756
- case ParticleSystemShapeMultiModeValue.PingPong:
757
- case ParticleSystemShapeMultiModeValue.Loop:
758
- theta += Math.PI + .5;
759
- theta += this._loopTime * Math.PI * 2;
760
- theta %= Mathf.toRadians(arc);
761
- break;
762
- }
763
- const phi = Math.acos(2 * v - 1);
764
- const r = Mathf.lerp(1, 1 - (Math.pow(1 - Math.random(), Math.PI)), thickness) * radius;
765
- const x = pos.x + (-r * Math.sin(phi) * Math.cos(theta));
766
- const y = pos.y + (r * Math.sin(phi) * Math.sin(theta));
767
- const z = pos.z;
768
- vec.x = x * this.scale.x;
769
- vec.y = y * this.scale.y;
770
- vec.z = z * this.scale.z;
771
- }
772
- }
773
- __decorate([
774
- serializable()
775
- ], ShapeModule.prototype, "shapeType", void 0);
776
- __decorate([
777
- serializable()
778
- ], ShapeModule.prototype, "enabled", void 0);
779
- __decorate([
780
- serializable()
781
- ], ShapeModule.prototype, "alignToDirection", void 0);
782
- __decorate([
783
- serializable()
784
- ], ShapeModule.prototype, "angle", void 0);
785
- __decorate([
786
- serializable()
787
- ], ShapeModule.prototype, "arc", void 0);
788
- __decorate([
789
- serializable()
790
- ], ShapeModule.prototype, "arcSpread", void 0);
791
- __decorate([
792
- serializable()
793
- ], ShapeModule.prototype, "arcSpeedMultiplier", void 0);
794
- __decorate([
795
- serializable()
796
- ], ShapeModule.prototype, "arcMode", void 0);
797
- __decorate([
798
- serializable(Vector3)
799
- ], ShapeModule.prototype, "boxThickness", void 0);
800
- __decorate([
801
- serializable(Vector3)
802
- ], ShapeModule.prototype, "position", void 0);
803
- __decorate([
804
- serializable(Vector3)
805
- ], ShapeModule.prototype, "rotation", void 0);
806
- __decorate([
807
- serializable(Vector3)
808
- ], ShapeModule.prototype, "scale", void 0);
809
- __decorate([
810
- serializable()
811
- ], ShapeModule.prototype, "radius", void 0);
812
- __decorate([
813
- serializable()
814
- ], ShapeModule.prototype, "radiusThickness", void 0);
815
- __decorate([
816
- serializable()
817
- ], ShapeModule.prototype, "sphericalDirectionAmount", void 0);
818
- __decorate([
819
- serializable()
820
- ], ShapeModule.prototype, "randomDirectionAmount", void 0);
821
- __decorate([
822
- serializable()
823
- ], ShapeModule.prototype, "randomPositionAmount", void 0);
824
- export class NoiseModule {
825
- damping;
826
- enabled;
827
- frequency;
828
- octaveCount;
829
- octaveMultiplier;
830
- octaveScale;
831
- positionAmount;
832
- quality;
833
- remap;
834
- remapEnabled;
835
- remapMultiplier;
836
- remapX;
837
- remapXMultiplier;
838
- remapY;
839
- remapYMultiplier;
840
- remapZ;
841
- remapZMultiplier;
842
- scrollSpeedMultiplier;
843
- separateAxes;
844
- strengthMultiplier;
845
- strengthX;
846
- strengthXMultiplier;
847
- strengthY;
848
- strengthYMultiplier;
849
- strengthZ;
850
- strengthZMultiplier;
851
- _noise;
852
- _time = 0;
853
- update(context) {
854
- this._time += context.time.deltaTime * this.scrollSpeedMultiplier;
855
- }
856
- /** nebula implementations: */
857
- _temp = new Vector3();
858
- apply(_index, pos, vel, _deltaTime, age, life) {
859
- if (!this.enabled)
860
- return;
861
- if (!this._noise) {
862
- this._noise = createNoise4D(() => 0);
863
- }
864
- const temp = this._temp.set(pos.x, pos.y, pos.z).multiplyScalar(this.frequency);
865
- const nx = this._noise(temp.x, temp.y, temp.z, this._time);
866
- const ny = this._noise(temp.x, temp.y, temp.z, this._time + 1000 * this.frequency);
867
- const nz = this._noise(temp.x, temp.y, temp.z, this._time + 2000 * this.frequency);
868
- this._temp.set(nx, ny, nz).normalize();
869
- const t = age / life;
870
- let strengthFactor = this.positionAmount.evaluate(t);
871
- if (!this.separateAxes) {
872
- if (this.strengthX) {
873
- strengthFactor *= this.strengthX.evaluate(t) * 1.5;
874
- }
875
- // strengthFactor *= this.strengthMultiplier;
876
- // strengthFactor *= deltaTime;
877
- this._temp.multiplyScalar(strengthFactor);
878
- }
879
- else {
880
- this._temp.x *= strengthFactor * this.strengthXMultiplier;
881
- this._temp.y *= strengthFactor * this.strengthYMultiplier;
882
- this._temp.z *= strengthFactor * this.strengthZMultiplier;
883
- }
884
- // this._temp.setLength(strengthFactor * deltaTime);
885
- vel.x += this._temp.x;
886
- vel.y += this._temp.y;
887
- vel.z += this._temp.z;
888
- }
889
- }
890
- __decorate([
891
- serializable()
892
- ], NoiseModule.prototype, "damping", void 0);
893
- __decorate([
894
- serializable()
895
- ], NoiseModule.prototype, "enabled", void 0);
896
- __decorate([
897
- serializable()
898
- ], NoiseModule.prototype, "frequency", void 0);
899
- __decorate([
900
- serializable()
901
- ], NoiseModule.prototype, "octaveCount", void 0);
902
- __decorate([
903
- serializable()
904
- ], NoiseModule.prototype, "octaveMultiplier", void 0);
905
- __decorate([
906
- serializable()
907
- ], NoiseModule.prototype, "octaveScale", void 0);
908
- __decorate([
909
- serializable(MinMaxCurve)
910
- ], NoiseModule.prototype, "positionAmount", void 0);
911
- __decorate([
912
- serializable()
913
- ], NoiseModule.prototype, "quality", void 0);
914
- __decorate([
915
- serializable(MinMaxCurve)
916
- ], NoiseModule.prototype, "remap", void 0);
917
- __decorate([
918
- serializable()
919
- ], NoiseModule.prototype, "remapEnabled", void 0);
920
- __decorate([
921
- serializable()
922
- ], NoiseModule.prototype, "remapMultiplier", void 0);
923
- __decorate([
924
- serializable(MinMaxCurve)
925
- ], NoiseModule.prototype, "remapX", void 0);
926
- __decorate([
927
- serializable()
928
- ], NoiseModule.prototype, "remapXMultiplier", void 0);
929
- __decorate([
930
- serializable(MinMaxCurve)
931
- ], NoiseModule.prototype, "remapY", void 0);
932
- __decorate([
933
- serializable()
934
- ], NoiseModule.prototype, "remapYMultiplier", void 0);
935
- __decorate([
936
- serializable(MinMaxCurve)
937
- ], NoiseModule.prototype, "remapZ", void 0);
938
- __decorate([
939
- serializable()
940
- ], NoiseModule.prototype, "remapZMultiplier", void 0);
941
- __decorate([
942
- serializable()
943
- ], NoiseModule.prototype, "scrollSpeedMultiplier", void 0);
944
- __decorate([
945
- serializable()
946
- ], NoiseModule.prototype, "separateAxes", void 0);
947
- __decorate([
948
- serializable()
949
- ], NoiseModule.prototype, "strengthMultiplier", void 0);
950
- __decorate([
951
- serializable(MinMaxCurve)
952
- ], NoiseModule.prototype, "strengthX", void 0);
953
- __decorate([
954
- serializable()
955
- ], NoiseModule.prototype, "strengthXMultiplier", void 0);
956
- __decorate([
957
- serializable(MinMaxCurve)
958
- ], NoiseModule.prototype, "strengthY", void 0);
959
- __decorate([
960
- serializable()
961
- ], NoiseModule.prototype, "strengthYMultiplier", void 0);
962
- __decorate([
963
- serializable(MinMaxCurve)
964
- ], NoiseModule.prototype, "strengthZ", void 0);
965
- __decorate([
966
- serializable()
967
- ], NoiseModule.prototype, "strengthZMultiplier", void 0);
968
- export var ParticleSystemTrailMode;
969
- (function (ParticleSystemTrailMode) {
970
- ParticleSystemTrailMode[ParticleSystemTrailMode["PerParticle"] = 0] = "PerParticle";
971
- ParticleSystemTrailMode[ParticleSystemTrailMode["Ribbon"] = 1] = "Ribbon";
972
- })(ParticleSystemTrailMode || (ParticleSystemTrailMode = {}));
973
- export var ParticleSystemTrailTextureMode;
974
- (function (ParticleSystemTrailTextureMode) {
975
- ParticleSystemTrailTextureMode[ParticleSystemTrailTextureMode["Stretch"] = 0] = "Stretch";
976
- ParticleSystemTrailTextureMode[ParticleSystemTrailTextureMode["Tile"] = 1] = "Tile";
977
- ParticleSystemTrailTextureMode[ParticleSystemTrailTextureMode["DistributePerSegment"] = 2] = "DistributePerSegment";
978
- ParticleSystemTrailTextureMode[ParticleSystemTrailTextureMode["RepeatPerSegment"] = 3] = "RepeatPerSegment";
979
- })(ParticleSystemTrailTextureMode || (ParticleSystemTrailTextureMode = {}));
980
- export class TrailModule {
981
- enabled;
982
- attachRibbonToTransform = false;
983
- colorOverLifetime;
984
- colorOverTrail;
985
- dieWithParticles = true;
986
- inheritParticleColor = true;
987
- lifetime;
988
- lifetimeMultiplier;
989
- minVertexDistance = .2;
990
- mode = ParticleSystemTrailMode.PerParticle;
991
- ratio = 1;
992
- ribbonCount = 1;
993
- shadowBias = 0;
994
- sizeAffectsLifetime = false;
995
- sizeAffectsWidth = false;
996
- splitSubEmitterRibbons = false;
997
- textureMode = ParticleSystemTrailTextureMode.Stretch;
998
- widthOverTrail;
999
- widthOverTrailMultiplier;
1000
- worldSpace = false;
1001
- getWidth(size, _life01, pos01, t) {
1002
- const res = this.widthOverTrail.evaluate(pos01, t);
1003
- size *= res;
1004
- return size;
1005
- }
1006
- getColor(color, life01, pos01) {
1007
- const overTrail = this.colorOverTrail.evaluate(pos01);
1008
- const overLife = this.colorOverLifetime.evaluate(life01);
1009
- color.x *= overTrail.r * overLife.r;
1010
- color.y *= overTrail.g * overLife.g;
1011
- color.z *= overTrail.b * overLife.b;
1012
- color.w *= overTrail.alpha * overLife.alpha;
1013
- }
1014
- }
1015
- __decorate([
1016
- serializable()
1017
- ], TrailModule.prototype, "enabled", void 0);
1018
- __decorate([
1019
- serializable()
1020
- ], TrailModule.prototype, "attachRibbonToTransform", void 0);
1021
- __decorate([
1022
- serializable(MinMaxGradient)
1023
- ], TrailModule.prototype, "colorOverLifetime", void 0);
1024
- __decorate([
1025
- serializable(MinMaxGradient)
1026
- ], TrailModule.prototype, "colorOverTrail", void 0);
1027
- __decorate([
1028
- serializable()
1029
- ], TrailModule.prototype, "dieWithParticles", void 0);
1030
- __decorate([
1031
- serializable()
1032
- ], TrailModule.prototype, "inheritParticleColor", void 0);
1033
- __decorate([
1034
- serializable(MinMaxCurve)
1035
- ], TrailModule.prototype, "lifetime", void 0);
1036
- __decorate([
1037
- serializable()
1038
- ], TrailModule.prototype, "lifetimeMultiplier", void 0);
1039
- __decorate([
1040
- serializable()
1041
- ], TrailModule.prototype, "minVertexDistance", void 0);
1042
- __decorate([
1043
- serializable()
1044
- ], TrailModule.prototype, "mode", void 0);
1045
- __decorate([
1046
- serializable()
1047
- ], TrailModule.prototype, "ratio", void 0);
1048
- __decorate([
1049
- serializable()
1050
- ], TrailModule.prototype, "ribbonCount", void 0);
1051
- __decorate([
1052
- serializable()
1053
- ], TrailModule.prototype, "shadowBias", void 0);
1054
- __decorate([
1055
- serializable()
1056
- ], TrailModule.prototype, "sizeAffectsLifetime", void 0);
1057
- __decorate([
1058
- serializable()
1059
- ], TrailModule.prototype, "sizeAffectsWidth", void 0);
1060
- __decorate([
1061
- serializable()
1062
- ], TrailModule.prototype, "splitSubEmitterRibbons", void 0);
1063
- __decorate([
1064
- serializable()
1065
- ], TrailModule.prototype, "textureMode", void 0);
1066
- __decorate([
1067
- serializable(MinMaxCurve)
1068
- ], TrailModule.prototype, "widthOverTrail", void 0);
1069
- __decorate([
1070
- serializable()
1071
- ], TrailModule.prototype, "widthOverTrailMultiplier", void 0);
1072
- __decorate([
1073
- serializable()
1074
- ], TrailModule.prototype, "worldSpace", void 0);
1075
- export class VelocityOverLifetimeModule {
1076
- enabled;
1077
- space = ParticleSystemSimulationSpace.Local;
1078
- orbitalX;
1079
- orbitalY;
1080
- orbitalZ;
1081
- orbitalXMultiplier;
1082
- orbitalYMultiplier;
1083
- orbitalZMultiplier;
1084
- orbitalOffsetX;
1085
- orbitalOffsetY;
1086
- orbitalOffsetZ;
1087
- speedModifier;
1088
- speedModifierMultiplier;
1089
- x;
1090
- xMultiplier;
1091
- y;
1092
- yMultiplier;
1093
- z;
1094
- zMultiplier;
1095
- _system;
1096
- // private _worldRotation: Quaternion = new Quaternion();
1097
- update(system) {
1098
- this._system = system;
1099
- }
1100
- _temp = new Vector3();
1101
- _temp2 = new Vector3();
1102
- _temp3 = new Vector3();
1103
- _hasOrbital = false;
1104
- _index = 0;
1105
- _orbitalMatrix = new Matrix4();
1106
- init(particle) {
1107
- if (this._index == 0)
1108
- particle["debug"] = true;
1109
- this._index += 1;
1110
- particle["orbitx"] = this.orbitalX.evaluate(Math.random());
1111
- particle["orbity"] = this.orbitalY.evaluate(Math.random());
1112
- particle["orbitz"] = this.orbitalZ.evaluate(Math.random());
1113
- // console.log(particle["orbitx"], particle["orbity"], particle["orbitz"])
1114
- this._hasOrbital = particle["orbitx"] != 0 || particle["orbity"] != 0 || particle["orbitz"] != 0;
1115
- }
1116
- apply(_particle, _index, _pos, vel, _dt, age, life) {
1117
- if (!this.enabled)
1118
- return;
1119
- const t = age / life;
1120
- const speed = this.speedModifier.evaluate(t) * this.speedModifierMultiplier;
1121
- const x = this.x.evaluate(t);
1122
- const y = this.y.evaluate(t);
1123
- const z = this.z.evaluate(t);
1124
- this._temp.set(-x, y, z);
1125
- if (this._system) {
1126
- // if (this.space === ParticleSystemSimulationSpace.World) {
1127
- // this._temp.applyQuaternion(this._system.worldQuaternionInverted);
1128
- // }
1129
- if (this._system.main.simulationSpace === ParticleSystemSimulationSpace.World) {
1130
- this._temp.applyQuaternion(this._system.worldQuaternion);
1131
- }
1132
- }
1133
- if (this._hasOrbital) {
1134
- const position = this._system?.worldPos;
1135
- if (position) {
1136
- // TODO: we absolutely need to fix this, this is a hack for a specific usecase and doesnt work yet correctly
1137
- // https://github.com/needle-tools/needle-tiny/issues/710
1138
- const pos = this._temp2.set(_pos.x, _pos.y, _pos.z);
1139
- const ox = this.orbitalXMultiplier; // particle["orbitx"];
1140
- const oy = this.orbitalYMultiplier; // particle["orbity"];
1141
- const oz = this.orbitalZMultiplier; // particle["orbitz"];
1142
- const angle = speed * Math.PI * 2 * 10; // < Oh god
1143
- const cosX = Math.cos(angle * ox);
1144
- const sinX = Math.sin(angle * ox);
1145
- const cosY = Math.cos(angle * oy);
1146
- const sinY = Math.sin(angle * oy);
1147
- const cosZ = Math.cos(angle * oz);
1148
- const sinZ = Math.sin(angle * oz);
1149
- const newX = pos.x * (cosY * cosZ) + pos.y * (cosY * sinZ) + pos.z * (-sinY);
1150
- const newY = pos.x * (sinX * sinY * cosZ - cosX * sinZ) + pos.y * (sinX * sinY * sinZ + cosX * cosZ) + pos.z * (sinX * cosY);
1151
- const newZ = pos.x * (cosX * sinY * cosZ + sinX * sinZ) + pos.y * (cosX * sinY * sinZ - sinX * cosZ) + pos.z * (cosX * cosY);
1152
- // pos.x += this.orbitalOffsetX;
1153
- // pos.y += this.orbitalOffsetY;
1154
- // pos.z += this.orbitalOffsetZ;
1155
- const v = this._temp3.set(pos.x - newX, pos.y - newY, pos.z - newZ);
1156
- v.normalize();
1157
- v.multiplyScalar(.2 / _dt * (Math.max(this.orbitalXMultiplier, this.orbitalYMultiplier, this.orbitalZMultiplier)));
1158
- vel.x += v.x;
1159
- vel.y += v.y;
1160
- vel.z += v.z;
1161
- }
1162
- }
1163
- vel.x += this._temp.x;
1164
- vel.y += this._temp.y;
1165
- vel.z += this._temp.z;
1166
- vel.x *= speed;
1167
- vel.y *= speed;
1168
- vel.z *= speed;
1169
- }
1170
- }
1171
- __decorate([
1172
- serializable()
1173
- ], VelocityOverLifetimeModule.prototype, "enabled", void 0);
1174
- __decorate([
1175
- serializable()
1176
- ], VelocityOverLifetimeModule.prototype, "space", void 0);
1177
- __decorate([
1178
- serializable(MinMaxCurve)
1179
- ], VelocityOverLifetimeModule.prototype, "orbitalX", void 0);
1180
- __decorate([
1181
- serializable(MinMaxCurve)
1182
- ], VelocityOverLifetimeModule.prototype, "orbitalY", void 0);
1183
- __decorate([
1184
- serializable(MinMaxCurve)
1185
- ], VelocityOverLifetimeModule.prototype, "orbitalZ", void 0);
1186
- __decorate([
1187
- serializable()
1188
- ], VelocityOverLifetimeModule.prototype, "orbitalXMultiplier", void 0);
1189
- __decorate([
1190
- serializable()
1191
- ], VelocityOverLifetimeModule.prototype, "orbitalYMultiplier", void 0);
1192
- __decorate([
1193
- serializable()
1194
- ], VelocityOverLifetimeModule.prototype, "orbitalZMultiplier", void 0);
1195
- __decorate([
1196
- serializable()
1197
- ], VelocityOverLifetimeModule.prototype, "orbitalOffsetX", void 0);
1198
- __decorate([
1199
- serializable()
1200
- ], VelocityOverLifetimeModule.prototype, "orbitalOffsetY", void 0);
1201
- __decorate([
1202
- serializable()
1203
- ], VelocityOverLifetimeModule.prototype, "orbitalOffsetZ", void 0);
1204
- __decorate([
1205
- serializable(MinMaxCurve)
1206
- ], VelocityOverLifetimeModule.prototype, "speedModifier", void 0);
1207
- __decorate([
1208
- serializable()
1209
- ], VelocityOverLifetimeModule.prototype, "speedModifierMultiplier", void 0);
1210
- __decorate([
1211
- serializable(MinMaxCurve)
1212
- ], VelocityOverLifetimeModule.prototype, "x", void 0);
1213
- __decorate([
1214
- serializable()
1215
- ], VelocityOverLifetimeModule.prototype, "xMultiplier", void 0);
1216
- __decorate([
1217
- serializable(MinMaxCurve)
1218
- ], VelocityOverLifetimeModule.prototype, "y", void 0);
1219
- __decorate([
1220
- serializable()
1221
- ], VelocityOverLifetimeModule.prototype, "yMultiplier", void 0);
1222
- __decorate([
1223
- serializable(MinMaxCurve)
1224
- ], VelocityOverLifetimeModule.prototype, "z", void 0);
1225
- __decorate([
1226
- serializable()
1227
- ], VelocityOverLifetimeModule.prototype, "zMultiplier", void 0);
1228
- var ParticleSystemAnimationTimeMode;
1229
- (function (ParticleSystemAnimationTimeMode) {
1230
- ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["Lifetime"] = 0] = "Lifetime";
1231
- ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["Speed"] = 1] = "Speed";
1232
- ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["FPS"] = 2] = "FPS";
1233
- })(ParticleSystemAnimationTimeMode || (ParticleSystemAnimationTimeMode = {}));
1234
- var ParticleSystemAnimationMode;
1235
- (function (ParticleSystemAnimationMode) {
1236
- ParticleSystemAnimationMode[ParticleSystemAnimationMode["Grid"] = 0] = "Grid";
1237
- ParticleSystemAnimationMode[ParticleSystemAnimationMode["Sprites"] = 1] = "Sprites";
1238
- })(ParticleSystemAnimationMode || (ParticleSystemAnimationMode = {}));
1239
- var ParticleSystemAnimationRowMode;
1240
- (function (ParticleSystemAnimationRowMode) {
1241
- ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["Custom"] = 0] = "Custom";
1242
- ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["Random"] = 1] = "Random";
1243
- ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["MeshIndex"] = 2] = "MeshIndex";
1244
- })(ParticleSystemAnimationRowMode || (ParticleSystemAnimationRowMode = {}));
1245
- var ParticleSystemAnimationType;
1246
- (function (ParticleSystemAnimationType) {
1247
- ParticleSystemAnimationType[ParticleSystemAnimationType["WholeSheet"] = 0] = "WholeSheet";
1248
- ParticleSystemAnimationType[ParticleSystemAnimationType["SingleRow"] = 1] = "SingleRow";
1249
- })(ParticleSystemAnimationType || (ParticleSystemAnimationType = {}));
1250
- export class TextureSheetAnimationModule {
1251
- animation;
1252
- enabled;
1253
- cycleCount;
1254
- frameOverTime;
1255
- frameOverTimeMultiplier;
1256
- numTilesX;
1257
- numTilesY;
1258
- startFrame;
1259
- startFrameMultiplier;
1260
- rowMode;
1261
- rowIndex;
1262
- spriteCount;
1263
- timeMode;
1264
- sampleOnceAtStart() {
1265
- if (this.timeMode === ParticleSystemAnimationTimeMode.Lifetime) {
1266
- switch (this.frameOverTime.mode) {
1267
- case ParticleSystemCurveMode.Constant:
1268
- case ParticleSystemCurveMode.TwoConstants:
1269
- case ParticleSystemCurveMode.TwoCurves:
1270
- case ParticleSystemCurveMode.Curve:
1271
- return true;
1272
- }
1273
- }
1274
- return false;
1275
- }
1276
- getStartIndex() {
1277
- if (this.sampleOnceAtStart()) {
1278
- const start = Math.random();
1279
- return start * (this.numTilesX * this.numTilesY);
1280
- }
1281
- return 0;
1282
- }
1283
- evaluate(t01) {
1284
- if (this.sampleOnceAtStart()) {
1285
- return undefined;
1286
- }
1287
- return this.getIndex(t01);
1288
- }
1289
- getIndex(t01) {
1290
- const tiles = this.numTilesX * this.numTilesY;
1291
- t01 = t01 * this.cycleCount;
1292
- let index = this.frameOverTime.evaluate(t01 % 1);
1293
- index *= this.frameOverTimeMultiplier;
1294
- index *= tiles;
1295
- index = index % tiles;
1296
- index = Math.floor(index);
1297
- return index;
1298
- }
1299
- }
1300
- __decorate([
1301
- serializable()
1302
- ], TextureSheetAnimationModule.prototype, "animation", void 0);
1303
- __decorate([
1304
- serializable()
1305
- ], TextureSheetAnimationModule.prototype, "enabled", void 0);
1306
- __decorate([
1307
- serializable()
1308
- ], TextureSheetAnimationModule.prototype, "cycleCount", void 0);
1309
- __decorate([
1310
- serializable(MinMaxCurve)
1311
- ], TextureSheetAnimationModule.prototype, "frameOverTime", void 0);
1312
- __decorate([
1313
- serializable()
1314
- ], TextureSheetAnimationModule.prototype, "frameOverTimeMultiplier", void 0);
1315
- __decorate([
1316
- serializable()
1317
- ], TextureSheetAnimationModule.prototype, "numTilesX", void 0);
1318
- __decorate([
1319
- serializable()
1320
- ], TextureSheetAnimationModule.prototype, "numTilesY", void 0);
1321
- __decorate([
1322
- serializable(MinMaxCurve)
1323
- ], TextureSheetAnimationModule.prototype, "startFrame", void 0);
1324
- __decorate([
1325
- serializable()
1326
- ], TextureSheetAnimationModule.prototype, "startFrameMultiplier", void 0);
1327
- __decorate([
1328
- serializable()
1329
- ], TextureSheetAnimationModule.prototype, "rowMode", void 0);
1330
- __decorate([
1331
- serializable()
1332
- ], TextureSheetAnimationModule.prototype, "rowIndex", void 0);
1333
- __decorate([
1334
- serializable()
1335
- ], TextureSheetAnimationModule.prototype, "spriteCount", void 0);
1336
- __decorate([
1337
- serializable()
1338
- ], TextureSheetAnimationModule.prototype, "timeMode", void 0);
1339
- export class RotationOverLifetimeModule {
1340
- enabled;
1341
- separateAxes;
1342
- x;
1343
- xMultiplier;
1344
- y;
1345
- yMultiplier;
1346
- z;
1347
- zMultiplier;
1348
- evaluate(t01, t) {
1349
- if (!this.enabled)
1350
- return 0;
1351
- if (!this.separateAxes) {
1352
- const rot = this.z.evaluate(t01, t) * -1;
1353
- return rot;
1354
- }
1355
- return 0;
1356
- }
1357
- }
1358
- __decorate([
1359
- serializable()
1360
- ], RotationOverLifetimeModule.prototype, "enabled", void 0);
1361
- __decorate([
1362
- serializable()
1363
- ], RotationOverLifetimeModule.prototype, "separateAxes", void 0);
1364
- __decorate([
1365
- serializable(MinMaxCurve)
1366
- ], RotationOverLifetimeModule.prototype, "x", void 0);
1367
- __decorate([
1368
- serializable()
1369
- ], RotationOverLifetimeModule.prototype, "xMultiplier", void 0);
1370
- __decorate([
1371
- serializable(MinMaxCurve)
1372
- ], RotationOverLifetimeModule.prototype, "y", void 0);
1373
- __decorate([
1374
- serializable()
1375
- ], RotationOverLifetimeModule.prototype, "yMultiplier", void 0);
1376
- __decorate([
1377
- serializable(MinMaxCurve)
1378
- ], RotationOverLifetimeModule.prototype, "z", void 0);
1379
- __decorate([
1380
- serializable()
1381
- ], RotationOverLifetimeModule.prototype, "zMultiplier", void 0);
1382
- export class RotationBySpeedModule {
1383
- enabled;
1384
- range;
1385
- separateAxes;
1386
- x;
1387
- xMultiplier;
1388
- y;
1389
- yMultiplier;
1390
- z;
1391
- zMultiplier;
1392
- evaluate(_t01, speed) {
1393
- if (!this.enabled)
1394
- return 0;
1395
- if (!this.separateAxes) {
1396
- const t = Mathf.lerp(this.range.x, this.range.y, speed);
1397
- const rot = this.z.evaluate(t) * -1;
1398
- return rot;
1399
- }
1400
- return 0;
1401
- }
1402
- }
1403
- __decorate([
1404
- serializable()
1405
- ], RotationBySpeedModule.prototype, "enabled", void 0);
1406
- __decorate([
1407
- serializable()
1408
- ], RotationBySpeedModule.prototype, "range", void 0);
1409
- __decorate([
1410
- serializable()
1411
- ], RotationBySpeedModule.prototype, "separateAxes", void 0);
1412
- __decorate([
1413
- serializable(MinMaxCurve)
1414
- ], RotationBySpeedModule.prototype, "x", void 0);
1415
- __decorate([
1416
- serializable()
1417
- ], RotationBySpeedModule.prototype, "xMultiplier", void 0);
1418
- __decorate([
1419
- serializable(MinMaxCurve)
1420
- ], RotationBySpeedModule.prototype, "y", void 0);
1421
- __decorate([
1422
- serializable()
1423
- ], RotationBySpeedModule.prototype, "yMultiplier", void 0);
1424
- __decorate([
1425
- serializable(MinMaxCurve)
1426
- ], RotationBySpeedModule.prototype, "z", void 0);
1427
- __decorate([
1428
- serializable()
1429
- ], RotationBySpeedModule.prototype, "zMultiplier", void 0);
1430
- export class LimitVelocityOverLifetimeModule {
1431
- enabled;
1432
- dampen;
1433
- drag;
1434
- dragMultiplier;
1435
- limit;
1436
- limitMultiplier;
1437
- separateAxes;
1438
- limitX;
1439
- limitXMultiplier;
1440
- limitY;
1441
- limitYMultiplier;
1442
- limitZ;
1443
- limitZMultiplier;
1444
- multiplyDragByParticleSize = false;
1445
- multiplyDragByParticleVelocity = false;
1446
- space;
1447
- _temp = new Vector3();
1448
- _temp2 = new Vector3();
1449
- apply(_position, baseVelocity, currentVelocity, _size, t01, _dt, _scale) {
1450
- if (!this.enabled)
1451
- return;
1452
- // if (this.separateAxes) {
1453
- // // const maxX = this.limitX.evaluate(t01) * this.limitXMultiplier;
1454
- // // const maxY = this.limitY.evaluate(t01) * this.limitYMultiplier;
1455
- // // const maxZ = this.limitZ.evaluate(t01) * this.limitZMultiplier;
1456
- // }
1457
- // else
1458
- {
1459
- const max = this.limit.evaluate(t01) * this.limitMultiplier;
1460
- const speed = baseVelocity.length();
1461
- if (speed > max) {
1462
- this._temp.copy(baseVelocity).normalize().multiplyScalar(max);
1463
- const t = this.dampen * .5;
1464
- // t *= scale;
1465
- baseVelocity.x = Mathf.lerp(baseVelocity.x, this._temp.x, t);
1466
- baseVelocity.y = Mathf.lerp(baseVelocity.y, this._temp.y, t);
1467
- baseVelocity.z = Mathf.lerp(baseVelocity.z, this._temp.z, t);
1468
- // this._temp2.set(0, 0, 0);
1469
- currentVelocity.x = Mathf.lerp(currentVelocity.x, this._temp.x, t);
1470
- currentVelocity.y = Mathf.lerp(currentVelocity.y, this._temp.y, t);
1471
- currentVelocity.z = Mathf.lerp(currentVelocity.z, this._temp.z, t);
1472
- }
1473
- // vel.multiplyScalar(dragFactor);
1474
- }
1475
- // vel.x *= 0.3;
1476
- // vel.y *= 0.3;
1477
- // vel.z *= 0.3;
1478
- }
1479
- }
1480
- __decorate([
1481
- serializable()
1482
- ], LimitVelocityOverLifetimeModule.prototype, "enabled", void 0);
1483
- __decorate([
1484
- serializable()
1485
- ], LimitVelocityOverLifetimeModule.prototype, "dampen", void 0);
1486
- __decorate([
1487
- serializable(MinMaxCurve)
1488
- ], LimitVelocityOverLifetimeModule.prototype, "drag", void 0);
1489
- __decorate([
1490
- serializable()
1491
- ], LimitVelocityOverLifetimeModule.prototype, "dragMultiplier", void 0);
1492
- __decorate([
1493
- serializable(MinMaxCurve)
1494
- ], LimitVelocityOverLifetimeModule.prototype, "limit", void 0);
1495
- __decorate([
1496
- serializable()
1497
- ], LimitVelocityOverLifetimeModule.prototype, "limitMultiplier", void 0);
1498
- __decorate([
1499
- serializable()
1500
- ], LimitVelocityOverLifetimeModule.prototype, "separateAxes", void 0);
1501
- __decorate([
1502
- serializable(MinMaxCurve)
1503
- ], LimitVelocityOverLifetimeModule.prototype, "limitX", void 0);
1504
- __decorate([
1505
- serializable()
1506
- ], LimitVelocityOverLifetimeModule.prototype, "limitXMultiplier", void 0);
1507
- __decorate([
1508
- serializable(MinMaxCurve)
1509
- ], LimitVelocityOverLifetimeModule.prototype, "limitY", void 0);
1510
- __decorate([
1511
- serializable()
1512
- ], LimitVelocityOverLifetimeModule.prototype, "limitYMultiplier", void 0);
1513
- __decorate([
1514
- serializable(MinMaxCurve)
1515
- ], LimitVelocityOverLifetimeModule.prototype, "limitZ", void 0);
1516
- __decorate([
1517
- serializable()
1518
- ], LimitVelocityOverLifetimeModule.prototype, "limitZMultiplier", void 0);
1519
- __decorate([
1520
- serializable()
1521
- ], LimitVelocityOverLifetimeModule.prototype, "multiplyDragByParticleSize", void 0);
1522
- __decorate([
1523
- serializable()
1524
- ], LimitVelocityOverLifetimeModule.prototype, "multiplyDragByParticleVelocity", void 0);
1525
- __decorate([
1526
- serializable()
1527
- ], LimitVelocityOverLifetimeModule.prototype, "space", void 0);
1528
- export var ParticleSystemInheritVelocityMode;
1529
- (function (ParticleSystemInheritVelocityMode) {
1530
- ParticleSystemInheritVelocityMode[ParticleSystemInheritVelocityMode["Initial"] = 0] = "Initial";
1531
- ParticleSystemInheritVelocityMode[ParticleSystemInheritVelocityMode["Current"] = 1] = "Current";
1532
- })(ParticleSystemInheritVelocityMode || (ParticleSystemInheritVelocityMode = {}));
1533
- export class InheritVelocityModule {
1534
- enabled;
1535
- curve;
1536
- curveMultiplier;
1537
- mode;
1538
- system;
1539
- _lastWorldPosition;
1540
- _velocity = new Vector3();
1541
- _temp = new Vector3();
1542
- update(_context) {
1543
- if (!this.enabled)
1544
- return;
1545
- if (this.system.worldspace === false)
1546
- return;
1547
- if (this._lastWorldPosition) {
1548
- this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1 / this.system.deltaTime);
1549
- this._lastWorldPosition.copy(this.system.worldPos);
1550
- }
1551
- else {
1552
- this._velocity.set(0, 0, 0);
1553
- this._lastWorldPosition = this.system.worldPos.clone();
1554
- }
1555
- }
1556
- // TODO: make work for subsystems
1557
- applyInitial(vel) {
1558
- if (!this.enabled)
1559
- return;
1560
- if (this.system.worldspace === false)
1561
- return;
1562
- if (this.mode === ParticleSystemInheritVelocityMode.Initial) {
1563
- const factor = this.curve.evaluate(Math.random(), Math.random());
1564
- this._temp.copy(this._velocity).multiplyScalar(factor);
1565
- vel.add(this._temp);
1566
- }
1567
- }
1568
- applyCurrent(vel, t01, lerpFactor) {
1569
- if (!this.enabled)
1570
- return;
1571
- if (this.system.worldspace === false)
1572
- return;
1573
- if (this.mode === ParticleSystemInheritVelocityMode.Current) {
1574
- const factor = this.curve.evaluate(t01, lerpFactor);
1575
- this._temp.copy(this._velocity).multiplyScalar(factor);
1576
- vel.add(this._temp);
1577
- }
1578
- }
1579
- }
1580
- __decorate([
1581
- serializable()
1582
- ], InheritVelocityModule.prototype, "enabled", void 0);
1583
- __decorate([
1584
- serializable(MinMaxCurve)
1585
- ], InheritVelocityModule.prototype, "curve", void 0);
1586
- __decorate([
1587
- serializable()
1588
- ], InheritVelocityModule.prototype, "curveMultiplier", void 0);
1589
- __decorate([
1590
- serializable()
1591
- ], InheritVelocityModule.prototype, "mode", void 0);
1592
- export class SizeBySpeedModule {
1593
- enabled;
1594
- range;
1595
- separateAxes;
1596
- size;
1597
- sizeMultiplier;
1598
- x;
1599
- xMultiplier;
1600
- y;
1601
- yMultiplier;
1602
- z;
1603
- zMultiplier;
1604
- evaluate(vel, _t01, lerpFactor, size) {
1605
- const speed = vel.length();
1606
- const x = Mathf.remap(speed, this.range.x, this.range.y, 0, 1);
1607
- const factor = this.size.evaluate(x, lerpFactor);
1608
- // return size;
1609
- return size * factor;
1610
- }
1611
- }
1612
- __decorate([
1613
- serializable()
1614
- ], SizeBySpeedModule.prototype, "enabled", void 0);
1615
- __decorate([
1616
- serializable(Vector2)
1617
- ], SizeBySpeedModule.prototype, "range", void 0);
1618
- __decorate([
1619
- serializable()
1620
- ], SizeBySpeedModule.prototype, "separateAxes", void 0);
1621
- __decorate([
1622
- serializable(MinMaxCurve)
1623
- ], SizeBySpeedModule.prototype, "size", void 0);
1624
- __decorate([
1625
- serializable()
1626
- ], SizeBySpeedModule.prototype, "sizeMultiplier", void 0);
1627
- __decorate([
1628
- serializable(MinMaxCurve)
1629
- ], SizeBySpeedModule.prototype, "x", void 0);
1630
- __decorate([
1631
- serializable()
1632
- ], SizeBySpeedModule.prototype, "xMultiplier", void 0);
1633
- __decorate([
1634
- serializable(MinMaxCurve)
1635
- ], SizeBySpeedModule.prototype, "y", void 0);
1636
- __decorate([
1637
- serializable()
1638
- ], SizeBySpeedModule.prototype, "yMultiplier", void 0);
1639
- __decorate([
1640
- serializable(MinMaxCurve)
1641
- ], SizeBySpeedModule.prototype, "z", void 0);
1642
- __decorate([
1643
- serializable()
1644
- ], SizeBySpeedModule.prototype, "zMultiplier", void 0);
1645
- export class ColorBySpeedModule {
1646
- enabled;
1647
- range;
1648
- color;
1649
- evaluate(vel, lerpFactor, color) {
1650
- const speed = vel.length();
1651
- const x = Mathf.remap(speed, this.range.x, this.range.y, 0, 1);
1652
- const res = this.color.evaluate(x, lerpFactor);
1653
- color.x *= res.r;
1654
- color.y *= res.g;
1655
- color.z *= res.b;
1656
- color.w *= res.alpha;
1657
- }
1658
- }
1659
- __decorate([
1660
- serializable()
1661
- ], ColorBySpeedModule.prototype, "enabled", void 0);
1662
- __decorate([
1663
- serializable(Vector2)
1664
- ], ColorBySpeedModule.prototype, "range", void 0);
1665
- __decorate([
1666
- serializable(MinMaxGradient)
1667
- ], ColorBySpeedModule.prototype, "color", void 0);
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Matrix4, Quaternion, Vector3, Vector2, Euler } from "three";
8
+ import { Mathf } from "../engine/engine_math.js";
9
+ import { serializable } from "../engine/engine_serialization.js";
10
+ import { RGBAColor } from "./js-extensions/RGBAColor.js";
11
+ import { AnimationCurve } from "./AnimationCurve.js";
12
+ import { createNoise4D } from 'simplex-noise';
13
+ import { Gizmos } from "../engine/engine_gizmos.js";
14
+ import { getParam } from "../engine/engine_utils.js";
15
+ const debug = getParam("debugparticles");
16
+ export var ParticleSystemRenderMode;
17
+ (function (ParticleSystemRenderMode) {
18
+ ParticleSystemRenderMode[ParticleSystemRenderMode["Billboard"] = 0] = "Billboard";
19
+ ParticleSystemRenderMode[ParticleSystemRenderMode["Stretch"] = 1] = "Stretch";
20
+ ParticleSystemRenderMode[ParticleSystemRenderMode["HorizontalBillboard"] = 2] = "HorizontalBillboard";
21
+ ParticleSystemRenderMode[ParticleSystemRenderMode["VerticalBillboard"] = 3] = "VerticalBillboard";
22
+ ParticleSystemRenderMode[ParticleSystemRenderMode["Mesh"] = 4] = "Mesh";
23
+ // None = 5,
24
+ })(ParticleSystemRenderMode || (ParticleSystemRenderMode = {}));
25
+ export class Gradient {
26
+ alphaKeys;
27
+ colorKeys;
28
+ get duration() {
29
+ return 1;
30
+ }
31
+ evaluate(time, target) {
32
+ // target.r = this.colorKeys[0].color.r;
33
+ // target.g = this.colorKeys[0].color.g;
34
+ // target.b = this.colorKeys[0].color.b;
35
+ // target.alpha = this.alphaKeys[0].alpha;
36
+ // return;
37
+ let closestAlpha = undefined;
38
+ let closestAlphaIndex = 0;
39
+ let closestColor = null;
40
+ let closestColorIndex = 0;
41
+ for (let i = 0; i < this.alphaKeys.length; i++) {
42
+ const key = this.alphaKeys[i];
43
+ if (key.time < time || !closestAlpha) {
44
+ closestAlpha = key;
45
+ closestAlphaIndex = i;
46
+ }
47
+ }
48
+ for (let i = 0; i < this.colorKeys.length; i++) {
49
+ const key = this.colorKeys[i];
50
+ if (key.time < time || !closestColor) {
51
+ closestColor = key;
52
+ closestColorIndex = i;
53
+ }
54
+ }
55
+ if (closestColor) {
56
+ const hasNextColor = closestColorIndex + 1 < this.colorKeys.length;
57
+ if (hasNextColor) {
58
+ const nextColor = this.colorKeys[closestColorIndex + 1];
59
+ const t = Mathf.remap(time, closestColor.time, nextColor.time, 0, 1);
60
+ target.r = Mathf.lerp(closestColor.color.r, nextColor.color.r, t);
61
+ target.g = Mathf.lerp(closestColor.color.g, nextColor.color.g, t);
62
+ target.b = Mathf.lerp(closestColor.color.b, nextColor.color.b, t);
63
+ }
64
+ else {
65
+ target.r = closestColor.color.r;
66
+ target.g = closestColor.color.g;
67
+ target.b = closestColor.color.b;
68
+ }
69
+ }
70
+ if (closestAlpha) {
71
+ const hasNextAlpha = closestAlphaIndex + 1 < this.alphaKeys.length;
72
+ if (hasNextAlpha) {
73
+ const nextAlpha = this.alphaKeys[closestAlphaIndex + 1];
74
+ const t = Mathf.remap(time, closestAlpha.time, nextAlpha.time, 0, 1);
75
+ target.alpha = Mathf.lerp(closestAlpha.alpha, nextAlpha.alpha, t);
76
+ }
77
+ else {
78
+ target.alpha = closestAlpha.alpha;
79
+ }
80
+ }
81
+ return target;
82
+ }
83
+ }
84
+ __decorate([
85
+ serializable()
86
+ ], Gradient.prototype, "alphaKeys", void 0);
87
+ __decorate([
88
+ serializable()
89
+ ], Gradient.prototype, "colorKeys", void 0);
90
+ export var ParticleSystemCurveMode;
91
+ (function (ParticleSystemCurveMode) {
92
+ ParticleSystemCurveMode[ParticleSystemCurveMode["Constant"] = 0] = "Constant";
93
+ ParticleSystemCurveMode[ParticleSystemCurveMode["Curve"] = 1] = "Curve";
94
+ ParticleSystemCurveMode[ParticleSystemCurveMode["TwoCurves"] = 2] = "TwoCurves";
95
+ ParticleSystemCurveMode[ParticleSystemCurveMode["TwoConstants"] = 3] = "TwoConstants";
96
+ })(ParticleSystemCurveMode || (ParticleSystemCurveMode = {}));
97
+ export var ParticleSystemGradientMode;
98
+ (function (ParticleSystemGradientMode) {
99
+ ParticleSystemGradientMode[ParticleSystemGradientMode["Color"] = 0] = "Color";
100
+ ParticleSystemGradientMode[ParticleSystemGradientMode["Gradient"] = 1] = "Gradient";
101
+ ParticleSystemGradientMode[ParticleSystemGradientMode["TwoColors"] = 2] = "TwoColors";
102
+ ParticleSystemGradientMode[ParticleSystemGradientMode["TwoGradients"] = 3] = "TwoGradients";
103
+ ParticleSystemGradientMode[ParticleSystemGradientMode["RandomColor"] = 4] = "RandomColor";
104
+ })(ParticleSystemGradientMode || (ParticleSystemGradientMode = {}));
105
+ export var ParticleSystemSimulationSpace;
106
+ (function (ParticleSystemSimulationSpace) {
107
+ ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["Local"] = 0] = "Local";
108
+ ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["World"] = 1] = "World";
109
+ ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["Custom"] = 2] = "Custom";
110
+ })(ParticleSystemSimulationSpace || (ParticleSystemSimulationSpace = {}));
111
+ export var ParticleSystemShapeType;
112
+ (function (ParticleSystemShapeType) {
113
+ ParticleSystemShapeType[ParticleSystemShapeType["Sphere"] = 0] = "Sphere";
114
+ ParticleSystemShapeType[ParticleSystemShapeType["SphereShell"] = 1] = "SphereShell";
115
+ ParticleSystemShapeType[ParticleSystemShapeType["Hemisphere"] = 2] = "Hemisphere";
116
+ ParticleSystemShapeType[ParticleSystemShapeType["HemisphereShell"] = 3] = "HemisphereShell";
117
+ ParticleSystemShapeType[ParticleSystemShapeType["Cone"] = 4] = "Cone";
118
+ ParticleSystemShapeType[ParticleSystemShapeType["Box"] = 5] = "Box";
119
+ ParticleSystemShapeType[ParticleSystemShapeType["Mesh"] = 6] = "Mesh";
120
+ ParticleSystemShapeType[ParticleSystemShapeType["ConeShell"] = 7] = "ConeShell";
121
+ ParticleSystemShapeType[ParticleSystemShapeType["ConeVolume"] = 8] = "ConeVolume";
122
+ ParticleSystemShapeType[ParticleSystemShapeType["ConeVolumeShell"] = 9] = "ConeVolumeShell";
123
+ ParticleSystemShapeType[ParticleSystemShapeType["Circle"] = 10] = "Circle";
124
+ ParticleSystemShapeType[ParticleSystemShapeType["CircleEdge"] = 11] = "CircleEdge";
125
+ ParticleSystemShapeType[ParticleSystemShapeType["SingleSidedEdge"] = 12] = "SingleSidedEdge";
126
+ ParticleSystemShapeType[ParticleSystemShapeType["MeshRenderer"] = 13] = "MeshRenderer";
127
+ ParticleSystemShapeType[ParticleSystemShapeType["SkinnedMeshRenderer"] = 14] = "SkinnedMeshRenderer";
128
+ ParticleSystemShapeType[ParticleSystemShapeType["BoxShell"] = 15] = "BoxShell";
129
+ ParticleSystemShapeType[ParticleSystemShapeType["BoxEdge"] = 16] = "BoxEdge";
130
+ ParticleSystemShapeType[ParticleSystemShapeType["Donut"] = 17] = "Donut";
131
+ ParticleSystemShapeType[ParticleSystemShapeType["Rectangle"] = 18] = "Rectangle";
132
+ ParticleSystemShapeType[ParticleSystemShapeType["Sprite"] = 19] = "Sprite";
133
+ ParticleSystemShapeType[ParticleSystemShapeType["SpriteRenderer"] = 20] = "SpriteRenderer";
134
+ })(ParticleSystemShapeType || (ParticleSystemShapeType = {}));
135
+ export var ParticleSystemShapeMultiModeValue;
136
+ (function (ParticleSystemShapeMultiModeValue) {
137
+ ParticleSystemShapeMultiModeValue[ParticleSystemShapeMultiModeValue["Random"] = 0] = "Random";
138
+ ParticleSystemShapeMultiModeValue[ParticleSystemShapeMultiModeValue["Loop"] = 1] = "Loop";
139
+ ParticleSystemShapeMultiModeValue[ParticleSystemShapeMultiModeValue["PingPong"] = 2] = "PingPong";
140
+ ParticleSystemShapeMultiModeValue[ParticleSystemShapeMultiModeValue["BurstSpread"] = 3] = "BurstSpread";
141
+ })(ParticleSystemShapeMultiModeValue || (ParticleSystemShapeMultiModeValue = {}));
142
+ export class MinMaxCurve {
143
+ mode;
144
+ constant;
145
+ constantMin;
146
+ constantMax;
147
+ curve;
148
+ curveMin;
149
+ curveMax;
150
+ curveMultiplier;
151
+ evaluate(t01, lerpFactor) {
152
+ const t = lerpFactor === undefined ? Math.random() : lerpFactor;
153
+ switch (this.mode) {
154
+ case ParticleSystemCurveMode.Constant:
155
+ return this.constant;
156
+ case ParticleSystemCurveMode.Curve:
157
+ t01 = Mathf.clamp01(t01);
158
+ return this.curve.evaluate(t01) * this.curveMultiplier;
159
+ case ParticleSystemCurveMode.TwoCurves:
160
+ const t1 = t01 * this.curveMin.duration;
161
+ const t2 = t01 * this.curveMax.duration;
162
+ return Mathf.lerp(this.curveMin.evaluate(t1), this.curveMax.evaluate(t2), t % 1) * this.curveMultiplier;
163
+ case ParticleSystemCurveMode.TwoConstants:
164
+ return Mathf.lerp(this.constantMin, this.constantMax, t % 1);
165
+ default:
166
+ this.curveMax.evaluate(t01) * this.curveMultiplier;
167
+ break;
168
+ }
169
+ return 0;
170
+ }
171
+ getMax() {
172
+ switch (this.mode) {
173
+ case ParticleSystemCurveMode.Constant:
174
+ return this.constant;
175
+ case ParticleSystemCurveMode.Curve:
176
+ return this.getMaxFromCurve(this.curve) * this.curveMultiplier;
177
+ case ParticleSystemCurveMode.TwoCurves:
178
+ return Math.max(this.getMaxFromCurve(this.curveMin), this.getMaxFromCurve(this.curveMax)) * this.curveMultiplier;
179
+ case ParticleSystemCurveMode.TwoConstants:
180
+ return Math.max(this.constantMin, this.constantMax);
181
+ default:
182
+ return 0;
183
+ }
184
+ }
185
+ getMaxFromCurve(curve) {
186
+ if (!curve)
187
+ return 0;
188
+ let maxNumber = Number.MIN_VALUE;
189
+ for (let i = 0; i < curve.keys.length; i++) {
190
+ const key = curve.keys[i];
191
+ if (key.value > maxNumber) {
192
+ maxNumber = key.value;
193
+ }
194
+ }
195
+ return maxNumber;
196
+ }
197
+ }
198
+ __decorate([
199
+ serializable()
200
+ ], MinMaxCurve.prototype, "mode", void 0);
201
+ __decorate([
202
+ serializable()
203
+ ], MinMaxCurve.prototype, "constant", void 0);
204
+ __decorate([
205
+ serializable()
206
+ ], MinMaxCurve.prototype, "constantMin", void 0);
207
+ __decorate([
208
+ serializable()
209
+ ], MinMaxCurve.prototype, "constantMax", void 0);
210
+ __decorate([
211
+ serializable(AnimationCurve)
212
+ ], MinMaxCurve.prototype, "curve", void 0);
213
+ __decorate([
214
+ serializable(AnimationCurve)
215
+ ], MinMaxCurve.prototype, "curveMin", void 0);
216
+ __decorate([
217
+ serializable(AnimationCurve)
218
+ ], MinMaxCurve.prototype, "curveMax", void 0);
219
+ __decorate([
220
+ serializable()
221
+ ], MinMaxCurve.prototype, "curveMultiplier", void 0);
222
+ export class MinMaxGradient {
223
+ mode;
224
+ color;
225
+ colorMin;
226
+ colorMax;
227
+ gradient;
228
+ gradientMin;
229
+ gradientMax;
230
+ static _temp = new RGBAColor(0, 0, 0, 1);
231
+ static _temp2 = new RGBAColor(0, 0, 0, 1);
232
+ evaluate(t01, lerpFactor) {
233
+ const t = lerpFactor === undefined ? Math.random() : lerpFactor;
234
+ switch (this.mode) {
235
+ case ParticleSystemGradientMode.Color:
236
+ return this.color;
237
+ case ParticleSystemGradientMode.Gradient:
238
+ this.gradient.evaluate(t01, MinMaxGradient._temp);
239
+ return MinMaxGradient._temp;
240
+ case ParticleSystemGradientMode.TwoColors:
241
+ const col1 = MinMaxGradient._temp.lerpColors(this.colorMin, this.colorMax, t);
242
+ return col1;
243
+ case ParticleSystemGradientMode.TwoGradients:
244
+ this.gradientMin.evaluate(t01, MinMaxGradient._temp);
245
+ this.gradientMax.evaluate(t01, MinMaxGradient._temp2);
246
+ return MinMaxGradient._temp.lerp(MinMaxGradient._temp2, t);
247
+ }
248
+ // console.warn("Not implemented", ParticleSystemGradientMode[this.mode]);
249
+ MinMaxGradient._temp.set(0xff00ff);
250
+ MinMaxGradient._temp.alpha = 1;
251
+ return MinMaxGradient._temp;
252
+ }
253
+ }
254
+ __decorate([
255
+ serializable(RGBAColor)
256
+ ], MinMaxGradient.prototype, "color", void 0);
257
+ __decorate([
258
+ serializable(RGBAColor)
259
+ ], MinMaxGradient.prototype, "colorMin", void 0);
260
+ __decorate([
261
+ serializable(RGBAColor)
262
+ ], MinMaxGradient.prototype, "colorMax", void 0);
263
+ __decorate([
264
+ serializable(Gradient)
265
+ ], MinMaxGradient.prototype, "gradient", void 0);
266
+ __decorate([
267
+ serializable(Gradient)
268
+ ], MinMaxGradient.prototype, "gradientMin", void 0);
269
+ __decorate([
270
+ serializable(Gradient)
271
+ ], MinMaxGradient.prototype, "gradientMax", void 0);
272
+ export var ParticleSystemScalingMode;
273
+ (function (ParticleSystemScalingMode) {
274
+ ParticleSystemScalingMode[ParticleSystemScalingMode["Hierarchy"] = 0] = "Hierarchy";
275
+ ParticleSystemScalingMode[ParticleSystemScalingMode["Local"] = 1] = "Local";
276
+ ParticleSystemScalingMode[ParticleSystemScalingMode["Shape"] = 2] = "Shape";
277
+ })(ParticleSystemScalingMode || (ParticleSystemScalingMode = {}));
278
+ export class MainModule {
279
+ cullingMode;
280
+ duration;
281
+ emitterVelocityMode;
282
+ flipRotation;
283
+ gravityModifier;
284
+ gravityModifierMultiplier;
285
+ loop;
286
+ maxParticles;
287
+ playOnAwake;
288
+ prewarm;
289
+ ringBufferLoopRange;
290
+ ringBufferMode;
291
+ scalingMode;
292
+ simulationSpace;
293
+ simulationSpeed;
294
+ startColor;
295
+ startDelay;
296
+ startDelayMultiplier;
297
+ startLifetime;
298
+ startLifetimeMultiplier;
299
+ startRotation;
300
+ startRotationMultiplier;
301
+ startRotation3D;
302
+ startRotationX;
303
+ startRotationXMultiplier;
304
+ startRotationY;
305
+ startRotationYMultiplier;
306
+ startRotationZ;
307
+ startRotationZMultiplier;
308
+ startSize;
309
+ startSize3D;
310
+ startSizeMultiplier;
311
+ startSizeX;
312
+ startSizeXMultiplier;
313
+ startSizeY;
314
+ startSizeYMultiplier;
315
+ startSizeZ;
316
+ startSizeZMultiplier;
317
+ startSpeed;
318
+ startSpeedMultiplier;
319
+ stopAction;
320
+ useUnscaledTime;
321
+ }
322
+ __decorate([
323
+ serializable(MinMaxCurve)
324
+ ], MainModule.prototype, "gravityModifier", void 0);
325
+ __decorate([
326
+ serializable(MinMaxGradient)
327
+ ], MainModule.prototype, "startColor", void 0);
328
+ __decorate([
329
+ serializable(MinMaxCurve)
330
+ ], MainModule.prototype, "startDelay", void 0);
331
+ __decorate([
332
+ serializable(MinMaxCurve)
333
+ ], MainModule.prototype, "startLifetime", void 0);
334
+ __decorate([
335
+ serializable(MinMaxCurve)
336
+ ], MainModule.prototype, "startRotation", void 0);
337
+ __decorate([
338
+ serializable(MinMaxCurve)
339
+ ], MainModule.prototype, "startRotationX", void 0);
340
+ __decorate([
341
+ serializable(MinMaxCurve)
342
+ ], MainModule.prototype, "startRotationY", void 0);
343
+ __decorate([
344
+ serializable(MinMaxCurve)
345
+ ], MainModule.prototype, "startRotationZ", void 0);
346
+ __decorate([
347
+ serializable(MinMaxCurve)
348
+ ], MainModule.prototype, "startSize", void 0);
349
+ __decorate([
350
+ serializable(MinMaxCurve)
351
+ ], MainModule.prototype, "startSizeX", void 0);
352
+ __decorate([
353
+ serializable(MinMaxCurve)
354
+ ], MainModule.prototype, "startSizeY", void 0);
355
+ __decorate([
356
+ serializable(MinMaxCurve)
357
+ ], MainModule.prototype, "startSizeZ", void 0);
358
+ __decorate([
359
+ serializable(MinMaxCurve)
360
+ ], MainModule.prototype, "startSpeed", void 0);
361
+ export class ParticleBurst {
362
+ cycleCount;
363
+ maxCount;
364
+ minCount;
365
+ probability;
366
+ repeatInterval;
367
+ time;
368
+ count;
369
+ _performed = 0;
370
+ reset() {
371
+ this._performed = 0;
372
+ }
373
+ run(time) {
374
+ if (time <= this.time) {
375
+ return 0;
376
+ }
377
+ let amount = 0;
378
+ if (this.cycleCount === 0 || this._performed < this.cycleCount) {
379
+ const nextTime = this.time + this.repeatInterval * this._performed;
380
+ if (time >= nextTime) {
381
+ this._performed += 1;
382
+ if (Math.random() < this.probability) {
383
+ switch (this.count.mode) {
384
+ case ParticleSystemCurveMode.Constant:
385
+ amount = this.count.constant;
386
+ break;
387
+ case ParticleSystemCurveMode.TwoConstants:
388
+ amount = Mathf.lerp(this.count.constantMin, this.count.constantMax, Math.random());
389
+ break;
390
+ case ParticleSystemCurveMode.Curve:
391
+ amount = this.count.curve.evaluate(Math.random());
392
+ break;
393
+ case ParticleSystemCurveMode.TwoCurves:
394
+ const t = Math.random();
395
+ amount = Mathf.lerp(this.count.curveMin.evaluate(t), this.count.curveMax.evaluate(t), Math.random());
396
+ break;
397
+ }
398
+ }
399
+ }
400
+ }
401
+ return amount;
402
+ }
403
+ }
404
+ export class EmissionModule {
405
+ enabled;
406
+ get burstCount() {
407
+ return this.bursts?.length ?? 0;
408
+ }
409
+ bursts;
410
+ rateOverTime;
411
+ rateOverTimeMultiplier;
412
+ rateOverDistance;
413
+ rateOverDistanceMultiplier;
414
+ /** set from system */
415
+ system;
416
+ reset() {
417
+ this.bursts?.forEach(b => b.reset());
418
+ }
419
+ getBurst() {
420
+ let amount = 0;
421
+ if (this.burstCount > 0) {
422
+ for (let i = 0; i < this.burstCount; i++) {
423
+ const burst = this.bursts[i];
424
+ if (this.system.main.loop && burst.time >= this.system.time) {
425
+ burst.reset();
426
+ }
427
+ amount += Math.round(burst.run(this.system.time));
428
+ }
429
+ }
430
+ return amount;
431
+ }
432
+ }
433
+ __decorate([
434
+ serializable()
435
+ ], EmissionModule.prototype, "enabled", void 0);
436
+ __decorate([
437
+ serializable()
438
+ ], EmissionModule.prototype, "bursts", void 0);
439
+ __decorate([
440
+ serializable(MinMaxCurve)
441
+ ], EmissionModule.prototype, "rateOverTime", void 0);
442
+ __decorate([
443
+ serializable()
444
+ ], EmissionModule.prototype, "rateOverTimeMultiplier", void 0);
445
+ __decorate([
446
+ serializable(MinMaxCurve)
447
+ ], EmissionModule.prototype, "rateOverDistance", void 0);
448
+ __decorate([
449
+ serializable()
450
+ ], EmissionModule.prototype, "rateOverDistanceMultiplier", void 0);
451
+ export class ColorOverLifetimeModule {
452
+ enabled;
453
+ color;
454
+ }
455
+ __decorate([
456
+ serializable(MinMaxGradient)
457
+ ], ColorOverLifetimeModule.prototype, "color", void 0);
458
+ export class SizeOverLifetimeModule {
459
+ enabled;
460
+ separateAxes;
461
+ size;
462
+ sizeMultiplier;
463
+ x;
464
+ xMultiplier;
465
+ y;
466
+ yMultiplier;
467
+ z;
468
+ zMultiplier;
469
+ _time = 0;
470
+ _temp = new Vector3();
471
+ evaluate(t01, target, lerpFactor) {
472
+ if (!target)
473
+ target = this._temp;
474
+ if (!this.enabled) {
475
+ target.x = target.y = target.z = 1;
476
+ return target;
477
+ }
478
+ if (!this.separateAxes) {
479
+ const scale = this.size.evaluate(t01, lerpFactor) * this.sizeMultiplier;
480
+ target.x = scale;
481
+ // target.y = scale;
482
+ // target.z = scale;
483
+ }
484
+ else {
485
+ target.x = this.x.evaluate(t01, lerpFactor) * this.xMultiplier;
486
+ target.y = this.y.evaluate(t01, lerpFactor) * this.yMultiplier;
487
+ target.z = this.z.evaluate(t01, lerpFactor) * this.zMultiplier;
488
+ }
489
+ return target;
490
+ }
491
+ }
492
+ __decorate([
493
+ serializable(MinMaxCurve)
494
+ ], SizeOverLifetimeModule.prototype, "size", void 0);
495
+ __decorate([
496
+ serializable(MinMaxCurve)
497
+ ], SizeOverLifetimeModule.prototype, "x", void 0);
498
+ __decorate([
499
+ serializable(MinMaxCurve)
500
+ ], SizeOverLifetimeModule.prototype, "y", void 0);
501
+ __decorate([
502
+ serializable(MinMaxCurve)
503
+ ], SizeOverLifetimeModule.prototype, "z", void 0);
504
+ export class ShapeModule {
505
+ // Emittershape start
506
+ get type() {
507
+ return ParticleSystemShapeType[this.shapeType];
508
+ }
509
+ initialize(particle) {
510
+ this.getPosition();
511
+ particle.position.copy(this._vector);
512
+ }
513
+ toJSON() {
514
+ return this;
515
+ }
516
+ clone() {
517
+ return new ShapeModule();
518
+ }
519
+ // EmitterShape end
520
+ shapeType = ParticleSystemShapeType.Box;
521
+ enabled = true;
522
+ alignToDirection = false;
523
+ angle = 0;
524
+ arc = 360;
525
+ arcSpread;
526
+ arcSpeedMultiplier;
527
+ arcMode;
528
+ boxThickness;
529
+ position;
530
+ rotation;
531
+ _rotation = new Euler();
532
+ scale;
533
+ radius;
534
+ radiusThickness;
535
+ sphericalDirectionAmount;
536
+ randomDirectionAmount;
537
+ randomPositionAmount;
538
+ system;
539
+ _space;
540
+ _worldSpaceMatrix = new Matrix4();
541
+ _worldSpaceMatrixInverse = new Matrix4();
542
+ constructor() {
543
+ if (debug)
544
+ console.log(this);
545
+ }
546
+ update(system, _context, simulationSpace, obj) {
547
+ this.system = system;
548
+ this._space = simulationSpace;
549
+ if (simulationSpace === ParticleSystemSimulationSpace.World) {
550
+ this._worldSpaceMatrix.copy(obj.matrixWorld);
551
+ // set scale to 1
552
+ this._worldSpaceMatrix.elements[0] = 1;
553
+ this._worldSpaceMatrix.elements[5] = 1;
554
+ this._worldSpaceMatrix.elements[10] = 1;
555
+ this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert();
556
+ }
557
+ }
558
+ applyRotation(vector) {
559
+ const isRotated = this.rotation.x !== 0 || this.rotation.y !== 0 || this.rotation.z !== 0;
560
+ if (isRotated) {
561
+ // console.log(this._rotation);
562
+ // TODO: we need to convert this to threejs euler
563
+ this._rotation.x = Mathf.toRadians(this.rotation.x);
564
+ this._rotation.y = Mathf.toRadians(this.rotation.y);
565
+ this._rotation.z = Mathf.toRadians(this.rotation.z);
566
+ this._rotation.order = 'ZYX';
567
+ vector.applyEuler(this._rotation);
568
+ // this._quat.setFromEuler(this._rotation);
569
+ // // this._quat.invert();
570
+ // this._quat.x *= -1;
571
+ // // this._quat.y *= -1;
572
+ // // this._quat.z *= -1;
573
+ // this._quat.w *= -1;
574
+ // vector.applyQuaternion(this._quat);
575
+ }
576
+ return isRotated;
577
+ }
578
+ /** nebula implementations: */
579
+ /** initializer implementation */
580
+ _vector = new Vector3(0, 0, 0);
581
+ _temp = new Vector3(0, 0, 0);
582
+ /** called by nebula on initialize */
583
+ get vector() {
584
+ return this._vector;
585
+ }
586
+ getPosition() {
587
+ this._vector.set(0, 0, 0);
588
+ const pos = this._temp.copy(this.position);
589
+ const isWorldSpace = this._space === ParticleSystemSimulationSpace.World;
590
+ if (isWorldSpace) {
591
+ pos.applyQuaternion(this.system.worldQuaternion);
592
+ }
593
+ let radius = this.radius;
594
+ if (isWorldSpace)
595
+ radius *= this.system.worldScale.x;
596
+ if (this.enabled) {
597
+ switch (this.shapeType) {
598
+ case ParticleSystemShapeType.Box:
599
+ if (debug)
600
+ Gizmos.DrawWireBox(this.position, this.scale, 0xdddddd, 1);
601
+ this._vector.x = Math.random() * this.scale.x - this.scale.x / 2;
602
+ this._vector.y = Math.random() * this.scale.y - this.scale.y / 2;
603
+ this._vector.z = Math.random() * this.scale.z - this.scale.z / 2;
604
+ this._vector.add(pos);
605
+ break;
606
+ case ParticleSystemShapeType.Cone:
607
+ this.randomConePoint(this.position, this.angle, radius, this.radiusThickness, this.arc, this.arcMode, this._vector);
608
+ break;
609
+ case ParticleSystemShapeType.Sphere:
610
+ this.randomSpherePoint(this.position, radius, this.radiusThickness, this.arc, this._vector);
611
+ break;
612
+ case ParticleSystemShapeType.Circle:
613
+ this.randomCirclePoint(this.position, radius, this.radiusThickness, this.arc, this._vector);
614
+ break;
615
+ default:
616
+ this._vector.set(0, 0, 0);
617
+ break;
618
+ // case ParticleSystemShapeType.Hemisphere:
619
+ // randomSpherePoint(this.position.x, this.position.y, this.position.z, this.radius, this.radiusThickness, 180, this._vector);
620
+ // break;
621
+ }
622
+ this.randomizePosition(this._vector, this.randomPositionAmount);
623
+ }
624
+ this.applyRotation(this._vector);
625
+ if (isWorldSpace) {
626
+ this._vector.applyQuaternion(this.system.worldQuaternion);
627
+ this._vector.add(this.system.worldPos);
628
+ }
629
+ if (debug) {
630
+ Gizmos.DrawSphere(this._vector, .03, 0xff0000, .5, true);
631
+ }
632
+ }
633
+ _dir = new Vector3();
634
+ getDirection(pos) {
635
+ if (!this.enabled) {
636
+ this._dir.set(0, 0, 1);
637
+ return this._dir;
638
+ }
639
+ switch (this.shapeType) {
640
+ case ParticleSystemShapeType.Box:
641
+ this._dir.set(0, 0, 1);
642
+ break;
643
+ case ParticleSystemShapeType.Cone:
644
+ this._dir.set(0, 0, 1);
645
+ // apply cone angle
646
+ // this._dir.applyAxisAngle(new Vector3(0, 1, 0), Mathf.toRadians(this.angle));
647
+ break;
648
+ case ParticleSystemShapeType.Circle:
649
+ case ParticleSystemShapeType.Sphere:
650
+ const rx = pos.x;
651
+ const ry = pos.y;
652
+ const rz = pos.z;
653
+ this._dir.set(rx, ry, rz);
654
+ if (this.system?.worldspace)
655
+ this._dir.sub(this.system.worldPos);
656
+ else
657
+ this._dir.sub(this.position);
658
+ break;
659
+ default:
660
+ this._dir.set(0, 0, 1);
661
+ break;
662
+ }
663
+ if (this._space === ParticleSystemSimulationSpace.World) {
664
+ this._dir.applyQuaternion(this.system.worldQuaternion);
665
+ }
666
+ this.applyRotation(this._dir);
667
+ this._dir.normalize();
668
+ this.spherizeDirection(this._dir, this.sphericalDirectionAmount);
669
+ this.randomizeDirection(this._dir, this.randomDirectionAmount);
670
+ if (debug) {
671
+ Gizmos.DrawSphere(pos, .01, 0x883300, .5, true);
672
+ Gizmos.DrawDirection(pos, this._dir, 0x883300, .5, true);
673
+ }
674
+ return this._dir;
675
+ }
676
+ static _randomQuat = new Quaternion();
677
+ static _tempVec = new Vector3();
678
+ randomizePosition(pos, amount) {
679
+ if (amount <= 0)
680
+ return;
681
+ const rp = ShapeModule._tempVec;
682
+ rp.set(Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1);
683
+ rp.x *= amount * this.scale.x;
684
+ rp.y *= amount * this.scale.y;
685
+ rp.z *= amount * this.scale.z;
686
+ pos.add(rp);
687
+ }
688
+ randomizeDirection(direction, amount) {
689
+ if (amount === 0)
690
+ return;
691
+ const randomQuat = ShapeModule._randomQuat;
692
+ const tempVec = ShapeModule._tempVec;
693
+ tempVec.set(Math.random() - .5, Math.random() - .5, Math.random() - .5).normalize();
694
+ randomQuat.setFromAxisAngle(tempVec, amount * Math.random() * Math.PI);
695
+ direction.applyQuaternion(randomQuat);
696
+ }
697
+ spherizeDirection(dir, amount) {
698
+ if (amount === 0)
699
+ return;
700
+ const theta = Math.random() * Math.PI * 2;
701
+ const phi = Math.acos(1 - Math.random() * 2);
702
+ const x = Math.sin(phi) * Math.cos(theta);
703
+ const y = Math.sin(phi) * Math.sin(theta);
704
+ const z = Math.cos(phi);
705
+ const v = new Vector3(x, y, z);
706
+ dir.lerp(v, amount);
707
+ }
708
+ randomSpherePoint(pos, radius, thickness, arc, vec) {
709
+ const u = Math.random();
710
+ const v = Math.random();
711
+ const theta = 2 * Math.PI * u * (arc / 360);
712
+ const phi = Math.acos(2 * v - 1);
713
+ const r = Mathf.lerp(1, 1 - (Math.pow(1 - Math.random(), Math.PI)), thickness) * (radius);
714
+ const x = pos.x + this.scale.x * (-r * Math.sin(phi) * Math.cos(theta));
715
+ const y = pos.y + this.scale.y * (r * Math.sin(phi) * Math.sin(theta));
716
+ const z = pos.z + this.scale.z * (r * Math.cos(phi));
717
+ vec.x = x;
718
+ vec.y = y;
719
+ vec.z = z;
720
+ }
721
+ randomCirclePoint(pos, radius, thickness, arg, vec) {
722
+ const u = Math.random();
723
+ const theta = 2 * Math.PI * u * (arg / 360);
724
+ const r = Mathf.lerp(1, 1 - (Math.pow(1 - Math.random(), Math.PI)), thickness) * (radius);
725
+ const x = pos.x + this.scale.x * r * Math.cos(theta);
726
+ const y = pos.y + this.scale.y * r * Math.sin(theta);
727
+ const z = pos.z;
728
+ vec.x = x;
729
+ vec.y = y;
730
+ vec.z = z;
731
+ }
732
+ _loopTime = 0;
733
+ _loopDirection = 1;
734
+ randomConePoint(pos, _angle, radius, thickness, arc, arcMode, vec) {
735
+ let u = 0;
736
+ let v = 0;
737
+ switch (arcMode) {
738
+ case ParticleSystemShapeMultiModeValue.Random:
739
+ u = Math.random();
740
+ v = Math.random();
741
+ break;
742
+ case ParticleSystemShapeMultiModeValue.PingPong:
743
+ if (this._loopTime > 1)
744
+ this._loopDirection = -1;
745
+ if (this._loopTime < 0)
746
+ this._loopDirection = 1;
747
+ // continue with loop
748
+ case ParticleSystemShapeMultiModeValue.Loop:
749
+ u = .5;
750
+ v = Math.random();
751
+ this._loopTime += this.system.deltaTime * this._loopDirection;
752
+ break;
753
+ }
754
+ let theta = 2 * Math.PI * u * (arc / 360);
755
+ switch (arcMode) {
756
+ case ParticleSystemShapeMultiModeValue.PingPong:
757
+ case ParticleSystemShapeMultiModeValue.Loop:
758
+ theta += Math.PI + .5;
759
+ theta += this._loopTime * Math.PI * 2;
760
+ theta %= Mathf.toRadians(arc);
761
+ break;
762
+ }
763
+ const phi = Math.acos(2 * v - 1);
764
+ const r = Mathf.lerp(1, 1 - (Math.pow(1 - Math.random(), Math.PI)), thickness) * radius;
765
+ const x = pos.x + (-r * Math.sin(phi) * Math.cos(theta));
766
+ const y = pos.y + (r * Math.sin(phi) * Math.sin(theta));
767
+ const z = pos.z;
768
+ vec.x = x * this.scale.x;
769
+ vec.y = y * this.scale.y;
770
+ vec.z = z * this.scale.z;
771
+ }
772
+ }
773
+ __decorate([
774
+ serializable()
775
+ ], ShapeModule.prototype, "shapeType", void 0);
776
+ __decorate([
777
+ serializable()
778
+ ], ShapeModule.prototype, "enabled", void 0);
779
+ __decorate([
780
+ serializable()
781
+ ], ShapeModule.prototype, "alignToDirection", void 0);
782
+ __decorate([
783
+ serializable()
784
+ ], ShapeModule.prototype, "angle", void 0);
785
+ __decorate([
786
+ serializable()
787
+ ], ShapeModule.prototype, "arc", void 0);
788
+ __decorate([
789
+ serializable()
790
+ ], ShapeModule.prototype, "arcSpread", void 0);
791
+ __decorate([
792
+ serializable()
793
+ ], ShapeModule.prototype, "arcSpeedMultiplier", void 0);
794
+ __decorate([
795
+ serializable()
796
+ ], ShapeModule.prototype, "arcMode", void 0);
797
+ __decorate([
798
+ serializable(Vector3)
799
+ ], ShapeModule.prototype, "boxThickness", void 0);
800
+ __decorate([
801
+ serializable(Vector3)
802
+ ], ShapeModule.prototype, "position", void 0);
803
+ __decorate([
804
+ serializable(Vector3)
805
+ ], ShapeModule.prototype, "rotation", void 0);
806
+ __decorate([
807
+ serializable(Vector3)
808
+ ], ShapeModule.prototype, "scale", void 0);
809
+ __decorate([
810
+ serializable()
811
+ ], ShapeModule.prototype, "radius", void 0);
812
+ __decorate([
813
+ serializable()
814
+ ], ShapeModule.prototype, "radiusThickness", void 0);
815
+ __decorate([
816
+ serializable()
817
+ ], ShapeModule.prototype, "sphericalDirectionAmount", void 0);
818
+ __decorate([
819
+ serializable()
820
+ ], ShapeModule.prototype, "randomDirectionAmount", void 0);
821
+ __decorate([
822
+ serializable()
823
+ ], ShapeModule.prototype, "randomPositionAmount", void 0);
824
+ export class NoiseModule {
825
+ damping;
826
+ enabled;
827
+ frequency;
828
+ octaveCount;
829
+ octaveMultiplier;
830
+ octaveScale;
831
+ positionAmount;
832
+ quality;
833
+ remap;
834
+ remapEnabled;
835
+ remapMultiplier;
836
+ remapX;
837
+ remapXMultiplier;
838
+ remapY;
839
+ remapYMultiplier;
840
+ remapZ;
841
+ remapZMultiplier;
842
+ scrollSpeedMultiplier;
843
+ separateAxes;
844
+ strengthMultiplier;
845
+ strengthX;
846
+ strengthXMultiplier;
847
+ strengthY;
848
+ strengthYMultiplier;
849
+ strengthZ;
850
+ strengthZMultiplier;
851
+ _noise;
852
+ _time = 0;
853
+ update(context) {
854
+ this._time += context.time.deltaTime * this.scrollSpeedMultiplier;
855
+ }
856
+ /** nebula implementations: */
857
+ _temp = new Vector3();
858
+ apply(_index, pos, vel, _deltaTime, age, life) {
859
+ if (!this.enabled)
860
+ return;
861
+ if (!this._noise) {
862
+ this._noise = createNoise4D(() => 0);
863
+ }
864
+ const temp = this._temp.set(pos.x, pos.y, pos.z).multiplyScalar(this.frequency);
865
+ const nx = this._noise(temp.x, temp.y, temp.z, this._time);
866
+ const ny = this._noise(temp.x, temp.y, temp.z, this._time + 1000 * this.frequency);
867
+ const nz = this._noise(temp.x, temp.y, temp.z, this._time + 2000 * this.frequency);
868
+ this._temp.set(nx, ny, nz).normalize();
869
+ const t = age / life;
870
+ let strengthFactor = this.positionAmount.evaluate(t);
871
+ if (!this.separateAxes) {
872
+ if (this.strengthX) {
873
+ strengthFactor *= this.strengthX.evaluate(t) * 1.5;
874
+ }
875
+ // strengthFactor *= this.strengthMultiplier;
876
+ // strengthFactor *= deltaTime;
877
+ this._temp.multiplyScalar(strengthFactor);
878
+ }
879
+ else {
880
+ this._temp.x *= strengthFactor * this.strengthXMultiplier;
881
+ this._temp.y *= strengthFactor * this.strengthYMultiplier;
882
+ this._temp.z *= strengthFactor * this.strengthZMultiplier;
883
+ }
884
+ // this._temp.setLength(strengthFactor * deltaTime);
885
+ vel.x += this._temp.x;
886
+ vel.y += this._temp.y;
887
+ vel.z += this._temp.z;
888
+ }
889
+ }
890
+ __decorate([
891
+ serializable()
892
+ ], NoiseModule.prototype, "damping", void 0);
893
+ __decorate([
894
+ serializable()
895
+ ], NoiseModule.prototype, "enabled", void 0);
896
+ __decorate([
897
+ serializable()
898
+ ], NoiseModule.prototype, "frequency", void 0);
899
+ __decorate([
900
+ serializable()
901
+ ], NoiseModule.prototype, "octaveCount", void 0);
902
+ __decorate([
903
+ serializable()
904
+ ], NoiseModule.prototype, "octaveMultiplier", void 0);
905
+ __decorate([
906
+ serializable()
907
+ ], NoiseModule.prototype, "octaveScale", void 0);
908
+ __decorate([
909
+ serializable(MinMaxCurve)
910
+ ], NoiseModule.prototype, "positionAmount", void 0);
911
+ __decorate([
912
+ serializable()
913
+ ], NoiseModule.prototype, "quality", void 0);
914
+ __decorate([
915
+ serializable(MinMaxCurve)
916
+ ], NoiseModule.prototype, "remap", void 0);
917
+ __decorate([
918
+ serializable()
919
+ ], NoiseModule.prototype, "remapEnabled", void 0);
920
+ __decorate([
921
+ serializable()
922
+ ], NoiseModule.prototype, "remapMultiplier", void 0);
923
+ __decorate([
924
+ serializable(MinMaxCurve)
925
+ ], NoiseModule.prototype, "remapX", void 0);
926
+ __decorate([
927
+ serializable()
928
+ ], NoiseModule.prototype, "remapXMultiplier", void 0);
929
+ __decorate([
930
+ serializable(MinMaxCurve)
931
+ ], NoiseModule.prototype, "remapY", void 0);
932
+ __decorate([
933
+ serializable()
934
+ ], NoiseModule.prototype, "remapYMultiplier", void 0);
935
+ __decorate([
936
+ serializable(MinMaxCurve)
937
+ ], NoiseModule.prototype, "remapZ", void 0);
938
+ __decorate([
939
+ serializable()
940
+ ], NoiseModule.prototype, "remapZMultiplier", void 0);
941
+ __decorate([
942
+ serializable()
943
+ ], NoiseModule.prototype, "scrollSpeedMultiplier", void 0);
944
+ __decorate([
945
+ serializable()
946
+ ], NoiseModule.prototype, "separateAxes", void 0);
947
+ __decorate([
948
+ serializable()
949
+ ], NoiseModule.prototype, "strengthMultiplier", void 0);
950
+ __decorate([
951
+ serializable(MinMaxCurve)
952
+ ], NoiseModule.prototype, "strengthX", void 0);
953
+ __decorate([
954
+ serializable()
955
+ ], NoiseModule.prototype, "strengthXMultiplier", void 0);
956
+ __decorate([
957
+ serializable(MinMaxCurve)
958
+ ], NoiseModule.prototype, "strengthY", void 0);
959
+ __decorate([
960
+ serializable()
961
+ ], NoiseModule.prototype, "strengthYMultiplier", void 0);
962
+ __decorate([
963
+ serializable(MinMaxCurve)
964
+ ], NoiseModule.prototype, "strengthZ", void 0);
965
+ __decorate([
966
+ serializable()
967
+ ], NoiseModule.prototype, "strengthZMultiplier", void 0);
968
+ export var ParticleSystemTrailMode;
969
+ (function (ParticleSystemTrailMode) {
970
+ ParticleSystemTrailMode[ParticleSystemTrailMode["PerParticle"] = 0] = "PerParticle";
971
+ ParticleSystemTrailMode[ParticleSystemTrailMode["Ribbon"] = 1] = "Ribbon";
972
+ })(ParticleSystemTrailMode || (ParticleSystemTrailMode = {}));
973
+ export var ParticleSystemTrailTextureMode;
974
+ (function (ParticleSystemTrailTextureMode) {
975
+ ParticleSystemTrailTextureMode[ParticleSystemTrailTextureMode["Stretch"] = 0] = "Stretch";
976
+ ParticleSystemTrailTextureMode[ParticleSystemTrailTextureMode["Tile"] = 1] = "Tile";
977
+ ParticleSystemTrailTextureMode[ParticleSystemTrailTextureMode["DistributePerSegment"] = 2] = "DistributePerSegment";
978
+ ParticleSystemTrailTextureMode[ParticleSystemTrailTextureMode["RepeatPerSegment"] = 3] = "RepeatPerSegment";
979
+ })(ParticleSystemTrailTextureMode || (ParticleSystemTrailTextureMode = {}));
980
+ export class TrailModule {
981
+ enabled;
982
+ attachRibbonToTransform = false;
983
+ colorOverLifetime;
984
+ colorOverTrail;
985
+ dieWithParticles = true;
986
+ inheritParticleColor = true;
987
+ lifetime;
988
+ lifetimeMultiplier;
989
+ minVertexDistance = .2;
990
+ mode = ParticleSystemTrailMode.PerParticle;
991
+ ratio = 1;
992
+ ribbonCount = 1;
993
+ shadowBias = 0;
994
+ sizeAffectsLifetime = false;
995
+ sizeAffectsWidth = false;
996
+ splitSubEmitterRibbons = false;
997
+ textureMode = ParticleSystemTrailTextureMode.Stretch;
998
+ widthOverTrail;
999
+ widthOverTrailMultiplier;
1000
+ worldSpace = false;
1001
+ getWidth(size, _life01, pos01, t) {
1002
+ const res = this.widthOverTrail.evaluate(pos01, t);
1003
+ size *= res;
1004
+ return size;
1005
+ }
1006
+ getColor(color, life01, pos01) {
1007
+ const overTrail = this.colorOverTrail.evaluate(pos01);
1008
+ const overLife = this.colorOverLifetime.evaluate(life01);
1009
+ color.x *= overTrail.r * overLife.r;
1010
+ color.y *= overTrail.g * overLife.g;
1011
+ color.z *= overTrail.b * overLife.b;
1012
+ color.w *= overTrail.alpha * overLife.alpha;
1013
+ }
1014
+ }
1015
+ __decorate([
1016
+ serializable()
1017
+ ], TrailModule.prototype, "enabled", void 0);
1018
+ __decorate([
1019
+ serializable()
1020
+ ], TrailModule.prototype, "attachRibbonToTransform", void 0);
1021
+ __decorate([
1022
+ serializable(MinMaxGradient)
1023
+ ], TrailModule.prototype, "colorOverLifetime", void 0);
1024
+ __decorate([
1025
+ serializable(MinMaxGradient)
1026
+ ], TrailModule.prototype, "colorOverTrail", void 0);
1027
+ __decorate([
1028
+ serializable()
1029
+ ], TrailModule.prototype, "dieWithParticles", void 0);
1030
+ __decorate([
1031
+ serializable()
1032
+ ], TrailModule.prototype, "inheritParticleColor", void 0);
1033
+ __decorate([
1034
+ serializable(MinMaxCurve)
1035
+ ], TrailModule.prototype, "lifetime", void 0);
1036
+ __decorate([
1037
+ serializable()
1038
+ ], TrailModule.prototype, "lifetimeMultiplier", void 0);
1039
+ __decorate([
1040
+ serializable()
1041
+ ], TrailModule.prototype, "minVertexDistance", void 0);
1042
+ __decorate([
1043
+ serializable()
1044
+ ], TrailModule.prototype, "mode", void 0);
1045
+ __decorate([
1046
+ serializable()
1047
+ ], TrailModule.prototype, "ratio", void 0);
1048
+ __decorate([
1049
+ serializable()
1050
+ ], TrailModule.prototype, "ribbonCount", void 0);
1051
+ __decorate([
1052
+ serializable()
1053
+ ], TrailModule.prototype, "shadowBias", void 0);
1054
+ __decorate([
1055
+ serializable()
1056
+ ], TrailModule.prototype, "sizeAffectsLifetime", void 0);
1057
+ __decorate([
1058
+ serializable()
1059
+ ], TrailModule.prototype, "sizeAffectsWidth", void 0);
1060
+ __decorate([
1061
+ serializable()
1062
+ ], TrailModule.prototype, "splitSubEmitterRibbons", void 0);
1063
+ __decorate([
1064
+ serializable()
1065
+ ], TrailModule.prototype, "textureMode", void 0);
1066
+ __decorate([
1067
+ serializable(MinMaxCurve)
1068
+ ], TrailModule.prototype, "widthOverTrail", void 0);
1069
+ __decorate([
1070
+ serializable()
1071
+ ], TrailModule.prototype, "widthOverTrailMultiplier", void 0);
1072
+ __decorate([
1073
+ serializable()
1074
+ ], TrailModule.prototype, "worldSpace", void 0);
1075
+ export class VelocityOverLifetimeModule {
1076
+ enabled;
1077
+ space = ParticleSystemSimulationSpace.Local;
1078
+ orbitalX;
1079
+ orbitalY;
1080
+ orbitalZ;
1081
+ orbitalXMultiplier;
1082
+ orbitalYMultiplier;
1083
+ orbitalZMultiplier;
1084
+ orbitalOffsetX;
1085
+ orbitalOffsetY;
1086
+ orbitalOffsetZ;
1087
+ speedModifier;
1088
+ speedModifierMultiplier;
1089
+ x;
1090
+ xMultiplier;
1091
+ y;
1092
+ yMultiplier;
1093
+ z;
1094
+ zMultiplier;
1095
+ _system;
1096
+ // private _worldRotation: Quaternion = new Quaternion();
1097
+ update(system) {
1098
+ this._system = system;
1099
+ }
1100
+ _temp = new Vector3();
1101
+ _temp2 = new Vector3();
1102
+ _temp3 = new Vector3();
1103
+ _hasOrbital = false;
1104
+ _index = 0;
1105
+ _orbitalMatrix = new Matrix4();
1106
+ init(particle) {
1107
+ if (this._index == 0)
1108
+ particle["debug"] = true;
1109
+ this._index += 1;
1110
+ particle["orbitx"] = this.orbitalX.evaluate(Math.random());
1111
+ particle["orbity"] = this.orbitalY.evaluate(Math.random());
1112
+ particle["orbitz"] = this.orbitalZ.evaluate(Math.random());
1113
+ // console.log(particle["orbitx"], particle["orbity"], particle["orbitz"])
1114
+ this._hasOrbital = particle["orbitx"] != 0 || particle["orbity"] != 0 || particle["orbitz"] != 0;
1115
+ }
1116
+ apply(_particle, _index, _pos, vel, _dt, age, life) {
1117
+ if (!this.enabled)
1118
+ return;
1119
+ const t = age / life;
1120
+ const speed = this.speedModifier.evaluate(t) * this.speedModifierMultiplier;
1121
+ const x = this.x.evaluate(t);
1122
+ const y = this.y.evaluate(t);
1123
+ const z = this.z.evaluate(t);
1124
+ this._temp.set(-x, y, z);
1125
+ if (this._system) {
1126
+ // if (this.space === ParticleSystemSimulationSpace.World) {
1127
+ // this._temp.applyQuaternion(this._system.worldQuaternionInverted);
1128
+ // }
1129
+ if (this._system.main.simulationSpace === ParticleSystemSimulationSpace.World) {
1130
+ this._temp.applyQuaternion(this._system.worldQuaternion);
1131
+ }
1132
+ }
1133
+ if (this._hasOrbital) {
1134
+ const position = this._system?.worldPos;
1135
+ if (position) {
1136
+ // TODO: we absolutely need to fix this, this is a hack for a specific usecase and doesnt work yet correctly
1137
+ // https://github.com/needle-tools/needle-tiny/issues/710
1138
+ const pos = this._temp2.set(_pos.x, _pos.y, _pos.z);
1139
+ const ox = this.orbitalXMultiplier; // particle["orbitx"];
1140
+ const oy = this.orbitalYMultiplier; // particle["orbity"];
1141
+ const oz = this.orbitalZMultiplier; // particle["orbitz"];
1142
+ const angle = speed * Math.PI * 2 * 10; // < Oh god
1143
+ const cosX = Math.cos(angle * ox);
1144
+ const sinX = Math.sin(angle * ox);
1145
+ const cosY = Math.cos(angle * oy);
1146
+ const sinY = Math.sin(angle * oy);
1147
+ const cosZ = Math.cos(angle * oz);
1148
+ const sinZ = Math.sin(angle * oz);
1149
+ const newX = pos.x * (cosY * cosZ) + pos.y * (cosY * sinZ) + pos.z * (-sinY);
1150
+ const newY = pos.x * (sinX * sinY * cosZ - cosX * sinZ) + pos.y * (sinX * sinY * sinZ + cosX * cosZ) + pos.z * (sinX * cosY);
1151
+ const newZ = pos.x * (cosX * sinY * cosZ + sinX * sinZ) + pos.y * (cosX * sinY * sinZ - sinX * cosZ) + pos.z * (cosX * cosY);
1152
+ // pos.x += this.orbitalOffsetX;
1153
+ // pos.y += this.orbitalOffsetY;
1154
+ // pos.z += this.orbitalOffsetZ;
1155
+ const v = this._temp3.set(pos.x - newX, pos.y - newY, pos.z - newZ);
1156
+ v.normalize();
1157
+ v.multiplyScalar(.2 / _dt * (Math.max(this.orbitalXMultiplier, this.orbitalYMultiplier, this.orbitalZMultiplier)));
1158
+ vel.x += v.x;
1159
+ vel.y += v.y;
1160
+ vel.z += v.z;
1161
+ }
1162
+ }
1163
+ vel.x += this._temp.x;
1164
+ vel.y += this._temp.y;
1165
+ vel.z += this._temp.z;
1166
+ vel.x *= speed;
1167
+ vel.y *= speed;
1168
+ vel.z *= speed;
1169
+ }
1170
+ }
1171
+ __decorate([
1172
+ serializable()
1173
+ ], VelocityOverLifetimeModule.prototype, "enabled", void 0);
1174
+ __decorate([
1175
+ serializable()
1176
+ ], VelocityOverLifetimeModule.prototype, "space", void 0);
1177
+ __decorate([
1178
+ serializable(MinMaxCurve)
1179
+ ], VelocityOverLifetimeModule.prototype, "orbitalX", void 0);
1180
+ __decorate([
1181
+ serializable(MinMaxCurve)
1182
+ ], VelocityOverLifetimeModule.prototype, "orbitalY", void 0);
1183
+ __decorate([
1184
+ serializable(MinMaxCurve)
1185
+ ], VelocityOverLifetimeModule.prototype, "orbitalZ", void 0);
1186
+ __decorate([
1187
+ serializable()
1188
+ ], VelocityOverLifetimeModule.prototype, "orbitalXMultiplier", void 0);
1189
+ __decorate([
1190
+ serializable()
1191
+ ], VelocityOverLifetimeModule.prototype, "orbitalYMultiplier", void 0);
1192
+ __decorate([
1193
+ serializable()
1194
+ ], VelocityOverLifetimeModule.prototype, "orbitalZMultiplier", void 0);
1195
+ __decorate([
1196
+ serializable()
1197
+ ], VelocityOverLifetimeModule.prototype, "orbitalOffsetX", void 0);
1198
+ __decorate([
1199
+ serializable()
1200
+ ], VelocityOverLifetimeModule.prototype, "orbitalOffsetY", void 0);
1201
+ __decorate([
1202
+ serializable()
1203
+ ], VelocityOverLifetimeModule.prototype, "orbitalOffsetZ", void 0);
1204
+ __decorate([
1205
+ serializable(MinMaxCurve)
1206
+ ], VelocityOverLifetimeModule.prototype, "speedModifier", void 0);
1207
+ __decorate([
1208
+ serializable()
1209
+ ], VelocityOverLifetimeModule.prototype, "speedModifierMultiplier", void 0);
1210
+ __decorate([
1211
+ serializable(MinMaxCurve)
1212
+ ], VelocityOverLifetimeModule.prototype, "x", void 0);
1213
+ __decorate([
1214
+ serializable()
1215
+ ], VelocityOverLifetimeModule.prototype, "xMultiplier", void 0);
1216
+ __decorate([
1217
+ serializable(MinMaxCurve)
1218
+ ], VelocityOverLifetimeModule.prototype, "y", void 0);
1219
+ __decorate([
1220
+ serializable()
1221
+ ], VelocityOverLifetimeModule.prototype, "yMultiplier", void 0);
1222
+ __decorate([
1223
+ serializable(MinMaxCurve)
1224
+ ], VelocityOverLifetimeModule.prototype, "z", void 0);
1225
+ __decorate([
1226
+ serializable()
1227
+ ], VelocityOverLifetimeModule.prototype, "zMultiplier", void 0);
1228
+ var ParticleSystemAnimationTimeMode;
1229
+ (function (ParticleSystemAnimationTimeMode) {
1230
+ ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["Lifetime"] = 0] = "Lifetime";
1231
+ ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["Speed"] = 1] = "Speed";
1232
+ ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["FPS"] = 2] = "FPS";
1233
+ })(ParticleSystemAnimationTimeMode || (ParticleSystemAnimationTimeMode = {}));
1234
+ var ParticleSystemAnimationMode;
1235
+ (function (ParticleSystemAnimationMode) {
1236
+ ParticleSystemAnimationMode[ParticleSystemAnimationMode["Grid"] = 0] = "Grid";
1237
+ ParticleSystemAnimationMode[ParticleSystemAnimationMode["Sprites"] = 1] = "Sprites";
1238
+ })(ParticleSystemAnimationMode || (ParticleSystemAnimationMode = {}));
1239
+ var ParticleSystemAnimationRowMode;
1240
+ (function (ParticleSystemAnimationRowMode) {
1241
+ ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["Custom"] = 0] = "Custom";
1242
+ ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["Random"] = 1] = "Random";
1243
+ ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["MeshIndex"] = 2] = "MeshIndex";
1244
+ })(ParticleSystemAnimationRowMode || (ParticleSystemAnimationRowMode = {}));
1245
+ var ParticleSystemAnimationType;
1246
+ (function (ParticleSystemAnimationType) {
1247
+ ParticleSystemAnimationType[ParticleSystemAnimationType["WholeSheet"] = 0] = "WholeSheet";
1248
+ ParticleSystemAnimationType[ParticleSystemAnimationType["SingleRow"] = 1] = "SingleRow";
1249
+ })(ParticleSystemAnimationType || (ParticleSystemAnimationType = {}));
1250
+ export class TextureSheetAnimationModule {
1251
+ animation;
1252
+ enabled;
1253
+ cycleCount;
1254
+ frameOverTime;
1255
+ frameOverTimeMultiplier;
1256
+ numTilesX;
1257
+ numTilesY;
1258
+ startFrame;
1259
+ startFrameMultiplier;
1260
+ rowMode;
1261
+ rowIndex;
1262
+ spriteCount;
1263
+ timeMode;
1264
+ sampleOnceAtStart() {
1265
+ if (this.timeMode === ParticleSystemAnimationTimeMode.Lifetime) {
1266
+ switch (this.frameOverTime.mode) {
1267
+ case ParticleSystemCurveMode.Constant:
1268
+ case ParticleSystemCurveMode.TwoConstants:
1269
+ case ParticleSystemCurveMode.TwoCurves:
1270
+ case ParticleSystemCurveMode.Curve:
1271
+ return true;
1272
+ }
1273
+ }
1274
+ return false;
1275
+ }
1276
+ getStartIndex() {
1277
+ if (this.sampleOnceAtStart()) {
1278
+ const start = Math.random();
1279
+ return start * (this.numTilesX * this.numTilesY);
1280
+ }
1281
+ return 0;
1282
+ }
1283
+ evaluate(t01) {
1284
+ if (this.sampleOnceAtStart()) {
1285
+ return undefined;
1286
+ }
1287
+ return this.getIndex(t01);
1288
+ }
1289
+ getIndex(t01) {
1290
+ const tiles = this.numTilesX * this.numTilesY;
1291
+ t01 = t01 * this.cycleCount;
1292
+ let index = this.frameOverTime.evaluate(t01 % 1);
1293
+ index *= this.frameOverTimeMultiplier;
1294
+ index *= tiles;
1295
+ index = index % tiles;
1296
+ index = Math.floor(index);
1297
+ return index;
1298
+ }
1299
+ }
1300
+ __decorate([
1301
+ serializable()
1302
+ ], TextureSheetAnimationModule.prototype, "animation", void 0);
1303
+ __decorate([
1304
+ serializable()
1305
+ ], TextureSheetAnimationModule.prototype, "enabled", void 0);
1306
+ __decorate([
1307
+ serializable()
1308
+ ], TextureSheetAnimationModule.prototype, "cycleCount", void 0);
1309
+ __decorate([
1310
+ serializable(MinMaxCurve)
1311
+ ], TextureSheetAnimationModule.prototype, "frameOverTime", void 0);
1312
+ __decorate([
1313
+ serializable()
1314
+ ], TextureSheetAnimationModule.prototype, "frameOverTimeMultiplier", void 0);
1315
+ __decorate([
1316
+ serializable()
1317
+ ], TextureSheetAnimationModule.prototype, "numTilesX", void 0);
1318
+ __decorate([
1319
+ serializable()
1320
+ ], TextureSheetAnimationModule.prototype, "numTilesY", void 0);
1321
+ __decorate([
1322
+ serializable(MinMaxCurve)
1323
+ ], TextureSheetAnimationModule.prototype, "startFrame", void 0);
1324
+ __decorate([
1325
+ serializable()
1326
+ ], TextureSheetAnimationModule.prototype, "startFrameMultiplier", void 0);
1327
+ __decorate([
1328
+ serializable()
1329
+ ], TextureSheetAnimationModule.prototype, "rowMode", void 0);
1330
+ __decorate([
1331
+ serializable()
1332
+ ], TextureSheetAnimationModule.prototype, "rowIndex", void 0);
1333
+ __decorate([
1334
+ serializable()
1335
+ ], TextureSheetAnimationModule.prototype, "spriteCount", void 0);
1336
+ __decorate([
1337
+ serializable()
1338
+ ], TextureSheetAnimationModule.prototype, "timeMode", void 0);
1339
+ export class RotationOverLifetimeModule {
1340
+ enabled;
1341
+ separateAxes;
1342
+ x;
1343
+ xMultiplier;
1344
+ y;
1345
+ yMultiplier;
1346
+ z;
1347
+ zMultiplier;
1348
+ evaluate(t01, t) {
1349
+ if (!this.enabled)
1350
+ return 0;
1351
+ if (!this.separateAxes) {
1352
+ const rot = this.z.evaluate(t01, t) * -1;
1353
+ return rot;
1354
+ }
1355
+ return 0;
1356
+ }
1357
+ }
1358
+ __decorate([
1359
+ serializable()
1360
+ ], RotationOverLifetimeModule.prototype, "enabled", void 0);
1361
+ __decorate([
1362
+ serializable()
1363
+ ], RotationOverLifetimeModule.prototype, "separateAxes", void 0);
1364
+ __decorate([
1365
+ serializable(MinMaxCurve)
1366
+ ], RotationOverLifetimeModule.prototype, "x", void 0);
1367
+ __decorate([
1368
+ serializable()
1369
+ ], RotationOverLifetimeModule.prototype, "xMultiplier", void 0);
1370
+ __decorate([
1371
+ serializable(MinMaxCurve)
1372
+ ], RotationOverLifetimeModule.prototype, "y", void 0);
1373
+ __decorate([
1374
+ serializable()
1375
+ ], RotationOverLifetimeModule.prototype, "yMultiplier", void 0);
1376
+ __decorate([
1377
+ serializable(MinMaxCurve)
1378
+ ], RotationOverLifetimeModule.prototype, "z", void 0);
1379
+ __decorate([
1380
+ serializable()
1381
+ ], RotationOverLifetimeModule.prototype, "zMultiplier", void 0);
1382
+ export class RotationBySpeedModule {
1383
+ enabled;
1384
+ range;
1385
+ separateAxes;
1386
+ x;
1387
+ xMultiplier;
1388
+ y;
1389
+ yMultiplier;
1390
+ z;
1391
+ zMultiplier;
1392
+ evaluate(_t01, speed) {
1393
+ if (!this.enabled)
1394
+ return 0;
1395
+ if (!this.separateAxes) {
1396
+ const t = Mathf.lerp(this.range.x, this.range.y, speed);
1397
+ const rot = this.z.evaluate(t) * -1;
1398
+ return rot;
1399
+ }
1400
+ return 0;
1401
+ }
1402
+ }
1403
+ __decorate([
1404
+ serializable()
1405
+ ], RotationBySpeedModule.prototype, "enabled", void 0);
1406
+ __decorate([
1407
+ serializable()
1408
+ ], RotationBySpeedModule.prototype, "range", void 0);
1409
+ __decorate([
1410
+ serializable()
1411
+ ], RotationBySpeedModule.prototype, "separateAxes", void 0);
1412
+ __decorate([
1413
+ serializable(MinMaxCurve)
1414
+ ], RotationBySpeedModule.prototype, "x", void 0);
1415
+ __decorate([
1416
+ serializable()
1417
+ ], RotationBySpeedModule.prototype, "xMultiplier", void 0);
1418
+ __decorate([
1419
+ serializable(MinMaxCurve)
1420
+ ], RotationBySpeedModule.prototype, "y", void 0);
1421
+ __decorate([
1422
+ serializable()
1423
+ ], RotationBySpeedModule.prototype, "yMultiplier", void 0);
1424
+ __decorate([
1425
+ serializable(MinMaxCurve)
1426
+ ], RotationBySpeedModule.prototype, "z", void 0);
1427
+ __decorate([
1428
+ serializable()
1429
+ ], RotationBySpeedModule.prototype, "zMultiplier", void 0);
1430
+ export class LimitVelocityOverLifetimeModule {
1431
+ enabled;
1432
+ dampen;
1433
+ drag;
1434
+ dragMultiplier;
1435
+ limit;
1436
+ limitMultiplier;
1437
+ separateAxes;
1438
+ limitX;
1439
+ limitXMultiplier;
1440
+ limitY;
1441
+ limitYMultiplier;
1442
+ limitZ;
1443
+ limitZMultiplier;
1444
+ multiplyDragByParticleSize = false;
1445
+ multiplyDragByParticleVelocity = false;
1446
+ space;
1447
+ _temp = new Vector3();
1448
+ _temp2 = new Vector3();
1449
+ apply(_position, baseVelocity, currentVelocity, _size, t01, _dt, _scale) {
1450
+ if (!this.enabled)
1451
+ return;
1452
+ // if (this.separateAxes) {
1453
+ // // const maxX = this.limitX.evaluate(t01) * this.limitXMultiplier;
1454
+ // // const maxY = this.limitY.evaluate(t01) * this.limitYMultiplier;
1455
+ // // const maxZ = this.limitZ.evaluate(t01) * this.limitZMultiplier;
1456
+ // }
1457
+ // else
1458
+ {
1459
+ const max = this.limit.evaluate(t01) * this.limitMultiplier;
1460
+ const speed = baseVelocity.length();
1461
+ if (speed > max) {
1462
+ this._temp.copy(baseVelocity).normalize().multiplyScalar(max);
1463
+ const t = this.dampen * .5;
1464
+ // t *= scale;
1465
+ baseVelocity.x = Mathf.lerp(baseVelocity.x, this._temp.x, t);
1466
+ baseVelocity.y = Mathf.lerp(baseVelocity.y, this._temp.y, t);
1467
+ baseVelocity.z = Mathf.lerp(baseVelocity.z, this._temp.z, t);
1468
+ // this._temp2.set(0, 0, 0);
1469
+ currentVelocity.x = Mathf.lerp(currentVelocity.x, this._temp.x, t);
1470
+ currentVelocity.y = Mathf.lerp(currentVelocity.y, this._temp.y, t);
1471
+ currentVelocity.z = Mathf.lerp(currentVelocity.z, this._temp.z, t);
1472
+ }
1473
+ // vel.multiplyScalar(dragFactor);
1474
+ }
1475
+ // vel.x *= 0.3;
1476
+ // vel.y *= 0.3;
1477
+ // vel.z *= 0.3;
1478
+ }
1479
+ }
1480
+ __decorate([
1481
+ serializable()
1482
+ ], LimitVelocityOverLifetimeModule.prototype, "enabled", void 0);
1483
+ __decorate([
1484
+ serializable()
1485
+ ], LimitVelocityOverLifetimeModule.prototype, "dampen", void 0);
1486
+ __decorate([
1487
+ serializable(MinMaxCurve)
1488
+ ], LimitVelocityOverLifetimeModule.prototype, "drag", void 0);
1489
+ __decorate([
1490
+ serializable()
1491
+ ], LimitVelocityOverLifetimeModule.prototype, "dragMultiplier", void 0);
1492
+ __decorate([
1493
+ serializable(MinMaxCurve)
1494
+ ], LimitVelocityOverLifetimeModule.prototype, "limit", void 0);
1495
+ __decorate([
1496
+ serializable()
1497
+ ], LimitVelocityOverLifetimeModule.prototype, "limitMultiplier", void 0);
1498
+ __decorate([
1499
+ serializable()
1500
+ ], LimitVelocityOverLifetimeModule.prototype, "separateAxes", void 0);
1501
+ __decorate([
1502
+ serializable(MinMaxCurve)
1503
+ ], LimitVelocityOverLifetimeModule.prototype, "limitX", void 0);
1504
+ __decorate([
1505
+ serializable()
1506
+ ], LimitVelocityOverLifetimeModule.prototype, "limitXMultiplier", void 0);
1507
+ __decorate([
1508
+ serializable(MinMaxCurve)
1509
+ ], LimitVelocityOverLifetimeModule.prototype, "limitY", void 0);
1510
+ __decorate([
1511
+ serializable()
1512
+ ], LimitVelocityOverLifetimeModule.prototype, "limitYMultiplier", void 0);
1513
+ __decorate([
1514
+ serializable(MinMaxCurve)
1515
+ ], LimitVelocityOverLifetimeModule.prototype, "limitZ", void 0);
1516
+ __decorate([
1517
+ serializable()
1518
+ ], LimitVelocityOverLifetimeModule.prototype, "limitZMultiplier", void 0);
1519
+ __decorate([
1520
+ serializable()
1521
+ ], LimitVelocityOverLifetimeModule.prototype, "multiplyDragByParticleSize", void 0);
1522
+ __decorate([
1523
+ serializable()
1524
+ ], LimitVelocityOverLifetimeModule.prototype, "multiplyDragByParticleVelocity", void 0);
1525
+ __decorate([
1526
+ serializable()
1527
+ ], LimitVelocityOverLifetimeModule.prototype, "space", void 0);
1528
+ export var ParticleSystemInheritVelocityMode;
1529
+ (function (ParticleSystemInheritVelocityMode) {
1530
+ ParticleSystemInheritVelocityMode[ParticleSystemInheritVelocityMode["Initial"] = 0] = "Initial";
1531
+ ParticleSystemInheritVelocityMode[ParticleSystemInheritVelocityMode["Current"] = 1] = "Current";
1532
+ })(ParticleSystemInheritVelocityMode || (ParticleSystemInheritVelocityMode = {}));
1533
+ export class InheritVelocityModule {
1534
+ enabled;
1535
+ curve;
1536
+ curveMultiplier;
1537
+ mode;
1538
+ system;
1539
+ _lastWorldPosition;
1540
+ _velocity = new Vector3();
1541
+ _temp = new Vector3();
1542
+ update(_context) {
1543
+ if (!this.enabled)
1544
+ return;
1545
+ if (this.system.worldspace === false)
1546
+ return;
1547
+ if (this._lastWorldPosition) {
1548
+ this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1 / this.system.deltaTime);
1549
+ this._lastWorldPosition.copy(this.system.worldPos);
1550
+ }
1551
+ else {
1552
+ this._velocity.set(0, 0, 0);
1553
+ this._lastWorldPosition = this.system.worldPos.clone();
1554
+ }
1555
+ }
1556
+ // TODO: make work for subsystems
1557
+ applyInitial(vel) {
1558
+ if (!this.enabled)
1559
+ return;
1560
+ if (this.system.worldspace === false)
1561
+ return;
1562
+ if (this.mode === ParticleSystemInheritVelocityMode.Initial) {
1563
+ const factor = this.curve.evaluate(Math.random(), Math.random());
1564
+ this._temp.copy(this._velocity).multiplyScalar(factor);
1565
+ vel.add(this._temp);
1566
+ }
1567
+ }
1568
+ applyCurrent(vel, t01, lerpFactor) {
1569
+ if (!this.enabled)
1570
+ return;
1571
+ if (this.system.worldspace === false)
1572
+ return;
1573
+ if (this.mode === ParticleSystemInheritVelocityMode.Current) {
1574
+ const factor = this.curve.evaluate(t01, lerpFactor);
1575
+ this._temp.copy(this._velocity).multiplyScalar(factor);
1576
+ vel.add(this._temp);
1577
+ }
1578
+ }
1579
+ }
1580
+ __decorate([
1581
+ serializable()
1582
+ ], InheritVelocityModule.prototype, "enabled", void 0);
1583
+ __decorate([
1584
+ serializable(MinMaxCurve)
1585
+ ], InheritVelocityModule.prototype, "curve", void 0);
1586
+ __decorate([
1587
+ serializable()
1588
+ ], InheritVelocityModule.prototype, "curveMultiplier", void 0);
1589
+ __decorate([
1590
+ serializable()
1591
+ ], InheritVelocityModule.prototype, "mode", void 0);
1592
+ export class SizeBySpeedModule {
1593
+ enabled;
1594
+ range;
1595
+ separateAxes;
1596
+ size;
1597
+ sizeMultiplier;
1598
+ x;
1599
+ xMultiplier;
1600
+ y;
1601
+ yMultiplier;
1602
+ z;
1603
+ zMultiplier;
1604
+ evaluate(vel, _t01, lerpFactor, size) {
1605
+ const speed = vel.length();
1606
+ const x = Mathf.remap(speed, this.range.x, this.range.y, 0, 1);
1607
+ const factor = this.size.evaluate(x, lerpFactor);
1608
+ // return size;
1609
+ return size * factor;
1610
+ }
1611
+ }
1612
+ __decorate([
1613
+ serializable()
1614
+ ], SizeBySpeedModule.prototype, "enabled", void 0);
1615
+ __decorate([
1616
+ serializable(Vector2)
1617
+ ], SizeBySpeedModule.prototype, "range", void 0);
1618
+ __decorate([
1619
+ serializable()
1620
+ ], SizeBySpeedModule.prototype, "separateAxes", void 0);
1621
+ __decorate([
1622
+ serializable(MinMaxCurve)
1623
+ ], SizeBySpeedModule.prototype, "size", void 0);
1624
+ __decorate([
1625
+ serializable()
1626
+ ], SizeBySpeedModule.prototype, "sizeMultiplier", void 0);
1627
+ __decorate([
1628
+ serializable(MinMaxCurve)
1629
+ ], SizeBySpeedModule.prototype, "x", void 0);
1630
+ __decorate([
1631
+ serializable()
1632
+ ], SizeBySpeedModule.prototype, "xMultiplier", void 0);
1633
+ __decorate([
1634
+ serializable(MinMaxCurve)
1635
+ ], SizeBySpeedModule.prototype, "y", void 0);
1636
+ __decorate([
1637
+ serializable()
1638
+ ], SizeBySpeedModule.prototype, "yMultiplier", void 0);
1639
+ __decorate([
1640
+ serializable(MinMaxCurve)
1641
+ ], SizeBySpeedModule.prototype, "z", void 0);
1642
+ __decorate([
1643
+ serializable()
1644
+ ], SizeBySpeedModule.prototype, "zMultiplier", void 0);
1645
+ export class ColorBySpeedModule {
1646
+ enabled;
1647
+ range;
1648
+ color;
1649
+ evaluate(vel, lerpFactor, color) {
1650
+ const speed = vel.length();
1651
+ const x = Mathf.remap(speed, this.range.x, this.range.y, 0, 1);
1652
+ const res = this.color.evaluate(x, lerpFactor);
1653
+ color.x *= res.r;
1654
+ color.y *= res.g;
1655
+ color.z *= res.b;
1656
+ color.w *= res.alpha;
1657
+ }
1658
+ }
1659
+ __decorate([
1660
+ serializable()
1661
+ ], ColorBySpeedModule.prototype, "enabled", void 0);
1662
+ __decorate([
1663
+ serializable(Vector2)
1664
+ ], ColorBySpeedModule.prototype, "range", void 0);
1665
+ __decorate([
1666
+ serializable(MinMaxGradient)
1667
+ ], ColorBySpeedModule.prototype, "color", void 0);
1668
1668
  //# sourceMappingURL=ParticleSystemModules.js.map