@zephyr3d/scene 0.7.1 → 0.8.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 (441) hide show
  1. package/dist/animation/animation.js +0 -18
  2. package/dist/animation/animation.js.map +1 -1
  3. package/dist/animation/animationset.js +200 -3
  4. package/dist/animation/animationset.js.map +1 -1
  5. package/dist/animation/ik/ccd_solver.js +371 -0
  6. package/dist/animation/ik/ccd_solver.js.map +1 -0
  7. package/dist/animation/ik/fabrik_solver.js +398 -0
  8. package/dist/animation/ik/fabrik_solver.js.map +1 -0
  9. package/dist/animation/ik/ik_angle_constraint.js +181 -0
  10. package/dist/animation/ik/ik_angle_constraint.js.map +1 -0
  11. package/dist/animation/ik/ik_chain.js +163 -0
  12. package/dist/animation/ik/ik_chain.js.map +1 -0
  13. package/dist/animation/ik/ik_constraint.js +25 -0
  14. package/dist/animation/ik/ik_constraint.js.map +1 -0
  15. package/dist/animation/ik/ik_pole_constraint.js +128 -0
  16. package/dist/animation/ik/ik_pole_constraint.js.map +1 -0
  17. package/dist/animation/ik/ik_solver.js +48 -0
  18. package/dist/animation/ik/ik_solver.js.map +1 -0
  19. package/dist/animation/ik/ik_track.js +96 -0
  20. package/dist/animation/ik/ik_track.js.map +1 -0
  21. package/dist/animation/ik/ik_utils.js +191 -0
  22. package/dist/animation/ik/ik_utils.js.map +1 -0
  23. package/dist/animation/ik/two_bone_ik_solver.js +331 -0
  24. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -0
  25. package/dist/animation/ik_modifier.js +61 -0
  26. package/dist/animation/ik_modifier.js.map +1 -0
  27. package/dist/animation/ik_postprocessor.js +71 -0
  28. package/dist/animation/ik_postprocessor.js.map +1 -0
  29. package/dist/animation/manual_transform_processor.js +156 -0
  30. package/dist/animation/manual_transform_processor.js.map +1 -0
  31. package/dist/animation/skeleton.js +55 -51
  32. package/dist/animation/skeleton.js.map +1 -1
  33. package/dist/animation/skeleton_modifier.js +38 -0
  34. package/dist/animation/skeleton_modifier.js.map +1 -0
  35. package/dist/animation/skeleton_postprocessor.js +50 -0
  36. package/dist/animation/skeleton_postprocessor.js.map +1 -0
  37. package/dist/animation/spring/multi_chain_spring_system.js +503 -0
  38. package/dist/animation/spring/multi_chain_spring_system.js.map +1 -0
  39. package/dist/animation/spring/spring_bone.js +240 -0
  40. package/dist/animation/spring/spring_bone.js.map +1 -0
  41. package/dist/animation/spring/spring_bone_collider.js +198 -0
  42. package/dist/animation/spring/spring_bone_collider.js.map +1 -0
  43. package/dist/animation/spring/spring_bone_constraint.js +170 -0
  44. package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
  45. package/dist/animation/spring/spring_bone_system.js +328 -0
  46. package/dist/animation/spring/spring_bone_system.js.map +1 -0
  47. package/dist/animation/spring/spring_chain.js +103 -0
  48. package/dist/animation/spring/spring_chain.js.map +1 -0
  49. package/dist/animation/spring/spring_collider.js +247 -0
  50. package/dist/animation/spring/spring_collider.js.map +1 -0
  51. package/dist/animation/spring/spring_constraint.js +21 -0
  52. package/dist/animation/spring/spring_constraint.js.map +1 -0
  53. package/dist/animation/spring/spring_particle.js +20 -0
  54. package/dist/animation/spring/spring_particle.js.map +1 -0
  55. package/dist/animation/spring/spring_system.js +526 -0
  56. package/dist/animation/spring/spring_system.js.map +1 -0
  57. package/dist/animation/spring_modifier.js +45 -0
  58. package/dist/animation/spring_modifier.js.map +1 -0
  59. package/dist/animation/spring_postprocessor.js +54 -0
  60. package/dist/animation/spring_postprocessor.js.map +1 -0
  61. package/dist/app/screen.js +1 -1
  62. package/dist/app/screen.js.map +1 -1
  63. package/dist/asset/model.js +10 -6
  64. package/dist/asset/model.js.map +1 -1
  65. package/dist/camera/perspectivecamera.js +3 -3
  66. package/dist/camera/perspectivecamera.js.map +1 -1
  67. package/dist/index.d.ts +1400 -4
  68. package/dist/index.js +16 -0
  69. package/dist/index.js.map +1 -1
  70. package/dist/material/mixins/lightmodel/blinnphong.js +66 -4
  71. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  72. package/dist/material/mixins/pbr/common.js +20 -17
  73. package/dist/material/mixins/pbr/common.js.map +1 -1
  74. package/dist/material/shader/helper.js +5 -3
  75. package/dist/material/shader/helper.js.map +1 -1
  76. package/dist/render/gpu_picking.js +100 -0
  77. package/dist/render/gpu_picking.js.map +1 -0
  78. package/dist/render/rendergraph/device_pool_allocator.js +41 -0
  79. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
  80. package/dist/render/rendergraph/executor.js +146 -0
  81. package/dist/render/rendergraph/executor.js.map +1 -0
  82. package/dist/render/rendergraph/forward_plus_builder.js +414 -0
  83. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
  84. package/dist/render/rendergraph/rendergraph.js +306 -0
  85. package/dist/render/rendergraph/rendergraph.js.map +1 -0
  86. package/dist/render/rendergraph/types.js +57 -0
  87. package/dist/render/rendergraph/types.js.map +1 -0
  88. package/dist/render/sky_motion_vector.js +85 -0
  89. package/dist/render/sky_motion_vector.js.map +1 -0
  90. package/dist/scene/mesh.js +15 -23
  91. package/dist/scene/mesh.js.map +1 -1
  92. package/dist/utility/serialization/scene/animation.js +24 -23
  93. package/dist/utility/serialization/scene/animation.js.map +1 -1
  94. package/dist/utility/serialization/scene/material.js +62 -0
  95. package/dist/utility/serialization/scene/material.js.map +1 -1
  96. package/dist/utility/serialization/scene/node.js +1 -1
  97. package/package.json +3 -3
  98. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
  99. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
  100. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
  101. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
  102. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
  103. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
  104. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
  105. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
  106. package/dist/src/animation/animation.js +0 -127
  107. package/dist/src/animation/animation.js.map +0 -1
  108. package/dist/src/animation/animationset.js +0 -255
  109. package/dist/src/animation/animationset.js.map +0 -1
  110. package/dist/src/animation/animationtrack.js +0 -34
  111. package/dist/src/animation/animationtrack.js.map +0 -1
  112. package/dist/src/animation/eulerrotationtrack.js +0 -52
  113. package/dist/src/animation/eulerrotationtrack.js.map +0 -1
  114. package/dist/src/animation/morphtarget.js +0 -93
  115. package/dist/src/animation/morphtarget.js.map +0 -1
  116. package/dist/src/animation/morphtrack.js +0 -70
  117. package/dist/src/animation/morphtrack.js.map +0 -1
  118. package/dist/src/animation/proptrack.js +0 -161
  119. package/dist/src/animation/proptrack.js.map +0 -1
  120. package/dist/src/animation/rotationtrack.js +0 -51
  121. package/dist/src/animation/rotationtrack.js.map +0 -1
  122. package/dist/src/animation/scaletrack.js +0 -50
  123. package/dist/src/animation/scaletrack.js.map +0 -1
  124. package/dist/src/animation/skeleton.js +0 -204
  125. package/dist/src/animation/skeleton.js.map +0 -1
  126. package/dist/src/animation/translationtrack.js +0 -50
  127. package/dist/src/animation/translationtrack.js.map +0 -1
  128. package/dist/src/app/app.js +0 -129
  129. package/dist/src/app/app.js.map +0 -1
  130. package/dist/src/app/inputmgr.js +0 -267
  131. package/dist/src/app/inputmgr.js.map +0 -1
  132. package/dist/src/asset/assetmanager.js +0 -404
  133. package/dist/src/asset/assetmanager.js.map +0 -1
  134. package/dist/src/asset/builtin.js +0 -337
  135. package/dist/src/asset/builtin.js.map +0 -1
  136. package/dist/src/asset/loaders/dds/dds.js +0 -470
  137. package/dist/src/asset/loaders/dds/dds.js.map +0 -1
  138. package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
  139. package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
  140. package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
  141. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
  142. package/dist/src/asset/loaders/gltf/helpers.js +0 -327
  143. package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
  144. package/dist/src/asset/loaders/hdr/hdr.js +0 -180
  145. package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
  146. package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
  147. package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
  148. package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
  149. package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
  150. package/dist/src/asset/loaders/loader.js +0 -45
  151. package/dist/src/asset/loaders/loader.js.map +0 -1
  152. package/dist/src/asset/model.js +0 -414
  153. package/dist/src/asset/model.js.map +0 -1
  154. package/dist/src/blitter/bilateralblur.js +0 -221
  155. package/dist/src/blitter/bilateralblur.js.map +0 -1
  156. package/dist/src/blitter/blitter.js +0 -390
  157. package/dist/src/blitter/blitter.js.map +0 -1
  158. package/dist/src/blitter/box.js +0 -118
  159. package/dist/src/blitter/box.js.map +0 -1
  160. package/dist/src/blitter/copy.js +0 -22
  161. package/dist/src/blitter/copy.js.map +0 -1
  162. package/dist/src/blitter/gaussianblur.js +0 -228
  163. package/dist/src/blitter/gaussianblur.js.map +0 -1
  164. package/dist/src/camera/base.js +0 -92
  165. package/dist/src/camera/base.js.map +0 -1
  166. package/dist/src/camera/camera.js +0 -1005
  167. package/dist/src/camera/camera.js.map +0 -1
  168. package/dist/src/camera/fps.js +0 -238
  169. package/dist/src/camera/fps.js.map +0 -1
  170. package/dist/src/camera/orbit.js +0 -245
  171. package/dist/src/camera/orbit.js.map +0 -1
  172. package/dist/src/camera/orthocamera.js +0 -167
  173. package/dist/src/camera/orthocamera.js.map +0 -1
  174. package/dist/src/camera/perspectivecamera.js +0 -141
  175. package/dist/src/camera/perspectivecamera.js.map +0 -1
  176. package/dist/src/index.js +0 -120
  177. package/dist/src/index.js.map +0 -1
  178. package/dist/src/material/blinn.js +0 -81
  179. package/dist/src/material/blinn.js.map +0 -1
  180. package/dist/src/material/grassmaterial.js +0 -113
  181. package/dist/src/material/grassmaterial.js.map +0 -1
  182. package/dist/src/material/lambert.js +0 -92
  183. package/dist/src/material/lambert.js.map +0 -1
  184. package/dist/src/material/material.js +0 -301
  185. package/dist/src/material/material.js.map +0 -1
  186. package/dist/src/material/meshmaterial.js +0 -704
  187. package/dist/src/material/meshmaterial.js.map +0 -1
  188. package/dist/src/material/mixins/albedocolor.js +0 -76
  189. package/dist/src/material/mixins/albedocolor.js.map +0 -1
  190. package/dist/src/material/mixins/foliage.js +0 -47
  191. package/dist/src/material/mixins/foliage.js.map +0 -1
  192. package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
  193. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
  194. package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
  195. package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
  196. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
  197. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
  198. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
  199. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
  200. package/dist/src/material/mixins/lit.js +0 -476
  201. package/dist/src/material/mixins/lit.js.map +0 -1
  202. package/dist/src/material/mixins/pbr/common.js +0 -918
  203. package/dist/src/material/mixins/pbr/common.js.map +0 -1
  204. package/dist/src/material/mixins/texture.js +0 -172
  205. package/dist/src/material/mixins/texture.js.map +0 -1
  206. package/dist/src/material/mixins/vertexcolor.js +0 -56
  207. package/dist/src/material/mixins/vertexcolor.js.map +0 -1
  208. package/dist/src/material/particle.js +0 -178
  209. package/dist/src/material/particle.js.map +0 -1
  210. package/dist/src/material/pbrmr.js +0 -97
  211. package/dist/src/material/pbrmr.js.map +0 -1
  212. package/dist/src/material/pbrsg.js +0 -97
  213. package/dist/src/material/pbrsg.js.map +0 -1
  214. package/dist/src/material/shader/helper.js +0 -1209
  215. package/dist/src/material/shader/helper.js.map +0 -1
  216. package/dist/src/material/terrain-cm.js +0 -606
  217. package/dist/src/material/terrain-cm.js.map +0 -1
  218. package/dist/src/material/terrainmaterial.js +0 -375
  219. package/dist/src/material/terrainmaterial.js.map +0 -1
  220. package/dist/src/material/unlit.js +0 -41
  221. package/dist/src/material/unlit.js.map +0 -1
  222. package/dist/src/material/water.js +0 -417
  223. package/dist/src/material/water.js.map +0 -1
  224. package/dist/src/posteffect/bloom.js +0 -361
  225. package/dist/src/posteffect/bloom.js.map +0 -1
  226. package/dist/src/posteffect/compositor.js +0 -226
  227. package/dist/src/posteffect/compositor.js.map +0 -1
  228. package/dist/src/posteffect/fxaa.js +0 -273
  229. package/dist/src/posteffect/fxaa.js.map +0 -1
  230. package/dist/src/posteffect/grayscale.js +0 -69
  231. package/dist/src/posteffect/grayscale.js.map +0 -1
  232. package/dist/src/posteffect/motionblur.js +0 -96
  233. package/dist/src/posteffect/motionblur.js.map +0 -1
  234. package/dist/src/posteffect/posteffect.js +0 -126
  235. package/dist/src/posteffect/posteffect.js.map +0 -1
  236. package/dist/src/posteffect/sao.js +0 -324
  237. package/dist/src/posteffect/sao.js.map +0 -1
  238. package/dist/src/posteffect/ssr.js +0 -489
  239. package/dist/src/posteffect/ssr.js.map +0 -1
  240. package/dist/src/posteffect/taa.js +0 -172
  241. package/dist/src/posteffect/taa.js.map +0 -1
  242. package/dist/src/posteffect/tonemap.js +0 -94
  243. package/dist/src/posteffect/tonemap.js.map +0 -1
  244. package/dist/src/render/abuffer_oit.js +0 -361
  245. package/dist/src/render/abuffer_oit.js.map +0 -1
  246. package/dist/src/render/clipmap.js +0 -851
  247. package/dist/src/render/clipmap.js.map +0 -1
  248. package/dist/src/render/cluster_light.js +0 -333
  249. package/dist/src/render/cluster_light.js.map +0 -1
  250. package/dist/src/render/cull_visitor.js +0 -187
  251. package/dist/src/render/cull_visitor.js.map +0 -1
  252. package/dist/src/render/depthpass.js +0 -68
  253. package/dist/src/render/depthpass.js.map +0 -1
  254. package/dist/src/render/drawable_mixin.js +0 -227
  255. package/dist/src/render/drawable_mixin.js.map +0 -1
  256. package/dist/src/render/envlight.js +0 -463
  257. package/dist/src/render/envlight.js.map +0 -1
  258. package/dist/src/render/fbm_wavegenerator.js +0 -251
  259. package/dist/src/render/fbm_wavegenerator.js.map +0 -1
  260. package/dist/src/render/fft_wavegenerator.js +0 -1006
  261. package/dist/src/render/fft_wavegenerator.js.map +0 -1
  262. package/dist/src/render/fullscreenquad.js +0 -38
  263. package/dist/src/render/fullscreenquad.js.map +0 -1
  264. package/dist/src/render/gerstner_wavegenerator.js +0 -314
  265. package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
  266. package/dist/src/render/globalbindgroup_allocator.js +0 -60
  267. package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
  268. package/dist/src/render/hzb.js +0 -273
  269. package/dist/src/render/hzb.js.map +0 -1
  270. package/dist/src/render/lightpass.js +0 -172
  271. package/dist/src/render/lightpass.js.map +0 -1
  272. package/dist/src/render/objectcolorpass.js +0 -51
  273. package/dist/src/render/objectcolorpass.js.map +0 -1
  274. package/dist/src/render/primitive.js +0 -364
  275. package/dist/src/render/primitive.js.map +0 -1
  276. package/dist/src/render/render_queue.js +0 -467
  277. package/dist/src/render/render_queue.js.map +0 -1
  278. package/dist/src/render/renderbundle_wrapper.js +0 -152
  279. package/dist/src/render/renderbundle_wrapper.js.map +0 -1
  280. package/dist/src/render/renderer.js +0 -455
  281. package/dist/src/render/renderer.js.map +0 -1
  282. package/dist/src/render/renderpass.js +0 -200
  283. package/dist/src/render/renderpass.js.map +0 -1
  284. package/dist/src/render/shadowmap_pass.js +0 -56
  285. package/dist/src/render/shadowmap_pass.js.map +0 -1
  286. package/dist/src/render/sky.js +0 -1103
  287. package/dist/src/render/sky.js.map +0 -1
  288. package/dist/src/render/weightedblended_oit.js +0 -168
  289. package/dist/src/render/weightedblended_oit.js.map +0 -1
  290. package/dist/src/scene/batchgroup.js +0 -162
  291. package/dist/src/scene/batchgroup.js.map +0 -1
  292. package/dist/src/scene/environment.js +0 -209
  293. package/dist/src/scene/environment.js.map +0 -1
  294. package/dist/src/scene/graph_node.js +0 -72
  295. package/dist/src/scene/graph_node.js.map +0 -1
  296. package/dist/src/scene/light.js +0 -416
  297. package/dist/src/scene/light.js.map +0 -1
  298. package/dist/src/scene/mesh.js +0 -341
  299. package/dist/src/scene/mesh.js.map +0 -1
  300. package/dist/src/scene/octree.js +0 -649
  301. package/dist/src/scene/octree.js.map +0 -1
  302. package/dist/src/scene/particlesys.js +0 -738
  303. package/dist/src/scene/particlesys.js.map +0 -1
  304. package/dist/src/scene/raycast_visitor.js +0 -103
  305. package/dist/src/scene/raycast_visitor.js.map +0 -1
  306. package/dist/src/scene/scene.js +0 -284
  307. package/dist/src/scene/scene.js.map +0 -1
  308. package/dist/src/scene/scene_node.js +0 -732
  309. package/dist/src/scene/scene_node.js.map +0 -1
  310. package/dist/src/scene/terrain/grass.js +0 -278
  311. package/dist/src/scene/terrain/grass.js.map +0 -1
  312. package/dist/src/scene/terrain/heightfield.js +0 -475
  313. package/dist/src/scene/terrain/heightfield.js.map +0 -1
  314. package/dist/src/scene/terrain/patch.js +0 -530
  315. package/dist/src/scene/terrain/patch.js.map +0 -1
  316. package/dist/src/scene/terrain/quadtree.js +0 -461
  317. package/dist/src/scene/terrain/quadtree.js.map +0 -1
  318. package/dist/src/scene/terrain/terrain.js +0 -246
  319. package/dist/src/scene/terrain/terrain.js.map +0 -1
  320. package/dist/src/scene/terrain-cm/grass.js +0 -594
  321. package/dist/src/scene/terrain-cm/grass.js.map +0 -1
  322. package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
  323. package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
  324. package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
  325. package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
  326. package/dist/src/scene/water.js +0 -374
  327. package/dist/src/scene/water.js.map +0 -1
  328. package/dist/src/shaders/atmosphere.js +0 -957
  329. package/dist/src/shaders/atmosphere.js.map +0 -1
  330. package/dist/src/shaders/fog.js +0 -112
  331. package/dist/src/shaders/fog.js.map +0 -1
  332. package/dist/src/shaders/misc.js +0 -266
  333. package/dist/src/shaders/misc.js.map +0 -1
  334. package/dist/src/shaders/noise.js +0 -222
  335. package/dist/src/shaders/noise.js.map +0 -1
  336. package/dist/src/shaders/pbr.js +0 -51
  337. package/dist/src/shaders/pbr.js.map +0 -1
  338. package/dist/src/shaders/shadow.js +0 -636
  339. package/dist/src/shaders/shadow.js.map +0 -1
  340. package/dist/src/shaders/ssr.js +0 -490
  341. package/dist/src/shaders/ssr.js.map +0 -1
  342. package/dist/src/shaders/temporal.js +0 -215
  343. package/dist/src/shaders/temporal.js.map +0 -1
  344. package/dist/src/shaders/water.js +0 -756
  345. package/dist/src/shaders/water.js.map +0 -1
  346. package/dist/src/shadow/esm.js +0 -237
  347. package/dist/src/shadow/esm.js.map +0 -1
  348. package/dist/src/shadow/pcf_opt.js +0 -181
  349. package/dist/src/shadow/pcf_opt.js.map +0 -1
  350. package/dist/src/shadow/pcf_pd.js +0 -189
  351. package/dist/src/shadow/pcf_pd.js.map +0 -1
  352. package/dist/src/shadow/shader.js +0 -37
  353. package/dist/src/shadow/shader.js.map +0 -1
  354. package/dist/src/shadow/shadow_impl.js +0 -15
  355. package/dist/src/shadow/shadow_impl.js.map +0 -1
  356. package/dist/src/shadow/shadowmapper.js +0 -790
  357. package/dist/src/shadow/shadowmapper.js.map +0 -1
  358. package/dist/src/shadow/ssm.js +0 -159
  359. package/dist/src/shadow/ssm.js.map +0 -1
  360. package/dist/src/shadow/vsm.js +0 -297
  361. package/dist/src/shadow/vsm.js.map +0 -1
  362. package/dist/src/shapes/box.js +0 -386
  363. package/dist/src/shapes/box.js.map +0 -1
  364. package/dist/src/shapes/cylinder.js +0 -125
  365. package/dist/src/shapes/cylinder.js.map +0 -1
  366. package/dist/src/shapes/plane.js +0 -88
  367. package/dist/src/shapes/plane.js.map +0 -1
  368. package/dist/src/shapes/shape.js +0 -87
  369. package/dist/src/shapes/shape.js.map +0 -1
  370. package/dist/src/shapes/sphere.js +0 -114
  371. package/dist/src/shapes/sphere.js.map +0 -1
  372. package/dist/src/shapes/tetrahedron.js +0 -188
  373. package/dist/src/shapes/tetrahedron.js.map +0 -1
  374. package/dist/src/shapes/torus.js +0 -111
  375. package/dist/src/shapes/torus.js.map +0 -1
  376. package/dist/src/utility/aabbtree.js +0 -400
  377. package/dist/src/utility/aabbtree.js.map +0 -1
  378. package/dist/src/utility/bounding_volume.js +0 -29
  379. package/dist/src/utility/bounding_volume.js.map +0 -1
  380. package/dist/src/utility/debug.js +0 -28
  381. package/dist/src/utility/debug.js.map +0 -1
  382. package/dist/src/utility/draco/decoder.js +0 -116
  383. package/dist/src/utility/draco/decoder.js.map +0 -1
  384. package/dist/src/utility/misc.js +0 -105
  385. package/dist/src/utility/misc.js.map +0 -1
  386. package/dist/src/utility/panorama.js +0 -163
  387. package/dist/src/utility/panorama.js.map +0 -1
  388. package/dist/src/utility/pmrem.js +0 -354
  389. package/dist/src/utility/pmrem.js.map +0 -1
  390. package/dist/src/utility/rendermipmap.js +0 -115
  391. package/dist/src/utility/rendermipmap.js.map +0 -1
  392. package/dist/src/utility/serialization/json.js +0 -402
  393. package/dist/src/utility/serialization/json.js.map +0 -1
  394. package/dist/src/utility/serialization/manager.js +0 -623
  395. package/dist/src/utility/serialization/manager.js.map +0 -1
  396. package/dist/src/utility/serialization/scene/animation.js +0 -248
  397. package/dist/src/utility/serialization/scene/animation.js.map +0 -1
  398. package/dist/src/utility/serialization/scene/batch.js +0 -59
  399. package/dist/src/utility/serialization/scene/batch.js.map +0 -1
  400. package/dist/src/utility/serialization/scene/camera.js +0 -790
  401. package/dist/src/utility/serialization/scene/camera.js.map +0 -1
  402. package/dist/src/utility/serialization/scene/common.js +0 -222
  403. package/dist/src/utility/serialization/scene/common.js.map +0 -1
  404. package/dist/src/utility/serialization/scene/light.js +0 -575
  405. package/dist/src/utility/serialization/scene/light.js.map +0 -1
  406. package/dist/src/utility/serialization/scene/material.js +0 -1111
  407. package/dist/src/utility/serialization/scene/material.js.map +0 -1
  408. package/dist/src/utility/serialization/scene/mesh.js +0 -148
  409. package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
  410. package/dist/src/utility/serialization/scene/misc.js +0 -39
  411. package/dist/src/utility/serialization/scene/misc.js.map +0 -1
  412. package/dist/src/utility/serialization/scene/node.js +0 -451
  413. package/dist/src/utility/serialization/scene/node.js.map +0 -1
  414. package/dist/src/utility/serialization/scene/particle.js +0 -425
  415. package/dist/src/utility/serialization/scene/particle.js.map +0 -1
  416. package/dist/src/utility/serialization/scene/primitive.js +0 -692
  417. package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
  418. package/dist/src/utility/serialization/scene/scene.js +0 -704
  419. package/dist/src/utility/serialization/scene/scene.js.map +0 -1
  420. package/dist/src/utility/serialization/scene/terrain.js +0 -488
  421. package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
  422. package/dist/src/utility/serialization/scene/water.js +0 -465
  423. package/dist/src/utility/serialization/scene/water.js.map +0 -1
  424. package/dist/src/utility/shprojector.js +0 -297
  425. package/dist/src/utility/shprojector.js.map +0 -1
  426. package/dist/src/utility/textures/ggxlut.js +0 -213
  427. package/dist/src/utility/textures/ggxlut.js.map +0 -1
  428. package/dist/src/utility/textures/gradientnoise.js +0 -62
  429. package/dist/src/utility/textures/gradientnoise.js.map +0 -1
  430. package/dist/src/utility/textures/randomnoise.js +0 -41
  431. package/dist/src/utility/textures/randomnoise.js.map +0 -1
  432. package/dist/src/values.js +0 -162
  433. package/dist/src/values.js.map +0 -1
  434. package/dist/utility/blueprint/material/common.js +0 -7
  435. package/dist/utility/blueprint/material/common.js.map +0 -1
  436. package/dist/utility/serialization/blueprint/constants.js +0 -255
  437. package/dist/utility/serialization/blueprint/constants.js.map +0 -1
  438. package/dist/utility/serialization/blueprint/material/constants.js +0 -203
  439. package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
  440. package/dist/utility/serialization/blueprint/material/texture.js +0 -165
  441. package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
