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