@zephyr3d/scene 0.9.26 → 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 +146 -30
- 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 +300 -56
- 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 +177 -3
- 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 +178 -200
- 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 +30475 -19865
- package/dist/index.js +67 -12
- 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/hairstrand.js +235 -235
- package/dist/material/hairstrand.js.map +1 -1
- package/dist/material/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +362 -300
- 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 +223 -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 +733 -190
- 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 +2009 -201
- 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 +668 -63
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js +12 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +48 -50
- 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 +34 -15
- 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 +40 -39
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +328 -62
- 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 +26 -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 +53 -53
- 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 +8 -13
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +268 -136
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +113 -28
- 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/hzb.js +80 -22
- package/dist/render/hzb.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 +23 -9
- 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/oit.js +11 -11
- package/dist/render/oit.js.map +1 -1
- 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 +198 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +14 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +15 -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 +585 -59
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
- package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +8 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- 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 +524 -0
- package/dist/render/underwater.js.map +1 -0
- 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 +1195 -0
- package/dist/render/water_caustics.js.map +1 -0
- 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 +36 -36
- 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 +997 -96
- 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/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 +40 -87
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +42 -0
- package/dist/shaders/water_medium.js.map +1 -0
- 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 +87 -49
- 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 +36 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +77 -7
- 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 +140 -279
- 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 +2473 -114
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +97 -109
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Vector3, Disposable, randomUUID, Quaternion, DWeakRef
|
|
1
|
+
import { Vector3, Matrix4x4, Disposable, randomUUID, Quaternion, DWeakRef } from '@zephyr3d/base';
|
|
2
2
|
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
-
import {
|
|
3
|
+
import { SkinPaletteAtlas } from './skin_palette_atlas.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Standardized humanoid joint names for consistent skeleton mapping across models and animations.
|
|
@@ -58,7 +58,9 @@ import { getDevice } from '../app/api.js';
|
|
|
58
58
|
return HumanoidHandRig;
|
|
59
59
|
}({});
|
|
60
60
|
const tmpV0 = new Vector3();
|
|
61
|
-
const
|
|
61
|
+
const tmpMatrix = new Matrix4x4();
|
|
62
|
+
const tmpMatrix2 = new Matrix4x4();
|
|
63
|
+
/** Palette header slot: absolute slot indices of the current and previous sets */ const tmpHeader = new Float32Array(16);
|
|
62
64
|
const humanoidHelperJointTokens = new Set([
|
|
63
65
|
'end',
|
|
64
66
|
'nub',
|
|
@@ -78,6 +80,8 @@ const humanoidHelperJointTokens = new Set([
|
|
|
78
80
|
_joints;
|
|
79
81
|
_bindPoseByJoint;
|
|
80
82
|
_bindPose;
|
|
83
|
+
_retargetPoseByJoint;
|
|
84
|
+
_retargetPose;
|
|
81
85
|
_rootJoint;
|
|
82
86
|
_rootBindPose;
|
|
83
87
|
_playing;
|
|
@@ -93,6 +97,14 @@ const humanoidHelperJointTokens = new Set([
|
|
|
93
97
|
for(let i = 0; i < joints.length; i++){
|
|
94
98
|
this._bindPoseByJoint.set(joints[i], bindPose[i]);
|
|
95
99
|
}
|
|
100
|
+
if (options?.retargetPose && options.retargetPose.length !== joints.length) {
|
|
101
|
+
throw new Error('SkeletonRig(): retarget pose must contain one transform per joint');
|
|
102
|
+
}
|
|
103
|
+
this._retargetPose = options?.retargetPose ?? null;
|
|
104
|
+
this._retargetPoseByJoint = this._retargetPose ? new Map(joints.map((joint, index)=>[
|
|
105
|
+
joint,
|
|
106
|
+
this._retargetPose[index]
|
|
107
|
+
])) : null;
|
|
96
108
|
const skeletonRoot = this.findRootJoint(this._joints);
|
|
97
109
|
this._rootJoint = options?.rootJoint ?? skeletonRoot;
|
|
98
110
|
this._rootBindPose = options?.rootBindPose ?? this.getNodeBindPose(this._rootJoint);
|
|
@@ -145,6 +157,12 @@ const humanoidHelperJointTokens = new Set([
|
|
|
145
157
|
get bindPose() {
|
|
146
158
|
return this._bindPose;
|
|
147
159
|
}
|
|
160
|
+
/** Effective humanoid retarget reference pose. */ get retargetPose() {
|
|
161
|
+
return this._retargetPose ?? this._bindPose;
|
|
162
|
+
}
|
|
163
|
+
/** Whether this rig has a reference pose that is distinct from its bind pose. */ get hasRetargetPose() {
|
|
164
|
+
return !!this._retargetPose;
|
|
165
|
+
}
|
|
148
166
|
get rootJoint() {
|
|
149
167
|
return this._rootJoint;
|
|
150
168
|
}
|
|
@@ -158,6 +176,9 @@ const humanoidHelperJointTokens = new Set([
|
|
|
158
176
|
getBindPoseForJoint(joint) {
|
|
159
177
|
return this._bindPoseByJoint.get(joint) ?? null;
|
|
160
178
|
}
|
|
179
|
+
getRetargetPoseForJoint(joint) {
|
|
180
|
+
return this._retargetPoseByJoint?.get(joint) ?? this.getBindPoseForJoint(joint);
|
|
181
|
+
}
|
|
161
182
|
get humanoidJointMapping() {
|
|
162
183
|
return this._humanoidJointMapping;
|
|
163
184
|
}
|
|
@@ -275,11 +296,14 @@ function sideJointPatterns(side, patterns) {
|
|
|
275
296
|
* - Applies skinning state to associated meshes each frame.
|
|
276
297
|
* - Computes animated axis-aligned bounding boxes using representative skinned vertices.
|
|
277
298
|
*
|
|
278
|
-
* Joint matrix
|
|
279
|
-
* -
|
|
280
|
-
* -
|
|
281
|
-
*
|
|
282
|
-
*
|
|
299
|
+
* Joint matrix palette layout:
|
|
300
|
+
* - A block of slots in the shared {@link SkinPaletteAtlas}, one slot per 4x4 matrix.
|
|
301
|
+
* - Slot 0 is a header holding the absolute slot indices of the current and previous sets.
|
|
302
|
+
* - The rest is a 2-layered ring buffer: current and previous joint transforms to support
|
|
303
|
+
* temporal addressing. Offsets relative to the block are tracked in `_jointOffsets[0]`
|
|
304
|
+
* (current) and `_jointOffsets[1]` (previous).
|
|
305
|
+
* - Palette matrices are relative to {@link SkinBinding.referenceNode}, so they do not change
|
|
306
|
+
* when the whole character moves and can be shared by instances of the same model.
|
|
283
307
|
*
|
|
284
308
|
* Usage:
|
|
285
309
|
* - Construct with a rig, bind data, meshes and submesh bounding info.
|
|
@@ -295,8 +319,17 @@ function sideJointPatterns(side, patterns) {
|
|
|
295
319
|
/** @internal */ _inverseBindMatrices;
|
|
296
320
|
/** @internal */ _jointMatrices;
|
|
297
321
|
/** @internal */ _jointOffsets;
|
|
298
|
-
/** @internal */
|
|
299
|
-
/** @internal */
|
|
322
|
+
/** @internal */ _paletteBlock;
|
|
323
|
+
/** @internal Number of meshes skinned by other palettes in place of this binding's */ _paletteSuspendCount;
|
|
324
|
+
/** @internal Increased each time the pose relative to the reference node changes */ _paletteVersion;
|
|
325
|
+
/** @internal Whether both palette sets hold the current pose, so a still pose needs no write */ _paletteSettled;
|
|
326
|
+
/**
|
|
327
|
+
* @internal Joints and the nodes between them and the reference node, whose local transforms
|
|
328
|
+
* make up the pose
|
|
329
|
+
*/ _poseNodes;
|
|
330
|
+
/** @internal Sum of the local transform tags of the pose nodes when the pose last changed */ _poseTag;
|
|
331
|
+
/** @internal Meshes waiting for the pose to change before updating again */ _sleepingMeshes;
|
|
332
|
+
/** @internal */ _paletteData;
|
|
300
333
|
/** @internal */ _playing;
|
|
301
334
|
/** @internal */ _lastUpdateTime;
|
|
302
335
|
/**
|
|
@@ -312,7 +345,13 @@ function sideJointPatterns(side, patterns) {
|
|
|
312
345
|
this._rig = rig;
|
|
313
346
|
this._joints = joints ?? rig.joints;
|
|
314
347
|
this._inverseBindMatrices = inverseBindMatrices;
|
|
315
|
-
this.
|
|
348
|
+
this._paletteBlock = null;
|
|
349
|
+
this._paletteSuspendCount = 0;
|
|
350
|
+
this._paletteVersion = 0;
|
|
351
|
+
this._paletteSettled = false;
|
|
352
|
+
this._poseNodes = null;
|
|
353
|
+
this._poseTag = -1;
|
|
354
|
+
this._sleepingMeshes = new Set();
|
|
316
355
|
this._playing = false;
|
|
317
356
|
this._lastUpdateTime = 0;
|
|
318
357
|
if (bindPose && bindPose !== rig.bindPose) {
|
|
@@ -321,7 +360,8 @@ function sideJointPatterns(side, patterns) {
|
|
|
321
360
|
this._rig = new SkeletonRig(rig.joints, bindPose, {
|
|
322
361
|
rootJoint: rig.rootJoint,
|
|
323
362
|
rootBindPose: rig.rootBindPose,
|
|
324
|
-
humanoidJointMapping: rig.humanoidJointMapping
|
|
363
|
+
humanoidJointMapping: rig.humanoidJointMapping,
|
|
364
|
+
retargetPose: rig.hasRetargetPose ? rig.retargetPose : null
|
|
325
365
|
});
|
|
326
366
|
}
|
|
327
367
|
this.updateJointMatrices();
|
|
@@ -385,9 +425,43 @@ function sideJointPatterns(side, patterns) {
|
|
|
385
425
|
/**
|
|
386
426
|
* Texture containing joint matrices for GPU skinning.
|
|
387
427
|
*
|
|
388
|
-
*
|
|
428
|
+
* This is the shared {@link SkinPaletteAtlas} texture; the palette of this binding starts at
|
|
429
|
+
* slot {@link SkinBinding.paletteBase}. Each matrix is stored in 4 texels (one row per texel,
|
|
430
|
+
* RGBA = 4 floats).
|
|
389
431
|
*/ get jointTexture() {
|
|
390
|
-
return
|
|
432
|
+
return SkinPaletteAtlas.instance.texture;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Index of the header slot of this binding's palette in the joint texture.
|
|
436
|
+
*
|
|
437
|
+
* @internal
|
|
438
|
+
*/ get paletteBase() {
|
|
439
|
+
return this._paletteBlock?.base ?? 0;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Increased each time the pose relative to the reference node changes, so skinned meshes
|
|
443
|
+
* recompute their bounds only then. A model moving as a whole keeps its pose.
|
|
444
|
+
*
|
|
445
|
+
* @internal
|
|
446
|
+
*/ get paletteVersion() {
|
|
447
|
+
return this._paletteVersion;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Have a skinned mesh queued for update the next time the pose changes, instead of every frame.
|
|
451
|
+
*
|
|
452
|
+
* @internal
|
|
453
|
+
*/ sleepUntilPoseChanges(mesh) {
|
|
454
|
+
this._sleepingMeshes.add(mesh);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Node the palette matrices are relative to: the parent of the rig's root joint, or null
|
|
458
|
+
* for world space.
|
|
459
|
+
*
|
|
460
|
+
* @remarks
|
|
461
|
+
* A mesh skinned by this binding transforms palette output to its local space by
|
|
462
|
+
* `inverse(mesh.worldMatrix) * referenceNode.worldMatrix`.
|
|
463
|
+
*/ get referenceNode() {
|
|
464
|
+
return this._rig.rootJoint?.parent ?? null;
|
|
391
465
|
}
|
|
392
466
|
/**
|
|
393
467
|
* Get joint index by joint node
|
|
@@ -419,10 +493,13 @@ function sideJointPatterns(side, patterns) {
|
|
|
419
493
|
* @param worldMatrix - Optional world-to-model transform applied before inverse bind.
|
|
420
494
|
* @internal
|
|
421
495
|
*/ updateJointMatrices() {
|
|
422
|
-
if (!this.
|
|
423
|
-
this.
|
|
496
|
+
if (!this._jointOffsets) {
|
|
497
|
+
this._createPalette();
|
|
498
|
+
} else if (!this._paletteBlock) {
|
|
499
|
+
this._paletteBlock = SkinPaletteAtlas.instance.allocate(this.joints.length * 2 + 1);
|
|
424
500
|
}
|
|
425
|
-
|
|
501
|
+
const first = this._jointOffsets[0] === 0;
|
|
502
|
+
if (first) {
|
|
426
503
|
this._jointOffsets[0] = 1;
|
|
427
504
|
this._jointOffsets[1] = 1;
|
|
428
505
|
} else {
|
|
@@ -432,6 +509,24 @@ function sideJointPatterns(side, patterns) {
|
|
|
432
509
|
for(let i = 0; i < this.joints.length; i++){
|
|
433
510
|
Matrix4x4.multiply(this.joints[i].worldMatrix, this._inverseBindMatrices[i], this._jointMatrices[i + this._jointOffsets[0] - 1]);
|
|
434
511
|
}
|
|
512
|
+
// CPU-side matrices are world space and always current; the palette and anything derived
|
|
513
|
+
// from the pose only change when the pose relative to the reference node does
|
|
514
|
+
const changed = this._poseChanged() || first;
|
|
515
|
+
if (changed) {
|
|
516
|
+
this._computePalette();
|
|
517
|
+
this._paletteSettled = false;
|
|
518
|
+
this._paletteVersion++;
|
|
519
|
+
for (const mesh of this._sleepingMeshes){
|
|
520
|
+
mesh.scene?.queueUpdateNode(mesh);
|
|
521
|
+
}
|
|
522
|
+
this._sleepingMeshes.clear();
|
|
523
|
+
}
|
|
524
|
+
// The first still frame writes the pose once more so the previous set equals the current
|
|
525
|
+
// one; after that both sets hold it and the atlas is left alone
|
|
526
|
+
if (!this._paletteSettled) {
|
|
527
|
+
this._writePalette();
|
|
528
|
+
this._paletteSettled = !changed;
|
|
529
|
+
}
|
|
435
530
|
}
|
|
436
531
|
/**
|
|
437
532
|
* Reset skeleton to bind pose
|
|
@@ -441,14 +536,44 @@ function sideJointPatterns(side, patterns) {
|
|
|
441
536
|
this._rig.computeBindPose();
|
|
442
537
|
}
|
|
443
538
|
/**
|
|
444
|
-
* Compute current joint matrices from the nodes and
|
|
539
|
+
* Compute current joint matrices from the nodes and write them to the joint texture.
|
|
540
|
+
*
|
|
541
|
+
* @remarks
|
|
542
|
+
* The joint texture is uploaded once per frame when the scene update completes.
|
|
445
543
|
*
|
|
446
544
|
* @internal
|
|
447
545
|
*/ apply() {
|
|
448
|
-
this.
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
546
|
+
if (this._paletteSuspendCount === 0) {
|
|
547
|
+
this.updateJointMatrices();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Stop or resume updating the palette, while meshes are skinned by other palettes in place of
|
|
552
|
+
* this binding's.
|
|
553
|
+
*
|
|
554
|
+
* @remarks
|
|
555
|
+
* Calls are counted; the palette updates again once every suspension is resumed. CPU-side joint
|
|
556
|
+
* matrices are not updated while suspended either.
|
|
557
|
+
*
|
|
558
|
+
* The atlas block of the palette is released while suspended, since no mesh reads it, and
|
|
559
|
+
* allocated again on resume, at a new base: meshes pick it up as their palette overrides are
|
|
560
|
+
* cleared.
|
|
561
|
+
*
|
|
562
|
+
* @param suspend - true to suspend, false to resume
|
|
563
|
+
* @internal
|
|
564
|
+
*/ suspendPalette(suspend) {
|
|
565
|
+
const wasSuspended = this._paletteSuspendCount > 0;
|
|
566
|
+
this._paletteSuspendCount = Math.max(0, this._paletteSuspendCount + (suspend ? 1 : -1));
|
|
567
|
+
if (!wasSuspended && this._paletteSuspendCount > 0 && this._paletteBlock) {
|
|
568
|
+
SkinPaletteAtlas.instance.free(this._paletteBlock);
|
|
569
|
+
this._paletteBlock = null;
|
|
570
|
+
} else if (wasSuspended && this._paletteSuspendCount === 0 && this._jointOffsets) {
|
|
571
|
+
this._paletteBlock = SkinPaletteAtlas.instance.allocate(this.joints.length * 2 + 1);
|
|
572
|
+
// The previous set is as old as the suspension, so restart the history: the next update
|
|
573
|
+
// writes both sets, giving no motion for one frame rather than the motion since then
|
|
574
|
+
this._jointOffsets[0] = 0;
|
|
575
|
+
this._paletteSettled = false;
|
|
576
|
+
}
|
|
452
577
|
}
|
|
453
578
|
/**
|
|
454
579
|
* Apply all enabled modifiers.
|
|
@@ -480,32 +605,50 @@ function sideJointPatterns(side, patterns) {
|
|
|
480
605
|
* Compute the animated bounding box for a single mesh using its representative vertices.
|
|
481
606
|
*
|
|
482
607
|
* For each representative vertex:
|
|
483
|
-
* - Blends the vertex by up to 4
|
|
484
|
-
* - Transforms to the mesh's local space using `
|
|
608
|
+
* - Blends the vertex by up to 4 palette matrices using provided weights.
|
|
609
|
+
* - Transforms to the mesh's local space using `skinSpaceMatrix`.
|
|
485
610
|
* - Expands the bounding box.
|
|
486
611
|
*
|
|
612
|
+
* @remarks
|
|
613
|
+
* Reads the palette, which is relative to {@link SkinBinding.referenceNode} and changes together
|
|
614
|
+
* with {@link SkinBinding.paletteVersion}, rather than the world-space joint matrices: those are
|
|
615
|
+
* a snapshot of when the joints were last updated, and the model may have moved since without
|
|
616
|
+
* changing the pose, so combining them with the current mesh transform offsets the bounds.
|
|
617
|
+
*
|
|
487
618
|
* @param info - Precomputed bounding data (representative vertices, indices, weights).
|
|
488
|
-
* @param
|
|
619
|
+
* @param skinSpaceMatrix - Matrix transforming palette output to the mesh's local space,
|
|
620
|
+
* see {@link Mesh.getSkinSpaceMatrix}.
|
|
489
621
|
* @internal
|
|
490
|
-
*/ computeBoundingBox(info,
|
|
622
|
+
*/ computeBoundingBox(info, skinSpaceMatrix) {
|
|
491
623
|
info.boundingBox.beginExtend();
|
|
624
|
+
const palette = this._paletteData;
|
|
625
|
+
if (!palette) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
const numJoints = this.joints.length;
|
|
492
629
|
const influenceCount = Math.max(1, info.influenceCount ?? 4);
|
|
493
630
|
for(let i = 0; i < info.boundingVertices.length; i++){
|
|
494
|
-
|
|
631
|
+
const v = info.boundingVertices[i];
|
|
632
|
+
let x = 0;
|
|
633
|
+
let y = 0;
|
|
634
|
+
let z = 0;
|
|
495
635
|
const base = i * influenceCount;
|
|
496
636
|
for(let j = 0; j < influenceCount; j++){
|
|
497
637
|
const weight = Number(info.boundingVertexJointWeights[base + j]) || 0;
|
|
498
638
|
if (weight <= 0) {
|
|
499
639
|
continue;
|
|
500
640
|
}
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
641
|
+
const joint = Number(info.boundingVertexBlendIndices[base + j]) || 0;
|
|
642
|
+
if (joint < 0 || joint >= numJoints) {
|
|
503
643
|
continue;
|
|
504
644
|
}
|
|
505
|
-
|
|
506
|
-
|
|
645
|
+
const m = joint * 16;
|
|
646
|
+
x += weight * (palette[m] * v.x + palette[m + 4] * v.y + palette[m + 8] * v.z + palette[m + 12]);
|
|
647
|
+
y += weight * (palette[m + 1] * v.x + palette[m + 5] * v.y + palette[m + 9] * v.z + palette[m + 13]);
|
|
648
|
+
z += weight * (palette[m + 2] * v.x + palette[m + 6] * v.y + palette[m + 10] * v.z + palette[m + 14]);
|
|
507
649
|
}
|
|
508
|
-
|
|
650
|
+
tmpV0.setXYZ(x, y, z);
|
|
651
|
+
skinSpaceMatrix.transformPointAffine(tmpV0, tmpV0);
|
|
509
652
|
info.boundingBox.extend(tmpV0);
|
|
510
653
|
}
|
|
511
654
|
}
|
|
@@ -516,7 +659,11 @@ function sideJointPatterns(side, patterns) {
|
|
|
516
659
|
* - Clears matrix arrays and joint references.
|
|
517
660
|
*/ onDispose() {
|
|
518
661
|
super.onDispose();
|
|
519
|
-
this.
|
|
662
|
+
if (this._paletteBlock) {
|
|
663
|
+
SkinPaletteAtlas.instance.free(this._paletteBlock);
|
|
664
|
+
this._paletteBlock = null;
|
|
665
|
+
}
|
|
666
|
+
this._sleepingMeshes.clear();
|
|
520
667
|
const m = SkinBinding._registry.get(this._id);
|
|
521
668
|
if (m?.get() === this) {
|
|
522
669
|
SkinBinding._registry.delete(this._id);
|
|
@@ -524,38 +671,78 @@ function sideJointPatterns(side, patterns) {
|
|
|
524
671
|
}
|
|
525
672
|
}
|
|
526
673
|
/**
|
|
527
|
-
*
|
|
674
|
+
* Allocate the palette block and CPU-side matrix storage.
|
|
528
675
|
*
|
|
529
676
|
* Layout details:
|
|
530
|
-
* -
|
|
531
|
-
* - `
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
* - `_jointMatrices` is a view into `_jointMatrixArray` providing Matrix4x4 objects per slot.
|
|
677
|
+
* - The block holds a header slot followed by 2×N matrix slots (current and previous).
|
|
678
|
+
* - `_jointOffsets` holds the ring buffer offsets `[current, previous]` relative to the block.
|
|
679
|
+
* - `_jointMatrices` holds the world-space skinning matrices of both sets, which CPU-side
|
|
680
|
+
* consumers (bounds, cloth) read.
|
|
535
681
|
*
|
|
536
682
|
* @internal
|
|
537
|
-
*/
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
this.
|
|
541
|
-
|
|
542
|
-
samplerOptions: {
|
|
543
|
-
magFilter: 'nearest',
|
|
544
|
-
minFilter: 'nearest'
|
|
545
|
-
}
|
|
546
|
-
}));
|
|
547
|
-
this._jointMatrixArray = new Float32Array(textureWidth * textureWidth * 4);
|
|
548
|
-
this._jointOffsets = this._jointMatrixArray.subarray(0, 2);
|
|
549
|
-
this._jointOffsets[0] = 0;
|
|
550
|
-
this._jointOffsets[1] = 0;
|
|
683
|
+
*/ _createPalette() {
|
|
684
|
+
this._paletteBlock = SkinPaletteAtlas.instance.allocate(this.joints.length * 2 + 1);
|
|
685
|
+
this._paletteData = new Float32Array(this.joints.length * 16);
|
|
686
|
+
this._paletteSettled = false;
|
|
687
|
+
this._jointOffsets = new Float32Array(2);
|
|
551
688
|
this._jointMatrices = Array.from({
|
|
552
689
|
length: this.joints.length * 2
|
|
553
690
|
}).map(()=>new Matrix4x4());
|
|
554
691
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
692
|
+
/**
|
|
693
|
+
* Whether the pose may have changed since it last did: the local transform of a joint, or of a
|
|
694
|
+
* node between the joints and the reference node, has changed.
|
|
695
|
+
*
|
|
696
|
+
* @remarks
|
|
697
|
+
* Moving the whole model changes the world matrices of the joints but not the pose, so world
|
|
698
|
+
* matrices cannot tell; and comparing matrices taken back to the reference node trips over
|
|
699
|
+
* rounding far from the origin.
|
|
700
|
+
*/ _poseChanged() {
|
|
701
|
+
const reference = this.referenceNode;
|
|
702
|
+
if (!this._poseNodes || this._poseNodes.reference !== reference) {
|
|
703
|
+
const nodes = new Set();
|
|
704
|
+
for (const joint of this.joints){
|
|
705
|
+
for(let node = joint; node && node !== reference; node = node.parent){
|
|
706
|
+
if (nodes.has(node)) {
|
|
707
|
+
break;
|
|
708
|
+
}
|
|
709
|
+
nodes.add(node);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
this._poseNodes = {
|
|
713
|
+
reference,
|
|
714
|
+
nodes: [
|
|
715
|
+
...nodes
|
|
716
|
+
]
|
|
717
|
+
};
|
|
718
|
+
this._poseTag = -1;
|
|
719
|
+
}
|
|
720
|
+
let tag = 0;
|
|
721
|
+
for (const node of this._poseNodes.nodes){
|
|
722
|
+
tag += node.localTransformTag;
|
|
723
|
+
}
|
|
724
|
+
if (tag !== this._poseTag) {
|
|
725
|
+
this._poseTag = tag;
|
|
726
|
+
return true;
|
|
558
727
|
}
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
/** Compute the current set of matrices relative to the reference node */ _computePalette() {
|
|
731
|
+
const reference = this.referenceNode;
|
|
732
|
+
const invReference = reference ? Matrix4x4.invertAffine(reference.worldMatrix, tmpMatrix) : null;
|
|
733
|
+
const offset = this._jointOffsets[0] - 1;
|
|
734
|
+
for(let i = 0; i < this.joints.length; i++){
|
|
735
|
+
const world = this._jointMatrices[i + offset];
|
|
736
|
+
this._paletteData.set(invReference ? Matrix4x4.multiplyAffine(invReference, world, tmpMatrix2) : world, i * 16);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
/** Write the header and the current set of matrices to the palette */ _writePalette() {
|
|
740
|
+
const atlas = SkinPaletteAtlas.instance;
|
|
741
|
+
const base = this._paletteBlock.base;
|
|
742
|
+
atlas.writeSlots(base + this._jointOffsets[0], this._paletteData);
|
|
743
|
+
tmpHeader[0] = base + this._jointOffsets[0];
|
|
744
|
+
tmpHeader[1] = base + this._jointOffsets[1];
|
|
745
|
+
atlas.writeSlots(base, tmpHeader);
|
|
559
746
|
}
|
|
560
747
|
/**
|
|
561
748
|
* Build representative skinned bounding data for a submesh.
|
|
@@ -700,6 +887,63 @@ function sideJointPatterns(side, patterns) {
|
|
|
700
887
|
}
|
|
701
888
|
return result;
|
|
702
889
|
}
|
|
890
|
+
/**
|
|
891
|
+
* Skin packed direction vectors into mesh-local space for the current skeleton pose.
|
|
892
|
+
*
|
|
893
|
+
* Unlike positions, directions ignore matrix translation and are normalized after
|
|
894
|
+
* conversion through the mesh inverse world matrix.
|
|
895
|
+
*
|
|
896
|
+
* @internal
|
|
897
|
+
*/ skinDirectionsToLocal(directions, blendIndices, weights, invWorldMatrix, out, influenceCount) {
|
|
898
|
+
const result = out && out.length === directions.length ? out : new Float32Array(directions.length);
|
|
899
|
+
const matrixOffset = this._jointOffsets[0] - 1;
|
|
900
|
+
const effectiveInfluenceCount = Math.max(1, influenceCount ?? Math.max(1, Math.floor(weights.length / Math.max(1, Math.floor(directions.length / 3)))));
|
|
901
|
+
for(let i = 0; i + 2 < directions.length; i += 3){
|
|
902
|
+
const vertexIndex = i / 3 >> 0;
|
|
903
|
+
const x = directions[i];
|
|
904
|
+
const y = directions[i + 1];
|
|
905
|
+
const z = directions[i + 2];
|
|
906
|
+
let skinnedX = 0;
|
|
907
|
+
let skinnedY = 0;
|
|
908
|
+
let skinnedZ = 0;
|
|
909
|
+
let weightSum = 0;
|
|
910
|
+
const base = vertexIndex * effectiveInfluenceCount;
|
|
911
|
+
for(let j = 0; j < effectiveInfluenceCount; j++){
|
|
912
|
+
const weight = Number(weights[base + j]) || 0;
|
|
913
|
+
if (weight <= 0) {
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
916
|
+
const jointIndex = (Number(blendIndices[base + j]) || 0) + matrixOffset;
|
|
917
|
+
const matrix = this._jointMatrices[jointIndex];
|
|
918
|
+
if (!matrix) {
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
skinnedX += (matrix[0] * x + matrix[4] * y + matrix[8] * z) * weight;
|
|
922
|
+
skinnedY += (matrix[1] * x + matrix[5] * y + matrix[9] * z) * weight;
|
|
923
|
+
skinnedZ += (matrix[2] * x + matrix[6] * y + matrix[10] * z) * weight;
|
|
924
|
+
weightSum += weight;
|
|
925
|
+
}
|
|
926
|
+
if (weightSum <= 1e-6) {
|
|
927
|
+
skinnedX = x;
|
|
928
|
+
skinnedY = y;
|
|
929
|
+
skinnedZ = z;
|
|
930
|
+
}
|
|
931
|
+
const localX = invWorldMatrix[0] * skinnedX + invWorldMatrix[4] * skinnedY + invWorldMatrix[8] * skinnedZ;
|
|
932
|
+
const localY = invWorldMatrix[1] * skinnedX + invWorldMatrix[5] * skinnedY + invWorldMatrix[9] * skinnedZ;
|
|
933
|
+
const localZ = invWorldMatrix[2] * skinnedX + invWorldMatrix[6] * skinnedY + invWorldMatrix[10] * skinnedZ;
|
|
934
|
+
const length = Math.hypot(localX, localY, localZ);
|
|
935
|
+
if (length > 1e-8) {
|
|
936
|
+
result[i] = localX / length;
|
|
937
|
+
result[i + 1] = localY / length;
|
|
938
|
+
result[i + 2] = localZ / length;
|
|
939
|
+
} else {
|
|
940
|
+
result[i] = 0;
|
|
941
|
+
result[i + 1] = 1;
|
|
942
|
+
result[i + 2] = 0;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return result;
|
|
946
|
+
}
|
|
703
947
|
static normalizeHumanoidJointName(name) {
|
|
704
948
|
return name.slice(name.lastIndexOf(':') + 1).replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2').replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/([a-zA-Z])(\d+)/g, '$1 $2').replace(/(\d+)([a-zA-Z])/g, '$1 $2').replace(/[_:\/\\.-]+/g, ' ').replace(/[^a-zA-Z0-9]+/g, ' ').toLowerCase().replace(/\bforearm\b/g, 'fore arm').replace(/\bupperarm\b/g, 'upper arm').replace(/\blowerarm\b/g, 'lower arm').replace(/\bupleg\b/g, 'up leg').replace(/\bupperleg\b/g, 'upper leg').replace(/\blowerleg\b/g, 'lower leg').replace(/\btoebase\b/g, 'toe base').replace(/\bupperchest\b/g, 'upper chest').replace(/\btoes\b/g, 'toe').replace(/\blittle\b/g, 'pinky').replace(/\bcollar\b/g, 'clavicle').replace(/\s+/g, ' ').trim();
|
|
705
949
|
}
|