@@ -1,738 +0,0 @@
1
- import { Vector3, applyMixins, DRef, nextPowerOf2 } from '@zephyr3d/base';
2
- import { GraphNode } from './graph_node.js';
3
- import { BoundingBox } from '../utility/bounding_volume.js';
4
- import { mixinDrawable } from '../render/drawable_mixin.js';
5
- import { QUEUE_OPAQUE } from '../values.js';
6
- import { Application } from '../app/app.js';
7
- import '@zephyr3d/device';
8
- import '../material/shader/helper.js';
9
- import '../material/lambert.js';
10
- import '../material/blinn.js';
11
- import '../material/unlit.js';
12
- import { ParticleMaterial } from '../material/particle.js';
13
- import '../material/meshmaterial.js';
14
- import '../material/grassmaterial.js';
15
- import '../material/terrainmaterial.js';
16
- import '../material/terrain-cm.js';
17
- import '../material/pbrmr.js';
18
- import '../material/pbrsg.js';
19
- import '../render/renderer.js';
20
- import { Primitive } from '../render/primitive.js';
21
- import '../render/sky.js';
22
- import '../render/clipmap.js';
23
- import '../shaders/atmosphere.js';
24
-
25
- const tmpVec3 = new Vector3();
26
- const PS_WORLDSPACE = 1 << 8;
27
- /**
28
- * Particle system class
29
- * @public
30
- */ class ParticleSystem extends applyMixins(GraphNode, mixinDrawable) {
31
- static updateFuncMap = new WeakMap();
32
- _activeParticleList;
33
- _maxParticleCount;
34
- _emitInterval;
35
- _emitCount;
36
- _startTick;
37
- _startEmitTime;
38
- _lastUpdateTime;
39
- _numEmitCount;
40
- _delay;
41
- _airResistence;
42
- _flags;
43
- _gravity;
44
- _wind;
45
- _scalar;
46
- _particleRotationMin;
47
- _particleRotationMax;
48
- _jitterSpeed;
49
- _emitterShape;
50
- _emitterBehavior;
51
- _emitterConeRadiusMin;
52
- _emitterConeRadiusMax;
53
- _particleVelocityMin;
54
- _particleVelocityMax;
55
- _particleLifeMin;
56
- _particleLifeMax;
57
- _particleSize1Min;
58
- _particleSize1Max;
59
- _particleSize2Min;
60
- _particleSize2Max;
61
- _particleAccelMin;
62
- _particleAccelMax;
63
- _emitterShapeSizeMin;
64
- _emitterShapeSizeMax;
65
- _primitive;
66
- _material;
67
- _wsBoundingBox;
68
- _pickTarget;
69
- _instanceData;
70
- /**
71
- * Creates a new ParticleSystem node
72
- * @param scene - Which scene the node belongs to
73
- */ constructor(scene){
74
- super(scene);
75
- this._activeParticleList = [];
76
- this._maxParticleCount = 100;
77
- this._emitInterval = 100;
78
- this._emitCount = 1;
79
- this._gravity = Vector3.zero();
80
- this._wind = Vector3.zero();
81
- this._startEmitTime = 0;
82
- this._lastUpdateTime = 0;
83
- this._numEmitCount = 0;
84
- this._scalar = 1;
85
- this._airResistence = false;
86
- this._startTick = 0;
87
- this._delay = 0;
88
- this._particleRotationMin = 0;
89
- this._particleRotationMax = 0;
90
- this._jitterSpeed = 1;
91
- this._emitterShape = 'point';
92
- this._emitterBehavior = 'surface';
93
- this._emitterConeRadiusMin = 0;
94
- this._emitterConeRadiusMax = 0.1;
95
- this._emitterShapeSizeMin = Vector3.one();
96
- this._emitterShapeSizeMax = Vector3.one();
97
- this._particleVelocityMin = 2;
98
- this._particleVelocityMax = 3;
99
- this._particleLifeMin = 1;
100
- this._particleLifeMax = 1.5;
101
- this._particleSize1Min = 0.4;
102
- this._particleSize1Max = 0.5;
103
- this._particleSize2Min = 0;
104
- this._particleSize2Max = 0.1;
105
- this._particleAccelMin = -0.01;
106
- this._particleAccelMax = -0.02;
107
- this._pickTarget = {
108
- node: this
109
- };
110
- this._flags = PS_WORLDSPACE;
111
- this._primitive = new DRef();
112
- this._wsBoundingBox = new BoundingBox();
113
- this._instanceData = null;
114
- this._material = new DRef(new ParticleMaterial());
115
- }
116
- /** {@inheritDoc SceneNode.clone} */ clone(method, recursive) {
117
- const other = new ParticleSystem(this.scene);
118
- other.copyFrom(this, method, recursive);
119
- other.parent = this.parent;
120
- return other;
121
- }
122
- /** {@inheritDoc SceneNode.copyFrom} */ copyFrom(other, method, recursive) {
123
- super.copyFrom(other, method, recursive);
124
- this.maxParticleCount = other.maxParticleCount;
125
- this.emitInterval = other.emitInterval;
126
- this.emitCount = other.emitCount;
127
- this.gravity = other.gravity.clone();
128
- this.wind = other.wind.clone();
129
- this.scalar = other.scalar;
130
- this.aspect = other.aspect;
131
- this.airResistence = other.airResistence;
132
- this.particleRotationMin = other.particleRotationMin;
133
- this.particleRotationMax = other.particleRotationMax;
134
- this.jitterSpeed = other.jitterSpeed;
135
- this.jitterPower = other.jitterPower;
136
- this.emitterShape = other.emitterShape;
137
- this.emitterBehavior = other.emitterBehavior;
138
- this.emitterConeRadiusMin = other.emitterConeRadiusMin;
139
- this.emitterConeRadiusMax = other.emitterConeRadiusMax;
140
- this.particleVelocityMin = other.particleVelocityMin;
141
- this.particleVelocityMax = other.particleVelocityMax;
142
- this.particleLifeMin = other.particleLifeMin;
143
- this.particleLifeMax = other.particleLifeMax;
144
- this.particleSize1Min = other.particleSize1Min;
145
- this.particleSize1Max = other.particleSize1Max;
146
- this.particleSize2Min = other.particleSize2Min;
147
- this.particleSize2Max = other.particleSize2Max;
148
- this.particleAccelMin = other.particleAccelMin;
149
- this.particleAccelMax = other.particleAccelMax;
150
- this.emitterShapeSizeMin = other.emitterShapeSizeMin.clone();
151
- this.emitterShapeSizeMax = other.emitterShapeSizeMax.clone();
152
- this.directional = other.directional;
153
- this.worldSpace = other.worldSpace;
154
- this.flags = other.flags;
155
- }
156
- /** Material of the particle system node */ get material() {
157
- return this._material.get();
158
- }
159
- set material(material) {
160
- this._material.set(material);
161
- }
162
- /** Maximum particle count */ get maxParticleCount() {
163
- return this._maxParticleCount;
164
- }
165
- set maxParticleCount(value) {
166
- if (value !== this._maxParticleCount) {
167
- this._maxParticleCount = value;
168
- this.invalidateBoundingVolume();
169
- }
170
- }
171
- /** Particle emit interval in ms */ get emitInterval() {
172
- return this._emitInterval;
173
- }
174
- set emitInterval(value) {
175
- if (value !== this._emitInterval) {
176
- this._emitInterval = Math.max(value, 1);
177
- this._startEmitTime = 0;
178
- }
179
- }
180
- /** How many particles should be emitted one time */ get emitCount() {
181
- return this._emitCount;
182
- }
183
- set emitCount(value) {
184
- this._emitCount = value;
185
- }
186
- /** Gravity force */ get gravity() {
187
- return this._gravity;
188
- }
189
- set gravity(value) {
190
- if (!value.equalsTo(this._gravity)) {
191
- this._gravity.set(value);
192
- this.invalidateBoundingVolume();
193
- }
194
- }
195
- /** Wind force */ get wind() {
196
- return this._wind;
197
- }
198
- set wind(value) {
199
- if (!value.equalsTo(this._wind)) {
200
- this._wind.set(value);
201
- this.invalidateBoundingVolume();
202
- }
203
- }
204
- /** Particle scalar */ get scalar() {
205
- return this._scalar;
206
- }
207
- set scalar(value) {
208
- if (value !== this._scalar) {
209
- this._scalar = value;
210
- this.invalidateBoundingVolume();
211
- }
212
- }
213
- /** Particle aspect ratio */ get aspect() {
214
- return this._material.get().aspect;
215
- }
216
- set aspect(value) {
217
- this._material.get().aspect = value;
218
- }
219
- /** true if particle effected by wind */ get airResistence() {
220
- return this._airResistence;
221
- }
222
- set airResistence(value) {
223
- this._airResistence = value;
224
- }
225
- /** Minimum particle rotation angle in radians */ get particleRotationMin() {
226
- return this._particleRotationMin;
227
- }
228
- set particleRotationMin(value) {
229
- this._particleRotationMin = value;
230
- }
231
- /** Maximum particle rotation angle in radians */ get particleRotationMax() {
232
- return this._particleRotationMax;
233
- }
234
- set particleRotationMax(value) {
235
- this._particleRotationMax = value;
236
- }
237
- /** Particle jitter speed */ get jitterSpeed() {
238
- return this._jitterSpeed;
239
- }
240
- set jitterSpeed(value) {
241
- this._jitterSpeed = value;
242
- }
243
- /** Particle jitter power */ get jitterPower() {
244
- return this._material.get().jitterPower;
245
- }
246
- set jitterPower(value) {
247
- this._material.get().jitterPower = value;
248
- }
249
- /** Particle emitter shape */ get emitterShape() {
250
- return this._emitterShape;
251
- }
252
- set emitterShape(value) {
253
- this._emitterShape = value;
254
- }
255
- /** Particle emitter behavior */ get emitterBehavior() {
256
- return this._emitterBehavior;
257
- }
258
- set emitterBehavior(value) {
259
- this._emitterBehavior = value;
260
- }
261
- /** Minimum cone radius of emitter */ get emitterConeRadiusMin() {
262
- return this._emitterConeRadiusMin;
263
- }
264
- set emitterConeRadiusMin(value) {
265
- this._emitterConeRadiusMin = value;
266
- }
267
- /** Maximum cone radius of emitter */ get emitterConeRadiusMax() {
268
- return this._emitterConeRadiusMax;
269
- }
270
- set emitterConeRadiusMax(value) {
271
- this._emitterConeRadiusMax = value;
272
- }
273
- /** Minimum particle velocity */ get particleVelocityMin() {
274
- return this._particleVelocityMin;
275
- }
276
- set particleVelocityMin(value) {
277
- this._particleVelocityMin = value;
278
- }
279
- /** Maximum particle velocity */ get particleVelocityMax() {
280
- return this._particleVelocityMax;
281
- }
282
- set particleVelocityMax(value) {
283
- this._particleVelocityMax = value;
284
- }
285
- /** Minimum particle life */ get particleLifeMin() {
286
- return this._particleLifeMin;
287
- }
288
- set particleLifeMin(value) {
289
- this._particleLifeMin = value;
290
- }
291
- /** Maximum particle life */ get particleLifeMax() {
292
- return this._particleLifeMax;
293
- }
294
- set particleLifeMax(value) {
295
- this._particleLifeMax = value;
296
- }
297
- /** Minimum particle start size */ get particleSize1Min() {
298
- return this._particleSize1Min;
299
- }
300
- set particleSize1Min(value) {
301
- this._particleSize1Min = value;
302
- }
303
- /** Maximum particle start size */ get particleSize1Max() {
304
- return this._particleSize1Max;
305
- }
306
- set particleSize1Max(value) {
307
- this._particleSize1Max = value;
308
- }
309
- /** Minimum particle end size */ get particleSize2Min() {
310
- return this._particleSize2Min;
311
- }
312
- set particleSize2Min(value) {
313
- this._particleSize2Min = value;
314
- }
315
- /** Maximum particle end size */ get particleSize2Max() {
316
- return this._particleSize2Max;
317
- }
318
- set particleSize2Max(value) {
319
- this._particleSize2Max = value;
320
- }
321
- /** Minimum particle acceleration */ get particleAccelMin() {
322
- return this._particleAccelMin;
323
- }
324
- set particleAccelMin(value) {
325
- this._particleAccelMin = value;
326
- }
327
- /** Maximum particle acceleration */ get particleAccelMax() {
328
- return this._particleAccelMax;
329
- }
330
- set particleAccelMax(value) {
331
- this._particleAccelMax = value;
332
- }
333
- /** Minimum emitter shape size */ get emitterShapeSizeMin() {
334
- return this._emitterShapeSizeMin;
335
- }
336
- set emitterShapeSizeMin(value) {
337
- this._emitterShapeSizeMin.set(value);
338
- }
339
- /** Maximum emitter shape size */ get emitterShapeSizeMax() {
340
- return this._emitterShapeSizeMax;
341
- }
342
- set emitterShapeSizeMax(value) {
343
- this._emitterShapeSizeMax.set(value);
344
- }
345
- /** Whether particles are directional */ get directional() {
346
- return this._material.get().directional;
347
- }
348
- set directional(val) {
349
- this._material.get().directional = val;
350
- }
351
- /** Whether particles are in world space */ get worldSpace() {
352
- return !!(this.flags & PS_WORLDSPACE);
353
- }
354
- set worldSpace(value) {
355
- if (value) {
356
- this.flags |= PS_WORLDSPACE;
357
- } else {
358
- this.flags &= -257;
359
- }
360
- }
361
- /** @internal */ get flags() {
362
- return this._flags;
363
- }
364
- set flags(value) {
365
- this._flags = value;
366
- }
367
- /** @internal */ computeBoundingVolume() {
368
- return this._wsBoundingBox;
369
- }
370
- /** @internal */ initParticle(p) {
371
- p = p ?? {
372
- position: new Vector3(),
373
- velocity: new Vector3()
374
- };
375
- this.getParticleInitialPosition(p.position, p.velocity);
376
- p.size1 = this._particleSize1Min + Math.random() * (this._particleSize1Max - this._particleSize1Min);
377
- p.size2 = this._particleSize2Min + Math.random() * (this._particleSize2Max - this._particleSize2Min);
378
- p.rotation = this._particleRotationMin + Math.random() * (this._particleRotationMax - this._particleRotationMin);
379
- p.lifeSpan = Math.max(this._particleLifeMin + Math.random() * (this._particleLifeMax - this._particleLifeMin), 0.01);
380
- p.acceleartion = this._particleAccelMin + Math.random() * (this._particleAccelMax - this._particleAccelMin);
381
- return p;
382
- }
383
- getParticleInitialPosition(pos, vel) {
384
- if (this._emitterShape === 'point') {
385
- pos.setXYZ(0, 0, 0);
386
- const coneRadius = this._emitterConeRadiusMin + Math.random() * (this._emitterConeRadiusMax - this._emitterConeRadiusMin);
387
- vel.x = -coneRadius + Math.random() * 2 * coneRadius;
388
- vel.y = 1;
389
- vel.z = -coneRadius + Math.random() * 2 * coneRadius;
390
- } else {
391
- const shapeSizeX = Math.max(this._emitterShapeSizeMin.x + (this._emitterShapeSizeMax.x - this._emitterShapeSizeMin.x) * Math.random(), 0.01);
392
- const shapeSizeY = Math.max(this._emitterShapeSizeMin.y + (this._emitterShapeSizeMax.y - this._emitterShapeSizeMin.y) * Math.random(), 0.01);
393
- const shapeSizeZ = Math.max(this._emitterShapeSizeMin.z + (this._emitterShapeSizeMax.z - this._emitterShapeSizeMin.z) * Math.random(), 0.01);
394
- switch(this._emitterShape){
395
- case 'sphere':
396
- {
397
- const alpha = Math.PI * Math.random();
398
- const theta = Math.PI * 2 * Math.random();
399
- const r = Math.sin(alpha);
400
- const y = Math.cos(alpha);
401
- const x = Math.sin(theta) * r;
402
- const z = Math.cos(theta) * r;
403
- pos.x = x * shapeSizeX;
404
- pos.y = y * shapeSizeY;
405
- pos.z = z * shapeSizeZ;
406
- vel.x = pos.x;
407
- vel.y = pos.y;
408
- vel.z = pos.z;
409
- if (this._emitterBehavior === 'volume') {
410
- const t = Math.random();
411
- pos.x *= t;
412
- pos.y *= t;
413
- pos.z *= t;
414
- }
415
- break;
416
- }
417
- case 'box':
418
- {
419
- let x = Math.random() * 2 - 1;
420
- let y = Math.random() * 2 - 1;
421
- let z = Math.random() * 2 - 1;
422
- if (this._emitterBehavior === 'volume') {
423
- const t = Math.max(Math.abs(x), Math.abs(y), Math.abs(z));
424
- if (t !== 0) {
425
- x /= t;
426
- y /= t;
427
- z /= t;
428
- }
429
- }
430
- pos.x = x * shapeSizeX;
431
- pos.y = y * shapeSizeY;
432
- pos.z = z * shapeSizeZ;
433
- const coneRadius = this._emitterConeRadiusMin + (this._emitterConeRadiusMax - this._emitterConeRadiusMin) * Math.random();
434
- vel.x = -coneRadius + Math.random() * 2 * coneRadius;
435
- vel.y = 1;
436
- vel.z = -coneRadius + Math.random() * 2 * coneRadius;
437
- break;
438
- }
439
- case 'cylinder':
440
- {
441
- const alpha = Math.random() * Math.PI * 2;
442
- let x = Math.sin(alpha);
443
- let z = Math.cos(alpha);
444
- const y = Math.random() * 2 - 1;
445
- const coneRadius = this._emitterConeRadiusMin + (this._emitterConeRadiusMax - this._emitterConeRadiusMin) * Math.random();
446
- vel.x = x * shapeSizeX;
447
- vel.y = (-coneRadius + Math.random() * 2 * coneRadius) * shapeSizeY;
448
- vel.z = z * shapeSizeZ;
449
- if (this._emitterBehavior === 'volume') {
450
- const t = Math.random();
451
- x *= t;
452
- z *= t;
453
- }
454
- pos.x = x * shapeSizeX;
455
- pos.y = y * shapeSizeY;
456
- pos.z = z * shapeSizeZ;
457
- break;
458
- }
459
- case 'cone':
460
- {
461
- const alpha = Math.random() * Math.PI * 2;
462
- const scale = Math.random();
463
- const s = Math.sin(alpha);
464
- const c = Math.cos(alpha);
465
- pos.x = s * scale * shapeSizeX;
466
- pos.y = (2 - 2 * scale) * shapeSizeY;
467
- pos.z = c * scale * shapeSizeZ;
468
- const t = shapeSizeY * shapeSizeY / Math.sqrt(shapeSizeY * shapeSizeY + shapeSizeX + shapeSizeX);
469
- vel.x = s * shapeSizeX * t;
470
- vel.y = -t * shapeSizeY;
471
- vel.z = c * shapeSizeX * t;
472
- break;
473
- }
474
- }
475
- }
476
- vel.inplaceNormalize();
477
- vel.scaleBy(this._particleVelocityMin + Math.random() * (this._particleVelocityMax - this._particleVelocityMin));
478
- }
479
- resizeVertexBuffers() {
480
- if (!this._primitive.get()) {
481
- this._primitive.set(new Primitive());
482
- this._primitive.get().createAndSetVertexBuffer('position_f32x4', new Float32Array([
483
- 0,
484
- 0,
485
- 0,
486
- 0,
487
- 0,
488
- 0,
489
- 0,
490
- 1,
491
- 0,
492
- 0,
493
- 0,
494
- 2,
495
- 0,
496
- 0,
497
- 0,
498
- 3
499
- ]));
500
- this._primitive.get().createAndSetIndexBuffer(new Uint16Array([
501
- 0,
502
- 1,
503
- 2,
504
- 3
505
- ]));
506
- this._primitive.get().primitiveType = 'triangle-strip';
507
- }
508
- if (!this._instanceData || this._instanceData.length < this._maxParticleCount * 10) {
509
- this._primitive.get().removeVertexBuffer('texCoord0');
510
- this._instanceData = new Float32Array(nextPowerOf2(this._maxParticleCount) * 10);
511
- this._primitive.get().createAndSetVertexBuffer([
512
- 'tex0_f32x3',
513
- 'tex1_f32x4',
514
- 'tex2_f32x3'
515
- ], this._instanceData, 'instance');
516
- }
517
- }
518
- update() {
519
- const tick = Application.instance.device.frameInfo.elapsedOverall;
520
- if (this._startTick === 0) {
521
- this._startTick = tick;
522
- }
523
- if (this._delay > 0 && tick - this._startTick < this._delay) {
524
- return;
525
- }
526
- if (this._lastUpdateTime === 0) {
527
- this._lastUpdateTime = tick;
528
- }
529
- const updateElapsed = tick - this._lastUpdateTime;
530
- this.invalidateBoundingVolume();
531
- const elapsedInSecond = updateElapsed * 0.001;
532
- this._lastUpdateTime = tick;
533
- for(let i = this._activeParticleList.length - 1; i >= 0; i--){
534
- const node = this._activeParticleList[i];
535
- const p = node.particle;
536
- node.elapsedTime += elapsedInSecond;
537
- const age = node.elapsedTime / p.lifeSpan;
538
- if (age >= 1) {
539
- this._activeParticleList.splice(i, 1);
540
- } else {
541
- p.velocity.x += this._gravity.x * elapsedInSecond;
542
- p.velocity.y += this._gravity.y * elapsedInSecond;
543
- p.velocity.z += this._gravity.z * elapsedInSecond;
544
- if (this._airResistence) {
545
- p.velocity.x += (this._wind.x - p.velocity.x) * elapsedInSecond;
546
- p.velocity.y += (this._wind.y - p.velocity.y) * elapsedInSecond;
547
- p.velocity.z += (this._wind.z - p.velocity.z) * elapsedInSecond;
548
- }
549
- const len = p.velocity.length;
550
- if (len > 0.0001) {
551
- const s = 1 + elapsedInSecond * p.acceleartion / len;
552
- p.velocity.scaleBy(s < 0 ? 0 : s);
553
- }
554
- p.position.x += p.velocity.x * elapsedInSecond * this._scalar;
555
- p.position.y += p.velocity.y * elapsedInSecond * this._scalar;
556
- p.position.z += p.velocity.z * elapsedInSecond * this._scalar;
557
- node.jitterAngle = (node.elapsedTime + p.lifeSpan * node.ageBias) * this._jitterSpeed;
558
- node.size = Math.max(p.size1 + p.size2 * age, 0);
559
- node.rotation += p.rotation * elapsedInSecond;
560
- }
561
- }
562
- let newParticleCount = 0;
563
- if (this._startEmitTime === 0) {
564
- newParticleCount = this._emitCount > this._maxParticleCount ? this._maxParticleCount : this._emitCount;
565
- this._numEmitCount = 1;
566
- this._startEmitTime = tick;
567
- } else {
568
- const emitElapsed = tick - this._startEmitTime;
569
- const count = (emitElapsed / this._emitInterval >> 0) + 1;
570
- if (count > this._numEmitCount) {
571
- newParticleCount = this._emitCount;
572
- this._numEmitCount = count;
573
- if (this._activeParticleList.length + newParticleCount > this._maxParticleCount) {
574
- newParticleCount = this._maxParticleCount - this._activeParticleList.length;
575
- }
576
- }
577
- }
578
- if (newParticleCount > 0) {
579
- this.newParticle(newParticleCount, this.worldMatrix);
580
- }
581
- this.resizeVertexBuffers();
582
- this._wsBoundingBox.beginExtend();
583
- let n = 0;
584
- const worldSpace = !!(this._flags & PS_WORLDSPACE);
585
- const invWorldMatrix = this.invWorldMatrix;
586
- for (const p of this._activeParticleList){
587
- if (worldSpace) {
588
- invWorldMatrix.transformPointAffine(p.particle.position, tmpVec3);
589
- this._instanceData[n++] = tmpVec3.x;
590
- this._instanceData[n++] = tmpVec3.y;
591
- this._instanceData[n++] = tmpVec3.z;
592
- this._wsBoundingBox.extend(tmpVec3);
593
- } else {
594
- this._instanceData[n++] = p.particle.position.x;
595
- this._instanceData[n++] = p.particle.position.y;
596
- this._instanceData[n++] = p.particle.position.z;
597
- this._wsBoundingBox.extend(p.particle.position);
598
- }
599
- this._instanceData[n++] = p.size;
600
- this._instanceData[n++] = p.rotation;
601
- this._instanceData[n++] = p.jitterAngle;
602
- this._instanceData[n++] = p.elapsedTime / p.particle.lifeSpan;
603
- if (worldSpace) {
604
- invWorldMatrix.transformVectorAffine(p.particle.velocity, tmpVec3);
605
- this._instanceData[n++] = tmpVec3.x;
606
- this._instanceData[n++] = tmpVec3.y;
607
- this._instanceData[n++] = tmpVec3.z;
608
- } else {
609
- this._instanceData[n++] = p.particle.velocity.x;
610
- this._instanceData[n++] = p.particle.velocity.y;
611
- this._instanceData[n++] = p.particle.velocity.z;
612
- }
613
- }
614
- let maxParticleSize = Math.max(Math.abs(this.particleSize1Min), Math.abs(this.particleSize1Max), Math.abs(this.particleSize2Min), Math.abs(this.particleSize2Max));
615
- invWorldMatrix.decompose(tmpVec3, null, null);
616
- const scale = Math.max(Math.abs(tmpVec3.x), Math.abs(tmpVec3.y), Math.abs(tmpVec3.z));
617
- maxParticleSize *= scale;
618
- if (this._jitterSpeed !== 0 && this.jitterPower !== 0) {
619
- maxParticleSize += 2 * Math.abs(this.jitterPower);
620
- }
621
- this._wsBoundingBox.minPoint.x -= maxParticleSize;
622
- this._wsBoundingBox.minPoint.y -= maxParticleSize;
623
- this._wsBoundingBox.minPoint.z -= maxParticleSize;
624
- this._wsBoundingBox.maxPoint.x += maxParticleSize;
625
- this._wsBoundingBox.maxPoint.y += maxParticleSize;
626
- this._wsBoundingBox.maxPoint.z += maxParticleSize;
627
- this._primitive.get().getVertexBuffer('texCoord0').bufferSubData(0, this._instanceData);
628
- }
629
- newParticle(num, worldMatrix) {
630
- for(let i = 0; i < num; i++){
631
- const particle = this.initParticle();
632
- particle.size1 *= this._scalar;
633
- particle.size2 *= this._scalar;
634
- particle.size2 -= particle.size1;
635
- const node = {
636
- particle,
637
- elapsedTime: 0,
638
- rotation: 0,
639
- size: particle.size1,
640
- ageBias: Math.random(),
641
- jitterAngle: 0
642
- };
643
- if (this._flags & PS_WORLDSPACE) {
644
- worldMatrix.transformPointAffine(particle.position, particle.position);
645
- worldMatrix.transformVectorAffine(particle.velocity, particle.velocity);
646
- }
647
- this._activeParticleList.push(node);
648
- }
649
- }
650
- /**
651
- * {@inheritDoc Drawable.getPickTarget }
652
- */ getPickTarget() {
653
- return this._pickTarget;
654
- }
655
- /**
656
- * {@inheritDoc Drawable.getMorphData}
657
- */ getMorphData() {
658
- return null;
659
- }
660
- /**
661
- * {@inheritDoc Drawable.getMorphInfo}
662
- */ getMorphInfo() {
663
- return null;
664
- }
665
- /**
666
- * {@inheritDoc Drawable.getQueueType}
667
- */ getQueueType() {
668
- return this._material.get()?.getQueueType() ?? QUEUE_OPAQUE;
669
- }
670
- /**
671
- * {@inheritDoc Drawable.isUnlit}
672
- */ isUnlit() {
673
- return !this._material.get()?.supportLighting();
674
- }
675
- /**
676
- * {@inheritDoc Drawable.needSceneColor}
677
- */ needSceneColor() {
678
- return this._material.get()?.needSceneColor();
679
- }
680
- /**
681
- * {@inheritDoc Drawable.needSceneDepth}
682
- */ needSceneDepth() {
683
- return this._material.get()?.needSceneDepth();
684
- }
685
- /**
686
- * {@inheritDoc Drawable.getMaterial}
687
- */ getMaterial() {
688
- return this._material.get();
689
- }
690
- /**
691
- * {@inheritDoc Drawable.getPrimitive}
692
- */ getPrimitive() {
693
- return this._primitive.get();
694
- }
695
- /**
696
- * {@inheritDoc SceneNode.isParticleSystem}
697
- */ isParticleSystem() {
698
- return true;
699
- }
700
- /**
701
- * {@inheritDoc Drawable.draw}
702
- */ draw(ctx) {
703
- if (this._activeParticleList.length > 0) {
704
- this.bind(ctx);
705
- this._material.get().draw(this._primitive.get(), ctx, this._activeParticleList.length);
706
- }
707
- }
708
- /**
709
- * {@inheritDoc SceneNode.dispose}
710
- */ dispose() {
711
- super.dispose();
712
- this._primitive.dispose();
713
- this._material.dispose();
714
- const func = ParticleSystem.updateFuncMap.get(this);
715
- if (func) {
716
- this._scene.off('update', func);
717
- }
718
- }
719
- _onDetached() {
720
- super._onDetached();
721
- const func = ParticleSystem.updateFuncMap.get(this);
722
- if (func) {
723
- this._scene.off('update', func);
724
- }
725
- }
726
- _onAttached() {
727
- super._onAttached();
728
- let func = ParticleSystem.updateFuncMap.get(this);
729
- if (!func) {
730
- func = this.update.bind(this);
731
- ParticleSystem.updateFuncMap.set(this, func);
732
- }
733
- this._scene.on('update', func);
734
- }
735
- }
736
-
737
- export { ParticleSystem };
738
- //# sourceMappingURL=particlesys.js.map