@zephyr3d/scene 0.9.27 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -27
- package/dist/animation/animation_bank.js +634 -0
- package/dist/animation/animation_bank.js.map +1 -0
- package/dist/animation/animation_bank_gpu.js +256 -0
- package/dist/animation/animation_bank_gpu.js.map +1 -0
- package/dist/animation/animationset.js +54 -0
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_component.js +406 -0
- package/dist/animation/cloth/gpu_cloth_component.js.map +1 -0
- package/dist/animation/cloth/gpu_cloth_system.js +332 -202
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/gpu_animation_driver.js +289 -0
- package/dist/animation/gpu_animation_driver.js.map +1 -0
- package/dist/animation/joint_dynamics/collision.js +112 -1
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +6 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +11 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +50 -12
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/skeleton.js +279 -55
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skin_palette_atlas.js +252 -0
- package/dist/animation/skin_palette_atlas.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +298 -38
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +2 -0
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +159 -21
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_solver.js +173 -0
- package/dist/animation/spring/spring_solver.js.map +1 -0
- package/dist/animation/spring/spring_system.js +249 -24
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +32 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/app.js +26 -0
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +86 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/gamepad.js +191 -0
- package/dist/app/gamepad.js.map +1 -0
- package/dist/app/inputactions.js +271 -0
- package/dist/app/inputactions.js.map +1 -0
- package/dist/app/inputmgr.js +331 -22
- package/dist/app/inputmgr.js.map +1 -1
- package/dist/app/loading.js +138 -0
- package/dist/app/loading.js.map +1 -0
- package/dist/app/pipelinecache.js +209 -0
- package/dist/app/pipelinecache.js.map +1 -0
- package/dist/app/runtimescript.js +25 -0
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/scriptingsystem.js +54 -0
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +7 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/asset_manifest.js +59 -0
- package/dist/asset/asset_manifest.js.map +1 -0
- package/dist/asset/asset_preload.js +258 -0
- package/dist/asset/asset_preload.js.map +1 -0
- package/dist/asset/assetmanager.js +117 -65
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/dist/asset/loaders/ktx2/basis_location.js +17 -0
- package/dist/asset/loaders/ktx2/basis_location.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js +88 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js +118 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js.map +1 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js +259 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js.map +1 -0
- package/dist/asset/mesh_lod_builder.js +104 -0
- package/dist/asset/mesh_lod_builder.js.map +1 -0
- package/dist/asset/mesh_settings.js +111 -0
- package/dist/asset/mesh_settings.js.map +1 -0
- package/dist/asset/meshopt_decoder.js +18 -0
- package/dist/asset/meshopt_decoder.js.map +1 -0
- package/dist/asset/meshopt_simplifier.js +26 -0
- package/dist/asset/meshopt_simplifier.js.map +1 -0
- package/dist/asset/model.js +171 -1
- package/dist/asset/model.js.map +1 -1
- package/dist/asset/texture_settings.js +231 -0
- package/dist/asset/texture_settings.js.map +1 -0
- package/dist/asset/zmsh_binary.js +131 -0
- package/dist/asset/zmsh_binary.js.map +1 -0
- package/dist/asset/zsdf_binary.js +111 -0
- package/dist/asset/zsdf_binary.js.map +1 -0
- package/dist/blitter/bilateralblur.js +1 -2
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/gaussianblur.js +1 -6
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +31 -10
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +104 -178
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/follow.js +342 -0
- package/dist/camera/follow.js.map +1 -0
- package/dist/camera/fps.js +9 -7
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +46 -19
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +25436 -15990
- package/dist/index.js +65 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +3 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/eye.js +1 -1
- package/dist/material/eye.js.map +1 -1
- package/dist/material/hair.js +2 -3
- package/dist/material/hair.js.map +1 -1
- package/dist/material/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +66 -4
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +118 -45
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +1 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +34 -61
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -2
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +2 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +191 -83
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +31 -206
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mtoon.js +1 -1
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrmr.js +3 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +3 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/sdf_debug.js +78 -0
- package/dist/material/sdf_debug.js.map +1 -0
- package/dist/material/shader/helper.js +333 -191
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +204 -43
- package/dist/material/shader/terrain_blend.js.map +1 -1
- package/dist/material/skin.js +331 -297
- package/dist/material/skin.js.map +1 -1
- package/dist/material/skinprofile.js +1058 -0
- package/dist/material/skinprofile.js.map +1 -0
- package/dist/material/sss.js +353 -0
- package/dist/material/sss.js.map +1 -0
- package/dist/material/sss_kernel.js +265 -0
- package/dist/material/sss_kernel.js.map +1 -0
- package/dist/material/sssprofile.js +879 -0
- package/dist/material/sssprofile.js.map +1 -0
- package/dist/material/subsurfaceprofile.js +4 -8
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/terrain-cm.js +464 -188
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/material/unlit.js +3 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +1261 -1438
- package/dist/material/water.js.map +1 -1
- package/dist/node_modules/meshoptimizer/LICENSE +21 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js +197 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js.map +1 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js +677 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js.map +1 -0
- package/dist/physics/character.js +226 -0
- package/dist/physics/character.js.map +1 -0
- package/dist/physics/collider.js +209 -0
- package/dist/physics/collider.js.map +1 -0
- package/dist/physics/events.js +79 -0
- package/dist/physics/events.js.map +1 -0
- package/dist/physics/joint.js +272 -0
- package/dist/physics/joint.js.map +1 -0
- package/dist/physics/node_physics.js +234 -0
- package/dist/physics/node_physics.js.map +1 -0
- package/dist/physics/part.js +91 -0
- package/dist/physics/part.js.map +1 -0
- package/dist/physics/rigid_body.js +379 -0
- package/dist/physics/rigid_body.js.map +1 -0
- package/dist/physics/vehicle.js +335 -0
- package/dist/physics/vehicle.js.map +1 -0
- package/dist/physics/world.js +25 -0
- package/dist/physics/world.js.map +1 -0
- package/dist/posteffect/bloom.js +49 -14
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/motionblur.js +106 -106
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +2 -6
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +605 -355
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +91 -162
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -11
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +4 -13
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js +1 -0
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +3 -2
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +179 -64
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +958 -224
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +25 -5
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/debug_views.js +37 -0
- package/dist/render/debug_views.js.map +1 -0
- package/dist/render/depthpass.js +5 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +53 -6
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +5 -5
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +196 -113
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +5 -10
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +247 -157
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +16 -38
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/gi/probe_volume.js +1334 -0
- package/dist/render/gi/probe_volume.js.map +1 -0
- package/dist/render/gi/scene_gi.js +282 -0
- package/dist/render/gi/scene_gi.js.map +1 -0
- package/dist/render/gi/voxel_atlas.js +198 -0
- package/dist/render/gi/voxel_atlas.js.map +1 -0
- package/dist/render/gi/voxel_lighting.js +652 -0
- package/dist/render/gi/voxel_lighting.js.map +1 -0
- package/dist/render/gi/voxel_scene.js +642 -0
- package/dist/render/gi/voxel_scene.js.map +1 -0
- package/dist/render/gi/voxelize_pass.js +223 -0
- package/dist/render/gi/voxelize_pass.js.map +1 -0
- package/dist/render/globalbindgroup_allocator.js +3 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/gpu_picking.js +9 -36
- package/dist/render/gpu_picking.js.map +1 -1
- package/dist/render/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +19 -8
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/lod.js +46 -0
- package/dist/render/lod.js.map +1 -0
- package/dist/render/primitive.js +301 -9
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/primitive_readback.js +209 -0
- package/dist/render/primitive_readback.js.map +1 -0
- package/dist/render/render_queue.js +162 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +10 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +14 -1
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/executor.js +136 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +272 -55
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_graph_context.js +41 -0
- package/dist/render/rendergraph/frame_graph_context.js.map +1 -0
- package/dist/render/rendergraph/scene_render_context.js +31 -2
- package/dist/render/rendergraph/scene_render_context.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +28 -5
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sdf/box_allocator.js +98 -0
- package/dist/render/sdf/box_allocator.js.map +1 -0
- package/dist/render/sdf/global_sdf.js +865 -0
- package/dist/render/sdf/global_sdf.js.map +1 -0
- package/dist/render/sdf/scene_sdf.js +562 -0
- package/dist/render/sdf/scene_sdf.js.map +1 -0
- package/dist/render/sdf/sdf_atlas.js +227 -0
- package/dist/render/sdf/sdf_atlas.js.map +1 -0
- package/dist/render/sdf/sdf_programs.js +42 -0
- package/dist/render/sdf/sdf_programs.js.map +1 -0
- package/dist/render/sdf/sdf_view.js +199 -0
- package/dist/render/sdf/sdf_view.js.map +1 -0
- package/dist/render/sdf/waterline.js +610 -0
- package/dist/render/sdf/waterline.js.map +1 -0
- package/dist/render/shadow_mask_pass.js +142 -25
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/shore_wave_generator.js +1193 -0
- package/dist/render/shore_wave_generator.js.map +1 -0
- package/dist/render/sky.js +516 -86
- package/dist/render/sky.js.map +1 -1
- package/dist/render/transmission_thickness_pass.js +477 -0
- package/dist/render/transmission_thickness_pass.js.map +1 -0
- package/dist/render/underwater.js +58 -158
- package/dist/render/underwater.js.map +1 -1
- package/dist/render/virtualtexture/virtual_texture.js +1214 -0
- package/dist/render/virtualtexture/virtual_texture.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_common.js +472 -0
- package/dist/render/volumetric_cloud/cloud_common.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_noise.js +189 -0
- package/dist/render/volumetric_cloud/cloud_noise.js.map +1 -0
- package/dist/render/volumetric_cloud/debug_view.js +131 -0
- package/dist/render/volumetric_cloud/debug_view.js.map +1 -0
- package/dist/render/volumetric_cloud/resources.js +380 -0
- package/dist/render/volumetric_cloud/resources.js.map +1 -0
- package/dist/render/volumetric_cloud/sky_cache.js +380 -0
- package/dist/render/volumetric_cloud/sky_cache.js.map +1 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js +318 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js.map +1 -0
- package/dist/render/water_caustics.js +134 -319
- package/dist/render/water_caustics.js.map +1 -1
- package/dist/render/water_foam.js +627 -0
- package/dist/render/water_foam.js.map +1 -0
- package/dist/render/water_interaction.js +1795 -0
- package/dist/render/water_interaction.js.map +1 -0
- package/dist/render/weightedblended_oit.js +3 -3
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +9 -4
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +108 -12
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +28 -7
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/foliage.js +1020 -0
- package/dist/scene/foliage.js.map +1 -0
- package/dist/scene/foliage_buckets.js +147 -0
- package/dist/scene/foliage_buckets.js.map +1 -0
- package/dist/scene/foliage_mask.js +358 -0
- package/dist/scene/foliage_mask.js.map +1 -0
- package/dist/scene/hair.js +15 -4
- package/dist/scene/hair.js.map +1 -1
- package/dist/scene/light.js +179 -13
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +327 -45
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +9 -3
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +9 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +8 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/physics_settings.js +157 -0
- package/dist/scene/physics_settings.js.map +1 -0
- package/dist/scene/scene.js +190 -44
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +147 -6
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/bladegrassmaterial.js +735 -0
- package/dist/scene/terrain-cm/bladegrassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +881 -42
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grass_gpu.js +929 -0
- package/dist/scene/terrain-cm/grass_gpu.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +180 -9
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +465 -36
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/terrain_gi_albedo.js +257 -0
- package/dist/scene/terrain-cm/terrain_gi_albedo.js.map +1 -0
- package/dist/scene/terrain-cm/terrain_rvt.js +395 -0
- package/dist/scene/terrain-cm/terrain_rvt.js.map +1 -0
- package/dist/scene/update_queue.js +54 -0
- package/dist/scene/update_queue.js.map +1 -0
- package/dist/scene/water.js +633 -268
- package/dist/scene/water.js.map +1 -1
- package/dist/scene/water_surface_sampler.js +324 -0
- package/dist/scene/water_surface_sampler.js.map +1 -0
- package/dist/scene/wind.js +317 -0
- package/dist/scene/wind.js.map +1 -0
- package/dist/shaders/atmosphere.js +388 -166
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/fog.js +100 -32
- package/dist/shaders/fog.js.map +1 -1
- package/dist/shaders/gi.js +365 -0
- package/dist/shaders/gi.js.map +1 -0
- package/dist/shaders/ltc_rect.js +202 -0
- package/dist/shaders/ltc_rect.js.map +1 -0
- package/dist/shaders/misc.js +1 -10
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +5 -1
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/probes.js +309 -0
- package/dist/shaders/probes.js.map +1 -0
- package/dist/shaders/sdf.js +537 -0
- package/dist/shaders/sdf.js.map +1 -0
- package/dist/shaders/shadow.js +104 -70
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/skin_brdf.js +243 -0
- package/dist/shaders/skin_brdf.js.map +1 -0
- package/dist/shaders/ssgi.js +63 -0
- package/dist/shaders/ssgi.js.map +1 -0
- package/dist/shaders/ssgi_reprojection.js +118 -0
- package/dist/shaders/ssgi_reprojection.js.map +1 -0
- package/dist/shaders/ssr.js +6 -159
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +38 -27
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +32 -82
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +7 -21
- package/dist/shaders/water_medium.js.map +1 -1
- package/dist/shadow/dom.js +110 -19
- package/dist/shadow/dom.js.map +1 -1
- package/dist/shadow/esm.js +3 -3
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +15 -48
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +15 -53
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/pcss.js +34 -9
- package/dist/shadow/pcss.js.map +1 -1
- package/dist/shadow/shadow_impl.js +3 -8
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +40 -2
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +93 -53
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +18 -72
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +3 -3
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/shape.js +44 -1
- package/dist/shapes/shape.js.map +1 -1
- package/dist/utility/buoyancy.js +287 -0
- package/dist/utility/buoyancy.js.map +1 -0
- package/dist/utility/physical.js +10 -1
- package/dist/utility/physical.js.map +1 -1
- package/dist/utility/pmrem.js +17 -43
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/sdf/bake.js +435 -0
- package/dist/utility/sdf/bake.js.map +1 -0
- package/dist/utility/sdf/bvh.js +576 -0
- package/dist/utility/sdf/bvh.js.map +1 -0
- package/dist/utility/serialization/manager.js +34 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +46 -5
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +11 -4
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +87 -254
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth.js +25 -0
- package/dist/utility/serialization/scene/cloth.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +14 -6
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/foliage.js +821 -0
- package/dist/utility/serialization/scene/foliage.js.map +1 -0
- package/dist/utility/serialization/scene/hair.js +11 -4
- package/dist/utility/serialization/scene/hair.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +115 -7
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +388 -220
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +69 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +140 -5
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/node_physics.js +1318 -0
- package/dist/utility/serialization/scene/node_physics.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +11 -4
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/physics.js +120 -0
- package/dist/utility/serialization/scene/physics.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +124 -10
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +1687 -51
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +11 -4
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +163 -33
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +11 -4
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +1543 -264
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +10 -22
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/utility/textures/foam.js +170 -0
- package/dist/utility/textures/foam.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +17 -43
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +4 -4
- package/dist/utility/textures/ltcdata.js.map +1 -1
- package/dist/utility/textures/ltclut.js +16 -6
- package/dist/utility/textures/ltclut.js.map +1 -1
- package/dist/utility/unsupported.js +24 -0
- package/dist/utility/unsupported.js.map +1 -0
- package/dist/values.js +13 -1
- package/dist/values.js.map +1 -1
- package/package.json +25 -12
- package/src/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/src/asset/meshoptimizer/LICENSE +21 -0
- package/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
import { Matrix4x4, Vector3, Quaternion, Disposable } from '@zephyr3d/base';
|
|
2
|
+
import { getDevice } from '../app/api.js';
|
|
3
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
4
|
+
import { SkinPaletteAtlas } from './skin_palette_atlas.js';
|
|
5
|
+
import { AnimationBankGpuEvaluator } from './animation_bank_gpu.js';
|
|
6
|
+
|
|
7
|
+
/** Rate clips are sampled at when baked into a bank */ const ANIMATION_BANK_SAMPLE_RATE = 30;
|
|
8
|
+
/** Floats in one baked joint key: position xyz, rotation quaternion xyzw, scale xyz */ const KEY_FLOATS = 10;
|
|
9
|
+
const tmpMatrix = new Matrix4x4();
|
|
10
|
+
const tmpMatrix2 = new Matrix4x4();
|
|
11
|
+
const tmpPosition = new Vector3();
|
|
12
|
+
const tmpRotation = new Quaternion();
|
|
13
|
+
const tmpScale = new Vector3();
|
|
14
|
+
const tmpPoint = new Vector3();
|
|
15
|
+
const tmpPoint2 = new Vector3();
|
|
16
|
+
const tmpHeader = new Float32Array(16);
|
|
17
|
+
/**
|
|
18
|
+
* Skeletal animation clips of one skin baked into joint poses, played back without the joint
|
|
19
|
+
* scene nodes the clips were made for.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Every clip is sampled at {@link ANIMATION_BANK_SAMPLE_RATE} frames per second into joint poses
|
|
23
|
+
* relative to the root of the skin, so that a pose is evaluated per joint without walking the
|
|
24
|
+
* joint hierarchy.
|
|
25
|
+
*
|
|
26
|
+
* A bank is played by {@link AnimationBankTrack}s. Each track owns one palette in the skin palette
|
|
27
|
+
* atlas, and any number of instances of the model skin their meshes by it, so a crowd costs the
|
|
28
|
+
* evaluation of its tracks rather than of its characters.
|
|
29
|
+
*
|
|
30
|
+
* Meshes skinned by a track do not run IK, joint dynamics or any other skeleton modifier, and do
|
|
31
|
+
* not blend clips.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/ class AnimationBank extends Disposable {
|
|
35
|
+
_jointCount;
|
|
36
|
+
_jointNames;
|
|
37
|
+
_inverseBindMatrices;
|
|
38
|
+
_entries;
|
|
39
|
+
_tracks;
|
|
40
|
+
_version;
|
|
41
|
+
/**
|
|
42
|
+
* Bake clips of an animation set into a bank for one skin.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Sampling poses the joints of the skin; their transforms are restored afterwards. Only tracks
|
|
46
|
+
* targeting the joints of the skin, or the root joint of its rig, are sampled, and skeleton
|
|
47
|
+
* modifiers do not run.
|
|
48
|
+
*
|
|
49
|
+
* @param animationSet - Animation set holding the clips
|
|
50
|
+
* @param binding - Skin binding whose joints the clips animate
|
|
51
|
+
* @param clipNames - Names of the clips to bake, default all clips of the set. More can be added
|
|
52
|
+
* later with {@link addClip}
|
|
53
|
+
*/ constructor(animationSet, binding, clipNames){
|
|
54
|
+
super();
|
|
55
|
+
this._jointCount = binding.joints.length;
|
|
56
|
+
this._jointNames = binding.joints.map((joint)=>joint.name);
|
|
57
|
+
this._inverseBindMatrices = binding.inverseBindMatrices.map((m)=>new Matrix4x4(new Float32Array(m)));
|
|
58
|
+
this._entries = [];
|
|
59
|
+
this._tracks = new Set();
|
|
60
|
+
this._version = 0;
|
|
61
|
+
const names = clipNames ?? animationSet.getAnimationNames();
|
|
62
|
+
for (const name of names){
|
|
63
|
+
this.addClip(animationSet, binding, name);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Bake one more clip into the bank.
|
|
68
|
+
*
|
|
69
|
+
* @param animationSet - Animation set holding the clip
|
|
70
|
+
* @param binding - Skin binding the bank was baked for, or a compatible one
|
|
71
|
+
* @param name - Name of the clip
|
|
72
|
+
* @returns Index of the entry, the existing one if the clip has been baked already, or -1 if
|
|
73
|
+
* the clip does not animate the joints of the skin
|
|
74
|
+
*/ addClip(animationSet, binding, name) {
|
|
75
|
+
const index = this.getEntryIndex(name);
|
|
76
|
+
if (index >= 0) {
|
|
77
|
+
return index;
|
|
78
|
+
}
|
|
79
|
+
const entry = this.bakeClip(animationSet, binding, name);
|
|
80
|
+
if (!entry) {
|
|
81
|
+
return -1;
|
|
82
|
+
}
|
|
83
|
+
this._entries.push(entry);
|
|
84
|
+
this._version++;
|
|
85
|
+
return this._entries.length - 1;
|
|
86
|
+
}
|
|
87
|
+
/** Increased each time a clip is added */ get version() {
|
|
88
|
+
return this._version;
|
|
89
|
+
}
|
|
90
|
+
/** Number of joints of the skin */ get jointCount() {
|
|
91
|
+
return this._jointCount;
|
|
92
|
+
}
|
|
93
|
+
/** Baked clips */ get entries() {
|
|
94
|
+
return this._entries;
|
|
95
|
+
}
|
|
96
|
+
/** Inverse bind matrices of the joints of the skin */ get inverseBindMatrices() {
|
|
97
|
+
return this._inverseBindMatrices;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gets the index of a baked clip by name.
|
|
101
|
+
*
|
|
102
|
+
* @param name - Name of the clip
|
|
103
|
+
* @returns Index of the entry, or -1 if the clip has not been baked
|
|
104
|
+
*/ getEntryIndex(name) {
|
|
105
|
+
return this._entries.findIndex((entry)=>entry.name === name);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Whether a skin binding has the joints this bank was baked for, in the same order.
|
|
109
|
+
*
|
|
110
|
+
* @param binding - Skin binding to check
|
|
111
|
+
*/ isCompatible(binding) {
|
|
112
|
+
const joints = binding.joints;
|
|
113
|
+
return joints.length === this._jointCount && joints.every((joint, i)=>joint.name === this._jointNames[i]) && // Skins sharing a rig differ by their inverse bind matrices
|
|
114
|
+
binding.inverseBindMatrices.every((m, i)=>m.equalsTo(this._inverseBindMatrices[i], 1e-4));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Create a track playing a baked clip.
|
|
118
|
+
*
|
|
119
|
+
* @param clip - Name or entry index of the clip
|
|
120
|
+
* @param options - Playback options
|
|
121
|
+
* @returns The track
|
|
122
|
+
*/ createTrack(clip, options) {
|
|
123
|
+
const index = typeof clip === 'number' ? clip : this.getEntryIndex(clip);
|
|
124
|
+
if (index < 0 || index >= this._entries.length) {
|
|
125
|
+
throw new Error(`AnimationBank.createTrack(): clip not baked: ${clip}`);
|
|
126
|
+
}
|
|
127
|
+
const track = new AnimationBankTrack(this, index, options);
|
|
128
|
+
this._tracks.add(track);
|
|
129
|
+
return track;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Write the skinning palette of a pose to the skin palette atlas.
|
|
133
|
+
*
|
|
134
|
+
* @remarks
|
|
135
|
+
* The two keys around the position are blended, positions and scales linearly and rotations by
|
|
136
|
+
* normalized linear interpolation along the shorter arc, and the pose is followed by the inverse
|
|
137
|
+
* bind matrix.
|
|
138
|
+
*
|
|
139
|
+
* @internal
|
|
140
|
+
*/ writePalette(entryIndex, position, slot, out) {
|
|
141
|
+
const entry = this._entries[entryIndex];
|
|
142
|
+
const { key0, key1, alpha } = getKeyIndicesFromTime(position, entry.frameCount, entry.playLength);
|
|
143
|
+
const keys = entry.keys;
|
|
144
|
+
const n = this._jointCount;
|
|
145
|
+
for(let i = 0; i < n; i++){
|
|
146
|
+
blendKeys(keys, (key0 * n + i) * KEY_FLOATS, (key1 * n + i) * KEY_FLOATS, alpha, tmpMatrix);
|
|
147
|
+
Matrix4x4.multiplyAffine(tmpMatrix, this._inverseBindMatrices[i], tmpMatrix2);
|
|
148
|
+
out.set(tmpMatrix2, i * 16);
|
|
149
|
+
}
|
|
150
|
+
SkinPaletteAtlas.instance.writeSlots(slot, out);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Compute the bounds of a mesh over all frames of a baked clip.
|
|
154
|
+
*
|
|
155
|
+
* @param entryIndex - Index of the baked clip
|
|
156
|
+
* @param mesh - Mesh skinned by the bank
|
|
157
|
+
* @param binding - Skin binding of the mesh, whose reference node the keys are relative to
|
|
158
|
+
* @returns Bounds in the local space of the mesh, or null if the mesh has no skinned bounding data
|
|
159
|
+
* @internal
|
|
160
|
+
*/ computeBoundingBox(entryIndex, mesh, binding) {
|
|
161
|
+
const info = mesh.skinnedBoundingInfo;
|
|
162
|
+
if (!info) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const entry = this._entries[entryIndex];
|
|
166
|
+
const skinSpace = mesh.getSkinSpaceMatrix(binding);
|
|
167
|
+
const influenceCount = Math.max(1, info.influenceCount ?? 4);
|
|
168
|
+
const n = this._jointCount;
|
|
169
|
+
const box = new BoundingBox();
|
|
170
|
+
box.beginExtend();
|
|
171
|
+
for(let frame = 0; frame < entry.frameCount; frame++){
|
|
172
|
+
for(let v = 0; v < info.boundingVertices.length; v++){
|
|
173
|
+
tmpPoint.setXYZ(0, 0, 0);
|
|
174
|
+
for(let j = 0; j < influenceCount; j++){
|
|
175
|
+
const weight = Number(info.boundingVertexJointWeights[v * influenceCount + j]) || 0;
|
|
176
|
+
const joint = Number(info.boundingVertexBlendIndices[v * influenceCount + j]) || 0;
|
|
177
|
+
if (weight <= 0 || joint >= n) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const offset = (frame * n + joint) * KEY_FLOATS;
|
|
181
|
+
blendKeys(entry.keys, offset, offset, 0, tmpMatrix);
|
|
182
|
+
Matrix4x4.multiplyAffine(tmpMatrix, this._inverseBindMatrices[joint], tmpMatrix2);
|
|
183
|
+
tmpMatrix2.transformPointAffine(info.boundingVertices[v], tmpPoint2).scaleBy(weight);
|
|
184
|
+
tmpPoint.addBy(tmpPoint2);
|
|
185
|
+
}
|
|
186
|
+
box.extend(skinSpace.transformPointAffine(tmpPoint, tmpPoint));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return box.isValid() ? box : null;
|
|
190
|
+
}
|
|
191
|
+
/** @internal */ removeTrack(track) {
|
|
192
|
+
this._tracks.delete(track);
|
|
193
|
+
}
|
|
194
|
+
/** Dispose all tracks of the bank */ onDispose() {
|
|
195
|
+
super.onDispose();
|
|
196
|
+
for (const track of [
|
|
197
|
+
...this._tracks
|
|
198
|
+
]){
|
|
199
|
+
track.dispose();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
bakeClip(animationSet, binding, name) {
|
|
203
|
+
const clip = animationSet.get(name);
|
|
204
|
+
if (!clip) {
|
|
205
|
+
console.error(`AnimationBank: animation not found: ${name}`);
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
const rig = binding.rig;
|
|
209
|
+
const joints = new Set(binding.joints);
|
|
210
|
+
if (rig.rootJoint) {
|
|
211
|
+
joints.add(rig.rootJoint);
|
|
212
|
+
}
|
|
213
|
+
const tracks = [
|
|
214
|
+
...clip.tracks
|
|
215
|
+
].filter(([target])=>joints.has(target));
|
|
216
|
+
if (tracks.length === 0) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
// Keep the joint transforms so baking leaves the model as it was
|
|
220
|
+
const saved = [
|
|
221
|
+
...joints
|
|
222
|
+
].map((joint)=>{
|
|
223
|
+
const node = joint;
|
|
224
|
+
return {
|
|
225
|
+
node,
|
|
226
|
+
position: node.position.clone(),
|
|
227
|
+
rotation: node.rotation.clone(),
|
|
228
|
+
scale: node.scale.clone()
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
const playLength = clip.timeDuration;
|
|
232
|
+
const frameCount = Math.max(1, Math.round(playLength * ANIMATION_BANK_SAMPLE_RATE) + 1);
|
|
233
|
+
const n = binding.joints.length;
|
|
234
|
+
const keys = new Float32Array(frameCount * n * KEY_FLOATS);
|
|
235
|
+
const reference = binding.referenceNode;
|
|
236
|
+
try {
|
|
237
|
+
rig.computeBindPose();
|
|
238
|
+
for(let frame = 0; frame < frameCount; frame++){
|
|
239
|
+
const time = frameCount > 1 ? playLength * frame / (frameCount - 1) : 0;
|
|
240
|
+
for (const [target, targetTracks] of tracks){
|
|
241
|
+
for (const track of targetTracks){
|
|
242
|
+
const t = playLength > 0 ? time / playLength * track.getDuration() : 0;
|
|
243
|
+
track.applyState(target, track.calculateState(target, t));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const invReference = reference ? Matrix4x4.invertAffine(reference.worldMatrix, tmpMatrix2) : null;
|
|
247
|
+
for(let i = 0; i < n; i++){
|
|
248
|
+
const world = binding.joints[i].worldMatrix;
|
|
249
|
+
if (invReference) {
|
|
250
|
+
Matrix4x4.multiplyAffine(invReference, world, tmpMatrix);
|
|
251
|
+
} else {
|
|
252
|
+
tmpMatrix.set(world);
|
|
253
|
+
}
|
|
254
|
+
tmpMatrix.decompose(tmpScale, tmpRotation, tmpPosition);
|
|
255
|
+
const offset = (frame * n + i) * KEY_FLOATS;
|
|
256
|
+
keys[offset] = tmpPosition.x;
|
|
257
|
+
keys[offset + 1] = tmpPosition.y;
|
|
258
|
+
keys[offset + 2] = tmpPosition.z;
|
|
259
|
+
keys[offset + 3] = tmpRotation.x;
|
|
260
|
+
keys[offset + 4] = tmpRotation.y;
|
|
261
|
+
keys[offset + 5] = tmpRotation.z;
|
|
262
|
+
keys[offset + 6] = tmpRotation.w;
|
|
263
|
+
keys[offset + 7] = tmpScale.x;
|
|
264
|
+
keys[offset + 8] = tmpScale.y;
|
|
265
|
+
keys[offset + 9] = tmpScale.z;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
} finally{
|
|
269
|
+
for (const { node, position, rotation, scale } of saved){
|
|
270
|
+
node.position.set(position);
|
|
271
|
+
node.rotation.set(rotation);
|
|
272
|
+
node.scale.set(scale);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
name,
|
|
277
|
+
frameCount,
|
|
278
|
+
playLength: frameCount > 1 ? playLength : 0,
|
|
279
|
+
keys
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* A playing clip of an animation bank, owning one skinning palette that any number of meshes
|
|
285
|
+
* of compatible skins are skinned by.
|
|
286
|
+
*
|
|
287
|
+
* @remarks
|
|
288
|
+
* Tracks advance once per frame before the skin palette atlas is uploaded. The palette keeps
|
|
289
|
+
* the previous pose as well, for motion vectors.
|
|
290
|
+
*
|
|
291
|
+
* Where supported (WebGPU), palettes are evaluated in a compute pass, see
|
|
292
|
+
* {@link AnimationBankTrackOptions.evaluation}; elsewhere on the CPU. Both produce the same pose.
|
|
293
|
+
*
|
|
294
|
+
* @public
|
|
295
|
+
*/ class AnimationBankTrack extends Disposable {
|
|
296
|
+
static _activeTracks = new Set();
|
|
297
|
+
static _updateFrame = -1;
|
|
298
|
+
_bank;
|
|
299
|
+
_entryIndex;
|
|
300
|
+
_position;
|
|
301
|
+
/** Position at the previous evaluation, for the previous pose of GPU evaluation */ _previousPosition;
|
|
302
|
+
/** Position the palette was last evaluated at */ _evaluatedPosition;
|
|
303
|
+
/** Whether the palette is evaluated on the GPU, into fixed current and previous sets */ _gpu;
|
|
304
|
+
_playRate;
|
|
305
|
+
_loop;
|
|
306
|
+
_autoPlay;
|
|
307
|
+
_block;
|
|
308
|
+
/** Offsets of the current and previous sets in the block, as `SkinBinding` keeps them */ _offsets;
|
|
309
|
+
_dirty;
|
|
310
|
+
_palette;
|
|
311
|
+
_meshes;
|
|
312
|
+
/** @internal */ constructor(bank, entryIndex, options){
|
|
313
|
+
super();
|
|
314
|
+
this._bank = bank;
|
|
315
|
+
this._entryIndex = entryIndex;
|
|
316
|
+
this._playRate = options?.playRate ?? 1;
|
|
317
|
+
this._loop = options?.loop ?? true;
|
|
318
|
+
this._autoPlay = options?.autoPlay ?? true;
|
|
319
|
+
this._position = this.wrap(options?.position ?? 0);
|
|
320
|
+
this._previousPosition = this._position;
|
|
321
|
+
this._evaluatedPosition = this._position;
|
|
322
|
+
this._gpu = (options?.evaluation ?? 'auto') === 'auto' && AnimationBankGpuEvaluator.isSupported();
|
|
323
|
+
this._block = SkinPaletteAtlas.instance.allocate(bank.jointCount * 2 + 1);
|
|
324
|
+
this._offsets = [
|
|
325
|
+
0,
|
|
326
|
+
0
|
|
327
|
+
];
|
|
328
|
+
this._dirty = true;
|
|
329
|
+
this._palette = new Float32Array(this._gpu ? 0 : bank.jointCount * 16);
|
|
330
|
+
this._meshes = new Map();
|
|
331
|
+
AnimationBankTrack._activeTracks.add(this);
|
|
332
|
+
if (this._gpu) {
|
|
333
|
+
// Fixed sets, both rewritten by every dispatch
|
|
334
|
+
this._offsets[0] = 1;
|
|
335
|
+
this._offsets[1] = 1 + bank.jointCount;
|
|
336
|
+
this.writeHeader();
|
|
337
|
+
AnimationBankGpuEvaluator.addTrack(this);
|
|
338
|
+
} else {
|
|
339
|
+
this.evaluate();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Advance all tracks by the frame time, once per device frame.
|
|
344
|
+
*
|
|
345
|
+
* @internal
|
|
346
|
+
*/ static updateAll(deltaInSeconds) {
|
|
347
|
+
const frame = getDevice().frameInfo.frameCounter;
|
|
348
|
+
if (frame !== this._updateFrame) {
|
|
349
|
+
this._updateFrame = frame;
|
|
350
|
+
for (const track of this._activeTracks){
|
|
351
|
+
track.update(deltaInSeconds);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/** The bank this track plays */ get bank() {
|
|
356
|
+
return this._bank;
|
|
357
|
+
}
|
|
358
|
+
/** Name of the clip playing */ get clipName() {
|
|
359
|
+
return this._bank.entries[this._entryIndex].name;
|
|
360
|
+
}
|
|
361
|
+
/** Length of the clip in seconds */ get playLength() {
|
|
362
|
+
return this._bank.entries[this._entryIndex].playLength;
|
|
363
|
+
}
|
|
364
|
+
/** Playback position in seconds */ get position() {
|
|
365
|
+
return this._position;
|
|
366
|
+
}
|
|
367
|
+
set position(val) {
|
|
368
|
+
this._position = this.wrap(val);
|
|
369
|
+
this._dirty = true;
|
|
370
|
+
}
|
|
371
|
+
/** Playback rate, negative values play backwards */ get playRate() {
|
|
372
|
+
return this._playRate;
|
|
373
|
+
}
|
|
374
|
+
set playRate(val) {
|
|
375
|
+
this._playRate = val;
|
|
376
|
+
}
|
|
377
|
+
/** Whether playback wraps around at either end */ get loop() {
|
|
378
|
+
return this._loop;
|
|
379
|
+
}
|
|
380
|
+
set loop(val) {
|
|
381
|
+
this._loop = val;
|
|
382
|
+
}
|
|
383
|
+
/** Whether the position advances with time */ get autoPlay() {
|
|
384
|
+
return this._autoPlay;
|
|
385
|
+
}
|
|
386
|
+
set autoPlay(val) {
|
|
387
|
+
this._autoPlay = val;
|
|
388
|
+
}
|
|
389
|
+
/** Slot index of the palette header in the skin palette atlas */ get paletteBase() {
|
|
390
|
+
return this._block?.base ?? 0;
|
|
391
|
+
}
|
|
392
|
+
/** Whether the palette is evaluated on the GPU */ get gpuEvaluated() {
|
|
393
|
+
return this._gpu;
|
|
394
|
+
}
|
|
395
|
+
/** @internal */ get entryIndex() {
|
|
396
|
+
return this._entryIndex;
|
|
397
|
+
}
|
|
398
|
+
/** @internal Position of the previous pose */ get previousPosition() {
|
|
399
|
+
return this._previousPosition;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Play another clip of the bank, keeping the playback options.
|
|
403
|
+
*
|
|
404
|
+
* @remarks
|
|
405
|
+
* The pose changes at once; tracks do not blend clips. The bounds of attached meshes are
|
|
406
|
+
* recomputed for the new clip.
|
|
407
|
+
*
|
|
408
|
+
* @param clip - Name or entry index of the clip
|
|
409
|
+
* @param position - Position to start at in seconds, default 0
|
|
410
|
+
*/ setClip(clip, position = 0) {
|
|
411
|
+
const index = typeof clip === 'number' ? clip : this._bank.getEntryIndex(clip);
|
|
412
|
+
if (index < 0 || index >= this._bank.entries.length) {
|
|
413
|
+
throw new Error(`AnimationBankTrack.setClip(): clip not baked: ${clip}`);
|
|
414
|
+
}
|
|
415
|
+
this._entryIndex = index;
|
|
416
|
+
this._position = this.wrap(position);
|
|
417
|
+
// The previous pose belonged to another clip, so the new one starts still
|
|
418
|
+
this._previousPosition = this._position;
|
|
419
|
+
this._evaluatedPosition = this._position;
|
|
420
|
+
this._dirty = true;
|
|
421
|
+
for (const mesh of this._meshes.keys()){
|
|
422
|
+
this.attachMesh(mesh);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Skin all meshes under a node by this track.
|
|
427
|
+
*
|
|
428
|
+
* @remarks
|
|
429
|
+
* Meshes whose skin binding has other joints than the bank are skipped. The skin bindings of the
|
|
430
|
+
* attached meshes stop updating their own palettes until detached.
|
|
431
|
+
*
|
|
432
|
+
* @param node - Root of the model, typically an instance of the model the bank was baked from
|
|
433
|
+
* @param binding - If given, only meshes skinned by this binding are attached
|
|
434
|
+
* @returns Number of meshes attached
|
|
435
|
+
*/ attach(node, binding) {
|
|
436
|
+
let count = 0;
|
|
437
|
+
node.iterate((child)=>{
|
|
438
|
+
if (child.isMesh() && this.attachMesh(child, binding)) {
|
|
439
|
+
count++;
|
|
440
|
+
}
|
|
441
|
+
return false;
|
|
442
|
+
});
|
|
443
|
+
return count;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Skin the meshes under a node by their skin bindings again.
|
|
447
|
+
*
|
|
448
|
+
* @param node - Node passed to {@link attach}
|
|
449
|
+
*/ detach(node) {
|
|
450
|
+
node.iterate((child)=>{
|
|
451
|
+
if (child.isMesh() && this._meshes.has(child)) {
|
|
452
|
+
this.detachMesh(child);
|
|
453
|
+
}
|
|
454
|
+
return false;
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Advance the position by the frame time and write the new pose.
|
|
459
|
+
*
|
|
460
|
+
* @internal
|
|
461
|
+
*/ update(deltaInSeconds) {
|
|
462
|
+
if (this._autoPlay && this._playRate !== 0) {
|
|
463
|
+
this._position = this.wrap(this._position + this._playRate * deltaInSeconds);
|
|
464
|
+
this._dirty = true;
|
|
465
|
+
}
|
|
466
|
+
if (this._gpu) {
|
|
467
|
+
// Evaluated by the next dispatch; a still pose evaluates to the same matrices twice
|
|
468
|
+
this._previousPosition = this._evaluatedPosition;
|
|
469
|
+
this._evaluatedPosition = this._position;
|
|
470
|
+
this._dirty = false;
|
|
471
|
+
} else if (this._dirty) {
|
|
472
|
+
this.evaluate();
|
|
473
|
+
} else if (this._offsets[1] !== this._offsets[0]) {
|
|
474
|
+
// A still pose: point the previous set at the current one so motion vectors become zero
|
|
475
|
+
this._offsets[1] = this._offsets[0];
|
|
476
|
+
this.writeHeader();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
/** Release the palette and skin the attached meshes by their skin bindings again */ onDispose() {
|
|
480
|
+
super.onDispose();
|
|
481
|
+
for (const mesh of [
|
|
482
|
+
...this._meshes.keys()
|
|
483
|
+
]){
|
|
484
|
+
this.detachMesh(mesh);
|
|
485
|
+
}
|
|
486
|
+
AnimationBankTrack._activeTracks.delete(this);
|
|
487
|
+
if (this._gpu) {
|
|
488
|
+
AnimationBankGpuEvaluator.removeTrack(this);
|
|
489
|
+
}
|
|
490
|
+
this._bank.removeTrack(this);
|
|
491
|
+
if (this._block) {
|
|
492
|
+
SkinPaletteAtlas.instance.free(this._block);
|
|
493
|
+
this._block = null;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
attachMesh(mesh, only) {
|
|
497
|
+
const binding = mesh.findSkinBindingById(mesh.skinBindingName);
|
|
498
|
+
if (!binding || only && binding !== only || !this._bank.isCompatible(binding)) {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
const previous = mesh.getSkinPaletteOverride();
|
|
502
|
+
if (previous?.owner && previous.owner !== this) {
|
|
503
|
+
previous.owner.detachMesh(mesh);
|
|
504
|
+
}
|
|
505
|
+
if (!this._meshes.has(mesh)) {
|
|
506
|
+
binding.suspendPalette(true);
|
|
507
|
+
}
|
|
508
|
+
const boundingBox = this._bank.computeBoundingBox(this._entryIndex, mesh, binding);
|
|
509
|
+
this._meshes.set(mesh, boundingBox);
|
|
510
|
+
mesh.setSkinPaletteOverride({
|
|
511
|
+
paletteBase: this.paletteBase,
|
|
512
|
+
boundingBox,
|
|
513
|
+
owner: this
|
|
514
|
+
});
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
/** @internal */ detachMesh(mesh) {
|
|
518
|
+
if (this._meshes.delete(mesh)) {
|
|
519
|
+
mesh.findSkinBindingById(mesh.skinBindingName)?.suspendPalette(false);
|
|
520
|
+
if (mesh.getSkinPaletteOverride()?.owner === this) {
|
|
521
|
+
mesh.setSkinPaletteOverride(null);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/** Write the pose at the position into the set not holding the previous pose */ evaluate() {
|
|
526
|
+
if (!this._block) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const n = this._bank.jointCount;
|
|
530
|
+
if (this._offsets[0] === 0) {
|
|
531
|
+
this._offsets[0] = 1;
|
|
532
|
+
this._offsets[1] = 1;
|
|
533
|
+
} else {
|
|
534
|
+
this._offsets[1] = this._offsets[0];
|
|
535
|
+
this._offsets[0] = n - this._offsets[0] + 2;
|
|
536
|
+
}
|
|
537
|
+
this._bank.writePalette(this._entryIndex, this._position, this._block.base + this._offsets[0], this._palette);
|
|
538
|
+
this.writeHeader();
|
|
539
|
+
this._dirty = false;
|
|
540
|
+
}
|
|
541
|
+
writeHeader() {
|
|
542
|
+
const base = this._block.base;
|
|
543
|
+
tmpHeader[0] = base + this._offsets[0];
|
|
544
|
+
tmpHeader[1] = base + this._offsets[1];
|
|
545
|
+
SkinPaletteAtlas.instance.writeSlots(base, tmpHeader);
|
|
546
|
+
}
|
|
547
|
+
wrap(position) {
|
|
548
|
+
const length = this.playLength;
|
|
549
|
+
if (this._loop) {
|
|
550
|
+
position = length === 0 ? 0 : position % length;
|
|
551
|
+
if (position < 0) {
|
|
552
|
+
position += length;
|
|
553
|
+
}
|
|
554
|
+
return position;
|
|
555
|
+
}
|
|
556
|
+
return Math.min(Math.max(position, 0), length);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
function getKeyIndicesFromTime(time, numKeys, sequenceLength) {
|
|
560
|
+
if (time <= 0 || numKeys === 1) {
|
|
561
|
+
return {
|
|
562
|
+
key0: 0,
|
|
563
|
+
key1: 0,
|
|
564
|
+
alpha: 0
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
const lastIndex = numKeys - 1;
|
|
568
|
+
if (time >= sequenceLength) {
|
|
569
|
+
return {
|
|
570
|
+
key0: lastIndex,
|
|
571
|
+
key1: 0,
|
|
572
|
+
alpha: 0
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
const keyPos = time * (lastIndex / sequenceLength);
|
|
576
|
+
const key0 = Math.min(Math.max(Math.floor(keyPos), 0), lastIndex);
|
|
577
|
+
const alpha = keyPos - key0;
|
|
578
|
+
const key1 = key0 + 1 === numKeys ? key0 : key0 + 1;
|
|
579
|
+
return {
|
|
580
|
+
key0,
|
|
581
|
+
key1,
|
|
582
|
+
alpha
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
/** Blend two keys into a joint pose matrix */ function blendKeys(keys, a, b, alpha, out) {
|
|
586
|
+
const beta = 1 - alpha;
|
|
587
|
+
// Rotations are normalized before and after blending, along the shorter arc
|
|
588
|
+
let ax = keys[a + 3], ay = keys[a + 4], az = keys[a + 5], aw = keys[a + 6];
|
|
589
|
+
let bx = keys[b + 3], by = keys[b + 4], bz = keys[b + 5], bw = keys[b + 6];
|
|
590
|
+
let len = Math.hypot(ax, ay, az, aw) || 1;
|
|
591
|
+
ax /= len;
|
|
592
|
+
ay /= len;
|
|
593
|
+
az /= len;
|
|
594
|
+
aw /= len;
|
|
595
|
+
len = Math.hypot(bx, by, bz, bw) || 1;
|
|
596
|
+
const sign = ax * bx + ay * by + az * bz + aw * bw < 0 ? -1 / len : 1 / len;
|
|
597
|
+
bx *= sign;
|
|
598
|
+
by *= sign;
|
|
599
|
+
bz *= sign;
|
|
600
|
+
bw *= sign;
|
|
601
|
+
let x = ax * beta + bx * alpha;
|
|
602
|
+
let y = ay * beta + by * alpha;
|
|
603
|
+
let z = az * beta + bz * alpha;
|
|
604
|
+
let w = aw * beta + bw * alpha;
|
|
605
|
+
len = Math.hypot(x, y, z, w) || 1;
|
|
606
|
+
x /= len;
|
|
607
|
+
y /= len;
|
|
608
|
+
z /= len;
|
|
609
|
+
w /= len;
|
|
610
|
+
const sx = keys[a + 7] * beta + keys[b + 7] * alpha;
|
|
611
|
+
const sy = keys[a + 8] * beta + keys[b + 8] * alpha;
|
|
612
|
+
const sz = keys[a + 9] * beta + keys[b + 9] * alpha;
|
|
613
|
+
// Column-major translation * rotation * scale
|
|
614
|
+
out[0] = (1 - 2 * (y * y + z * z)) * sx;
|
|
615
|
+
out[1] = 2 * (x * y + z * w) * sx;
|
|
616
|
+
out[2] = 2 * (x * z - y * w) * sx;
|
|
617
|
+
out[3] = 0;
|
|
618
|
+
out[4] = 2 * (x * y - z * w) * sy;
|
|
619
|
+
out[5] = (1 - 2 * (x * x + z * z)) * sy;
|
|
620
|
+
out[6] = 2 * (y * z + x * w) * sy;
|
|
621
|
+
out[7] = 0;
|
|
622
|
+
out[8] = 2 * (x * z + y * w) * sz;
|
|
623
|
+
out[9] = 2 * (y * z - x * w) * sz;
|
|
624
|
+
out[10] = (1 - 2 * (x * x + y * y)) * sz;
|
|
625
|
+
out[11] = 0;
|
|
626
|
+
out[12] = keys[a] * beta + keys[b] * alpha;
|
|
627
|
+
out[13] = keys[a + 1] * beta + keys[b + 1] * alpha;
|
|
628
|
+
out[14] = keys[a + 2] * beta + keys[b + 2] * alpha;
|
|
629
|
+
out[15] = 1;
|
|
630
|
+
return out;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export { ANIMATION_BANK_SAMPLE_RATE, AnimationBank, AnimationBankTrack };
|
|
634
|
+
//# sourceMappingURL=animation_bank.js.map
|