@zephyr3d/scene 0.6.1 → 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/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
|
@@ -1,52 +1,145 @@
|
|
|
1
|
+
import { Disposable } from '@zephyr3d/base';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Animation
|
|
4
|
+
* Animation clip
|
|
5
|
+
*
|
|
6
|
+
* Represents a named animation composed of multiple tracks targeting various objects/properties,
|
|
7
|
+
* with an overall duration, weight, and optional auto-play behavior. Tracks may target different
|
|
8
|
+
* objects and are grouped by a per-target array. Skeletons used by this clip are tracked for
|
|
9
|
+
* lifecycle and application during playback.
|
|
10
|
+
*
|
|
11
|
+
* Typical workflow:
|
|
12
|
+
* - Create a clip via `AnimationSet.createAnimation(name)`.
|
|
13
|
+
* - Add one or more `AnimationTrack`s via `addTrack(target, track)`.
|
|
14
|
+
* - Optionally register skeletons via `addSkeleton(...)`.
|
|
15
|
+
* - Start playback through the owning `AnimationSet.playAnimation(name, options)`.
|
|
16
|
+
*
|
|
3
17
|
* @public
|
|
4
|
-
*/ class AnimationClip {
|
|
18
|
+
*/ class AnimationClip extends Disposable {
|
|
5
19
|
/** @internal */ _name;
|
|
20
|
+
/** @internal */ _animationSet;
|
|
21
|
+
/** @internal */ _embedded;
|
|
6
22
|
/** @internal */ _duration;
|
|
23
|
+
/** @internal */ _autoPlay;
|
|
7
24
|
/** @internal */ _tracks;
|
|
25
|
+
_weight;
|
|
8
26
|
/** @internal */ _skeletons;
|
|
9
27
|
/**
|
|
10
28
|
* Creates an animation instance
|
|
11
29
|
* @param name - Name of the animation
|
|
12
30
|
* @param model - Parent node if this is a skeleton animation
|
|
13
|
-
*/ constructor(name){
|
|
31
|
+
*/ constructor(name, animationSet, embedded = false){
|
|
32
|
+
super();
|
|
14
33
|
this._name = name;
|
|
34
|
+
this._animationSet = animationSet;
|
|
35
|
+
this._embedded = embedded;
|
|
15
36
|
this._tracks = new Map();
|
|
16
37
|
this._duration = 0;
|
|
38
|
+
this._weight = 1;
|
|
39
|
+
this._autoPlay = false;
|
|
17
40
|
this._skeletons = new Set();
|
|
18
41
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
42
|
+
/**
|
|
43
|
+
* Whether this clip is embedded (owned inline by its container/resource).
|
|
44
|
+
*/ get embedded() {
|
|
45
|
+
return this._embedded;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The `AnimationSet` that owns this clip.
|
|
49
|
+
*/ get animationSet() {
|
|
50
|
+
return this._animationSet;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Global blend weight for the clip.
|
|
54
|
+
*
|
|
55
|
+
* Used by the animation system when combining multiple active clips.
|
|
56
|
+
*/ get weight() {
|
|
57
|
+
return this._weight;
|
|
23
58
|
}
|
|
24
|
-
|
|
59
|
+
set weight(val) {
|
|
60
|
+
this._weight = val;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether this clip should start playing automatically when loaded/instantiated.
|
|
64
|
+
*/ get autoPlay() {
|
|
65
|
+
return this._autoPlay;
|
|
66
|
+
}
|
|
67
|
+
set autoPlay(val) {
|
|
68
|
+
this._autoPlay = val;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The unique name of this clip.
|
|
72
|
+
*/ get name() {
|
|
25
73
|
return this._name;
|
|
26
74
|
}
|
|
27
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* All animation tracks grouped by target object.
|
|
77
|
+
*
|
|
78
|
+
* Key: target object; Value: list of `AnimationTrack`s affecting that target.
|
|
79
|
+
*/ get tracks() {
|
|
28
80
|
return this._tracks;
|
|
29
81
|
}
|
|
30
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* All skeletons referenced by this clip.
|
|
84
|
+
*/ get skeletons() {
|
|
31
85
|
return this._skeletons;
|
|
32
86
|
}
|
|
33
|
-
|
|
87
|
+
set skeletons(val) {
|
|
88
|
+
this._skeletons = val;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Total time span of the clip in seconds.
|
|
92
|
+
*
|
|
93
|
+
* Automatically extended when adding tracks with longer duration.
|
|
94
|
+
*/ get timeDuration() {
|
|
34
95
|
return this._duration;
|
|
35
96
|
}
|
|
97
|
+
set timeDuration(val) {
|
|
98
|
+
this._duration = val;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Add a skeleton used by this clip.
|
|
102
|
+
*
|
|
103
|
+
* @param skeletonId - Persistent ID of Skeleton to register for this clip.
|
|
104
|
+
*/ addSkeleton(skeletonId) {
|
|
105
|
+
this._skeletons.add(skeletonId);
|
|
106
|
+
}
|
|
36
107
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
|
|
108
|
+
* Remove a specific track from this clip.
|
|
109
|
+
*
|
|
110
|
+
* Errors if the track does not belong to this clip. Does nothing if not found.
|
|
111
|
+
*
|
|
112
|
+
* @param track - The track instance to remove.
|
|
113
|
+
* @returns This clip (for chaining).
|
|
114
|
+
*/ deleteTrack(track) {
|
|
115
|
+
if (track?.animation !== this) {
|
|
116
|
+
console.error('Cannot delete animation track which is not belongs to THIS animation');
|
|
117
|
+
}
|
|
118
|
+
for (const k of this._tracks.keys()){
|
|
119
|
+
const tracks = this._tracks.get(k);
|
|
120
|
+
const index = tracks.indexOf(track);
|
|
121
|
+
if (index >= 0) {
|
|
122
|
+
tracks.splice(index, 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return this;
|
|
43
126
|
}
|
|
44
127
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
128
|
+
* Add a track to this clip for a specific target object.
|
|
129
|
+
*
|
|
130
|
+
* Constraints:
|
|
131
|
+
* - The track must not already belong to another clip.
|
|
132
|
+
* - Only one track with the same blendId may exist per target in a single clip.
|
|
133
|
+
*
|
|
134
|
+
* Side effects:
|
|
135
|
+
* - Assigns this clip to `track.animation`.
|
|
136
|
+
* - Extends `timeDuration` to cover the track duration if longer.
|
|
137
|
+
* - Calls `track.reset(target)` to initialize the target state if needed.
|
|
138
|
+
*
|
|
139
|
+
* @param target - Target object controlled by the track.
|
|
140
|
+
* @param track - Track to add.
|
|
141
|
+
* @returns This clip (for chaining).
|
|
142
|
+
*/ addTrack(target, track) {
|
|
50
143
|
if (!track) {
|
|
51
144
|
return;
|
|
52
145
|
}
|
|
@@ -59,22 +152,51 @@
|
|
|
59
152
|
}
|
|
60
153
|
}
|
|
61
154
|
const blendId = track.getBlendId();
|
|
62
|
-
const tracks = this._tracks.get(
|
|
155
|
+
const tracks = this._tracks.get(target);
|
|
63
156
|
if (tracks && tracks.findIndex((track)=>track.getBlendId() === blendId) >= 0) {
|
|
64
157
|
console.error('Tracks with same BlendId could not be added to same animation');
|
|
65
158
|
return;
|
|
66
159
|
}
|
|
67
160
|
track.animation = this;
|
|
68
|
-
let trackInfo = this._tracks.get(
|
|
161
|
+
let trackInfo = this._tracks.get(target);
|
|
69
162
|
if (!trackInfo) {
|
|
70
163
|
trackInfo = [];
|
|
71
|
-
this._tracks.set(
|
|
164
|
+
this._tracks.set(target, trackInfo);
|
|
72
165
|
}
|
|
73
166
|
trackInfo.push(track);
|
|
74
|
-
this._duration = Math.max(this._duration, track.
|
|
75
|
-
track.reset(
|
|
167
|
+
this._duration = Math.max(this._duration, track.getDuration() ?? 0);
|
|
168
|
+
track.reset(target);
|
|
76
169
|
return this;
|
|
77
170
|
}
|
|
171
|
+
/** @internal */ resample(frames, callback) {
|
|
172
|
+
for(let frame = 0; frame <= frames; frame++){
|
|
173
|
+
const t = frame / this.timeDuration;
|
|
174
|
+
for (const [k, v] of this.tracks){
|
|
175
|
+
for (const track of v){
|
|
176
|
+
const state = track.calculateState(k, t);
|
|
177
|
+
track.applyState(k, state);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
for (const sk of this.skeletons){
|
|
181
|
+
const skeleton = this._animationSet.model.findSkeletonById(sk);
|
|
182
|
+
if (skeleton) {
|
|
183
|
+
skeleton.computeJoints();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
callback(frame);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Dispose internal resources/references held by this clip.
|
|
191
|
+
*
|
|
192
|
+
* Notes:
|
|
193
|
+
* - Clears track collections and disposes registered skeletons.
|
|
194
|
+
* - The clip becomes unusable after disposing.
|
|
195
|
+
*/ onDispose() {
|
|
196
|
+
super.onDispose();
|
|
197
|
+
this._tracks = null;
|
|
198
|
+
this._skeletons = null;
|
|
199
|
+
}
|
|
78
200
|
}
|
|
79
201
|
|
|
80
202
|
export { AnimationClip };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"animation.js","sources":["../../src/animation/animation.ts"],"sourcesContent":["import { Disposable } from '@zephyr3d/base';\r\nimport type { AnimationSet } from './animationset';\r\nimport type { AnimationTrack } from './animationtrack';\r\n\r\n/**\r\n * Animation clip\r\n *\r\n * Represents a named animation composed of multiple tracks targeting various objects/properties,\r\n * with an overall duration, weight, and optional auto-play behavior. Tracks may target different\r\n * objects and are grouped by a per-target array. Skeletons used by this clip are tracked for\r\n * lifecycle and application during playback.\r\n *\r\n * Typical workflow:\r\n * - Create a clip via `AnimationSet.createAnimation(name)`.\r\n * - Add one or more `AnimationTrack`s via `addTrack(target, track)`.\r\n * - Optionally register skeletons via `addSkeleton(...)`.\r\n * - Start playback through the owning `AnimationSet.playAnimation(name, options)`.\r\n *\r\n * @public\r\n */\r\nexport class AnimationClip extends Disposable {\r\n /** @internal */\r\n protected _name: string;\r\n /** @internal */\r\n protected _animationSet: AnimationSet;\r\n /** @internal */\r\n protected _embedded: boolean;\r\n /** @internal */\r\n protected _duration: number;\r\n /** @internal */\r\n protected _autoPlay: boolean;\r\n /** @internal */\r\n protected _tracks: Map<object, AnimationTrack[]>;\r\n protected _weight: number;\r\n /** @internal */\r\n protected _skeletons: Set<string>;\r\n /**\r\n * Creates an animation instance\r\n * @param name - Name of the animation\r\n * @param model - Parent node if this is a skeleton animation\r\n */\r\n constructor(name: string, animationSet: AnimationSet, embedded = false) {\r\n super();\r\n this._name = name;\r\n this._animationSet = animationSet;\r\n this._embedded = embedded;\r\n this._tracks = new Map();\r\n this._duration = 0;\r\n this._weight = 1;\r\n this._autoPlay = false;\r\n this._skeletons = new Set();\r\n }\r\n /**\r\n * Whether this clip is embedded (owned inline by its container/resource).\r\n */\r\n get embedded(): boolean {\r\n return this._embedded;\r\n }\r\n /**\r\n * The `AnimationSet` that owns this clip.\r\n */\r\n get animationSet() {\r\n return this._animationSet;\r\n }\r\n /**\r\n * Global blend weight for the clip.\r\n *\r\n * Used by the animation system when combining multiple active clips.\r\n */\r\n get weight() {\r\n return this._weight;\r\n }\r\n set weight(val: number) {\r\n this._weight = val;\r\n }\r\n /**\r\n * Whether this clip should start playing automatically when loaded/instantiated.\r\n */\r\n get autoPlay() {\r\n return this._autoPlay;\r\n }\r\n set autoPlay(val: boolean) {\r\n this._autoPlay = val;\r\n }\r\n /**\r\n * The unique name of this clip.\r\n */\r\n get name(): string {\r\n return this._name;\r\n }\r\n /**\r\n * All animation tracks grouped by target object.\r\n *\r\n * Key: target object; Value: list of `AnimationTrack`s affecting that target.\r\n */\r\n get tracks() {\r\n return this._tracks;\r\n }\r\n /**\r\n * All skeletons referenced by this clip.\r\n */\r\n get skeletons() {\r\n return this._skeletons;\r\n }\r\n set skeletons(val: Set<string>) {\r\n this._skeletons = val;\r\n }\r\n /**\r\n * Total time span of the clip in seconds.\r\n *\r\n * Automatically extended when adding tracks with longer duration.\r\n */\r\n get timeDuration(): number {\r\n return this._duration;\r\n }\r\n set timeDuration(val: number) {\r\n this._duration = val;\r\n }\r\n /**\r\n * Add a skeleton used by this clip.\r\n *\r\n * @param skeletonId - Persistent ID of Skeleton to register for this clip.\r\n */\r\n addSkeleton(skeletonId: string) {\r\n this._skeletons.add(skeletonId);\r\n }\r\n /**\r\n * Remove a specific track from this clip.\r\n *\r\n * Errors if the track does not belong to this clip. Does nothing if not found.\r\n *\r\n * @param track - The track instance to remove.\r\n * @returns This clip (for chaining).\r\n */\r\n deleteTrack(track: AnimationTrack): this {\r\n if (track?.animation !== this) {\r\n console.error('Cannot delete animation track which is not belongs to THIS animation');\r\n }\r\n for (const k of this._tracks.keys()) {\r\n const tracks = this._tracks.get(k);\r\n const index = tracks.indexOf(track);\r\n if (index >= 0) {\r\n tracks.splice(index, 1);\r\n }\r\n }\r\n return this;\r\n }\r\n /**\r\n * Add a track to this clip for a specific target object.\r\n *\r\n * Constraints:\r\n * - The track must not already belong to another clip.\r\n * - Only one track with the same blendId may exist per target in a single clip.\r\n *\r\n * Side effects:\r\n * - Assigns this clip to `track.animation`.\r\n * - Extends `timeDuration` to cover the track duration if longer.\r\n * - Calls `track.reset(target)` to initialize the target state if needed.\r\n *\r\n * @param target - Target object controlled by the track.\r\n * @param track - Track to add.\r\n * @returns This clip (for chaining).\r\n */\r\n addTrack(target: object, track: AnimationTrack): this {\r\n if (!track) {\r\n return;\r\n }\r\n if (track.animation) {\r\n if (track.animation === this) {\r\n return;\r\n } else {\r\n console.error('Track is already in another animation');\r\n return;\r\n }\r\n }\r\n const blendId = track.getBlendId();\r\n const tracks = this._tracks.get(target);\r\n if (tracks && tracks.findIndex((track) => track.getBlendId() === blendId) >= 0) {\r\n console.error('Tracks with same BlendId could not be added to same animation');\r\n return;\r\n }\r\n track.animation = this;\r\n let trackInfo = this._tracks.get(target);\r\n if (!trackInfo) {\r\n trackInfo = [];\r\n this._tracks.set(target, trackInfo);\r\n }\r\n trackInfo.push(track);\r\n this._duration = Math.max(this._duration, track.getDuration() ?? 0);\r\n track.reset(target);\r\n return this;\r\n }\r\n /** @internal */\r\n resample(frames: number, callback: (frame: number) => void) {\r\n for (let frame = 0; frame <= frames; frame++) {\r\n const t = frame / this.timeDuration;\r\n for (const [k, v] of this.tracks) {\r\n for (const track of v) {\r\n const state = track.calculateState(k, t);\r\n track.applyState(k, state);\r\n }\r\n }\r\n for (const sk of this.skeletons) {\r\n const skeleton = this._animationSet.model.findSkeletonById(sk);\r\n if (skeleton) {\r\n skeleton.computeJoints();\r\n }\r\n }\r\n callback(frame);\r\n }\r\n }\r\n /**\r\n * Dispose internal resources/references held by this clip.\r\n *\r\n * Notes:\r\n * - Clears track collections and disposes registered skeletons.\r\n * - The clip becomes unusable after disposing.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._tracks = null;\r\n this._skeletons = null;\r\n }\r\n}\r\n"],"names":["AnimationClip","Disposable","_weight","name","animationSet","embedded","_name","_animationSet","_embedded","_tracks","Map","_duration","_autoPlay","_skeletons","Set","weight","val","autoPlay","tracks","skeletons","timeDuration","addSkeleton","skeletonId","add","deleteTrack","track","animation","console","error","k","keys","get","index","indexOf","splice","addTrack","target","blendId","getBlendId","findIndex","trackInfo","set","push","Math","max","getDuration","reset","resample","frames","callback","frame","t","v","state","calculateState","applyState","sk","skeleton","model","findSkeletonById","computeJoints","onDispose"],"mappings":"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"}
|
|
@@ -1,53 +1,116 @@
|
|
|
1
|
-
import { weightedAverage } from '@zephyr3d/base';
|
|
2
|
-
import {
|
|
1
|
+
import { Disposable, DWeakRef, weightedAverage } from '@zephyr3d/base';
|
|
2
|
+
import { AnimationClip } from './animation.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Animation set
|
|
6
|
-
*
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Animation set
|
|
6
|
+
*
|
|
7
|
+
* Manages a collection of named animation clips for a model and orchestrates:
|
|
8
|
+
* - Playback state (time, loops, speed, weights, fade-in/out).
|
|
9
|
+
* - Blending across multiple tracks targeting the same property via weighted averages.
|
|
10
|
+
* - Skeleton usage and application for clips that drive skeletal animation.
|
|
11
|
+
* - Active track registration and cleanup as clips start/stop.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* - Create or retrieve `AnimationClip`s by name.
|
|
15
|
+
* - Start playback with `playAnimation(name, options)`.
|
|
16
|
+
* - Advance animation with `update(deltaSeconds)`.
|
|
17
|
+
* - Optionally adjust weight while playing with `setAnimationWeight(name, weight)`.
|
|
18
|
+
*
|
|
19
|
+
* Lifetime:
|
|
20
|
+
* - Disposing the set releases references to the model, clips, and clears active state.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/ class AnimationSet extends Disposable {
|
|
8
24
|
/** @internal */ _model;
|
|
9
25
|
/** @internal */ _animations;
|
|
10
|
-
/** @internal */
|
|
26
|
+
/** @internal */ _skeletons;
|
|
11
27
|
/** @internal */ _activeTracks;
|
|
12
28
|
/** @internal */ _activeSkeletons;
|
|
13
29
|
/** @internal */ _activeAnimations;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.
|
|
30
|
+
/**
|
|
31
|
+
* Create an AnimationSet controlling the provided model.
|
|
32
|
+
*
|
|
33
|
+
* @param model - The SceneNode (model root) controlled by this animation set.
|
|
34
|
+
*/ constructor(model){
|
|
35
|
+
super();
|
|
36
|
+
this._model = new DWeakRef(model);
|
|
21
37
|
this._animations = {};
|
|
22
38
|
this._activeTracks = new Map();
|
|
23
39
|
this._activeSkeletons = new Map();
|
|
24
40
|
this._activeAnimations = new Map();
|
|
41
|
+
this._skeletons = [];
|
|
25
42
|
}
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
43
|
+
/**
|
|
44
|
+
* The model (SceneNode) controlled by this animation set.
|
|
45
|
+
*/ get model() {
|
|
46
|
+
return this._model.get();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Number of animation clips registered in this set.
|
|
28
50
|
*/ get numAnimations() {
|
|
29
51
|
return Object.getOwnPropertyNames(this._animations).length;
|
|
30
52
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
53
|
+
/** @internal */ get skeletons() {
|
|
54
|
+
return this._skeletons;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Retrieve an animation clip by name.
|
|
58
|
+
*
|
|
59
|
+
* @param name - Name of the animation.
|
|
60
|
+
* @returns The clip if present; otherwise null.
|
|
34
61
|
*/ get(name) {
|
|
35
62
|
return this._animations[name] ?? null;
|
|
36
63
|
}
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Create and register a new animation clip.
|
|
66
|
+
*
|
|
67
|
+
* @param name - Unique name for the animation clip.
|
|
68
|
+
* @param embedded - Whether the clip is embedded/owned (implementation-specific). Default false.
|
|
69
|
+
* @returns The created clip, or null if the name is empty or not unique.
|
|
70
|
+
*/ createAnimation(name, embedded = false) {
|
|
71
|
+
if (!name || this._animations[name]) {
|
|
72
|
+
console.error('Animation must have unique name');
|
|
73
|
+
return null;
|
|
74
|
+
} else {
|
|
75
|
+
const animation = new AnimationClip(name, this, embedded);
|
|
76
|
+
this._animations[name] = animation;
|
|
77
|
+
this._model.get().scene.queueUpdateNode(this._model.get());
|
|
78
|
+
return animation;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Delete and dispose an animation clip by name.
|
|
83
|
+
*
|
|
84
|
+
* - If the animation is currently playing, it is first stopped (immediately).
|
|
85
|
+
*
|
|
86
|
+
* @param name - Name of the animation to remove.
|
|
87
|
+
*/ deleteAnimation(name) {
|
|
88
|
+
const animation = this._animations[name];
|
|
89
|
+
if (animation) {
|
|
90
|
+
this.stopAnimation(name);
|
|
91
|
+
delete this._animations[name];
|
|
92
|
+
animation.dispose();
|
|
93
|
+
}
|
|
41
94
|
}
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
95
|
+
/**
|
|
96
|
+
* Get the list of all registered animation names.
|
|
97
|
+
*
|
|
98
|
+
* @returns An array of clip names.
|
|
45
99
|
*/ getAnimationNames() {
|
|
46
100
|
return Object.keys(this._animations);
|
|
47
101
|
}
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Advance and apply active animations.
|
|
104
|
+
*
|
|
105
|
+
* Responsibilities per call:
|
|
106
|
+
* - Update time cursor for each active clip (respecting speedRatio and looping).
|
|
107
|
+
* - Enforce repeat limits and apply fade-out termination if configured.
|
|
108
|
+
* - For each animated target, blend active tracks (weighted by clip weight × fade-in × fade-out)
|
|
109
|
+
* and apply the resulting state to the target.
|
|
110
|
+
* - Apply all active skeletons to update skinning transforms.
|
|
111
|
+
*
|
|
112
|
+
* @param deltaInSeconds - Time step in seconds since last update.
|
|
113
|
+
*/ update(deltaInSeconds) {
|
|
51
114
|
this._activeAnimations.forEach((v, k)=>{
|
|
52
115
|
if (v.fadeOut > 0 && v.fadeOutStart < 0) {
|
|
53
116
|
v.fadeOutStart = v.animateTime;
|
|
@@ -56,7 +119,7 @@ import { Application } from '../app.js';
|
|
|
56
119
|
if (v.firstFrame) {
|
|
57
120
|
v.firstFrame = false;
|
|
58
121
|
} else {
|
|
59
|
-
const timeAdvance =
|
|
122
|
+
const timeAdvance = deltaInSeconds * v.speedRatio;
|
|
60
123
|
v.currentTime += timeAdvance;
|
|
61
124
|
v.animateTime += timeAdvance;
|
|
62
125
|
if (v.currentTime > k.timeDuration) {
|
|
@@ -77,7 +140,9 @@ import { Application } from '../app.js';
|
|
|
77
140
|
});
|
|
78
141
|
// Update tracks
|
|
79
142
|
this._activeTracks.forEach((v, k)=>{
|
|
80
|
-
v.forEach((
|
|
143
|
+
v.forEach((alltracks)=>{
|
|
144
|
+
// Only deal with tracks which have not been removed
|
|
145
|
+
const tracks = alltracks.filter((track)=>track.animation && this.isPlayingAnimation(track.animation.name));
|
|
81
146
|
if (tracks.length > 0) {
|
|
82
147
|
const weights = tracks.map((track)=>{
|
|
83
148
|
const info = this._activeAnimations.get(track.animation);
|
|
@@ -89,7 +154,10 @@ import { Application } from '../app.js';
|
|
|
89
154
|
}
|
|
90
155
|
return weight * fadeIn * fadeOut;
|
|
91
156
|
});
|
|
92
|
-
const states = tracks.map((track)=>
|
|
157
|
+
const states = tracks.map((track)=>{
|
|
158
|
+
const t = this._activeAnimations.get(track.animation).currentTime / track.animation.timeDuration * track.getDuration();
|
|
159
|
+
return track.calculateState(k, t);
|
|
160
|
+
});
|
|
93
161
|
const state = weightedAverage(weights, states, (a, b, t)=>{
|
|
94
162
|
return tracks[0].mixState(a, b, t);
|
|
95
163
|
});
|
|
@@ -102,26 +170,31 @@ import { Application } from '../app.js';
|
|
|
102
170
|
k.apply();
|
|
103
171
|
});
|
|
104
172
|
}
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @returns true if
|
|
173
|
+
/**
|
|
174
|
+
* Check whether an animation is currently playing.
|
|
175
|
+
*
|
|
176
|
+
* @param name - Optional animation name. If omitted, returns true if any animation is playing.
|
|
177
|
+
* @returns True if playing; otherwise false.
|
|
109
178
|
*/ isPlayingAnimation(name) {
|
|
110
179
|
return name ? this._activeAnimations.has(this._animations[name]) : this._activeAnimations.size > 0;
|
|
111
180
|
}
|
|
112
|
-
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Get an animation clip by name.
|
|
183
|
+
*
|
|
184
|
+
* Alias of `get(name)` returning a nullable type.
|
|
185
|
+
*
|
|
186
|
+
* @param name - Name of the animation.
|
|
187
|
+
* @returns The clip if present; otherwise null.
|
|
188
|
+
*/ getAnimationClip(name) {
|
|
189
|
+
return this._animations[name] ?? null;
|
|
120
190
|
}
|
|
121
|
-
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
191
|
+
/**
|
|
192
|
+
* Set the runtime blend weight for a currently playing animation.
|
|
193
|
+
*
|
|
194
|
+
* Has no effect if the clip is not active.
|
|
195
|
+
*
|
|
196
|
+
* @param name - Name of the playing animation.
|
|
197
|
+
* @param weight - New weight value used during blending.
|
|
125
198
|
*/ setAnimationWeight(name, weight) {
|
|
126
199
|
const ani = this._animations[name];
|
|
127
200
|
const info = this._activeAnimations.get(ani);
|
|
@@ -129,10 +202,16 @@ import { Application } from '../app.js';
|
|
|
129
202
|
info.weight = weight;
|
|
130
203
|
}
|
|
131
204
|
}
|
|
132
|
-
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
205
|
+
/**
|
|
206
|
+
* Start (or update) playback of an animation clip.
|
|
207
|
+
*
|
|
208
|
+
* Behavior:
|
|
209
|
+
* - If the clip is already playing, updates its fade-in (resets fade-out).
|
|
210
|
+
* - Otherwise initializes playback state (repeat counter, speed, weight, initial time).
|
|
211
|
+
* - Registers clip tracks and skeletons into the active sets for blending and application.
|
|
212
|
+
*
|
|
213
|
+
* @param name - Name of the animation to play.
|
|
214
|
+
* @param options - Playback options (repeat, speedRatio, fadeIn).
|
|
136
215
|
*/ playAnimation(name, options) {
|
|
137
216
|
const ani = this._animations[name];
|
|
138
217
|
if (!ani) {
|
|
@@ -147,7 +226,7 @@ import { Application } from '../app.js';
|
|
|
147
226
|
} else {
|
|
148
227
|
const repeat = options?.repeat ?? 0;
|
|
149
228
|
const speedRatio = options?.speedRatio ?? 1;
|
|
150
|
-
const weight = options?.weight ?? 1;
|
|
229
|
+
const weight = options?.weight ?? ani.weight ?? 1;
|
|
151
230
|
this._activeAnimations.set(ani, {
|
|
152
231
|
repeat,
|
|
153
232
|
weight,
|
|
@@ -177,18 +256,31 @@ import { Application } from '../app.js';
|
|
|
177
256
|
}
|
|
178
257
|
});
|
|
179
258
|
ani.skeletons?.forEach((v, k)=>{
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
182
|
-
this._activeSkeletons.
|
|
183
|
-
|
|
184
|
-
|
|
259
|
+
const skeleton = this.model.findSkeletonById(k);
|
|
260
|
+
if (skeleton) {
|
|
261
|
+
const refcount = this._activeSkeletons.get(skeleton);
|
|
262
|
+
if (refcount) {
|
|
263
|
+
this._activeSkeletons.set(skeleton, refcount + 1);
|
|
264
|
+
} else {
|
|
265
|
+
this._activeSkeletons.set(skeleton, 1);
|
|
266
|
+
}
|
|
267
|
+
skeleton.playing = true;
|
|
185
268
|
}
|
|
186
269
|
});
|
|
187
270
|
}
|
|
188
271
|
}
|
|
189
|
-
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
272
|
+
/**
|
|
273
|
+
* Stop playback of an animation clip.
|
|
274
|
+
*
|
|
275
|
+
* Behavior:
|
|
276
|
+
* - If `options.fadeOut > 0`, marks the clip for fade-out; actual removal occurs after fade completes.
|
|
277
|
+
* - If `fadeOut` is 0 or omitted, immediately:
|
|
278
|
+
* - Removes the clip from active animations.
|
|
279
|
+
* - Unregisters its tracks from active track maps.
|
|
280
|
+
* - Decrements skeleton reference counts; resets and removes skeletons when refcount reaches 0.
|
|
281
|
+
*
|
|
282
|
+
* @param name - Name of the animation to stop.
|
|
283
|
+
* @param options - Optional fade-out configuration.
|
|
192
284
|
*/ stopAnimation(name, options) {
|
|
193
285
|
const ani = this._animations[name];
|
|
194
286
|
const info = this._activeAnimations.get(ani);
|
|
@@ -199,28 +291,36 @@ import { Application } from '../app.js';
|
|
|
199
291
|
info.fadeOutStart = -1;
|
|
200
292
|
} else {
|
|
201
293
|
this._activeAnimations.delete(ani);
|
|
202
|
-
this._activeTracks.forEach((v
|
|
294
|
+
this._activeTracks.forEach((v)=>{
|
|
203
295
|
v.forEach((tracks, id)=>{
|
|
204
296
|
v.set(id, tracks.filter((track)=>track.animation !== ani));
|
|
205
297
|
});
|
|
206
298
|
});
|
|
207
299
|
ani.skeletons?.forEach((v, k)=>{
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
300
|
+
const skeleton = this.model.findSkeletonById(k);
|
|
301
|
+
if (skeleton) {
|
|
302
|
+
const refcount = this._activeSkeletons.get(skeleton);
|
|
303
|
+
if (refcount === 1) {
|
|
304
|
+
skeleton.reset();
|
|
305
|
+
this._activeSkeletons.delete(skeleton);
|
|
306
|
+
} else {
|
|
307
|
+
this._activeSkeletons.set(skeleton, refcount - 1);
|
|
308
|
+
}
|
|
214
309
|
}
|
|
215
310
|
});
|
|
216
311
|
}
|
|
217
312
|
}
|
|
218
313
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Dispose the animation set and release owned resources.
|
|
316
|
+
*
|
|
317
|
+
* - Disposes the weak reference to the model.
|
|
318
|
+
* - Disposes all registered animation clips.
|
|
319
|
+
* - Clears active animations, tracks, and skeleton references.
|
|
320
|
+
*/ onDispose() {
|
|
321
|
+
super.onDispose();
|
|
322
|
+
this._model?.dispose();
|
|
323
|
+
this._model = null;
|
|
224
324
|
for(const k in this._animations){
|
|
225
325
|
this._animations[k].dispose();
|
|
226
326
|
}
|