@zephyr3d/scene 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationset.js +220 -1
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ccd_solver.js +3 -4
- package/dist/animation/ik/ccd_solver.js.map +1 -1
- package/dist/animation/ik/fabrik_solver.js +3 -4
- package/dist/animation/ik/fabrik_solver.js.map +1 -1
- package/dist/animation/ik/ik_pole_constraint.js +7 -2
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
- package/dist/animation/ik/ik_utils.js +0 -79
- package/dist/animation/ik/ik_utils.js.map +1 -1
- package/dist/animation/ik/two_bone_ik_solver.js +3 -4
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
- package/dist/animation/skeleton.js +157 -125
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/spring_bone.js +240 -0
- package/dist/animation/spring/spring_bone.js.map +1 -0
- package/dist/animation/spring/spring_bone_collider.js +198 -0
- package/dist/animation/spring/spring_bone_collider.js.map +1 -0
- package/dist/animation/spring/spring_bone_constraint.js +170 -0
- package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
- package/dist/animation/spring/spring_bone_system.js +328 -0
- package/dist/animation/spring/spring_bone_system.js.map +1 -0
- package/dist/asset/model.js +2 -2
- package/dist/index.d.ts +17 -0
- package/dist/material/mixins/pbr/common.js +20 -17
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/render/gpu_picking.js +100 -0
- package/dist/render/gpu_picking.js.map +1 -0
- package/dist/render/rendergraph/device_pool_allocator.js +41 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
- package/dist/render/rendergraph/executor.js +146 -0
- package/dist/render/rendergraph/executor.js.map +1 -0
- package/dist/render/rendergraph/forward_plus_builder.js +414 -0
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +306 -0
- package/dist/render/rendergraph/rendergraph.js.map +1 -0
- package/dist/render/rendergraph/types.js +57 -0
- package/dist/render/rendergraph/types.js.map +1 -0
- package/dist/render/sky_motion_vector.js +85 -0
- package/dist/render/sky_motion_vector.js.map +1 -0
- package/dist/utility/serialization/scene/animation.js +3 -3
- package/dist/utility/serialization/scene/node.js +1 -1
- package/package.json +2 -2
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
- package/dist/src/animation/animation.js +0 -127
- package/dist/src/animation/animation.js.map +0 -1
- package/dist/src/animation/animationset.js +0 -255
- package/dist/src/animation/animationset.js.map +0 -1
- package/dist/src/animation/animationtrack.js +0 -34
- package/dist/src/animation/animationtrack.js.map +0 -1
- package/dist/src/animation/eulerrotationtrack.js +0 -52
- package/dist/src/animation/eulerrotationtrack.js.map +0 -1
- package/dist/src/animation/morphtarget.js +0 -93
- package/dist/src/animation/morphtarget.js.map +0 -1
- package/dist/src/animation/morphtrack.js +0 -70
- package/dist/src/animation/morphtrack.js.map +0 -1
- package/dist/src/animation/proptrack.js +0 -161
- package/dist/src/animation/proptrack.js.map +0 -1
- package/dist/src/animation/rotationtrack.js +0 -51
- package/dist/src/animation/rotationtrack.js.map +0 -1
- package/dist/src/animation/scaletrack.js +0 -50
- package/dist/src/animation/scaletrack.js.map +0 -1
- package/dist/src/animation/skeleton.js +0 -204
- package/dist/src/animation/skeleton.js.map +0 -1
- package/dist/src/animation/translationtrack.js +0 -50
- package/dist/src/animation/translationtrack.js.map +0 -1
- package/dist/src/app/app.js +0 -129
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/inputmgr.js +0 -267
- package/dist/src/app/inputmgr.js.map +0 -1
- package/dist/src/asset/assetmanager.js +0 -404
- package/dist/src/asset/assetmanager.js.map +0 -1
- package/dist/src/asset/builtin.js +0 -337
- package/dist/src/asset/builtin.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds.js +0 -470
- package/dist/src/asset/loaders/dds/dds.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
- package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/helpers.js +0 -327
- package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/src/asset/loaders/hdr/hdr.js +0 -180
- package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
- package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
- package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
- package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
- package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
- package/dist/src/asset/loaders/loader.js +0 -45
- package/dist/src/asset/loaders/loader.js.map +0 -1
- package/dist/src/asset/model.js +0 -414
- package/dist/src/asset/model.js.map +0 -1
- package/dist/src/blitter/bilateralblur.js +0 -221
- package/dist/src/blitter/bilateralblur.js.map +0 -1
- package/dist/src/blitter/blitter.js +0 -390
- package/dist/src/blitter/blitter.js.map +0 -1
- package/dist/src/blitter/box.js +0 -118
- package/dist/src/blitter/box.js.map +0 -1
- package/dist/src/blitter/copy.js +0 -22
- package/dist/src/blitter/copy.js.map +0 -1
- package/dist/src/blitter/gaussianblur.js +0 -228
- package/dist/src/blitter/gaussianblur.js.map +0 -1
- package/dist/src/camera/base.js +0 -92
- package/dist/src/camera/base.js.map +0 -1
- package/dist/src/camera/camera.js +0 -1005
- package/dist/src/camera/camera.js.map +0 -1
- package/dist/src/camera/fps.js +0 -238
- package/dist/src/camera/fps.js.map +0 -1
- package/dist/src/camera/orbit.js +0 -245
- package/dist/src/camera/orbit.js.map +0 -1
- package/dist/src/camera/orthocamera.js +0 -167
- package/dist/src/camera/orthocamera.js.map +0 -1
- package/dist/src/camera/perspectivecamera.js +0 -141
- package/dist/src/camera/perspectivecamera.js.map +0 -1
- package/dist/src/index.js +0 -120
- package/dist/src/index.js.map +0 -1
- package/dist/src/material/blinn.js +0 -81
- package/dist/src/material/blinn.js.map +0 -1
- package/dist/src/material/grassmaterial.js +0 -113
- package/dist/src/material/grassmaterial.js.map +0 -1
- package/dist/src/material/lambert.js +0 -92
- package/dist/src/material/lambert.js.map +0 -1
- package/dist/src/material/material.js +0 -301
- package/dist/src/material/material.js.map +0 -1
- package/dist/src/material/meshmaterial.js +0 -704
- package/dist/src/material/meshmaterial.js.map +0 -1
- package/dist/src/material/mixins/albedocolor.js +0 -76
- package/dist/src/material/mixins/albedocolor.js.map +0 -1
- package/dist/src/material/mixins/foliage.js +0 -47
- package/dist/src/material/mixins/foliage.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
- package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
- package/dist/src/material/mixins/lit.js +0 -476
- package/dist/src/material/mixins/lit.js.map +0 -1
- package/dist/src/material/mixins/pbr/common.js +0 -918
- package/dist/src/material/mixins/pbr/common.js.map +0 -1
- package/dist/src/material/mixins/texture.js +0 -172
- package/dist/src/material/mixins/texture.js.map +0 -1
- package/dist/src/material/mixins/vertexcolor.js +0 -56
- package/dist/src/material/mixins/vertexcolor.js.map +0 -1
- package/dist/src/material/particle.js +0 -178
- package/dist/src/material/particle.js.map +0 -1
- package/dist/src/material/pbrmr.js +0 -97
- package/dist/src/material/pbrmr.js.map +0 -1
- package/dist/src/material/pbrsg.js +0 -97
- package/dist/src/material/pbrsg.js.map +0 -1
- package/dist/src/material/shader/helper.js +0 -1209
- package/dist/src/material/shader/helper.js.map +0 -1
- package/dist/src/material/terrain-cm.js +0 -606
- package/dist/src/material/terrain-cm.js.map +0 -1
- package/dist/src/material/terrainmaterial.js +0 -375
- package/dist/src/material/terrainmaterial.js.map +0 -1
- package/dist/src/material/unlit.js +0 -41
- package/dist/src/material/unlit.js.map +0 -1
- package/dist/src/material/water.js +0 -417
- package/dist/src/material/water.js.map +0 -1
- package/dist/src/posteffect/bloom.js +0 -361
- package/dist/src/posteffect/bloom.js.map +0 -1
- package/dist/src/posteffect/compositor.js +0 -226
- package/dist/src/posteffect/compositor.js.map +0 -1
- package/dist/src/posteffect/fxaa.js +0 -273
- package/dist/src/posteffect/fxaa.js.map +0 -1
- package/dist/src/posteffect/grayscale.js +0 -69
- package/dist/src/posteffect/grayscale.js.map +0 -1
- package/dist/src/posteffect/motionblur.js +0 -96
- package/dist/src/posteffect/motionblur.js.map +0 -1
- package/dist/src/posteffect/posteffect.js +0 -126
- package/dist/src/posteffect/posteffect.js.map +0 -1
- package/dist/src/posteffect/sao.js +0 -324
- package/dist/src/posteffect/sao.js.map +0 -1
- package/dist/src/posteffect/ssr.js +0 -489
- package/dist/src/posteffect/ssr.js.map +0 -1
- package/dist/src/posteffect/taa.js +0 -172
- package/dist/src/posteffect/taa.js.map +0 -1
- package/dist/src/posteffect/tonemap.js +0 -94
- package/dist/src/posteffect/tonemap.js.map +0 -1
- package/dist/src/render/abuffer_oit.js +0 -361
- package/dist/src/render/abuffer_oit.js.map +0 -1
- package/dist/src/render/clipmap.js +0 -851
- package/dist/src/render/clipmap.js.map +0 -1
- package/dist/src/render/cluster_light.js +0 -333
- package/dist/src/render/cluster_light.js.map +0 -1
- package/dist/src/render/cull_visitor.js +0 -187
- package/dist/src/render/cull_visitor.js.map +0 -1
- package/dist/src/render/depthpass.js +0 -68
- package/dist/src/render/depthpass.js.map +0 -1
- package/dist/src/render/drawable_mixin.js +0 -227
- package/dist/src/render/drawable_mixin.js.map +0 -1
- package/dist/src/render/envlight.js +0 -463
- package/dist/src/render/envlight.js.map +0 -1
- package/dist/src/render/fbm_wavegenerator.js +0 -251
- package/dist/src/render/fbm_wavegenerator.js.map +0 -1
- package/dist/src/render/fft_wavegenerator.js +0 -1006
- package/dist/src/render/fft_wavegenerator.js.map +0 -1
- package/dist/src/render/fullscreenquad.js +0 -38
- package/dist/src/render/fullscreenquad.js.map +0 -1
- package/dist/src/render/gerstner_wavegenerator.js +0 -314
- package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
- package/dist/src/render/globalbindgroup_allocator.js +0 -60
- package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
- package/dist/src/render/hzb.js +0 -273
- package/dist/src/render/hzb.js.map +0 -1
- package/dist/src/render/lightpass.js +0 -172
- package/dist/src/render/lightpass.js.map +0 -1
- package/dist/src/render/objectcolorpass.js +0 -51
- package/dist/src/render/objectcolorpass.js.map +0 -1
- package/dist/src/render/primitive.js +0 -364
- package/dist/src/render/primitive.js.map +0 -1
- package/dist/src/render/render_queue.js +0 -467
- package/dist/src/render/render_queue.js.map +0 -1
- package/dist/src/render/renderbundle_wrapper.js +0 -152
- package/dist/src/render/renderbundle_wrapper.js.map +0 -1
- package/dist/src/render/renderer.js +0 -455
- package/dist/src/render/renderer.js.map +0 -1
- package/dist/src/render/renderpass.js +0 -200
- package/dist/src/render/renderpass.js.map +0 -1
- package/dist/src/render/shadowmap_pass.js +0 -56
- package/dist/src/render/shadowmap_pass.js.map +0 -1
- package/dist/src/render/sky.js +0 -1103
- package/dist/src/render/sky.js.map +0 -1
- package/dist/src/render/weightedblended_oit.js +0 -168
- package/dist/src/render/weightedblended_oit.js.map +0 -1
- package/dist/src/scene/batchgroup.js +0 -162
- package/dist/src/scene/batchgroup.js.map +0 -1
- package/dist/src/scene/environment.js +0 -209
- package/dist/src/scene/environment.js.map +0 -1
- package/dist/src/scene/graph_node.js +0 -72
- package/dist/src/scene/graph_node.js.map +0 -1
- package/dist/src/scene/light.js +0 -416
- package/dist/src/scene/light.js.map +0 -1
- package/dist/src/scene/mesh.js +0 -341
- package/dist/src/scene/mesh.js.map +0 -1
- package/dist/src/scene/octree.js +0 -649
- package/dist/src/scene/octree.js.map +0 -1
- package/dist/src/scene/particlesys.js +0 -738
- package/dist/src/scene/particlesys.js.map +0 -1
- package/dist/src/scene/raycast_visitor.js +0 -103
- package/dist/src/scene/raycast_visitor.js.map +0 -1
- package/dist/src/scene/scene.js +0 -284
- package/dist/src/scene/scene.js.map +0 -1
- package/dist/src/scene/scene_node.js +0 -732
- package/dist/src/scene/scene_node.js.map +0 -1
- package/dist/src/scene/terrain/grass.js +0 -278
- package/dist/src/scene/terrain/grass.js.map +0 -1
- package/dist/src/scene/terrain/heightfield.js +0 -475
- package/dist/src/scene/terrain/heightfield.js.map +0 -1
- package/dist/src/scene/terrain/patch.js +0 -530
- package/dist/src/scene/terrain/patch.js.map +0 -1
- package/dist/src/scene/terrain/quadtree.js +0 -461
- package/dist/src/scene/terrain/quadtree.js.map +0 -1
- package/dist/src/scene/terrain/terrain.js +0 -246
- package/dist/src/scene/terrain/terrain.js.map +0 -1
- package/dist/src/scene/terrain-cm/grass.js +0 -594
- package/dist/src/scene/terrain-cm/grass.js.map +0 -1
- package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
- package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
- package/dist/src/scene/water.js +0 -374
- package/dist/src/scene/water.js.map +0 -1
- package/dist/src/shaders/atmosphere.js +0 -957
- package/dist/src/shaders/atmosphere.js.map +0 -1
- package/dist/src/shaders/fog.js +0 -112
- package/dist/src/shaders/fog.js.map +0 -1
- package/dist/src/shaders/misc.js +0 -266
- package/dist/src/shaders/misc.js.map +0 -1
- package/dist/src/shaders/noise.js +0 -222
- package/dist/src/shaders/noise.js.map +0 -1
- package/dist/src/shaders/pbr.js +0 -51
- package/dist/src/shaders/pbr.js.map +0 -1
- package/dist/src/shaders/shadow.js +0 -636
- package/dist/src/shaders/shadow.js.map +0 -1
- package/dist/src/shaders/ssr.js +0 -490
- package/dist/src/shaders/ssr.js.map +0 -1
- package/dist/src/shaders/temporal.js +0 -215
- package/dist/src/shaders/temporal.js.map +0 -1
- package/dist/src/shaders/water.js +0 -756
- package/dist/src/shaders/water.js.map +0 -1
- package/dist/src/shadow/esm.js +0 -237
- package/dist/src/shadow/esm.js.map +0 -1
- package/dist/src/shadow/pcf_opt.js +0 -181
- package/dist/src/shadow/pcf_opt.js.map +0 -1
- package/dist/src/shadow/pcf_pd.js +0 -189
- package/dist/src/shadow/pcf_pd.js.map +0 -1
- package/dist/src/shadow/shader.js +0 -37
- package/dist/src/shadow/shader.js.map +0 -1
- package/dist/src/shadow/shadow_impl.js +0 -15
- package/dist/src/shadow/shadow_impl.js.map +0 -1
- package/dist/src/shadow/shadowmapper.js +0 -790
- package/dist/src/shadow/shadowmapper.js.map +0 -1
- package/dist/src/shadow/ssm.js +0 -159
- package/dist/src/shadow/ssm.js.map +0 -1
- package/dist/src/shadow/vsm.js +0 -297
- package/dist/src/shadow/vsm.js.map +0 -1
- package/dist/src/shapes/box.js +0 -386
- package/dist/src/shapes/box.js.map +0 -1
- package/dist/src/shapes/cylinder.js +0 -125
- package/dist/src/shapes/cylinder.js.map +0 -1
- package/dist/src/shapes/plane.js +0 -88
- package/dist/src/shapes/plane.js.map +0 -1
- package/dist/src/shapes/shape.js +0 -87
- package/dist/src/shapes/shape.js.map +0 -1
- package/dist/src/shapes/sphere.js +0 -114
- package/dist/src/shapes/sphere.js.map +0 -1
- package/dist/src/shapes/tetrahedron.js +0 -188
- package/dist/src/shapes/tetrahedron.js.map +0 -1
- package/dist/src/shapes/torus.js +0 -111
- package/dist/src/shapes/torus.js.map +0 -1
- package/dist/src/utility/aabbtree.js +0 -400
- package/dist/src/utility/aabbtree.js.map +0 -1
- package/dist/src/utility/bounding_volume.js +0 -29
- package/dist/src/utility/bounding_volume.js.map +0 -1
- package/dist/src/utility/debug.js +0 -28
- package/dist/src/utility/debug.js.map +0 -1
- package/dist/src/utility/draco/decoder.js +0 -116
- package/dist/src/utility/draco/decoder.js.map +0 -1
- package/dist/src/utility/misc.js +0 -105
- package/dist/src/utility/misc.js.map +0 -1
- package/dist/src/utility/panorama.js +0 -163
- package/dist/src/utility/panorama.js.map +0 -1
- package/dist/src/utility/pmrem.js +0 -354
- package/dist/src/utility/pmrem.js.map +0 -1
- package/dist/src/utility/rendermipmap.js +0 -115
- package/dist/src/utility/rendermipmap.js.map +0 -1
- package/dist/src/utility/serialization/json.js +0 -402
- package/dist/src/utility/serialization/json.js.map +0 -1
- package/dist/src/utility/serialization/manager.js +0 -623
- package/dist/src/utility/serialization/manager.js.map +0 -1
- package/dist/src/utility/serialization/scene/animation.js +0 -248
- package/dist/src/utility/serialization/scene/animation.js.map +0 -1
- package/dist/src/utility/serialization/scene/batch.js +0 -59
- package/dist/src/utility/serialization/scene/batch.js.map +0 -1
- package/dist/src/utility/serialization/scene/camera.js +0 -790
- package/dist/src/utility/serialization/scene/camera.js.map +0 -1
- package/dist/src/utility/serialization/scene/common.js +0 -222
- package/dist/src/utility/serialization/scene/common.js.map +0 -1
- package/dist/src/utility/serialization/scene/light.js +0 -575
- package/dist/src/utility/serialization/scene/light.js.map +0 -1
- package/dist/src/utility/serialization/scene/material.js +0 -1111
- package/dist/src/utility/serialization/scene/material.js.map +0 -1
- package/dist/src/utility/serialization/scene/mesh.js +0 -148
- package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
- package/dist/src/utility/serialization/scene/misc.js +0 -39
- package/dist/src/utility/serialization/scene/misc.js.map +0 -1
- package/dist/src/utility/serialization/scene/node.js +0 -451
- package/dist/src/utility/serialization/scene/node.js.map +0 -1
- package/dist/src/utility/serialization/scene/particle.js +0 -425
- package/dist/src/utility/serialization/scene/particle.js.map +0 -1
- package/dist/src/utility/serialization/scene/primitive.js +0 -692
- package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
- package/dist/src/utility/serialization/scene/scene.js +0 -704
- package/dist/src/utility/serialization/scene/scene.js.map +0 -1
- package/dist/src/utility/serialization/scene/terrain.js +0 -488
- package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
- package/dist/src/utility/serialization/scene/water.js +0 -465
- package/dist/src/utility/serialization/scene/water.js.map +0 -1
- package/dist/src/utility/shprojector.js +0 -297
- package/dist/src/utility/shprojector.js.map +0 -1
- package/dist/src/utility/textures/ggxlut.js +0 -213
- package/dist/src/utility/textures/ggxlut.js.map +0 -1
- package/dist/src/utility/textures/gradientnoise.js +0 -62
- package/dist/src/utility/textures/gradientnoise.js.map +0 -1
- package/dist/src/utility/textures/randomnoise.js +0 -41
- package/dist/src/utility/textures/randomnoise.js.map +0 -1
- package/dist/src/values.js +0 -162
- package/dist/src/values.js.map +0 -1
- package/dist/utility/blueprint/material/common.js +0 -7
- package/dist/utility/blueprint/material/common.js.map +0 -1
- package/dist/utility/serialization/blueprint/constants.js +0 -255
- package/dist/utility/serialization/blueprint/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/constants.js +0 -203
- package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/texture.js +0 -165
- package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector3, Disposable, randomUUID, DRef,
|
|
1
|
+
import { Vector3, Disposable, randomUUID, DRef, Matrix4x4, DWeakRef, nextPowerOf2 } from '@zephyr3d/base';
|
|
2
2
|
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
3
|
import { getDevice } from '../app/api.js';
|
|
4
4
|
|
|
@@ -6,32 +6,33 @@ const tmpV0 = new Vector3();
|
|
|
6
6
|
const tmpV1 = new Vector3();
|
|
7
7
|
const tmpV2 = new Vector3();
|
|
8
8
|
const tmpV3 = new Vector3();
|
|
9
|
-
/**
|
|
10
|
-
* Skeleton for skinned animation.
|
|
11
|
-
*
|
|
12
|
-
* Responsibilities:
|
|
13
|
-
* - Maintains joint transforms: inverse bind, bind pose, and current skinning matrices.
|
|
14
|
-
* - Provides a texture containing joint matrices for GPU skinning.
|
|
15
|
-
* - Applies skinning state to associated meshes each frame.
|
|
16
|
-
* - Computes animated axis-aligned bounding boxes using representative skinned vertices.
|
|
17
|
-
*
|
|
18
|
-
* Joint matrix texture layout:
|
|
19
|
-
* - Texture format: `rgba32f`.
|
|
20
|
-
* - Stored as a 2-layered ring buffer: current and previous joint transforms to support
|
|
21
|
-
* temporal addressing if needed. Offsets are tracked in `_jointOffsets[0]` (current)
|
|
22
|
-
* and `_jointOffsets[1]` (previous).
|
|
23
|
-
*
|
|
24
|
-
* Usage:
|
|
25
|
-
* - Construct with joints, bind data, meshes and submesh bounding info.
|
|
26
|
-
* - Call `apply()` each frame to update joint texture, bind to meshes, and update bounds.
|
|
27
|
-
* - Call `reset()` to clear skinning on meshes.
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
9
|
+
/**
|
|
10
|
+
* Skeleton for skinned animation.
|
|
11
|
+
*
|
|
12
|
+
* Responsibilities:
|
|
13
|
+
* - Maintains joint transforms: inverse bind, bind pose, and current skinning matrices.
|
|
14
|
+
* - Provides a texture containing joint matrices for GPU skinning.
|
|
15
|
+
* - Applies skinning state to associated meshes each frame.
|
|
16
|
+
* - Computes animated axis-aligned bounding boxes using representative skinned vertices.
|
|
17
|
+
*
|
|
18
|
+
* Joint matrix texture layout:
|
|
19
|
+
* - Texture format: `rgba32f`.
|
|
20
|
+
* - Stored as a 2-layered ring buffer: current and previous joint transforms to support
|
|
21
|
+
* temporal addressing if needed. Offsets are tracked in `_jointOffsets[0]` (current)
|
|
22
|
+
* and `_jointOffsets[1]` (previous).
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* - Construct with joints, bind data, meshes and submesh bounding info.
|
|
26
|
+
* - Call `apply()` each frame to update joint texture, bind to meshes, and update bounds.
|
|
27
|
+
* - Call `reset()` to clear skinning on meshes.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
30
|
*/ class Skeleton extends Disposable {
|
|
31
31
|
/** @internal Global weak registry keyed by persistentId for serialization/lookup. */ static _registry = new Map();
|
|
32
32
|
/** @internal */ _id;
|
|
33
33
|
/** @internal */ _joints;
|
|
34
34
|
/** @internal */ _inverseBindMatrices;
|
|
35
|
+
/** @internal */ _bindPoseModelSpace;
|
|
35
36
|
/** @internal */ _bindPose;
|
|
36
37
|
/** @internal */ _jointMatrices;
|
|
37
38
|
/** @internal */ _jointOffsets;
|
|
@@ -40,12 +41,12 @@ const tmpV3 = new Vector3();
|
|
|
40
41
|
/** @internal */ _playing;
|
|
41
42
|
/** @internal */ _modifiers;
|
|
42
43
|
/** @internal */ _lastUpdateTime;
|
|
43
|
-
/**
|
|
44
|
-
* Create a skeleton instance.
|
|
45
|
-
*
|
|
46
|
-
* @param joints - Joint scene nodes (one per joint), ordered to match skin data.
|
|
47
|
-
* @param inverseBindMatrices - Inverse bind matrices for each joint.
|
|
48
|
-
* @param bindPoseMatrices - Bind pose matrices for each joint (model-space).
|
|
44
|
+
/**
|
|
45
|
+
* Create a skeleton instance.
|
|
46
|
+
*
|
|
47
|
+
* @param joints - Joint scene nodes (one per joint), ordered to match skin data.
|
|
48
|
+
* @param inverseBindMatrices - Inverse bind matrices for each joint.
|
|
49
|
+
* @param bindPoseMatrices - Bind pose matrices for each joint (model-space).
|
|
49
50
|
*/ constructor(joints, inverseBindMatrices, bindPose){
|
|
50
51
|
super();
|
|
51
52
|
this._id = randomUUID();
|
|
@@ -56,16 +57,29 @@ const tmpV3 = new Vector3();
|
|
|
56
57
|
this._playing = false;
|
|
57
58
|
this._modifiers = [];
|
|
58
59
|
this._lastUpdateTime = 0;
|
|
60
|
+
this._bindPoseModelSpace = [];
|
|
59
61
|
this.computeBindPose();
|
|
60
62
|
this.updateJointMatrices(0);
|
|
63
|
+
let skeletonRoot = this.findRootJoint(this._joints);
|
|
64
|
+
if (!skeletonRoot || !this._joints.includes(skeletonRoot)) {
|
|
65
|
+
throw new Error('Skeleton root must be included in the joint list');
|
|
66
|
+
}
|
|
67
|
+
while(skeletonRoot.parent && this._joints.includes(skeletonRoot.parent)){
|
|
68
|
+
skeletonRoot = skeletonRoot.parent;
|
|
69
|
+
}
|
|
70
|
+
const im = skeletonRoot.parent.invWorldMatrix;
|
|
71
|
+
for (const joint of this._joints){
|
|
72
|
+
const m = Matrix4x4.multiplyAffine(im, joint.worldMatrix);
|
|
73
|
+
this._bindPoseModelSpace.push(m);
|
|
74
|
+
}
|
|
61
75
|
Skeleton._registry.set(this._id, new DWeakRef(this));
|
|
62
76
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Lookup a skeleton from the global registry by persistent id.
|
|
65
|
-
*
|
|
66
|
-
* @param id - The persistent UUID to search for.
|
|
67
|
-
* @returns The skeleton if alive, otherwise `null`.
|
|
68
|
-
* @internal
|
|
77
|
+
/**
|
|
78
|
+
* Lookup a skeleton from the global registry by persistent id.
|
|
79
|
+
*
|
|
80
|
+
* @param id - The persistent UUID to search for.
|
|
81
|
+
* @returns The skeleton if alive, otherwise `null`.
|
|
82
|
+
* @internal
|
|
69
83
|
*/ static findSkeletonById(id) {
|
|
70
84
|
const m = this._registry.get(id);
|
|
71
85
|
if (m && !m.get()) {
|
|
@@ -83,6 +97,9 @@ const tmpV3 = new Vector3();
|
|
|
83
97
|
/** @internal */ get bindPose() {
|
|
84
98
|
return this._bindPose;
|
|
85
99
|
}
|
|
100
|
+
get bindPoseModelSpace() {
|
|
101
|
+
return this._bindPoseModelSpace;
|
|
102
|
+
}
|
|
86
103
|
/** @internal */ get playing() {
|
|
87
104
|
return this._playing;
|
|
88
105
|
}
|
|
@@ -103,42 +120,42 @@ const tmpV3 = new Vector3();
|
|
|
103
120
|
Skeleton._registry.set(this._id, m);
|
|
104
121
|
}
|
|
105
122
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Texture containing joint matrices for GPU skinning.
|
|
108
|
-
*
|
|
109
|
-
* Each matrix is stored in 4 texels (one row per texel, RGBA = 4 floats).
|
|
123
|
+
/**
|
|
124
|
+
* Texture containing joint matrices for GPU skinning.
|
|
125
|
+
*
|
|
126
|
+
* Each matrix is stored in 4 texels (one row per texel, RGBA = 4 floats).
|
|
110
127
|
*/ get jointTexture() {
|
|
111
128
|
return this._jointTexture.get();
|
|
112
129
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Get joint index by joint node
|
|
115
|
-
* @param joint - joint node
|
|
116
|
-
* @returns The index of the joint
|
|
130
|
+
/**
|
|
131
|
+
* Get joint index by joint node
|
|
132
|
+
* @param joint - joint node
|
|
133
|
+
* @returns The index of the joint
|
|
117
134
|
*/ getJointIndex(joint) {
|
|
118
135
|
return this._joints.indexOf(joint);
|
|
119
136
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Get joint index by joint name
|
|
122
|
-
* @param jointName - joint name
|
|
123
|
-
* @returns The index of the joint
|
|
137
|
+
/**
|
|
138
|
+
* Get joint index by joint name
|
|
139
|
+
* @param jointName - joint name
|
|
140
|
+
* @returns The index of the joint
|
|
124
141
|
*/ getJointIndexByName(jointName) {
|
|
125
142
|
return this._joints.findIndex((joint)=>joint.name === jointName);
|
|
126
143
|
}
|
|
127
|
-
/**
|
|
128
|
-
* Update joint matrices from either provided transforms or the joints' world matrices.
|
|
129
|
-
*
|
|
130
|
-
* - Lazily creates the joint texture and its backing arrays on first call.
|
|
131
|
-
* - Advances the ring buffer offset in `_jointOffsets` to write a new "current" set.
|
|
132
|
-
* - For each joint:
|
|
133
|
-
* - Optionally premultiplies by `worldMatrix` (to transform into model space).
|
|
134
|
-
* - Computes skinning matrix: ( M_\{skin\} = M_\{joint\} \\times M_\{inverseBind\} ).
|
|
135
|
-
*
|
|
136
|
-
* Note: This method only writes into the CPU-side array; callers like `computeJoints()`
|
|
137
|
-
* update the GPU texture.
|
|
138
|
-
*
|
|
139
|
-
* @param jointTransforms - Optional per-joint transforms to use instead of node world matrices.
|
|
140
|
-
* @param worldMatrix - Optional world-to-model transform applied before inverse bind.
|
|
141
|
-
* @internal
|
|
144
|
+
/**
|
|
145
|
+
* Update joint matrices from either provided transforms or the joints' world matrices.
|
|
146
|
+
*
|
|
147
|
+
* - Lazily creates the joint texture and its backing arrays on first call.
|
|
148
|
+
* - Advances the ring buffer offset in `_jointOffsets` to write a new "current" set.
|
|
149
|
+
* - For each joint:
|
|
150
|
+
* - Optionally premultiplies by `worldMatrix` (to transform into model space).
|
|
151
|
+
* - Computes skinning matrix: ( M_\{skin\} = M_\{joint\} \\times M_\{inverseBind\} ).
|
|
152
|
+
*
|
|
153
|
+
* Note: This method only writes into the CPU-side array; callers like `computeJoints()`
|
|
154
|
+
* update the GPU texture.
|
|
155
|
+
*
|
|
156
|
+
* @param jointTransforms - Optional per-joint transforms to use instead of node world matrices.
|
|
157
|
+
* @param worldMatrix - Optional world-to-model transform applied before inverse bind.
|
|
158
|
+
* @internal
|
|
142
159
|
*/ updateJointMatrices(deltaTime) {
|
|
143
160
|
this.applyModifiers(deltaTime);
|
|
144
161
|
if (!this._jointTexture.get()) {
|
|
@@ -155,10 +172,10 @@ const tmpV3 = new Vector3();
|
|
|
155
172
|
Matrix4x4.multiply(this._joints[i].worldMatrix, this._inverseBindMatrices[i], this._jointMatrices[i + this._jointOffsets[0] - 1]);
|
|
156
173
|
}
|
|
157
174
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Reset skeleton to bind pose
|
|
160
|
-
*
|
|
161
|
-
* @internal
|
|
175
|
+
/**
|
|
176
|
+
* Reset skeleton to bind pose
|
|
177
|
+
*
|
|
178
|
+
* @internal
|
|
162
179
|
*/ computeBindPose() {
|
|
163
180
|
for(let i = 0; i < this._joints.length; i++){
|
|
164
181
|
const joint = this._joints[i];
|
|
@@ -168,54 +185,54 @@ const tmpV3 = new Vector3();
|
|
|
168
185
|
joint.scale.set(bindpose.scale);
|
|
169
186
|
}
|
|
170
187
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Compute current joint matrices from the nodes and upload them to the joint texture.
|
|
173
|
-
*
|
|
174
|
-
* @internal
|
|
188
|
+
/**
|
|
189
|
+
* Compute current joint matrices from the nodes and upload them to the joint texture.
|
|
190
|
+
*
|
|
191
|
+
* @internal
|
|
175
192
|
*/ apply(deltaTime) {
|
|
176
193
|
this.updateJointMatrices(deltaTime);
|
|
177
194
|
const tex = this.jointTexture;
|
|
178
195
|
tex.update(this._jointMatrixArray, 0, 0, tex.width, tex.height);
|
|
179
196
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Apply all enabled modifiers.
|
|
182
|
-
*
|
|
183
|
-
* Modifiers are applied after the base animation/bind pose layer,
|
|
184
|
-
* allowing procedural modifications like IK, spring physics, or manual overrides.
|
|
185
|
-
*
|
|
186
|
-
* @param deltaTime - Time elapsed since last frame (in seconds)
|
|
187
|
-
* @internal
|
|
197
|
+
/**
|
|
198
|
+
* Apply all enabled modifiers.
|
|
199
|
+
*
|
|
200
|
+
* Modifiers are applied after the base animation/bind pose layer,
|
|
201
|
+
* allowing procedural modifications like IK, spring physics, or manual overrides.
|
|
202
|
+
*
|
|
203
|
+
* @param deltaTime - Time elapsed since last frame (in seconds)
|
|
204
|
+
* @internal
|
|
188
205
|
*/ applyModifiers(deltaTime) {
|
|
189
206
|
for (const modifier of this._modifiers){
|
|
190
207
|
modifier.apply(this, deltaTime);
|
|
191
208
|
}
|
|
192
209
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Get all modifiers attached to this skeleton.
|
|
195
|
-
*
|
|
196
|
-
* @public
|
|
210
|
+
/**
|
|
211
|
+
* Get all modifiers attached to this skeleton.
|
|
212
|
+
*
|
|
213
|
+
* @public
|
|
197
214
|
*/ get modifiers() {
|
|
198
215
|
return this._modifiers;
|
|
199
216
|
}
|
|
200
|
-
/**
|
|
201
|
-
* Reset all meshes to an unskinned state and clear animated bounds.
|
|
202
|
-
*
|
|
203
|
-
* @internal
|
|
217
|
+
/**
|
|
218
|
+
* Reset all meshes to an unskinned state and clear animated bounds.
|
|
219
|
+
*
|
|
220
|
+
* @internal
|
|
204
221
|
*/ reset() {
|
|
205
222
|
//this.updateJointMatrices(this._bindPoseMatrices);
|
|
206
223
|
this._playing = false;
|
|
207
224
|
}
|
|
208
|
-
/**
|
|
209
|
-
* Compute the animated bounding box for a single mesh using its representative vertices.
|
|
210
|
-
*
|
|
211
|
-
* For each representative vertex:
|
|
212
|
-
* - Blends the vertex by up to 4 joint matrices using provided weights.
|
|
213
|
-
* - Transforms to the mesh's local space using `invWorldMatrix`.
|
|
214
|
-
* - Expands the bounding box.
|
|
215
|
-
*
|
|
216
|
-
* @param info - Precomputed bounding data (representative vertices, indices, weights).
|
|
217
|
-
* @param invWorldMatrix - Mesh inverse world matrix to convert to model/local space.
|
|
218
|
-
* @internal
|
|
225
|
+
/**
|
|
226
|
+
* Compute the animated bounding box for a single mesh using its representative vertices.
|
|
227
|
+
*
|
|
228
|
+
* For each representative vertex:
|
|
229
|
+
* - Blends the vertex by up to 4 joint matrices using provided weights.
|
|
230
|
+
* - Transforms to the mesh's local space using `invWorldMatrix`.
|
|
231
|
+
* - Expands the bounding box.
|
|
232
|
+
*
|
|
233
|
+
* @param info - Precomputed bounding data (representative vertices, indices, weights).
|
|
234
|
+
* @param invWorldMatrix - Mesh inverse world matrix to convert to model/local space.
|
|
235
|
+
* @internal
|
|
219
236
|
*/ computeBoundingBox(info, invWorldMatrix) {
|
|
220
237
|
info.boundingBox.beginExtend();
|
|
221
238
|
for(let i = 0; i < info.boundingVertices.length; i++){
|
|
@@ -228,11 +245,11 @@ const tmpV3 = new Vector3();
|
|
|
228
245
|
info.boundingBox.extend(tmpV0);
|
|
229
246
|
}
|
|
230
247
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Dispose GPU resources and references held by the skeleton.
|
|
233
|
-
*
|
|
234
|
-
* - Disposes the joint texture.
|
|
235
|
-
* - Clears matrix arrays and joint references.
|
|
248
|
+
/**
|
|
249
|
+
* Dispose GPU resources and references held by the skeleton.
|
|
250
|
+
*
|
|
251
|
+
* - Disposes the joint texture.
|
|
252
|
+
* - Clears matrix arrays and joint references.
|
|
236
253
|
*/ onDispose() {
|
|
237
254
|
super.onDispose();
|
|
238
255
|
this._jointTexture.dispose();
|
|
@@ -242,17 +259,17 @@ const tmpV3 = new Vector3();
|
|
|
242
259
|
m.dispose();
|
|
243
260
|
}
|
|
244
261
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Initialize joint texture and CPU-side matrix storage.
|
|
247
|
-
*
|
|
248
|
-
* Layout details:
|
|
249
|
-
* - Texture size is the next power-of-two able to contain all matrices plus two offset texels.
|
|
250
|
-
* - `_jointMatrixArray` holds:
|
|
251
|
-
* - First 2 vec4s: ring buffer offsets `[current, previous, 0, 0]`.
|
|
252
|
-
* - Followed by 2×N matrices (current and previous), each as 16 floats.
|
|
253
|
-
* - `_jointMatrices` is a view into `_jointMatrixArray` providing Matrix4x4 objects per slot.
|
|
254
|
-
*
|
|
255
|
-
* @internal
|
|
262
|
+
/**
|
|
263
|
+
* Initialize joint texture and CPU-side matrix storage.
|
|
264
|
+
*
|
|
265
|
+
* Layout details:
|
|
266
|
+
* - Texture size is the next power-of-two able to contain all matrices plus two offset texels.
|
|
267
|
+
* - `_jointMatrixArray` holds:
|
|
268
|
+
* - First 2 vec4s: ring buffer offsets `[current, previous, 0, 0]`.
|
|
269
|
+
* - Followed by 2×N matrices (current and previous), each as 16 floats.
|
|
270
|
+
* - `_jointMatrices` is a view into `_jointMatrixArray` providing Matrix4x4 objects per slot.
|
|
271
|
+
*
|
|
272
|
+
* @internal
|
|
256
273
|
*/ _createJointTexture() {
|
|
257
274
|
const textureWidth = nextPowerOf2(Math.max(4, Math.ceil(Math.sqrt((this._joints.length * 2 + 1) * 4))));
|
|
258
275
|
const device = getDevice();
|
|
@@ -272,19 +289,19 @@ const tmpV3 = new Vector3();
|
|
|
272
289
|
length: this._joints.length * 2
|
|
273
290
|
}).map((val, index)=>new Matrix4x4(buffer, (index + 1) * 16 * Float32Array.BYTES_PER_ELEMENT));
|
|
274
291
|
}
|
|
275
|
-
/**
|
|
276
|
-
* Build representative skinned bounding data for a submesh.
|
|
277
|
-
*
|
|
278
|
-
* Strategy:
|
|
279
|
-
* - For all vertices, compute their skinned position (using current ring buffer slot).
|
|
280
|
-
* - Track the indices of the min/max extents along x, y, z (6 indices total).
|
|
281
|
-
* - Store:
|
|
282
|
-
* - The 6 representative positions in object space.
|
|
283
|
-
* - Their 4 joint indices and weights (flattened).
|
|
284
|
-
* - An empty BoundingBox to be filled during animation.
|
|
285
|
-
*
|
|
286
|
-
* @param meshData - Raw submesh attributes (positions, blend indices, weights).
|
|
287
|
-
* @returns Skinned bounding box info used during per-frame updates.
|
|
292
|
+
/**
|
|
293
|
+
* Build representative skinned bounding data for a submesh.
|
|
294
|
+
*
|
|
295
|
+
* Strategy:
|
|
296
|
+
* - For all vertices, compute their skinned position (using current ring buffer slot).
|
|
297
|
+
* - Track the indices of the min/max extents along x, y, z (6 indices total).
|
|
298
|
+
* - Store:
|
|
299
|
+
* - The 6 representative positions in object space.
|
|
300
|
+
* - Their 4 joint indices and weights (flattened).
|
|
301
|
+
* - An empty BoundingBox to be filled during animation.
|
|
302
|
+
*
|
|
303
|
+
* @param meshData - Raw submesh attributes (positions, blend indices, weights).
|
|
304
|
+
* @returns Skinned bounding box info used during per-frame updates.
|
|
288
305
|
*/ getBoundingInfo(data) {
|
|
289
306
|
const indices = [
|
|
290
307
|
0,
|
|
@@ -353,6 +370,21 @@ const tmpV3 = new Vector3();
|
|
|
353
370
|
};
|
|
354
371
|
return info;
|
|
355
372
|
}
|
|
373
|
+
findRootJoint(joints) {
|
|
374
|
+
let root = null;
|
|
375
|
+
for (const joint of joints){
|
|
376
|
+
if (!root) {
|
|
377
|
+
root = joint;
|
|
378
|
+
}
|
|
379
|
+
while(!root.isParentOf(joint)){
|
|
380
|
+
root = root.parent;
|
|
381
|
+
}
|
|
382
|
+
if (!root) {
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return root;
|
|
387
|
+
}
|
|
356
388
|
}
|
|
357
389
|
|
|
358
390
|
export { Skeleton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.js","sources":["../../src/animation/skeleton.ts"],"sourcesContent":["import { DRef, randomUUID, DWeakRef } from '@zephyr3d/base';\r\nimport type { Quaternion, TypedArray } from '@zephyr3d/base';\r\nimport { Disposable, Matrix4x4, Vector3, nextPowerOf2 } from '@zephyr3d/base';\r\nimport type { Texture2D } from '@zephyr3d/device';\r\nimport type { SceneNode } from '../scene/scene_node';\r\nimport { BoundingBox } from '../utility/bounding_volume';\r\nimport { getDevice } from '../app/api';\r\nimport type { SkeletonModifier } from './skeleton_modifier';\r\n\r\n/**\r\n * Skinned bounding box information for a submesh.\r\n *\r\n * Used to compute animated AABB for skinned meshes.\r\n *\r\n * @public\r\n */\r\nexport interface SkinnedBoundingBox {\r\n /**\r\n * Representative vertices used to bound a skinned mesh (extreme points along axes).\r\n */\r\n boundingVertices: Vector3[];\r\n /**\r\n * Joint indices (up to 4 per vertex) for each representative vertex, flattened.\r\n * Layout: [i0_0, i0_1, i0_2, i0_3, i1_0, ...] for 6 vertices.\r\n */\r\n boundingVertexBlendIndices: Float32Array;\r\n /**\r\n * Corresponding joint weights (up to 4 per vertex) for each representative vertex, flattened.\r\n * Layout matches `boundingVertexBlendIndices`.\r\n */\r\n boundingVertexJointWeights: Float32Array;\r\n /**\r\n * Computed axis-aligned bounding box in model space for the current pose.\r\n */\r\n boundingBox: BoundingBox;\r\n}\r\n\r\nconst tmpV0 = new Vector3();\r\nconst tmpV1 = new Vector3();\r\nconst tmpV2 = new Vector3();\r\nconst tmpV3 = new Vector3();\r\n\r\n/**\r\n * Skeleton for skinned animation.\r\n *\r\n * Responsibilities:\r\n * - Maintains joint transforms: inverse bind, bind pose, and current skinning matrices.\r\n * - Provides a texture containing joint matrices for GPU skinning.\r\n * - Applies skinning state to associated meshes each frame.\r\n * - Computes animated axis-aligned bounding boxes using representative skinned vertices.\r\n *\r\n * Joint matrix texture layout:\r\n * - Texture format: `rgba32f`.\r\n * - Stored as a 2-layered ring buffer: current and previous joint transforms to support\r\n * temporal addressing if needed. Offsets are tracked in `_jointOffsets[0]` (current)\r\n * and `_jointOffsets[1]` (previous).\r\n *\r\n * Usage:\r\n * - Construct with joints, bind data, meshes and submesh bounding info.\r\n * - Call `apply()` each frame to update joint texture, bind to meshes, and update bounds.\r\n * - Call `reset()` to clear skinning on meshes.\r\n *\r\n * @public\r\n */\r\nexport class Skeleton extends Disposable {\r\n /** @internal Global weak registry keyed by persistentId for serialization/lookup. */\r\n private static readonly _registry: Map<string, DWeakRef<Skeleton>> = new Map();\r\n /** @internal */\r\n protected _id: string;\r\n /** @internal */\r\n protected _joints: SceneNode[];\r\n /** @internal */\r\n protected _inverseBindMatrices: Matrix4x4[];\r\n /** @internal */\r\n protected _bindPose: { rotation: Quaternion; scale: Vector3; position: Vector3 }[];\r\n /** @internal */\r\n protected _jointMatrices!: Matrix4x4[];\r\n /** @internal */\r\n protected _jointOffsets!: Float32Array<ArrayBuffer>;\r\n /** @internal */\r\n protected _jointMatrixArray!: Float32Array<ArrayBuffer>;\r\n /** @internal */\r\n protected _jointTexture: DRef<Texture2D>;\r\n /** @internal */\r\n protected _playing: boolean;\r\n /** @internal */\r\n protected _modifiers: SkeletonModifier[];\r\n /** @internal */\r\n protected _lastUpdateTime: number;\r\n /**\r\n * Create a skeleton instance.\r\n *\r\n * @param joints - Joint scene nodes (one per joint), ordered to match skin data.\r\n * @param inverseBindMatrices - Inverse bind matrices for each joint.\r\n * @param bindPoseMatrices - Bind pose matrices for each joint (model-space).\r\n */\r\n constructor(\r\n joints: SceneNode[],\r\n inverseBindMatrices: Matrix4x4[],\r\n bindPose: { rotation: Quaternion; scale: Vector3; position: Vector3 }[]\r\n ) {\r\n super();\r\n this._id = randomUUID();\r\n this._joints = joints;\r\n this._inverseBindMatrices = inverseBindMatrices;\r\n this._bindPose = bindPose;\r\n this._jointTexture = new DRef();\r\n this._playing = false;\r\n this._modifiers = [];\r\n this._lastUpdateTime = 0;\r\n this.computeBindPose();\r\n this.updateJointMatrices(0);\r\n Skeleton._registry.set(this._id, new DWeakRef(this));\r\n }\r\n /**\r\n * Lookup a skeleton from the global registry by persistent id.\r\n *\r\n * @param id - The persistent UUID to search for.\r\n * @returns The skeleton if alive, otherwise `null`.\r\n * @internal\r\n */\r\n static findSkeletonById(id: string) {\r\n const m = this._registry.get(id);\r\n if (m && !m.get()) {\r\n this._registry.delete(id);\r\n return null;\r\n }\r\n return m ? m.get() : null;\r\n }\r\n /** @internal */\r\n get joints() {\r\n return this._joints;\r\n }\r\n /** @internal */\r\n get inverseBindMatrices() {\r\n return this._inverseBindMatrices;\r\n }\r\n /** @internal */\r\n get bindPose() {\r\n return this._bindPose;\r\n }\r\n /** @internal */\r\n get playing() {\r\n return this._playing;\r\n }\r\n set playing(b: boolean) {\r\n this._playing = b;\r\n }\r\n /** @internal */\r\n get persistentId() {\r\n return this._id;\r\n }\r\n set persistentId(val) {\r\n if (val !== this._id) {\r\n const m = Skeleton._registry.get(this._id);\r\n if (!m || m.get() !== this) {\r\n throw new Error('Registry skeleton mismatch');\r\n }\r\n Skeleton._registry.delete(this._id);\r\n this._id = val;\r\n Skeleton._registry.set(this._id, m);\r\n }\r\n }\r\n /**\r\n * Texture containing joint matrices for GPU skinning.\r\n *\r\n * Each matrix is stored in 4 texels (one row per texel, RGBA = 4 floats).\r\n */\r\n get jointTexture() {\r\n return this._jointTexture.get()!;\r\n }\r\n /**\r\n * Get joint index by joint node\r\n * @param joint - joint node\r\n * @returns The index of the joint\r\n */\r\n getJointIndex(joint: SceneNode) {\r\n return this._joints.indexOf(joint);\r\n }\r\n /**\r\n * Get joint index by joint name\r\n * @param jointName - joint name\r\n * @returns The index of the joint\r\n */\r\n getJointIndexByName(jointName: string) {\r\n return this._joints.findIndex((joint) => joint.name === jointName);\r\n }\r\n /**\r\n * Update joint matrices from either provided transforms or the joints' world matrices.\r\n *\r\n * - Lazily creates the joint texture and its backing arrays on first call.\r\n * - Advances the ring buffer offset in `_jointOffsets` to write a new \"current\" set.\r\n * - For each joint:\r\n * - Optionally premultiplies by `worldMatrix` (to transform into model space).\r\n * - Computes skinning matrix: ( M_\\{skin\\} = M_\\{joint\\} \\\\times M_\\{inverseBind\\} ).\r\n *\r\n * Note: This method only writes into the CPU-side array; callers like `computeJoints()`\r\n * update the GPU texture.\r\n *\r\n * @param jointTransforms - Optional per-joint transforms to use instead of node world matrices.\r\n * @param worldMatrix - Optional world-to-model transform applied before inverse bind.\r\n * @internal\r\n */\r\n updateJointMatrices(deltaTime: number) {\r\n this.applyModifiers(deltaTime);\r\n if (!this._jointTexture.get()) {\r\n this._createJointTexture();\r\n }\r\n if (this._jointOffsets[0] === 0) {\r\n this._jointOffsets[0] = 1;\r\n this._jointOffsets[1] = 1;\r\n } else {\r\n this._jointOffsets[1] = this._jointOffsets[0];\r\n this._jointOffsets[0] = this._joints.length - this._jointOffsets[0] + 2;\r\n }\r\n for (let i = 0; i < this._joints.length; i++) {\r\n Matrix4x4.multiply(\r\n this._joints[i].worldMatrix,\r\n this._inverseBindMatrices[i],\r\n this._jointMatrices[i + this._jointOffsets[0] - 1]\r\n );\r\n }\r\n }\r\n /**\r\n * Reset skeleton to bind pose\r\n *\r\n * @internal\r\n */\r\n computeBindPose() {\r\n for (let i = 0; i < this._joints.length; i++) {\r\n const joint = this._joints[i];\r\n const bindpose = this._bindPose[i];\r\n joint.position.set(bindpose.position);\r\n joint.rotation.set(bindpose.rotation);\r\n joint.scale.set(bindpose.scale);\r\n }\r\n }\r\n /**\r\n * Compute current joint matrices from the nodes and upload them to the joint texture.\r\n *\r\n * @internal\r\n */\r\n apply(deltaTime: number) {\r\n this.updateJointMatrices(deltaTime);\r\n const tex = this.jointTexture;\r\n tex.update(this._jointMatrixArray, 0, 0, tex.width, tex.height);\r\n }\r\n /**\r\n * Apply all enabled modifiers.\r\n *\r\n * Modifiers are applied after the base animation/bind pose layer,\r\n * allowing procedural modifications like IK, spring physics, or manual overrides.\r\n *\r\n * @param deltaTime - Time elapsed since last frame (in seconds)\r\n * @internal\r\n */\r\n protected applyModifiers(deltaTime: number): void {\r\n for (const modifier of this._modifiers) {\r\n modifier.apply(this, deltaTime);\r\n }\r\n }\r\n /**\r\n * Get all modifiers attached to this skeleton.\r\n *\r\n * @public\r\n */\r\n get modifiers(): SkeletonModifier[] {\r\n return this._modifiers;\r\n }\r\n /**\r\n * Reset all meshes to an unskinned state and clear animated bounds.\r\n *\r\n * @internal\r\n */\r\n reset() {\r\n //this.updateJointMatrices(this._bindPoseMatrices);\r\n this._playing = false;\r\n }\r\n /**\r\n * Compute the animated bounding box for a single mesh using its representative vertices.\r\n *\r\n * For each representative vertex:\r\n * - Blends the vertex by up to 4 joint matrices using provided weights.\r\n * - Transforms to the mesh's local space using `invWorldMatrix`.\r\n * - Expands the bounding box.\r\n *\r\n * @param info - Precomputed bounding data (representative vertices, indices, weights).\r\n * @param invWorldMatrix - Mesh inverse world matrix to convert to model/local space.\r\n * @internal\r\n */\r\n computeBoundingBox(info: SkinnedBoundingBox, invWorldMatrix: Matrix4x4) {\r\n info.boundingBox.beginExtend();\r\n for (let i = 0; i < info.boundingVertices.length; i++) {\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV0)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 0]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV1)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 1]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV2)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 2]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV3)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 3]);\r\n tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);\r\n invWorldMatrix.transformPointAffine(tmpV0, tmpV0);\r\n info.boundingBox.extend(tmpV0);\r\n }\r\n }\r\n /**\r\n * Dispose GPU resources and references held by the skeleton.\r\n *\r\n * - Disposes the joint texture.\r\n * - Clears matrix arrays and joint references.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._jointTexture.dispose();\r\n const m = Skeleton._registry.get(this._id);\r\n if (m?.get() === this) {\r\n Skeleton._registry.delete(this._id);\r\n m.dispose();\r\n }\r\n }\r\n /**\r\n * Initialize joint texture and CPU-side matrix storage.\r\n *\r\n * Layout details:\r\n * - Texture size is the next power-of-two able to contain all matrices plus two offset texels.\r\n * - `_jointMatrixArray` holds:\r\n * - First 2 vec4s: ring buffer offsets `[current, previous, 0, 0]`.\r\n * - Followed by 2×N matrices (current and previous), each as 16 floats.\r\n * - `_jointMatrices` is a view into `_jointMatrixArray` providing Matrix4x4 objects per slot.\r\n *\r\n * @internal\r\n */\r\n private _createJointTexture() {\r\n const textureWidth = nextPowerOf2(Math.max(4, Math.ceil(Math.sqrt((this._joints.length * 2 + 1) * 4))));\r\n const device = getDevice();\r\n this._jointTexture.set(\r\n device.createTexture2D('rgba32f', textureWidth, textureWidth, {\r\n mipmapping: false,\r\n samplerOptions: {\r\n magFilter: 'nearest',\r\n minFilter: 'nearest'\r\n }\r\n })\r\n );\r\n this._jointMatrixArray = new Float32Array(textureWidth * textureWidth * 4);\r\n const buffer = this._jointMatrixArray.buffer;\r\n this._jointOffsets = new Float32Array(buffer);\r\n this._jointOffsets[0] = 0;\r\n this._jointOffsets[1] = 0;\r\n this._jointMatrices = Array.from({ length: this._joints.length * 2 }).map(\r\n (val, index) => new Matrix4x4(buffer, (index + 1) * 16 * Float32Array.BYTES_PER_ELEMENT)\r\n );\r\n }\r\n /**\r\n * Build representative skinned bounding data for a submesh.\r\n *\r\n * Strategy:\r\n * - For all vertices, compute their skinned position (using current ring buffer slot).\r\n * - Track the indices of the min/max extents along x, y, z (6 indices total).\r\n * - Store:\r\n * - The 6 representative positions in object space.\r\n * - Their 4 joint indices and weights (flattened).\r\n * - An empty BoundingBox to be filled during animation.\r\n *\r\n * @param meshData - Raw submesh attributes (positions, blend indices, weights).\r\n * @returns Skinned bounding box info used during per-frame updates.\r\n */\r\n getBoundingInfo(data: { positions: Float32Array; blendIndices: TypedArray; weights: TypedArray }) {\r\n const indices = [0, 0, 0, 0, 0, 0];\r\n let minx = Number.MAX_VALUE;\r\n let maxx = -Number.MAX_VALUE;\r\n let miny = Number.MAX_VALUE;\r\n let maxy = -Number.MAX_VALUE;\r\n let minz = Number.MAX_VALUE;\r\n let maxz = -Number.MAX_VALUE;\r\n const v = data.positions;\r\n const vert = new Vector3();\r\n const tmpV0 = new Vector3();\r\n const tmpV1 = new Vector3();\r\n const tmpV2 = new Vector3();\r\n const tmpV3 = new Vector3();\r\n const numVertices = Math.floor(v.length / 3);\r\n for (let i = 0; i < numVertices; i++) {\r\n vert.setXYZ(v[i * 3], v[i * 3 + 1], v[i * 3 + 2]);\r\n this._jointMatrices[data.blendIndices[i * 4 + 0] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV0)\r\n .scaleBy(data.weights[i * 4 + 0]);\r\n this._jointMatrices[data.blendIndices[i * 4 + 1] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV1)\r\n .scaleBy(data.weights[i * 4 + 1]);\r\n this._jointMatrices[data.blendIndices[i * 4 + 2] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV2)\r\n .scaleBy(data.weights[i * 4 + 2]);\r\n this._jointMatrices[data.blendIndices[i * 4 + 3] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV3)\r\n .scaleBy(data.weights[i * 4 + 3]);\r\n tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);\r\n if (tmpV0.x < minx) {\r\n minx = tmpV0.x;\r\n indices[0] = i;\r\n }\r\n if (tmpV0.x > maxx) {\r\n maxx = tmpV0.x;\r\n indices[1] = i;\r\n }\r\n if (tmpV0.y < miny) {\r\n miny = tmpV0.y;\r\n indices[2] = i;\r\n }\r\n if (tmpV0.y > maxy) {\r\n maxy = tmpV0.y;\r\n indices[3] = i;\r\n }\r\n if (tmpV0.z < minz) {\r\n minz = tmpV0.z;\r\n indices[4] = i;\r\n }\r\n if (tmpV0.z > maxz) {\r\n maxz = tmpV0.z;\r\n indices[5] = i;\r\n }\r\n }\r\n const info: SkinnedBoundingBox = {\r\n boundingVertexBlendIndices: new Float32Array(\r\n Array.from({ length: 6 * 4 }).map(\r\n (val, index) => data.blendIndices[indices[index >> 2] * 4 + (index % 4)]\r\n )\r\n ),\r\n boundingVertexJointWeights: new Float32Array(\r\n Array.from({ length: 6 * 4 }).map((val, index) => data.weights[indices[index >> 2] * 4 + (index % 4)])\r\n ),\r\n boundingVertices: Array.from({ length: 6 }).map(\r\n (val, index) =>\r\n new Vector3(\r\n data.positions[indices[index] * 3],\r\n data.positions[indices[index] * 3 + 1],\r\n data.positions[indices[index] * 3 + 2]\r\n )\r\n ),\r\n boundingBox: new BoundingBox()\r\n };\r\n return info;\r\n }\r\n}\r\n"],"names":["tmpV0","Vector3","tmpV1","tmpV2","tmpV3","Skeleton","Disposable","_registry","Map","joints","inverseBindMatrices","bindPose","_id","randomUUID","_joints","_inverseBindMatrices","_bindPose","_jointTexture","DRef","_playing","_modifiers","_lastUpdateTime","computeBindPose","updateJointMatrices","set","DWeakRef","findSkeletonById","id","m","get","delete","playing","b","persistentId","val","Error","jointTexture","getJointIndex","joint","indexOf","getJointIndexByName","jointName","findIndex","name","deltaTime","applyModifiers","_createJointTexture","_jointOffsets","length","i","Matrix4x4","multiply","worldMatrix","_jointMatrices","bindpose","position","rotation","scale","apply","tex","update","_jointMatrixArray","width","height","modifier","modifiers","reset","computeBoundingBox","info","invWorldMatrix","boundingBox","beginExtend","boundingVertices","boundingVertexBlendIndices","transformPointAffine","scaleBy","boundingVertexJointWeights","addBy","extend","onDispose","dispose","textureWidth","nextPowerOf2","Math","max","ceil","sqrt","device","getDevice","createTexture2D","mipmapping","samplerOptions","magFilter","minFilter","Float32Array","buffer","Array","from","map","index","BYTES_PER_ELEMENT","getBoundingInfo","data","indices","minx","Number","MAX_VALUE","maxx","miny","maxy","minz","maxz","v","positions","vert","numVertices","floor","setXYZ","blendIndices","weights","x","y","z","BoundingBox"],"mappings":";;;;AAqCA,MAAMA,QAAQ,IAAIC,OAAAA,EAAAA;AAClB,MAAMC,QAAQ,IAAID,OAAAA,EAAAA;AAClB,MAAME,QAAQ,IAAIF,OAAAA,EAAAA;AAClB,MAAMG,QAAQ,IAAIH,OAAAA,EAAAA;AAElB;;;;;;;;;;;;;;;;;;;;;IAsBO,MAAMI,QAAiBC,SAAAA,UAAAA,CAAAA;AAC5B,0FACA,OAAwBC,SAA6C,GAAA,IAAIC,GAAM,EAAA;qBAE/E,GAAsB;qBAEtB,OAA+B;qBAE/B,oBAA4C;qBAE5C,SA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,GAAAA,EAAKiE,QACJ,IAAIlG,OAAAA,CACFqG,IAAKW,CAAAA,SAAS,CAACV,OAAO,CAACJ,KAAM,CAAA,GAAG,EAAE,EAClCG,IAAAA,CAAKW,SAAS,CAACV,OAAO,CAACJ,KAAM,CAAA,GAAG,IAAI,CAAE,CAAA,EACtCG,IAAKW,CAAAA,SAAS,CAACV,OAAO,CAACJ,KAAM,CAAA,GAAG,IAAI,CAAE,CAAA,CAAA,CAAA;AAG5C7B,YAAAA,WAAAA,EAAa,IAAIqD,WAAAA;AACnB,SAAA;QACA,OAAOvD,IAAAA;AACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"skeleton.js","sources":["../../src/animation/skeleton.ts"],"sourcesContent":["import { DRef, randomUUID, DWeakRef } from '@zephyr3d/base';\nimport type { Nullable, Quaternion, TypedArray } from '@zephyr3d/base';\nimport { Disposable, Matrix4x4, Vector3, nextPowerOf2 } from '@zephyr3d/base';\nimport type { Texture2D } from '@zephyr3d/device';\nimport type { SceneNode } from '../scene/scene_node';\nimport { BoundingBox } from '../utility/bounding_volume';\nimport { getDevice } from '../app/api';\nimport type { SkeletonModifier } from './skeleton_modifier';\n\n/**\n * Skinned bounding box information for a submesh.\n *\n * Used to compute animated AABB for skinned meshes.\n *\n * @public\n */\nexport interface SkinnedBoundingBox {\n /**\n * Representative vertices used to bound a skinned mesh (extreme points along axes).\n */\n boundingVertices: Vector3[];\n /**\n * Joint indices (up to 4 per vertex) for each representative vertex, flattened.\n * Layout: [i0_0, i0_1, i0_2, i0_3, i1_0, ...] for 6 vertices.\n */\n boundingVertexBlendIndices: Float32Array;\n /**\n * Corresponding joint weights (up to 4 per vertex) for each representative vertex, flattened.\n * Layout matches `boundingVertexBlendIndices`.\n */\n boundingVertexJointWeights: Float32Array;\n /**\n * Computed axis-aligned bounding box in model space for the current pose.\n */\n boundingBox: BoundingBox;\n}\n\nconst tmpV0 = new Vector3();\nconst tmpV1 = new Vector3();\nconst tmpV2 = new Vector3();\nconst tmpV3 = new Vector3();\n\n/**\n * Skeleton for skinned animation.\n *\n * Responsibilities:\n * - Maintains joint transforms: inverse bind, bind pose, and current skinning matrices.\n * - Provides a texture containing joint matrices for GPU skinning.\n * - Applies skinning state to associated meshes each frame.\n * - Computes animated axis-aligned bounding boxes using representative skinned vertices.\n *\n * Joint matrix texture layout:\n * - Texture format: `rgba32f`.\n * - Stored as a 2-layered ring buffer: current and previous joint transforms to support\n * temporal addressing if needed. Offsets are tracked in `_jointOffsets[0]` (current)\n * and `_jointOffsets[1]` (previous).\n *\n * Usage:\n * - Construct with joints, bind data, meshes and submesh bounding info.\n * - Call `apply()` each frame to update joint texture, bind to meshes, and update bounds.\n * - Call `reset()` to clear skinning on meshes.\n *\n * @public\n */\nexport class Skeleton extends Disposable {\n /** @internal Global weak registry keyed by persistentId for serialization/lookup. */\n private static readonly _registry: Map<string, DWeakRef<Skeleton>> = new Map();\n /** @internal */\n protected _id: string;\n /** @internal */\n protected _joints: SceneNode[];\n /** @internal */\n protected _inverseBindMatrices: Matrix4x4[];\n /** @internal */\n protected _bindPoseModelSpace: Matrix4x4[];\n /** @internal */\n protected _bindPose: { rotation: Quaternion; scale: Vector3; position: Vector3 }[];\n /** @internal */\n protected _jointMatrices!: Matrix4x4[];\n /** @internal */\n protected _jointOffsets!: Float32Array<ArrayBuffer>;\n /** @internal */\n protected _jointMatrixArray!: Float32Array<ArrayBuffer>;\n /** @internal */\n protected _jointTexture: DRef<Texture2D>;\n /** @internal */\n protected _playing: boolean;\n /** @internal */\n protected _modifiers: SkeletonModifier[];\n /** @internal */\n protected _lastUpdateTime: number;\n /**\n * Create a skeleton instance.\n *\n * @param joints - Joint scene nodes (one per joint), ordered to match skin data.\n * @param inverseBindMatrices - Inverse bind matrices for each joint.\n * @param bindPoseMatrices - Bind pose matrices for each joint (model-space).\n */\n constructor(\n joints: SceneNode[],\n inverseBindMatrices: Matrix4x4[],\n bindPose: { rotation: Quaternion; scale: Vector3; position: Vector3 }[]\n ) {\n super();\n this._id = randomUUID();\n this._joints = joints;\n this._inverseBindMatrices = inverseBindMatrices;\n this._bindPose = bindPose;\n this._jointTexture = new DRef();\n this._playing = false;\n this._modifiers = [];\n this._lastUpdateTime = 0;\n this._bindPoseModelSpace = [];\n this.computeBindPose();\n this.updateJointMatrices(0);\n let skeletonRoot = this.findRootJoint(this._joints);\n if (!skeletonRoot || !this._joints.includes(skeletonRoot)) {\n throw new Error('Skeleton root must be included in the joint list');\n }\n while (skeletonRoot.parent && this._joints.includes(skeletonRoot.parent)) {\n skeletonRoot = skeletonRoot.parent;\n }\n const im = skeletonRoot.parent!.invWorldMatrix;\n for (const joint of this._joints) {\n const m = Matrix4x4.multiplyAffine(im, joint.worldMatrix);\n this._bindPoseModelSpace.push(m);\n }\n Skeleton._registry.set(this._id, new DWeakRef(this));\n }\n /**\n * Lookup a skeleton from the global registry by persistent id.\n *\n * @param id - The persistent UUID to search for.\n * @returns The skeleton if alive, otherwise `null`.\n * @internal\n */\n static findSkeletonById(id: string) {\n const m = this._registry.get(id);\n if (m && !m.get()) {\n this._registry.delete(id);\n return null;\n }\n return m ? m.get() : null;\n }\n /** @internal */\n get joints() {\n return this._joints;\n }\n /** @internal */\n get inverseBindMatrices() {\n return this._inverseBindMatrices;\n }\n /** @internal */\n get bindPose() {\n return this._bindPose;\n }\n get bindPoseModelSpace() {\n return this._bindPoseModelSpace;\n }\n /** @internal */\n get playing() {\n return this._playing;\n }\n set playing(b: boolean) {\n this._playing = b;\n }\n /** @internal */\n get persistentId() {\n return this._id;\n }\n set persistentId(val) {\n if (val !== this._id) {\n const m = Skeleton._registry.get(this._id);\n if (!m || m.get() !== this) {\n throw new Error('Registry skeleton mismatch');\n }\n Skeleton._registry.delete(this._id);\n this._id = val;\n Skeleton._registry.set(this._id, m);\n }\n }\n /**\n * Texture containing joint matrices for GPU skinning.\n *\n * Each matrix is stored in 4 texels (one row per texel, RGBA = 4 floats).\n */\n get jointTexture() {\n return this._jointTexture.get()!;\n }\n /**\n * Get joint index by joint node\n * @param joint - joint node\n * @returns The index of the joint\n */\n getJointIndex(joint: SceneNode) {\n return this._joints.indexOf(joint);\n }\n /**\n * Get joint index by joint name\n * @param jointName - joint name\n * @returns The index of the joint\n */\n getJointIndexByName(jointName: string) {\n return this._joints.findIndex((joint) => joint.name === jointName);\n }\n /**\n * Update joint matrices from either provided transforms or the joints' world matrices.\n *\n * - Lazily creates the joint texture and its backing arrays on first call.\n * - Advances the ring buffer offset in `_jointOffsets` to write a new \"current\" set.\n * - For each joint:\n * - Optionally premultiplies by `worldMatrix` (to transform into model space).\n * - Computes skinning matrix: ( M_\\{skin\\} = M_\\{joint\\} \\\\times M_\\{inverseBind\\} ).\n *\n * Note: This method only writes into the CPU-side array; callers like `computeJoints()`\n * update the GPU texture.\n *\n * @param jointTransforms - Optional per-joint transforms to use instead of node world matrices.\n * @param worldMatrix - Optional world-to-model transform applied before inverse bind.\n * @internal\n */\n updateJointMatrices(deltaTime: number) {\n this.applyModifiers(deltaTime);\n if (!this._jointTexture.get()) {\n this._createJointTexture();\n }\n if (this._jointOffsets[0] === 0) {\n this._jointOffsets[0] = 1;\n this._jointOffsets[1] = 1;\n } else {\n this._jointOffsets[1] = this._jointOffsets[0];\n this._jointOffsets[0] = this._joints.length - this._jointOffsets[0] + 2;\n }\n for (let i = 0; i < this._joints.length; i++) {\n Matrix4x4.multiply(\n this._joints[i].worldMatrix,\n this._inverseBindMatrices[i],\n this._jointMatrices[i + this._jointOffsets[0] - 1]\n );\n }\n }\n /**\n * Reset skeleton to bind pose\n *\n * @internal\n */\n computeBindPose() {\n for (let i = 0; i < this._joints.length; i++) {\n const joint = this._joints[i];\n const bindpose = this._bindPose[i];\n joint.position.set(bindpose.position);\n joint.rotation.set(bindpose.rotation);\n joint.scale.set(bindpose.scale);\n }\n }\n /**\n * Compute current joint matrices from the nodes and upload them to the joint texture.\n *\n * @internal\n */\n apply(deltaTime: number) {\n this.updateJointMatrices(deltaTime);\n const tex = this.jointTexture;\n tex.update(this._jointMatrixArray, 0, 0, tex.width, tex.height);\n }\n /**\n * Apply all enabled modifiers.\n *\n * Modifiers are applied after the base animation/bind pose layer,\n * allowing procedural modifications like IK, spring physics, or manual overrides.\n *\n * @param deltaTime - Time elapsed since last frame (in seconds)\n * @internal\n */\n protected applyModifiers(deltaTime: number): void {\n for (const modifier of this._modifiers) {\n modifier.apply(this, deltaTime);\n }\n }\n /**\n * Get all modifiers attached to this skeleton.\n *\n * @public\n */\n get modifiers(): SkeletonModifier[] {\n return this._modifiers;\n }\n /**\n * Reset all meshes to an unskinned state and clear animated bounds.\n *\n * @internal\n */\n reset() {\n //this.updateJointMatrices(this._bindPoseMatrices);\n this._playing = false;\n }\n /**\n * Compute the animated bounding box for a single mesh using its representative vertices.\n *\n * For each representative vertex:\n * - Blends the vertex by up to 4 joint matrices using provided weights.\n * - Transforms to the mesh's local space using `invWorldMatrix`.\n * - Expands the bounding box.\n *\n * @param info - Precomputed bounding data (representative vertices, indices, weights).\n * @param invWorldMatrix - Mesh inverse world matrix to convert to model/local space.\n * @internal\n */\n computeBoundingBox(info: SkinnedBoundingBox, invWorldMatrix: Matrix4x4) {\n info.boundingBox.beginExtend();\n for (let i = 0; i < info.boundingVertices.length; i++) {\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1]\n .transformPointAffine(info.boundingVertices[i], tmpV0)\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 0]);\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1]\n .transformPointAffine(info.boundingVertices[i], tmpV1)\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 1]);\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1]\n .transformPointAffine(info.boundingVertices[i], tmpV2)\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 2]);\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1]\n .transformPointAffine(info.boundingVertices[i], tmpV3)\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 3]);\n tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);\n invWorldMatrix.transformPointAffine(tmpV0, tmpV0);\n info.boundingBox.extend(tmpV0);\n }\n }\n /**\n * Dispose GPU resources and references held by the skeleton.\n *\n * - Disposes the joint texture.\n * - Clears matrix arrays and joint references.\n */\n protected onDispose() {\n super.onDispose();\n this._jointTexture.dispose();\n const m = Skeleton._registry.get(this._id);\n if (m?.get() === this) {\n Skeleton._registry.delete(this._id);\n m.dispose();\n }\n }\n /**\n * Initialize joint texture and CPU-side matrix storage.\n *\n * Layout details:\n * - Texture size is the next power-of-two able to contain all matrices plus two offset texels.\n * - `_jointMatrixArray` holds:\n * - First 2 vec4s: ring buffer offsets `[current, previous, 0, 0]`.\n * - Followed by 2×N matrices (current and previous), each as 16 floats.\n * - `_jointMatrices` is a view into `_jointMatrixArray` providing Matrix4x4 objects per slot.\n *\n * @internal\n */\n private _createJointTexture() {\n const textureWidth = nextPowerOf2(Math.max(4, Math.ceil(Math.sqrt((this._joints.length * 2 + 1) * 4))));\n const device = getDevice();\n this._jointTexture.set(\n device.createTexture2D('rgba32f', textureWidth, textureWidth, {\n mipmapping: false,\n samplerOptions: {\n magFilter: 'nearest',\n minFilter: 'nearest'\n }\n })\n );\n this._jointMatrixArray = new Float32Array(textureWidth * textureWidth * 4);\n const buffer = this._jointMatrixArray.buffer;\n this._jointOffsets = new Float32Array(buffer);\n this._jointOffsets[0] = 0;\n this._jointOffsets[1] = 0;\n this._jointMatrices = Array.from({ length: this._joints.length * 2 }).map(\n (val, index) => new Matrix4x4(buffer, (index + 1) * 16 * Float32Array.BYTES_PER_ELEMENT)\n );\n }\n /**\n * Build representative skinned bounding data for a submesh.\n *\n * Strategy:\n * - For all vertices, compute their skinned position (using current ring buffer slot).\n * - Track the indices of the min/max extents along x, y, z (6 indices total).\n * - Store:\n * - The 6 representative positions in object space.\n * - Their 4 joint indices and weights (flattened).\n * - An empty BoundingBox to be filled during animation.\n *\n * @param meshData - Raw submesh attributes (positions, blend indices, weights).\n * @returns Skinned bounding box info used during per-frame updates.\n */\n getBoundingInfo(data: { positions: Float32Array; blendIndices: TypedArray; weights: TypedArray }) {\n const indices = [0, 0, 0, 0, 0, 0];\n let minx = Number.MAX_VALUE;\n let maxx = -Number.MAX_VALUE;\n let miny = Number.MAX_VALUE;\n let maxy = -Number.MAX_VALUE;\n let minz = Number.MAX_VALUE;\n let maxz = -Number.MAX_VALUE;\n const v = data.positions;\n const vert = new Vector3();\n const tmpV0 = new Vector3();\n const tmpV1 = new Vector3();\n const tmpV2 = new Vector3();\n const tmpV3 = new Vector3();\n const numVertices = Math.floor(v.length / 3);\n for (let i = 0; i < numVertices; i++) {\n vert.setXYZ(v[i * 3], v[i * 3 + 1], v[i * 3 + 2]);\n this._jointMatrices[data.blendIndices[i * 4 + 0] + this._jointOffsets[0] - 1]\n .transformPointAffine(vert, tmpV0)\n .scaleBy(data.weights[i * 4 + 0]);\n this._jointMatrices[data.blendIndices[i * 4 + 1] + this._jointOffsets[0] - 1]\n .transformPointAffine(vert, tmpV1)\n .scaleBy(data.weights[i * 4 + 1]);\n this._jointMatrices[data.blendIndices[i * 4 + 2] + this._jointOffsets[0] - 1]\n .transformPointAffine(vert, tmpV2)\n .scaleBy(data.weights[i * 4 + 2]);\n this._jointMatrices[data.blendIndices[i * 4 + 3] + this._jointOffsets[0] - 1]\n .transformPointAffine(vert, tmpV3)\n .scaleBy(data.weights[i * 4 + 3]);\n tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);\n if (tmpV0.x < minx) {\n minx = tmpV0.x;\n indices[0] = i;\n }\n if (tmpV0.x > maxx) {\n maxx = tmpV0.x;\n indices[1] = i;\n }\n if (tmpV0.y < miny) {\n miny = tmpV0.y;\n indices[2] = i;\n }\n if (tmpV0.y > maxy) {\n maxy = tmpV0.y;\n indices[3] = i;\n }\n if (tmpV0.z < minz) {\n minz = tmpV0.z;\n indices[4] = i;\n }\n if (tmpV0.z > maxz) {\n maxz = tmpV0.z;\n indices[5] = i;\n }\n }\n const info: SkinnedBoundingBox = {\n boundingVertexBlendIndices: new Float32Array(\n Array.from({ length: 6 * 4 }).map(\n (val, index) => data.blendIndices[indices[index >> 2] * 4 + (index % 4)]\n )\n ),\n boundingVertexJointWeights: new Float32Array(\n Array.from({ length: 6 * 4 }).map((val, index) => data.weights[indices[index >> 2] * 4 + (index % 4)])\n ),\n boundingVertices: Array.from({ length: 6 }).map(\n (val, index) =>\n new Vector3(\n data.positions[indices[index] * 3],\n data.positions[indices[index] * 3 + 1],\n data.positions[indices[index] * 3 + 2]\n )\n ),\n boundingBox: new BoundingBox()\n };\n return info;\n }\n private findRootJoint(joints: SceneNode[]) {\n let root: Nullable<SceneNode> = null;\n for (const joint of joints) {\n if (!root) {\n root = joint;\n }\n while (!root!.isParentOf(joint)) {\n root = root!.parent;\n }\n if (!root) {\n break;\n }\n }\n return root;\n }\n}\n"],"names":["tmpV0","Vector3","tmpV1","tmpV2","tmpV3","Skeleton","Disposable","_registry","Map","joints","inverseBindMatrices","bindPose","_id","randomUUID","_joints","_inverseBindMatrices","_bindPose","_jointTexture","DRef","_playing","_modifiers","_lastUpdateTime","_bindPoseModelSpace","computeBindPose","updateJointMatrices","skeletonRoot","findRootJoint","includes","Error","parent","im","invWorldMatrix","joint","m","Matrix4x4","multiplyAffine","worldMatrix","push","set","DWeakRef","findSkeletonById","id","get","delete","bindPoseModelSpace","playing","b","persistentId","val","jointTexture","getJointIndex","indexOf","getJointIndexByName","jointName","findIndex","name","deltaTime","applyModifiers","_createJointTexture","_jointOffsets","length","i","multiply","_jointMatrices","bindpose","position","rotation","scale","apply","tex","update","_jointMatrixArray","width","height","modifier","modifiers","reset","computeBoundingBox","info","boundingBox","beginExtend","boundingVertices","boundingVertexBlendIndices","transformPointAffine","scaleBy","boundingVertexJointWeights","addBy","extend","onDispose","dispose","textureWidth","nextPowerOf2","Math","max","ceil","sqrt","device","getDevice","createTexture2D","mipmapping","samplerOptions","magFilter","minFilter","Float32Array","buffer","Array","from","map","index","BYTES_PER_ELEMENT","getBoundingInfo","data","indices","minx","Number","MAX_VALUE","maxx","miny","maxy","minz","maxz","v","positions","vert","numVertices","floor","setXYZ","blendIndices","weights","x","y","z","BoundingBox","root","isParentOf"],"mappings":";;;;AAqCA,MAAMA,QAAQ,IAAIC,OAAAA,EAAAA;AAClB,MAAMC,QAAQ,IAAID,OAAAA,EAAAA;AAClB,MAAME,QAAQ,IAAIF,OAAAA,EAAAA;AAClB,MAAMG,QAAQ,IAAIH,OAAAA,EAAAA;AAElB;;;;;;;;;;;;;;;;;;;;;IAsBO,MAAMI,QAAiBC,SAAAA,UAAAA,CAAAA;AAC5B,0FACA,OAAwBC,SAA6C,GAAA,IAAIC,GAAM,EAAA;qBAE/E,GAAsB;qBAEtB,OAA+B;qBAE/B,oBAA4C;qBAE5C,mBAA2C;qBAE3C,SAAmF;qBAEnF,cAAuC;qBAEvC,aAAoD;qBAEpD,iBAAwD;qBAExD,aAAyC;qBAEzC,QAA4B;qBAE5B,UAAyC;qBAEzC,eAAkC;AAClC;;;;;;AAMC,MACD,YACEC,MAAmB,EACnBC,mBAAgC,EAChCC,QAAuE,CACvE;QACA,KAAK,EAAA;QACL,IAAI,CAACC,GAAG,GAAGC,UAAAA,EAAAA;QACX,IAAI,CAACC,OAAO,GAAGL,MAAAA;QACf,IAAI,CAACM,oBAAoB,GAAGL,mBAAAA;QAC5B,IAAI,CAACM,SAAS,GAAGL,QAAAA;QACjB,IAAI,CAACM,aAAa,GAAG,IAAIC,IAAAA,EAAAA;QACzB,IAAI,CAACC,QAAQ,GAAG,KAAA;QAChB,IAAI,CAACC,UAAU,GAAG,EAAE;QACpB,IAAI,CAACC,eAAe,GAAG,CAAA;QACvB,IAAI,CAACC,mBAAmB,GAAG,EAAE;AAC7B,QAAA,IAAI,CAACC,eAAe,EAAA;QACpB,IAAI,CAACC,m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