@zephyr3d/scene 0.9.2 → 0.9.4
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/animationset.js +135 -135
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ik_chain_builder.js +68 -0
- package/dist/animation/ik/ik_chain_builder.js.map +1 -0
- package/dist/animation/ik/ik_pole_constraint.js +2 -7
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +146 -146
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/math.js +16 -0
- package/dist/animation/joint_dynamics/math.js.map +1 -0
- package/dist/animation/spring/spring_system.js +75 -75
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring2/constraints.js.map +1 -1
- package/dist/animation/spring2/controller.js +64 -64
- package/dist/animation/spring2/controller.js.map +1 -1
- package/dist/animation/spring2/math.js.map +1 -1
- package/dist/animation/spring2/spring_system.js +8 -8
- package/dist/animation/spring2/spring_system.js.map +1 -1
- package/dist/app/engine.js +119 -71
- package/dist/app/engine.js.map +1 -1
- package/dist/asset/assetmanager.js +296 -244
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +1 -0
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/camera/camera.js +184 -184
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +685 -38
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +290 -290
- package/dist/material/material.js.map +1 -1
- package/dist/material/msdf_text.js +180 -0
- package/dist/material/msdf_text.js.map +1 -0
- package/dist/material/msdf_text_sprite.js +64 -0
- package/dist/material/msdf_text_sprite.js.map +1 -0
- package/dist/material/pbrblueprint.js +123 -108
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/shader/helper.js +6 -3
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite_sdf.js +106 -0
- package/dist/material/sprite_sdf.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/posteffect/ssr.js +1 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/render/abuffer_oit.js +1 -0
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +3 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +28 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +1 -0
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/render_queue.js +1 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +93 -93
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -3
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js +22 -22
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/scene/basesprite.js +1 -5
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +29 -17
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +1 -0
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +8 -9
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +96 -0
- package/dist/scene/meshdrawable.js.map +1 -0
- package/dist/scene/msdftext.js +341 -0
- package/dist/scene/msdftext.js.map +1 -0
- package/dist/scene/msdftextsprite.js +349 -0
- package/dist/scene/msdftextsprite.js.map +1 -0
- package/dist/scene/particlesys.js +1 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +1 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -0
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sdftextsprite.js +322 -0
- package/dist/scene/sdftextsprite.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/textsprite.js +120 -0
- package/dist/scene/textsprite.js.map +1 -0
- package/dist/scene/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shadow/shader.js +1 -0
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shapes/torus.js +90 -59
- 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/src/app/app.js +129 -0
- package/dist/src/app/app.js.map +1 -0
- package/dist/src/app/inputmgr.js +267 -0
- 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/src/blitter/bilateralblur.js +221 -0
- 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/src/utility/textures/ggxlut.js +213 -0
- 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/text/font/font_asset.js +884 -0
- package/dist/text/font/font_asset.js.map +1 -0
- package/dist/text/font/sfnt_reader.js +43 -0
- package/dist/text/font/sfnt_reader.js.map +1 -0
- package/dist/text/msdf/generator.js +417 -0
- package/dist/text/msdf/generator.js.map +1 -0
- package/dist/text/msdf/shape.js +143 -0
- package/dist/text/msdf/shape.js.map +1 -0
- package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
- package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js +47 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
- package/dist/text/runtime/text_layout.js +96 -0
- package/dist/text/runtime/text_layout.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/inputs.js +1275 -1091
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +505 -490
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +32 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- 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/manager.js +55 -11
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +2 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +2 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +2 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +2 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +2 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +2 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +2 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +2 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +2 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +516 -0
- package/dist/utility/serialization/scene/text.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +2 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +4 -4
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/values.js +1 -5
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
- package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
- package/dist/animation/spring/spring_bone.js +0 -240
- package/dist/animation/spring/spring_bone.js.map +0 -1
- package/dist/animation/spring/spring_bone_collider.js +0 -198
- package/dist/animation/spring/spring_bone_collider.js.map +0 -1
- package/dist/animation/spring/spring_bone_constraint.js +0 -170
- package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
- package/dist/animation/spring/spring_bone_system.js +0 -328
- package/dist/animation/spring/spring_bone_system.js.map +0 -1
- package/dist/render/sky_motion_vector.js +0 -85
- package/dist/render/sky_motion_vector.js.map +0 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { AnimationTrack } from './animationtrack.js';
|
|
2
|
+
import { Interpolator } from '@zephyr3d/base';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Translate animation track
|
|
6
|
+
* @public
|
|
7
|
+
*/ class PropertyTrack extends AnimationTrack {
|
|
8
|
+
_state;
|
|
9
|
+
_stateAlpha;
|
|
10
|
+
_target;
|
|
11
|
+
_prop;
|
|
12
|
+
_count;
|
|
13
|
+
_interpolator;
|
|
14
|
+
_interpolatorAlpha;
|
|
15
|
+
/**
|
|
16
|
+
* Create an instance of TranslationTrack from keyframe values
|
|
17
|
+
* @param prop - Property to be animated
|
|
18
|
+
*/ constructor(prop, value, embedded){
|
|
19
|
+
super(embedded);
|
|
20
|
+
this._prop = prop;
|
|
21
|
+
this._target = '';
|
|
22
|
+
this._state = {
|
|
23
|
+
num: [
|
|
24
|
+
0,
|
|
25
|
+
0,
|
|
26
|
+
0,
|
|
27
|
+
0
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
this._stateAlpha = null;
|
|
31
|
+
this._interpolator = null;
|
|
32
|
+
this._interpolatorAlpha = null;
|
|
33
|
+
if (value) {
|
|
34
|
+
this._state.num = value.slice();
|
|
35
|
+
}
|
|
36
|
+
switch(this._prop.type){
|
|
37
|
+
case 'float':
|
|
38
|
+
this._count = 1;
|
|
39
|
+
this._interpolator = new Interpolator('cubicspline-natural', 'number', new Float32Array([
|
|
40
|
+
0,
|
|
41
|
+
1
|
|
42
|
+
]), new Float32Array([
|
|
43
|
+
this._state.num[0],
|
|
44
|
+
this._state.num[0]
|
|
45
|
+
]));
|
|
46
|
+
break;
|
|
47
|
+
case 'vec2':
|
|
48
|
+
this._count = 2;
|
|
49
|
+
this._interpolator = new Interpolator('cubicspline-natural', 'vec2', new Float32Array([
|
|
50
|
+
0,
|
|
51
|
+
1
|
|
52
|
+
]), new Float32Array([
|
|
53
|
+
...this._state.num.slice(0, 2),
|
|
54
|
+
...this._state.num.slice(0, 2)
|
|
55
|
+
]));
|
|
56
|
+
break;
|
|
57
|
+
case 'rgb':
|
|
58
|
+
case 'vec3':
|
|
59
|
+
this._count = 3;
|
|
60
|
+
this._interpolator = new Interpolator('cubicspline-natural', 'vec3', new Float32Array([
|
|
61
|
+
0,
|
|
62
|
+
1
|
|
63
|
+
]), new Float32Array([
|
|
64
|
+
...this._state.num.slice(0, 3),
|
|
65
|
+
...this._state.num.slice(0, 3)
|
|
66
|
+
]));
|
|
67
|
+
break;
|
|
68
|
+
case 'vec4':
|
|
69
|
+
this._count = 4;
|
|
70
|
+
this._interpolator = new Interpolator('cubicspline-natural', 'vec4', new Float32Array([
|
|
71
|
+
0,
|
|
72
|
+
1
|
|
73
|
+
]), new Float32Array([
|
|
74
|
+
...this._state.num.slice(0, 4),
|
|
75
|
+
...this._state.num.slice(0, 4)
|
|
76
|
+
]));
|
|
77
|
+
break;
|
|
78
|
+
case 'rgba':
|
|
79
|
+
this._count = 4;
|
|
80
|
+
this._interpolator = new Interpolator('linear', 'vec3', new Float32Array([
|
|
81
|
+
0,
|
|
82
|
+
1
|
|
83
|
+
]), new Float32Array([
|
|
84
|
+
...this._state.num.slice(0, 3),
|
|
85
|
+
...this._state.num.slice(0, 3)
|
|
86
|
+
]));
|
|
87
|
+
this._interpolatorAlpha = new Interpolator('linear', 'number', new Float32Array([
|
|
88
|
+
0,
|
|
89
|
+
1
|
|
90
|
+
]), new Float32Array([
|
|
91
|
+
this._state.num[3],
|
|
92
|
+
this._state.num[3]
|
|
93
|
+
]));
|
|
94
|
+
this._stateAlpha = {
|
|
95
|
+
num: [
|
|
96
|
+
this._state.num[3]
|
|
97
|
+
]
|
|
98
|
+
};
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`Property '${this._prop.name}' cannot be animated`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
get target() {
|
|
105
|
+
return this._target;
|
|
106
|
+
}
|
|
107
|
+
set target(val) {
|
|
108
|
+
this._target = val;
|
|
109
|
+
}
|
|
110
|
+
get interpolator() {
|
|
111
|
+
return this._interpolator;
|
|
112
|
+
}
|
|
113
|
+
set interpolator(interpolator) {
|
|
114
|
+
this._interpolator = interpolator;
|
|
115
|
+
}
|
|
116
|
+
get interpolatorAlpha() {
|
|
117
|
+
return this._interpolatorAlpha;
|
|
118
|
+
}
|
|
119
|
+
set interpolatorAlpha(interpolator) {
|
|
120
|
+
this._interpolatorAlpha = interpolator ?? null;
|
|
121
|
+
if (!this._stateAlpha && this._interpolatorAlpha) {
|
|
122
|
+
this._stateAlpha = {
|
|
123
|
+
num: [
|
|
124
|
+
0
|
|
125
|
+
]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
calculateState(target, currentTime) {
|
|
130
|
+
this._interpolator.interpolate(currentTime, this._state.num);
|
|
131
|
+
if (this._interpolatorAlpha) {
|
|
132
|
+
this._interpolatorAlpha.interpolate(currentTime, this._stateAlpha.num);
|
|
133
|
+
this._state.num[3] = this._stateAlpha.num[0];
|
|
134
|
+
}
|
|
135
|
+
return this._state;
|
|
136
|
+
}
|
|
137
|
+
applyState(target, state) {
|
|
138
|
+
this._prop.set.call(target, state);
|
|
139
|
+
}
|
|
140
|
+
mixState(a, b, t) {
|
|
141
|
+
const v = [];
|
|
142
|
+
for(let i = 0; i < this._count; i++){
|
|
143
|
+
v[i] = a.num[i] + t * (b.num[i] - a.num[i]);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
num: v
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
getBlendId() {
|
|
150
|
+
return this._prop;
|
|
151
|
+
}
|
|
152
|
+
getDuration() {
|
|
153
|
+
return this._interpolator.maxTime;
|
|
154
|
+
}
|
|
155
|
+
getProp() {
|
|
156
|
+
return this._prop;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { PropertyTrack };
|
|
161
|
+
//# sourceMappingURL=proptrack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proptrack.js","sources":["../../../src/animation/proptrack.ts"],"sourcesContent":["import { AnimationTrack } from './animationtrack';\r\nimport type { PropertyAccessor, PropertyValue } from '../utility';\r\nimport { Interpolator } from '@zephyr3d/base';\r\n\r\n/**\r\n * Translate animation track\r\n * @public\r\n */\r\nexport class PropertyTrack extends AnimationTrack<PropertyValue> {\r\n private readonly _state: PropertyValue;\r\n private _stateAlpha: PropertyValue;\r\n private _target: string;\r\n private readonly _prop: PropertyAccessor;\r\n private readonly _count: number;\r\n private _interpolator: Interpolator;\r\n private _interpolatorAlpha: Interpolator;\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param prop - Property to be animated\r\n */\r\n constructor(prop: PropertyAccessor, value?: number[], embedded?: boolean) {\r\n super(embedded);\r\n this._prop = prop;\r\n this._target = '';\r\n this._state = { num: [0, 0, 0, 0] };\r\n this._stateAlpha = null;\r\n this._interpolator = null;\r\n this._interpolatorAlpha = null;\r\n if (value) {\r\n this._state.num = value.slice();\r\n }\r\n switch (this._prop.type) {\r\n case 'float':\r\n this._count = 1;\r\n this._interpolator = new Interpolator(\r\n 'cubicspline-natural',\r\n 'number',\r\n new Float32Array([0, 1]),\r\n new Float32Array([this._state.num[0], this._state.num[0]])\r\n );\r\n break;\r\n case 'vec2':\r\n this._count = 2;\r\n this._interpolator = new Interpolator(\r\n 'cubicspline-natural',\r\n 'vec2',\r\n new Float32Array([0, 1]),\r\n new Float32Array([...this._state.num.slice(0, 2), ...this._state.num.slice(0, 2)])\r\n );\r\n break;\r\n case 'rgb':\r\n case 'vec3':\r\n this._count = 3;\r\n this._interpolator = new Interpolator(\r\n 'cubicspline-natural',\r\n 'vec3',\r\n new Float32Array([0, 1]),\r\n new Float32Array([...this._state.num.slice(0, 3), ...this._state.num.slice(0, 3)])\r\n );\r\n break;\r\n case 'vec4':\r\n this._count = 4;\r\n this._interpolator = new Interpolator(\r\n 'cubicspline-natural',\r\n 'vec4',\r\n new Float32Array([0, 1]),\r\n new Float32Array([...this._state.num.slice(0, 4), ...this._state.num.slice(0, 4)])\r\n );\r\n break;\r\n case 'rgba':\r\n this._count = 4;\r\n this._interpolator = new Interpolator(\r\n 'linear',\r\n 'vec3',\r\n new Float32Array([0, 1]),\r\n new Float32Array([...this._state.num.slice(0, 3), ...this._state.num.slice(0, 3)])\r\n );\r\n this._interpolatorAlpha = new Interpolator(\r\n 'linear',\r\n 'number',\r\n new Float32Array([0, 1]),\r\n new Float32Array([this._state.num[3], this._state.num[3]])\r\n );\r\n this._stateAlpha = { num: [this._state.num[3]] };\r\n break;\r\n default:\r\n throw new Error(`Property '${this._prop.name}' cannot be animated`);\r\n }\r\n }\r\n get target() {\r\n return this._target;\r\n }\r\n set target(val: string) {\r\n this._target = val;\r\n }\r\n get interpolator() {\r\n return this._interpolator;\r\n }\r\n set interpolator(interpolator: Interpolator) {\r\n this._interpolator = interpolator;\r\n }\r\n get interpolatorAlpha() {\r\n return this._interpolatorAlpha;\r\n }\r\n set interpolatorAlpha(interpolator: Interpolator) {\r\n this._interpolatorAlpha = interpolator ?? null;\r\n if (!this._stateAlpha && this._interpolatorAlpha) {\r\n this._stateAlpha = { num: [0] };\r\n }\r\n }\r\n calculateState(target: unknown, currentTime: number): PropertyValue {\r\n this._interpolator.interpolate(currentTime, this._state.num);\r\n if (this._interpolatorAlpha) {\r\n this._interpolatorAlpha.interpolate(currentTime, this._stateAlpha.num);\r\n this._state.num[3] = this._stateAlpha.num[0];\r\n }\r\n return this._state;\r\n }\r\n applyState(target: object, state: PropertyValue) {\r\n this._prop.set.call(target, state);\r\n }\r\n mixState(a: PropertyValue, b: PropertyValue, t: number): PropertyValue {\r\n const v: number[] = [];\r\n for (let i = 0; i < this._count; i++) {\r\n v[i] = a.num[i] + t * (b.num[i] - a.num[i]);\r\n }\r\n return { num: v };\r\n }\r\n getBlendId(): unknown {\r\n return this._prop;\r\n }\r\n getDuration(): number {\r\n return this._interpolator.maxTime;\r\n }\r\n getProp(): PropertyAccessor {\r\n return this._prop;\r\n }\r\n}\r\n"],"names":["PropertyTrack","AnimationTrack","_state","_stateAlpha","_target","_prop","_count","_interpolator","_interpolatorAlpha","prop","value","embedded","num","slice","type","Interpolator","Float32Array","Error","name","target","val","interpolator","interpolatorAlpha","calculateState","currentTime","interpolate","applyState","state","set","call","mixState","a","b","t","v","i","getBlendId","getDuration","maxTime","getProp"],"mappings":";;;AAIA;;;IAIO,MAAMA,aAAsBC,SAAAA,cAAAA,CAAAA;IAChBC,MAAsB;IAC/BC,WAA2B;IAC3BC,OAAgB;IACPC,KAAwB;IACxBC,MAAe;IACxBC,aAA4B;IAC5BC,kBAAiC;AACzC;;;AAGC,MACD,YAAYC,IAAsB,EAAEC,KAAgB,EAAEC,QAAkB,CAAE;AACxE,QAAA,KAAK,CAACA,QAAAA,CAAAA;QACN,IAAI,CAACN,KAAK,GAAGI,IAAAA;QACb,IAAI,CAACL,OAAO,GAAG,EAAA;QACf,IAAI,CAACF,MAAM,GAAG;YAAEU,GAAK,EAAA;AAAC,gBAAA,CAAA;AAAG,gBAAA,CAAA;AAAG,gBAAA,CAAA;AAAG,gBAAA;AAAE;AAAC,SAAA;QAClC,IAAI,CAACT,WAAW,GAAG,IAAA;QACnB,IAAI,CAACI,aAAa,GAAG,IAAA;QACrB,IAAI,CAACC,kBAAkB,GAAG,IAAA;AAC1B,QAAA,IAAIE,KAAO,EAAA;AACT,YAAA,IAAI,CAACR,MAAM,CAACU,GAAG,GAAGF,MAAMG,KAAK,EAAA;AAC/B;AACA,QAAA,OAAQ,IAAI,CAACR,KAAK,CAACS,IAAI;YACrB,KAAK,OAAA;gBACH,IAAI,CAACR,MAAM,GAAG,CAAA;gBACd,IAAI,CAACC,aAAa,GAAG,IAAIQ,aACvB,qBACA,EAAA,QAAA,EACA,IAAIC,YAAa,CAAA;AAAC,oBAAA,CAAA;AAAG,oBAAA;AAAE,iBAAA,CAAA,EACvB,IAAIA,YAAa,CAAA;AAAC,oBAA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C,CAAgB,EAAEC,CAAgB,EAAEC,CAAS,EAAiB;AACrE,QAAA,MAAMC,IAAc,EAAE;QACtB,IAAK,IAAIC,IAAI,CAAGA,EAAAA,CAAAA,GAAI,IAAI,CAAC7B,MAAM,EAAE6B,CAAK,EAAA,CAAA;AACpCD,YAAAA,CAAC,CAACC,CAAE,CAAA,GAAGJ,EAAEnB,GAAG,CAACuB,EAAE,GAAGF,CAAAA,IAAKD,CAAEpB,CAAAA,GAAG,CAACuB,CAAE,CAAA,GAAGJ,EAAEnB,GAAG,CAACuB,EAAE,CAAD;AAC3C;QACA,OAAO;YAAEvB,GAAKsB,EAAAA;AAAE,SAAA;AAClB;IACAE,UAAsB,GAAA;QACpB,OAAO,IAAI,CAAC/B,KAAK;AACnB;IACAgC,WAAsB,GAAA;AACpB,QAAA,OAAO,IAAI,CAAC9B,aAAa,CAAC+B,OAAO;AACnC;IACAC,OAA4B,GAAA;QAC1B,OAAO,IAAI,CAAClC,KAAK;AACnB;AACF;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Interpolator, Quaternion } from '@zephyr3d/base';
|
|
2
|
+
import { AnimationTrack } from './animationtrack.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Rotation animation track
|
|
6
|
+
* @public
|
|
7
|
+
*/ class NodeRotationTrack extends AnimationTrack {
|
|
8
|
+
_state;
|
|
9
|
+
_interpolator;
|
|
10
|
+
constructor(modeOrInterpolator, keyFramesOrEmbedded, embedded){
|
|
11
|
+
if (modeOrInterpolator instanceof Interpolator) {
|
|
12
|
+
if (modeOrInterpolator.target !== 'quat') {
|
|
13
|
+
throw new Error(`RotationTrack(): interpolator target must be 'quat'`);
|
|
14
|
+
}
|
|
15
|
+
super(keyFramesOrEmbedded ?? false);
|
|
16
|
+
this._interpolator = modeOrInterpolator;
|
|
17
|
+
} else {
|
|
18
|
+
const keyFrames = keyFramesOrEmbedded;
|
|
19
|
+
const inputs = new Float32Array(keyFrames.map((val)=>val.time));
|
|
20
|
+
const outputs = new Float32Array(keyFrames.length * 4);
|
|
21
|
+
for(let i = 0; i < keyFrames.length; i++){
|
|
22
|
+
outputs[i * 4 + 0] = keyFrames[i].value.x;
|
|
23
|
+
outputs[i * 4 + 1] = keyFrames[i].value.y;
|
|
24
|
+
outputs[i * 4 + 2] = keyFrames[i].value.z;
|
|
25
|
+
outputs[i * 4 + 3] = keyFrames[i].value.w;
|
|
26
|
+
}
|
|
27
|
+
super(embedded ?? false);
|
|
28
|
+
this._interpolator = new Interpolator(modeOrInterpolator, 'quat', inputs, outputs);
|
|
29
|
+
}
|
|
30
|
+
this._state = new Quaternion();
|
|
31
|
+
}
|
|
32
|
+
calculateState(target, currentTime) {
|
|
33
|
+
this._interpolator.interpolate(currentTime, this._state);
|
|
34
|
+
return this._state;
|
|
35
|
+
}
|
|
36
|
+
applyState(node, state) {
|
|
37
|
+
node.rotation.set(state);
|
|
38
|
+
}
|
|
39
|
+
mixState(a, b, t) {
|
|
40
|
+
return Quaternion.slerp(a, b, t);
|
|
41
|
+
}
|
|
42
|
+
getBlendId() {
|
|
43
|
+
return 'node-rotation';
|
|
44
|
+
}
|
|
45
|
+
getDuration() {
|
|
46
|
+
return this._interpolator.maxTime;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { NodeRotationTrack };
|
|
51
|
+
//# sourceMappingURL=rotationtrack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotationtrack.js","sources":["../../../src/animation/rotationtrack.ts"],"sourcesContent":["import type { InterpolationMode } from '@zephyr3d/base';\r\nimport { Interpolator, Quaternion } from '@zephyr3d/base';\r\nimport { AnimationTrack } from './animationtrack';\r\nimport type { SceneNode } from '../scene';\r\n\r\n/**\r\n * Rotation animation track\r\n * @public\r\n */\r\nexport class NodeRotationTrack extends AnimationTrack<Quaternion> {\r\n private readonly _state: Quaternion;\r\n private readonly _interpolator: Interpolator;\r\n /**\r\n * Create an instance of RotationTrack from keyframe values\r\n * @param interpolator - Interpolator object that contains keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(interpolator: Interpolator, embedded?: boolean);\r\n /**\r\n * Create an instance of RotationTrack from keyframe values\r\n * @param mode - The interpolation mode of keyframes\r\n * @param keyFrames - Keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(mode: InterpolationMode, keyFrames: { time: number; value: Quaternion }[], embedded?: boolean);\r\n constructor(\r\n modeOrInterpolator: Interpolator | InterpolationMode,\r\n keyFramesOrEmbedded?: { time: number; value: Quaternion }[] | boolean,\r\n embedded?: boolean\r\n ) {\r\n if (modeOrInterpolator instanceof Interpolator) {\r\n if (modeOrInterpolator.target !== 'quat') {\r\n throw new Error(`RotationTrack(): interpolator target must be 'quat'`);\r\n }\r\n super((keyFramesOrEmbedded as boolean) ?? false);\r\n this._interpolator = modeOrInterpolator;\r\n } else {\r\n const keyFrames = keyFramesOrEmbedded as { time: number; value: Quaternion }[];\r\n const inputs = new Float32Array(keyFrames.map((val) => val.time));\r\n const outputs = new Float32Array(keyFrames.length * 4);\r\n for (let i = 0; i < keyFrames.length; i++) {\r\n outputs[i * 4 + 0] = keyFrames[i].value.x;\r\n outputs[i * 4 + 1] = keyFrames[i].value.y;\r\n outputs[i * 4 + 2] = keyFrames[i].value.z;\r\n outputs[i * 4 + 3] = keyFrames[i].value.w;\r\n }\r\n super(embedded ?? false);\r\n this._interpolator = new Interpolator(modeOrInterpolator, 'quat', inputs, outputs);\r\n }\r\n this._state = new Quaternion();\r\n }\r\n calculateState(target: object, currentTime: number): Quaternion {\r\n this._interpolator.interpolate(currentTime, this._state);\r\n return this._state;\r\n }\r\n applyState(node: SceneNode, state: Quaternion) {\r\n node.rotation.set(state);\r\n }\r\n mixState(a: Quaternion, b: Quaternion, t: number): Quaternion {\r\n return Quaternion.slerp(a, b, t);\r\n }\r\n getBlendId(): unknown {\r\n return 'node-rotation';\r\n }\r\n getDuration(): number {\r\n return this._interpolator.maxTime;\r\n }\r\n}\r\n"],"names":["NodeRotationTrack","AnimationTrack","_state","_interpolator","modeOrInterpolator","keyFramesOrEmbedded","embedded","Interpolator","target","Error","keyFrames","inputs","Float32Array","map","val","time","outputs","length","i","value","x","y","z","w","Quaternion","calculateState","currentTime","interpolate","applyState","node","state","rotation","set","mixState","a","b","t","slerp","getBlendId","getDuration","maxTime"],"mappings":";;;AAKA;;;IAIO,MAAMA,iBAA0BC,SAAAA,cAAAA,CAAAA;IACpBC,MAAmB;IACnBC,aAA4B;AAc7C,IAAA,WAAA,CACEC,kBAAoD,EACpDC,mBAAqE,EACrEC,QAAkB,CAClB;AACA,QAAA,IAAIF,8BAA8BG,YAAc,EAAA;YAC9C,IAAIH,kBAAAA,CAAmBI,MAAM,KAAK,MAAQ,EAAA;AACxC,gBAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,mDAAmD,CAAC,CAAA;AACvE;YACA,KAAK,CAAC,mBAAoC,IAAA,KAAA,CAAA;YAC1C,IAAI,CAACN,aAAa,GAAGC,kBAAAA;SAChB,MAAA;AACL,YAAA,MAAMM,SAAYL,GAAAA,mBAAAA;YAClB,MAAMM,MAAAA,GAAS,IAAIC,YAAaF,CAAAA,SAAAA,CAAUG,GAAG,CAAC,CAACC,GAAQA,GAAAA,GAAAA,CAAIC,IAAI,CAAA,CAAA;AAC/D,YAAA,MAAMC,OAAU,GAAA,IAAIJ,YAAaF,CAAAA,SAAAA,CAAUO,MAAM,GAAG,CAAA,CAAA;AACpD,YAAA,IAAK,IAAIC,CAAI,GAAA,CAAA,EAAGA,IAAIR,SAAUO,CAAAA,MAAM,EAAEC,CAAK,EAAA,CAAA;gBACzCF,OAAO,CAACE,CAAI,GAAA,CAAA,GAAI,CAAE,CAAA,GAAGR,SAAS,CAACQ,CAAE,CAAA,CAACC,KAAK,CAACC,CAAC;gBACzCJ,OAAO,CAACE,CAAI,GAAA,CAAA,GAAI,CAAE,CAAA,GAAGR,SAAS,CAACQ,CAAE,CAAA,CAACC,KAAK,CAACE,CAAC;gBACzCL,OAAO,CAACE,CAAI,GAAA,CAAA,GAAI,CAAE,CAAA,GAAGR,SAAS,CAACQ,CAAE,CAAA,CAACC,KAAK,CAACG,CAAC;gBACzCN,OAAO,CAACE,CAAI,GAAA,CAAA,GAAI,CAAE,CAAA,GAAGR,SAAS,CAACQ,CAAE,CAAA,CAACC,KAAK,CAACI,CAAC;AAC3C;AACA,YAAA,KAAK,CAACjB,QAAY,IAAA,KAAA,CAAA;AAClB,YAAA,IAAI,CAACH,aAAa,GAAG,IAAII,YAAaH,CAAAA,kBAAAA,EAAoB,QAAQO,MAAQK,EAAAA,OAAAA,CAAAA;AAC5E;QACA,IAAI,CAACd,MAAM,GAAG,IAAIsB,UAAAA,EAAAA;AACpB;IACAC,cAAejB,CAAAA,MAAc,EAAEkB,WAAmB,EAAc;QAC9D,IAAI,CAACvB,aAAa,CAACwB,WAAW,CAACD,WAAa,EAAA,IAAI,CAACxB,MAAM,CAAA;QACvD,OAAO,IAAI,CAACA,MAAM;AACpB;IACA0B,UAAWC,CAAAA,IAAe,EAAEC,KAAiB,EAAE;QAC7CD,IAAKE,CAAAA,QAAQ,CAACC,GAAG,CAACF,KAAAA,CAAAA;AACpB;AACAG,IAAAA,QAAAA,CAASC,CAAa,EAAEC,CAAa,EAAEC,CAAS,EAAc;AAC5D,QAAA,OAAOZ,UAAWa,CAAAA,KAAK,CAACH,CAAAA,EAAGC,CAAGC,EAAAA,CAAAA,CAAAA;AAChC;IACAE,UAAsB,GAAA;QACpB,OAAO,eAAA;AACT;IACAC,WAAsB,GAAA;AACpB,QAAA,OAAO,IAAI,CAACpC,aAAa,CAACqC,OAAO;AACnC;AACF;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Interpolator, Vector3 } from '@zephyr3d/base';
|
|
2
|
+
import { AnimationTrack } from './animationtrack.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Scale animation track
|
|
6
|
+
* @public
|
|
7
|
+
*/ class NodeScaleTrack extends AnimationTrack {
|
|
8
|
+
_state;
|
|
9
|
+
_interpolator;
|
|
10
|
+
constructor(modeOrInterpolator, keyFramesOrEmbedded, embedded){
|
|
11
|
+
if (modeOrInterpolator instanceof Interpolator) {
|
|
12
|
+
if (modeOrInterpolator.target !== 'vec3') {
|
|
13
|
+
throw new Error(`ScaleTrack(): interpolator target must be 'vec3'`);
|
|
14
|
+
}
|
|
15
|
+
super(keyFramesOrEmbedded ?? false);
|
|
16
|
+
this._interpolator = modeOrInterpolator;
|
|
17
|
+
} else {
|
|
18
|
+
const keyFrames = keyFramesOrEmbedded;
|
|
19
|
+
const inputs = new Float32Array(keyFrames.map((val)=>val.time));
|
|
20
|
+
const outputs = new Float32Array(keyFrames.length * 3);
|
|
21
|
+
for(let i = 0; i < keyFrames.length; i++){
|
|
22
|
+
outputs[i * 3 + 0] = keyFrames[i].value.x;
|
|
23
|
+
outputs[i * 3 + 1] = keyFrames[i].value.y;
|
|
24
|
+
outputs[i * 3 + 2] = keyFrames[i].value.z;
|
|
25
|
+
}
|
|
26
|
+
super(embedded ?? false);
|
|
27
|
+
this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);
|
|
28
|
+
}
|
|
29
|
+
this._state = new Vector3();
|
|
30
|
+
}
|
|
31
|
+
calculateState(target, currentTime) {
|
|
32
|
+
this._interpolator.interpolate(currentTime, this._state);
|
|
33
|
+
return this._state;
|
|
34
|
+
}
|
|
35
|
+
applyState(node, state) {
|
|
36
|
+
node.scale.set(state);
|
|
37
|
+
}
|
|
38
|
+
mixState(a, b, t) {
|
|
39
|
+
return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));
|
|
40
|
+
}
|
|
41
|
+
getBlendId() {
|
|
42
|
+
return 'node-scale';
|
|
43
|
+
}
|
|
44
|
+
getDuration() {
|
|
45
|
+
return this._interpolator.maxTime;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { NodeScaleTrack };
|
|
50
|
+
//# sourceMappingURL=scaletrack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaletrack.js","sources":["../../../src/animation/scaletrack.ts"],"sourcesContent":["import type { InterpolationMode } from '@zephyr3d/base';\r\nimport { Interpolator, Vector3 } from '@zephyr3d/base';\r\nimport { AnimationTrack } from './animationtrack';\r\nimport type { SceneNode } from '../scene';\r\n\r\n/**\r\n * Scale animation track\r\n * @public\r\n */\r\nexport class NodeScaleTrack extends AnimationTrack<Vector3> {\r\n private readonly _state: Vector3;\r\n private readonly _interpolator: Interpolator;\r\n /**\r\n * Create an instance of ScaleTrack from keyframe values\r\n * @param interpolator - Interpolator object that contains keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(interpolator: Interpolator, embedded?: boolean);\r\n /**\r\n * Create an instance of ScaleTrack from keyframe values\r\n * @param mode - The interpolation mode of keyframes\r\n * @param keyFrames - Keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(mode: InterpolationMode, keyFrames: { time: number; value: Vector3 }[], embedded?: boolean);\r\n constructor(\r\n modeOrInterpolator?: Interpolator | InterpolationMode,\r\n keyFramesOrEmbedded?: { time: number; value: Vector3 }[] | boolean,\r\n embedded?: boolean\r\n ) {\r\n if (modeOrInterpolator instanceof Interpolator) {\r\n if (modeOrInterpolator.target !== 'vec3') {\r\n throw new Error(`ScaleTrack(): interpolator target must be 'vec3'`);\r\n }\r\n super((keyFramesOrEmbedded as boolean) ?? false);\r\n this._interpolator = modeOrInterpolator;\r\n } else {\r\n const keyFrames = keyFramesOrEmbedded as { time: number; value: Vector3 }[];\r\n const inputs = new Float32Array(keyFrames.map((val) => val.time));\r\n const outputs = new Float32Array(keyFrames.length * 3);\r\n for (let i = 0; i < keyFrames.length; i++) {\r\n outputs[i * 3 + 0] = keyFrames[i].value.x;\r\n outputs[i * 3 + 1] = keyFrames[i].value.y;\r\n outputs[i * 3 + 2] = keyFrames[i].value.z;\r\n }\r\n super(embedded ?? false);\r\n this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);\r\n }\r\n this._state = new Vector3();\r\n }\r\n calculateState(target: object, currentTime: number): Vector3 {\r\n this._interpolator.interpolate(currentTime, this._state);\r\n return this._state;\r\n }\r\n applyState(node: SceneNode, state: Vector3) {\r\n node.scale.set(state);\r\n }\r\n mixState(a: Vector3, b: Vector3, t: number): Vector3 {\r\n return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));\r\n }\r\n getBlendId(): unknown {\r\n return 'node-scale';\r\n }\r\n getDuration(): number {\r\n return this._interpolator.maxTime;\r\n }\r\n}\r\n"],"names":["NodeScaleTrack","AnimationTrack","_state","_interpolator","modeOrInterpolator","keyFramesOrEmbedded","embedded","Interpolator","target","Error","keyFrames","inputs","Float32Array","map","val","time","outputs","length","i","value","x","y","z","Vector3","calculateState","currentTime","interpolate","applyState","node","state","scale","set","mixState","a","b","t","getBlendId","getDuration","maxTime"],"mappings":";;;AAKA;;;IAIO,MAAMA,cAAuBC,SAAAA,cAAAA,CAAAA;IACjBC,MAAgB;IAChBC,aAA4B;AAc7C,IAAA,WAAA,CACEC,kBAAqD,EACrDC,mBAAkE,EAClEC,QAAkB,CAClB;AACA,QAAA,IAAIF,8BAA8BG,YAAc,EAAA;YAC9C,IAAIH,kBAAAA,CAAmBI,MAAM,KAAK,MAAQ,EAAA;AACxC,gBAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,gDAAgD,CAAC,CAAA;AACpE;YACA,KAAK,CAAC,mBAAoC,IAAA,KAAA,CAAA;YAC1C,IAAI,CAACN,aAAa,GAAGC,kBAAAA;SAChB,MAAA;AACL,YAAA,MAAMM,SAAYL,GAAAA,mBAAAA;YAClB,MAAMM,MAAAA,GAAS,IAAIC,YAAaF,CAAAA,SAAAA,CAAUG,GAAG,CAAC,CAACC,GAAQA,GAAAA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AEd,CAAC,GAAGa,EAAEb,CAAAA,CAAIa,EAAAA,CAAAA,CAAEZ,CAAC,GAAGc,CAAAA,IAAKD,CAAAA,CAAEb,CAAC,GAAGY,CAAAA,CAAEZ,CAAAA,GAAIY,CAAEX,CAAAA,CAAC,GAAGa,CAAAA,IAAKD,CAAEZ,CAAAA,CAAC,GAAGW,CAAAA,CAAEX,CAAC,CAADA,CAAAA;AACtF;IACAc,UAAsB,GAAA;QACpB,OAAO,YAAA;AACT;IACAC,WAAsB,GAAA;AACpB,QAAA,OAAO,IAAI,CAAClC,aAAa,CAACmC,OAAO;AACnC;AACF;;;;"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Vector3, Matrix4x4, nextPowerOf2 } from '@zephyr3d/base';
|
|
2
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
+
import { Application } from '../app/app.js';
|
|
4
|
+
|
|
5
|
+
const tmpV0 = new Vector3();
|
|
6
|
+
const tmpV1 = new Vector3();
|
|
7
|
+
const tmpV2 = new Vector3();
|
|
8
|
+
const tmpV3 = new Vector3();
|
|
9
|
+
/**
|
|
10
|
+
* Skeleton for skinned animation
|
|
11
|
+
* @public
|
|
12
|
+
*/ class Skeleton {
|
|
13
|
+
/** @internal */ _meshes;
|
|
14
|
+
/** @internal */ _joints;
|
|
15
|
+
/** @internal */ _inverseBindMatrices;
|
|
16
|
+
/** @internal */ _bindPoseMatrices;
|
|
17
|
+
/** @internal */ _jointMatrices;
|
|
18
|
+
/** @internal */ _jointOffsets;
|
|
19
|
+
/** @internal */ _jointMatrixArray;
|
|
20
|
+
/** @internal */ _jointTexture;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of skeleton
|
|
23
|
+
* @param joints - The joint nodes
|
|
24
|
+
* @param inverseBindMatrices - The inverse binding matrices of the joints
|
|
25
|
+
* @param bindPoseMatrices - The binding pose matrices of the joints
|
|
26
|
+
*/ constructor(joints, inverseBindMatrices, bindPoseMatrices, meshes, bounding){
|
|
27
|
+
this._joints = joints;
|
|
28
|
+
this._inverseBindMatrices = inverseBindMatrices;
|
|
29
|
+
this._bindPoseMatrices = bindPoseMatrices;
|
|
30
|
+
this._jointMatrixArray = null;
|
|
31
|
+
this._jointMatrices = null;
|
|
32
|
+
this._jointOffsets = null;
|
|
33
|
+
this._jointTexture = null;
|
|
34
|
+
this.updateJointMatrices();
|
|
35
|
+
this._meshes = meshes.map((mesh, index)=>{
|
|
36
|
+
return {
|
|
37
|
+
mesh,
|
|
38
|
+
bounding: this.getBoundingInfo(bounding[index]),
|
|
39
|
+
box: new BoundingBox()
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Disposes self
|
|
45
|
+
*/ dispose() {
|
|
46
|
+
this._jointTexture?.dispose();
|
|
47
|
+
this._jointTexture = null;
|
|
48
|
+
this._joints = null;
|
|
49
|
+
this._inverseBindMatrices = null;
|
|
50
|
+
this._bindPoseMatrices = null;
|
|
51
|
+
this._jointMatrices = null;
|
|
52
|
+
this._jointMatrixArray = null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The texture that contains the transform matrices of all the joints
|
|
56
|
+
*/ get jointTexture() {
|
|
57
|
+
return this._jointTexture;
|
|
58
|
+
}
|
|
59
|
+
/** @internal */ updateJointMatrices(jointTransforms, worldMatrix) {
|
|
60
|
+
if (!this._jointTexture) {
|
|
61
|
+
this._createJointTexture();
|
|
62
|
+
}
|
|
63
|
+
if (this._jointOffsets[0] === 0) {
|
|
64
|
+
this._jointOffsets[0] = 1;
|
|
65
|
+
this._jointOffsets[1] = 1;
|
|
66
|
+
} else {
|
|
67
|
+
this._jointOffsets[1] = this._jointOffsets[0];
|
|
68
|
+
this._jointOffsets[0] = this._joints.length - this._jointOffsets[0] + 2;
|
|
69
|
+
}
|
|
70
|
+
for(let i = 0; i < this._joints.length; i++){
|
|
71
|
+
const mat = this._jointMatrices[i + this._jointOffsets[0] - 1];
|
|
72
|
+
const jointTransform = jointTransforms ? jointTransforms[i] : this._joints[i].worldMatrix;
|
|
73
|
+
if (worldMatrix) {
|
|
74
|
+
Matrix4x4.multiplyAffine(worldMatrix, jointTransform, jointTransform);
|
|
75
|
+
}
|
|
76
|
+
Matrix4x4.multiply(jointTransform, this._inverseBindMatrices[i], mat);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** @internal */ computeBindPose(model) {
|
|
80
|
+
this.updateJointMatrices(this._bindPoseMatrices, model.worldMatrix);
|
|
81
|
+
this._jointOffsets[1] = this._jointOffsets[0];
|
|
82
|
+
this._jointTexture.update(this._jointMatrixArray, 0, 0, this._jointTexture.width, this._jointTexture.height);
|
|
83
|
+
}
|
|
84
|
+
/** @internal */ computeJoints() {
|
|
85
|
+
this.updateJointMatrices();
|
|
86
|
+
this._jointTexture.update(this._jointMatrixArray, 0, 0, this._jointTexture.width, this._jointTexture.height);
|
|
87
|
+
}
|
|
88
|
+
/** @internal */ apply() {
|
|
89
|
+
this.computeJoints();
|
|
90
|
+
for (const mesh of this._meshes){
|
|
91
|
+
this.computeBoundingBox(mesh.bounding, mesh.mesh.invWorldMatrix);
|
|
92
|
+
mesh.mesh.setBoneMatrices(this.jointTexture);
|
|
93
|
+
mesh.mesh.setAnimatedBoundingBox(mesh.bounding.boundingBox);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** @internal */ reset() {
|
|
97
|
+
for (const mesh of this._meshes){
|
|
98
|
+
mesh.mesh.setBoneMatrices(null);
|
|
99
|
+
mesh.mesh.setAnimatedBoundingBox(null);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** @internal */ computeBoundingBox(info, invWorldMatrix) {
|
|
103
|
+
info.boundingBox.beginExtend();
|
|
104
|
+
for(let i = 0; i < info.boundingVertices.length; i++){
|
|
105
|
+
this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1].transformPointAffine(info.boundingVertices[i], tmpV0).scaleBy(info.boundingVertexJointWeights[i * 4 + 0]);
|
|
106
|
+
this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1].transformPointAffine(info.boundingVertices[i], tmpV1).scaleBy(info.boundingVertexJointWeights[i * 4 + 1]);
|
|
107
|
+
this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1].transformPointAffine(info.boundingVertices[i], tmpV2).scaleBy(info.boundingVertexJointWeights[i * 4 + 2]);
|
|
108
|
+
this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1].transformPointAffine(info.boundingVertices[i], tmpV3).scaleBy(info.boundingVertexJointWeights[i * 4 + 3]);
|
|
109
|
+
tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);
|
|
110
|
+
invWorldMatrix.transformPointAffine(tmpV0, tmpV0);
|
|
111
|
+
info.boundingBox.extend(tmpV0);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** @internal */ _createJointTexture() {
|
|
115
|
+
const textureWidth = nextPowerOf2(Math.max(4, Math.ceil(Math.sqrt((this._joints.length * 2 + 1) * 4))));
|
|
116
|
+
const device = Application.instance.device;
|
|
117
|
+
this._jointTexture = device.createTexture2D('rgba32f', textureWidth, textureWidth, {
|
|
118
|
+
samplerOptions: {
|
|
119
|
+
magFilter: 'nearest',
|
|
120
|
+
minFilter: 'nearest',
|
|
121
|
+
mipFilter: 'none'
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
this._jointMatrixArray = new Float32Array(textureWidth * textureWidth * 4);
|
|
125
|
+
const buffer = this._jointMatrixArray.buffer;
|
|
126
|
+
this._jointOffsets = new Float32Array(buffer);
|
|
127
|
+
this._jointOffsets[0] = 0;
|
|
128
|
+
this._jointOffsets[1] = 0;
|
|
129
|
+
this._jointMatrices = Array.from({
|
|
130
|
+
length: this._joints.length * 2
|
|
131
|
+
}).map((val, index)=>new Matrix4x4(buffer, (index + 1) * 16 * Float32Array.BYTES_PER_ELEMENT));
|
|
132
|
+
}
|
|
133
|
+
/** @internal */ getBoundingInfo(meshData) {
|
|
134
|
+
const indices = [
|
|
135
|
+
0,
|
|
136
|
+
0,
|
|
137
|
+
0,
|
|
138
|
+
0,
|
|
139
|
+
0,
|
|
140
|
+
0
|
|
141
|
+
];
|
|
142
|
+
let minx = Number.MAX_VALUE;
|
|
143
|
+
let maxx = -Number.MAX_VALUE;
|
|
144
|
+
let miny = Number.MAX_VALUE;
|
|
145
|
+
let maxy = -Number.MAX_VALUE;
|
|
146
|
+
let minz = Number.MAX_VALUE;
|
|
147
|
+
let maxz = -Number.MAX_VALUE;
|
|
148
|
+
const v = meshData.rawPositions;
|
|
149
|
+
const vert = new Vector3();
|
|
150
|
+
const tmpV0 = new Vector3();
|
|
151
|
+
const tmpV1 = new Vector3();
|
|
152
|
+
const tmpV2 = new Vector3();
|
|
153
|
+
const tmpV3 = new Vector3();
|
|
154
|
+
const numVertices = Math.floor(v.length / 3);
|
|
155
|
+
for(let i = 0; i < numVertices; i++){
|
|
156
|
+
vert.setXYZ(v[i * 3], v[i * 3 + 1], v[i * 3 + 2]);
|
|
157
|
+
this._jointMatrices[meshData.rawBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1].transformPointAffine(vert, tmpV0).scaleBy(meshData.rawJointWeights[i * 4 + 0]);
|
|
158
|
+
this._jointMatrices[meshData.rawBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1].transformPointAffine(vert, tmpV1).scaleBy(meshData.rawJointWeights[i * 4 + 1]);
|
|
159
|
+
this._jointMatrices[meshData.rawBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1].transformPointAffine(vert, tmpV2).scaleBy(meshData.rawJointWeights[i * 4 + 2]);
|
|
160
|
+
this._jointMatrices[meshData.rawBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1].transformPointAffine(vert, tmpV3).scaleBy(meshData.rawJointWeights[i * 4 + 3]);
|
|
161
|
+
tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);
|
|
162
|
+
if (tmpV0.x < minx) {
|
|
163
|
+
minx = tmpV0.x;
|
|
164
|
+
indices[0] = i;
|
|
165
|
+
}
|
|
166
|
+
if (tmpV0.x > maxx) {
|
|
167
|
+
maxx = tmpV0.x;
|
|
168
|
+
indices[1] = i;
|
|
169
|
+
}
|
|
170
|
+
if (tmpV0.y < miny) {
|
|
171
|
+
miny = tmpV0.y;
|
|
172
|
+
indices[2] = i;
|
|
173
|
+
}
|
|
174
|
+
if (tmpV0.y > maxy) {
|
|
175
|
+
maxy = tmpV0.y;
|
|
176
|
+
indices[3] = i;
|
|
177
|
+
}
|
|
178
|
+
if (tmpV0.z < minz) {
|
|
179
|
+
minz = tmpV0.z;
|
|
180
|
+
indices[4] = i;
|
|
181
|
+
}
|
|
182
|
+
if (tmpV0.z > maxz) {
|
|
183
|
+
maxz = tmpV0.z;
|
|
184
|
+
indices[5] = i;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const info = {
|
|
188
|
+
boundingVertexBlendIndices: new Float32Array(Array.from({
|
|
189
|
+
length: 6 * 4
|
|
190
|
+
}).map((val, index)=>meshData.rawBlendIndices[indices[index >> 2] * 4 + index % 4])),
|
|
191
|
+
boundingVertexJointWeights: new Float32Array(Array.from({
|
|
192
|
+
length: 6 * 4
|
|
193
|
+
}).map((val, index)=>meshData.rawJointWeights[indices[index >> 2] * 4 + index % 4])),
|
|
194
|
+
boundingVertices: Array.from({
|
|
195
|
+
length: 6
|
|
196
|
+
}).map((val, index)=>new Vector3(meshData.rawPositions[indices[index] * 3], meshData.rawPositions[indices[index] * 3 + 1], meshData.rawPositions[indices[index] * 3 + 2])),
|
|
197
|
+
boundingBox: new BoundingBox()
|
|
198
|
+
};
|
|
199
|
+
return info;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export { Skeleton };
|
|
204
|
+
//# sourceMappingURL=skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.js","sources":["../../../src/animation/skeleton.ts"],"sourcesContent":["import { Matrix4x4, Vector3, nextPowerOf2 } from '@zephyr3d/base';\r\nimport type { Texture2D } from '@zephyr3d/device';\r\nimport type { SceneNode } from '../scene/scene_node';\r\nimport type { Mesh } from '../scene';\r\nimport { BoundingBox } from '../utility/bounding_volume';\r\nimport type { AssetSubMeshData } from '../asset';\r\nimport { Application } from '../app/app';\r\n\r\ninterface SkinnedBoundingBox {\r\n boundingVertices: Vector3[];\r\n boundingVertexBlendIndices: Float32Array;\r\n boundingVertexJointWeights: Float32Array;\r\n boundingBox: BoundingBox;\r\n}\r\n\r\nconst tmpV0 = new Vector3();\r\nconst tmpV1 = new Vector3();\r\nconst tmpV2 = new Vector3();\r\nconst tmpV3 = new Vector3();\r\n\r\n/**\r\n * Skeleton for skinned animation\r\n * @public\r\n */\r\nexport class Skeleton {\r\n /** @internal */\r\n protected _meshes: { mesh: Mesh; bounding: SkinnedBoundingBox; box: BoundingBox }[];\r\n /** @internal */\r\n protected _joints: SceneNode[];\r\n /** @internal */\r\n protected _inverseBindMatrices: Matrix4x4[];\r\n /** @internal */\r\n protected _bindPoseMatrices: Matrix4x4[];\r\n /** @internal */\r\n protected _jointMatrices: Matrix4x4[];\r\n /** @internal */\r\n protected _jointOffsets: Float32Array<ArrayBuffer>;\r\n /** @internal */\r\n protected _jointMatrixArray: Float32Array<ArrayBuffer>;\r\n /** @internal */\r\n protected _jointTexture: Texture2D;\r\n /**\r\n * Creates an instance of skeleton\r\n * @param joints - The joint nodes\r\n * @param inverseBindMatrices - The inverse binding matrices of the joints\r\n * @param bindPoseMatrices - The binding pose matrices of the joints\r\n */\r\n constructor(\r\n joints: SceneNode[],\r\n inverseBindMatrices: Matrix4x4[],\r\n bindPoseMatrices: Matrix4x4[],\r\n meshes: Mesh[],\r\n bounding: AssetSubMeshData[]\r\n ) {\r\n this._joints = joints;\r\n this._inverseBindMatrices = inverseBindMatrices;\r\n this._bindPoseMatrices = bindPoseMatrices;\r\n this._jointMatrixArray = null;\r\n this._jointMatrices = null;\r\n this._jointOffsets = null;\r\n this._jointTexture = null;\r\n this.updateJointMatrices();\r\n this._meshes = meshes.map((mesh, index) => {\r\n return {\r\n mesh,\r\n bounding: this.getBoundingInfo(bounding[index]),\r\n box: new BoundingBox()\r\n };\r\n });\r\n }\r\n /**\r\n * Disposes self\r\n */\r\n dispose() {\r\n this._jointTexture?.dispose();\r\n this._jointTexture = null;\r\n this._joints = null;\r\n this._inverseBindMatrices = null;\r\n this._bindPoseMatrices = null;\r\n this._jointMatrices = null;\r\n this._jointMatrixArray = null;\r\n }\r\n /**\r\n * The texture that contains the transform matrices of all the joints\r\n */\r\n get jointTexture(): Texture2D {\r\n return this._jointTexture;\r\n }\r\n /** @internal */\r\n updateJointMatrices(jointTransforms?: Matrix4x4[], worldMatrix?: Matrix4x4) {\r\n if (!this._jointTexture) {\r\n this._createJointTexture();\r\n }\r\n if (this._jointOffsets[0] === 0) {\r\n this._jointOffsets[0] = 1;\r\n this._jointOffsets[1] = 1;\r\n } else {\r\n this._jointOffsets[1] = this._jointOffsets[0];\r\n this._jointOffsets[0] = this._joints.length - this._jointOffsets[0] + 2;\r\n }\r\n for (let i = 0; i < this._joints.length; i++) {\r\n const mat = this._jointMatrices[i + this._jointOffsets[0] - 1];\r\n const jointTransform = jointTransforms ? jointTransforms[i] : this._joints[i].worldMatrix;\r\n if (worldMatrix) {\r\n Matrix4x4.multiplyAffine(worldMatrix, jointTransform, jointTransform);\r\n }\r\n Matrix4x4.multiply(jointTransform, this._inverseBindMatrices[i], mat);\r\n }\r\n }\r\n /** @internal */\r\n computeBindPose(model: SceneNode) {\r\n this.updateJointMatrices(this._bindPoseMatrices, model.worldMatrix);\r\n this._jointOffsets[1] = this._jointOffsets[0];\r\n this._jointTexture.update(\r\n this._jointMatrixArray,\r\n 0,\r\n 0,\r\n this._jointTexture.width,\r\n this._jointTexture.height\r\n );\r\n }\r\n /** @internal */\r\n computeJoints() {\r\n this.updateJointMatrices();\r\n this._jointTexture.update(\r\n this._jointMatrixArray,\r\n 0,\r\n 0,\r\n this._jointTexture.width,\r\n this._jointTexture.height\r\n );\r\n }\r\n /** @internal */\r\n apply() {\r\n this.computeJoints();\r\n for (const mesh of this._meshes) {\r\n this.computeBoundingBox(mesh.bounding, mesh.mesh.invWorldMatrix);\r\n mesh.mesh.setBoneMatrices(this.jointTexture);\r\n mesh.mesh.setAnimatedBoundingBox(mesh.bounding.boundingBox);\r\n }\r\n }\r\n /** @internal */\r\n reset() {\r\n for (const mesh of this._meshes) {\r\n mesh.mesh.setBoneMatrices(null);\r\n mesh.mesh.setAnimatedBoundingBox(null);\r\n }\r\n }\r\n /** @internal */\r\n computeBoundingBox(info: SkinnedBoundingBox, invWorldMatrix: Matrix4x4) {\r\n info.boundingBox.beginExtend();\r\n for (let i = 0; i < info.boundingVertices.length; i++) {\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV0)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 0]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV1)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 1]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV2)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 2]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV3)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 3]);\r\n tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);\r\n invWorldMatrix.transformPointAffine(tmpV0, tmpV0);\r\n info.boundingBox.extend(tmpV0);\r\n }\r\n }\r\n /** @internal */\r\n private _createJointTexture() {\r\n const textureWidth = nextPowerOf2(Math.max(4, Math.ceil(Math.sqrt((this._joints.length * 2 + 1) * 4))));\r\n const device = Application.instance.device;\r\n this._jointTexture = device.createTexture2D('rgba32f', textureWidth, textureWidth, {\r\n samplerOptions: {\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'none'\r\n }\r\n });\r\n this._jointMatrixArray = new Float32Array(textureWidth * textureWidth * 4);\r\n const buffer = this._jointMatrixArray.buffer;\r\n this._jointOffsets = new Float32Array(buffer);\r\n this._jointOffsets[0] = 0;\r\n this._jointOffsets[1] = 0;\r\n this._jointMatrices = Array.from({ length: this._joints.length * 2 }).map(\r\n (val, index) => new Matrix4x4(buffer, (index + 1) * 16 * Float32Array.BYTES_PER_ELEMENT)\r\n );\r\n }\r\n /** @internal */\r\n private getBoundingInfo(meshData: AssetSubMeshData): SkinnedBoundingBox {\r\n const indices = [0, 0, 0, 0, 0, 0];\r\n let minx = Number.MAX_VALUE;\r\n let maxx = -Number.MAX_VALUE;\r\n let miny = Number.MAX_VALUE;\r\n let maxy = -Number.MAX_VALUE;\r\n let minz = Number.MAX_VALUE;\r\n let maxz = -Number.MAX_VALUE;\r\n const v = meshData.rawPositions;\r\n const vert = new Vector3();\r\n const tmpV0 = new Vector3();\r\n const tmpV1 = new Vector3();\r\n const tmpV2 = new Vector3();\r\n const tmpV3 = new Vector3();\r\n const numVertices = Math.floor(v.length / 3);\r\n for (let i = 0; i < numVertices; i++) {\r\n vert.setXYZ(v[i * 3], v[i * 3 + 1], v[i * 3 + 2]);\r\n this._jointMatrices[meshData.rawBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV0)\r\n .scaleBy(meshData.rawJointWeights[i * 4 + 0]);\r\n this._jointMatrices[meshData.rawBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV1)\r\n .scaleBy(meshData.rawJointWeights[i * 4 + 1]);\r\n this._jointMatrices[meshData.rawBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV2)\r\n .scaleBy(meshData.rawJointWeights[i * 4 + 2]);\r\n this._jointMatrices[meshData.rawBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV3)\r\n .scaleBy(meshData.rawJointWeights[i * 4 + 3]);\r\n tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);\r\n if (tmpV0.x < minx) {\r\n minx = tmpV0.x;\r\n indices[0] = i;\r\n }\r\n if (tmpV0.x > maxx) {\r\n maxx = tmpV0.x;\r\n indices[1] = i;\r\n }\r\n if (tmpV0.y < miny) {\r\n miny = tmpV0.y;\r\n indices[2] = i;\r\n }\r\n if (tmpV0.y > maxy) {\r\n maxy = tmpV0.y;\r\n indices[3] = i;\r\n }\r\n if (tmpV0.z < minz) {\r\n minz = tmpV0.z;\r\n indices[4] = i;\r\n }\r\n if (tmpV0.z > maxz) {\r\n maxz = tmpV0.z;\r\n indices[5] = i;\r\n }\r\n }\r\n const info: SkinnedBoundingBox = {\r\n boundingVertexBlendIndices: new Float32Array(\r\n Array.from({ length: 6 * 4 }).map(\r\n (val, index) => meshData.rawBlendIndices[indices[index >> 2] * 4 + (index % 4)]\r\n )\r\n ),\r\n boundingVertexJointWeights: new Float32Array(\r\n Array.from({ length: 6 * 4 }).map(\r\n (val, index) => meshData.rawJointWeights[indices[index >> 2] * 4 + (index % 4)]\r\n )\r\n ),\r\n boundingVertices: Array.from({ length: 6 }).map(\r\n (val, index) =>\r\n new Vector3(\r\n meshData.rawPositions[indices[index] * 3],\r\n meshData.rawPositions[indices[index] * 3 + 1],\r\n meshData.rawPositions[indices[index] * 3 + 2]\r\n )\r\n ),\r\n boundingBox: new BoundingBox()\r\n };\r\n return info;\r\n }\r\n}\r\n"],"names":["tmpV0","Vector3","tmpV1","tmpV2","tmpV3","Skeleton","joints","inverseBindMatrices","bindPoseMatrices","meshes","bounding","_joints","_inverseBindMatrices","_bindPoseMatrices","_jointMatrixArray","_jointMatrices","_jointOffsets","_jointTexture","updateJointMatrices","_meshes","map","mesh","index","getBoundingInfo","box","BoundingBox","dispose","jointTexture","jointTransforms","worldMatrix","_createJointTexture","length","i","mat","jointTransform","Matrix4x4","multiplyAffine","multiply","computeBindPose","model","update","width","height","computeJoints","apply","computeBoundingBox","invWorldMatrix","setBoneMatrices","setAnimatedBoundingBox","boundingBox","reset","info","beginExtend","boundingVertices","boundingVertexBlendIndices","transformPointAffine","scaleBy","boundingVertexJointWeights","addBy","extend","textureWidth","nextPowerOf2","Math","max","ceil","sqrt","device","Application","instance","createTexture2D","samplerOptions","magFilter","minFilter","mipFilter","Float32Array","buffer","Array","from","val","BYTES_PER_ELEMENT","meshData","indices","minx","Number","MAX_VALUE","maxx","miny","maxy","minz","maxz","v","rawPositions","vert","numVertices","floor","setXYZ","rawBlendIndices","rawJointWeights","x","y","z"],"mappings":";;;;AAeA,MAAMA,QAAQ,IAAIC,OAAAA,EAAAA;AAClB,MAAMC,QAAQ,IAAID,OAAAA,EAAAA;AAClB,MAAME,QAAQ,IAAIF,OAAAA,EAAAA;AAClB,MAAMG,QAAQ,IAAIH,OAAAA,EAAAA;AAElB;;;AAGC,IACM,MAAMI,QAAAA,CAAAA;qBAEX,OAAoF;qBAEpF,OAA+B;qBAE/B,oBAA4C;qBAE5C,iBAAyC;qBAEzC,cAAsC;qBAEtC,aAAmD;qBAEnD,iBAAuD;qBAEvD,aAAmC;AACnC;;;;;MAMA,WAAA,CACEC,MAAmB,EACnBC,mBAAgC,EAChCC,gBAA6B,EAC7BC,MAAc,EACdC,QAA4B,CAC5B;QACA,IAAI,CAACC,OAAO,GAAGL,MAAAA;QACf,IAAI,CAACM,oBAAoB,GAAGL,mBAAAA;QAC5B,IAAI,CAACM,iBAAiB,GAAGL,gBAAAA;QACzB,IAA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
|
+
* @public
|
|
7
|
+
*/ class NodeTranslationTrack extends AnimationTrack {
|
|
8
|
+
_state;
|
|
9
|
+
_interpolator;
|
|
10
|
+
constructor(modeOrInterpolator, keyFramesOrEmbedded, embedded){
|
|
11
|
+
if (modeOrInterpolator instanceof Interpolator) {
|
|
12
|
+
if (modeOrInterpolator.target !== 'vec3') {
|
|
13
|
+
throw new Error(`TranslationTrack(): interpolator target must be 'vec3'`);
|
|
14
|
+
}
|
|
15
|
+
super(keyFramesOrEmbedded ?? false);
|
|
16
|
+
this._interpolator = modeOrInterpolator;
|
|
17
|
+
} else {
|
|
18
|
+
const keyFrames = keyFramesOrEmbedded;
|
|
19
|
+
const inputs = new Float32Array(keyFrames.map((val)=>val.time));
|
|
20
|
+
const outputs = new Float32Array(keyFrames.length * 3);
|
|
21
|
+
for(let i = 0; i < keyFrames.length; i++){
|
|
22
|
+
outputs[i * 3 + 0] = keyFrames[i].value.x;
|
|
23
|
+
outputs[i * 3 + 1] = keyFrames[i].value.y;
|
|
24
|
+
outputs[i * 3 + 2] = keyFrames[i].value.z;
|
|
25
|
+
}
|
|
26
|
+
super(embedded ?? false);
|
|
27
|
+
this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);
|
|
28
|
+
}
|
|
29
|
+
this._state = new Vector3();
|
|
30
|
+
}
|
|
31
|
+
calculateState(target, currentTime) {
|
|
32
|
+
this._interpolator.interpolate(currentTime, this._state);
|
|
33
|
+
return this._state;
|
|
34
|
+
}
|
|
35
|
+
applyState(node, state) {
|
|
36
|
+
node.position.set(state);
|
|
37
|
+
}
|
|
38
|
+
mixState(a, b, t) {
|
|
39
|
+
return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));
|
|
40
|
+
}
|
|
41
|
+
getBlendId() {
|
|
42
|
+
return 'node-translation';
|
|
43
|
+
}
|
|
44
|
+
getDuration() {
|
|
45
|
+
return this._interpolator.maxTime;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { NodeTranslationTrack };
|
|
50
|
+
//# sourceMappingURL=translationtrack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translationtrack.js","sources":["../../../src/animation/translationtrack.ts"],"sourcesContent":["import type { InterpolationMode } from '@zephyr3d/base';\r\nimport { Interpolator, Vector3 } from '@zephyr3d/base';\r\nimport { AnimationTrack } from './animationtrack';\r\nimport type { SceneNode } from '../scene';\r\n\r\n/**\r\n * Translate animation track\r\n * @public\r\n */\r\nexport class NodeTranslationTrack extends AnimationTrack<Vector3> {\r\n private readonly _state: Vector3;\r\n private readonly _interpolator: Interpolator;\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param interpolator - Interpolator object that contains the keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(interpolator: Interpolator, embedded?: boolean);\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param mode - The interpolation mode of keyframes\r\n * @param keyFrames - Keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(mode: InterpolationMode, keyFrames: { time: number; value: Vector3 }[], embedded?: boolean);\r\n constructor(\r\n modeOrInterpolator?: Interpolator | InterpolationMode,\r\n keyFramesOrEmbedded?: { time: number; value: Vector3 }[] | boolean,\r\n embedded?: boolean\r\n ) {\r\n if (modeOrInterpolator instanceof Interpolator) {\r\n if (modeOrInterpolator.target !== 'vec3') {\r\n throw new Error(`TranslationTrack(): interpolator target must be 'vec3'`);\r\n }\r\n super((keyFramesOrEmbedded as boolean) ?? false);\r\n this._interpolator = modeOrInterpolator;\r\n } else {\r\n const keyFrames = keyFramesOrEmbedded as { time: number; value: Vector3 }[];\r\n const inputs = new Float32Array(keyFrames.map((val) => val.time));\r\n const outputs = new Float32Array(keyFrames.length * 3);\r\n for (let i = 0; i < keyFrames.length; i++) {\r\n outputs[i * 3 + 0] = keyFrames[i].value.x;\r\n outputs[i * 3 + 1] = keyFrames[i].value.y;\r\n outputs[i * 3 + 2] = keyFrames[i].value.z;\r\n }\r\n super(embedded ?? false);\r\n this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);\r\n }\r\n this._state = new Vector3();\r\n }\r\n calculateState(target: object, currentTime: number): Vector3 {\r\n this._interpolator.interpolate(currentTime, this._state);\r\n return this._state;\r\n }\r\n applyState(node: SceneNode, state: Vector3) {\r\n node.position.set(state);\r\n }\r\n mixState(a: Vector3, b: Vector3, t: number): Vector3 {\r\n return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));\r\n }\r\n getBlendId(): unknown {\r\n return 'node-translation';\r\n }\r\n getDuration(): number {\r\n return this._interpolator.maxTime;\r\n }\r\n}\r\n"],"names":["NodeTranslationTrack","AnimationTrack","_state","_interpolator","modeOrInterpolator","keyFramesOrEmbedded","embedded","Interpolator","target","Error","keyFrames","inputs","Float32Array","map","val","time","outputs","length","i","value","x","y","z","Vector3","calculateState","currentTime","interpolate","applyState","node","state","position","set","mixState","a","b","t","getBlendId","getDuration","maxTime"],"mappings":";;;AAKA;;;IAIO,MAAMA,oBAA6BC,SAAAA,cAAAA,CAAAA;IACvBC,MAAgB;IAChBC,aAA4B;AAc7C,IAAA,WAAA,CACEC,kBAAqD,EACrDC,mBAAkE,EAClEC,QAAkB,CAClB;AACA,QAAA,IAAIF,8BAA8BG,YAAc,EAAA;YAC9C,IAAIH,kBAAAA,CAAmBI,MAAM,KAAK,MAAQ,EAAA;AACxC,gBAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,sDAAsD,CAAC,CAAA;AAC1E;YACA,KAAK,CAAC,mBAAoC,IAAA,KAAA,CAAA;YAC1C,IAAI,CAACN,aAAa,GAAGC,kBAAAA;SAChB,MAAA;AACL,YAAA,MAAMM,SAAYL,GAAAA,mBAAAA;YAClB,MAAMM,MAAAA,GAAS,IAAIC,YAAaF,CAAAA,SAAAA,CAAUG,GAAG,CAAC,CAACC,GA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