@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
package/dist/scene/mesh.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { castObservable, applyMixins, DRef } from '@zephyr3d/base';
|
|
1
|
+
import { Vector3, castObservable, applyMixins, DRef, DWeakRef, Matrix4x4, Vector4 } from '@zephyr3d/base';
|
|
2
|
+
import { isWireframeActive } from '../render/debug_views.js';
|
|
2
3
|
import { GraphNode } from './graph_node.js';
|
|
3
4
|
import { ShaderHelper } from '../material/shader/helper.js';
|
|
4
5
|
import { LambertMaterial } from '../material/lambert.js';
|
|
5
6
|
import '../material/blinn.js';
|
|
6
7
|
import '../material/unlit.js';
|
|
8
|
+
import '../material/meshmaterial.js';
|
|
7
9
|
import '../material/particle.js';
|
|
8
10
|
import '../material/subsurfaceprofile.js';
|
|
9
|
-
import '../material/
|
|
11
|
+
import '../material/sssprofile.js';
|
|
12
|
+
import '../material/sss.js';
|
|
10
13
|
import '../material/eye.js';
|
|
11
14
|
import { PBStructTypeInfo, PBArrayTypeInfo, PBPrimitiveTypeInfo, PBPrimitiveType } from '@zephyr3d/device';
|
|
12
|
-
import { QUEUE_OPAQUE, MORPH_WEIGHTS_VECTOR_COUNT, MORPH_ATTRIBUTE_VECTOR_COUNT, getMorphTargetLimit, getActiveMorphTargetLimit } from '../values.js';
|
|
15
|
+
import { QUEUE_OPAQUE, RENDER_PASS_TYPE_LIGHT, MORPH_WEIGHTS_VECTOR_COUNT, MORPH_ATTRIBUTE_VECTOR_COUNT, getMorphTargetLimit, getActiveMorphTargetLimit } from '../values.js';
|
|
13
16
|
import { RenderBundleWrapper } from '../render/renderbundle_wrapper.js';
|
|
14
17
|
import { getDevice } from '../app/api.js';
|
|
15
|
-
import '../material/meshmaterial.js';
|
|
16
18
|
import '../material/hair.js';
|
|
17
19
|
import '../material/hairstrand.js';
|
|
18
20
|
import '../material/grassmaterial.js';
|
|
@@ -27,7 +29,52 @@ import '../utility/blueprint/material/texture.js';
|
|
|
27
29
|
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
28
30
|
import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
29
31
|
import { calculateMorphBoundingBox } from '../animation/morphtarget.js';
|
|
32
|
+
import { SkinPaletteAtlas } from '../animation/skin_palette_atlas.js';
|
|
33
|
+
import { computeAABBScreenRadiusSquared, selectLod } from '../render/lod.js';
|
|
30
34
|
|
|
35
|
+
const tmpLodCenter = new Vector3();
|
|
36
|
+
const LOD_COLORATION_COLORS = [
|
|
37
|
+
[
|
|
38
|
+
1,
|
|
39
|
+
1,
|
|
40
|
+
1
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
1,
|
|
44
|
+
0,
|
|
45
|
+
0
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
0,
|
|
49
|
+
1,
|
|
50
|
+
0
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
0,
|
|
54
|
+
0,
|
|
55
|
+
1
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
1,
|
|
59
|
+
1,
|
|
60
|
+
0
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
1,
|
|
64
|
+
0,
|
|
65
|
+
1
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
0,
|
|
69
|
+
1,
|
|
70
|
+
1
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
0.5,
|
|
74
|
+
0,
|
|
75
|
+
0.5
|
|
76
|
+
]
|
|
77
|
+
];
|
|
31
78
|
const MORPH_WEIGHT_CAPACITY = MORPH_WEIGHTS_VECTOR_COUNT * 4;
|
|
32
79
|
const MORPH_ATTRIBUTE_CAPACITY = MORPH_ATTRIBUTE_VECTOR_COUNT * 4;
|
|
33
80
|
const MORPH_INFO_DATA_LENGTH = 4 + MORPH_WEIGHT_CAPACITY + MORPH_ATTRIBUTE_CAPACITY;
|
|
@@ -70,10 +117,16 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
70
117
|
/** @internal */ _primitive;
|
|
71
118
|
/** @internal */ _material;
|
|
72
119
|
/** @internal */ _castShadow;
|
|
120
|
+
/** @internal */ _sdfMode;
|
|
73
121
|
/** @internal */ _skinnedBoundingInfo;
|
|
74
122
|
/** @internal */ _animatedBoundingBox;
|
|
75
123
|
/** @internal */ _skinBindingName;
|
|
76
124
|
/** @internal */ _boneMatrices;
|
|
125
|
+
/** @internal Skin binding resolved from _skinBindingName at the last skeleton state update */ _skinBinding;
|
|
126
|
+
/** @internal */ _skinSpaceMatrix;
|
|
127
|
+
/** @internal Skin binding and palette version the skinned bounds were last computed for */ _skinnedBoundsVersion;
|
|
128
|
+
/** @internal Palette written by an animation bank track in place of the skin binding's */ _skinPaletteOverride;
|
|
129
|
+
/** Palette base last written to instance data and drawable uniforms */ _appliedSkinPaletteBase;
|
|
77
130
|
/** @internal */ _skinInfluenceData;
|
|
78
131
|
/** @internal */ _morphData;
|
|
79
132
|
/** @internal */ _morphInfo;
|
|
@@ -94,6 +147,9 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
94
147
|
/** @internal */ _materialChangeTag;
|
|
95
148
|
/** @internal */ _primitiveChangeTag;
|
|
96
149
|
/** @internal */ _postUpdateCallbacks;
|
|
150
|
+
/** @internal */ _forcedLod;
|
|
151
|
+
/** @internal */ _minLod;
|
|
152
|
+
/** @internal Level of detail last selected for each camera, for the hysteresis */ _lodByCamera;
|
|
97
153
|
/**
|
|
98
154
|
* Creates an instance of mesh node
|
|
99
155
|
* @param scene - The scene to which the mesh node belongs
|
|
@@ -102,9 +158,18 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
102
158
|
this._primitive = new DRef();
|
|
103
159
|
this._material = new DRef();
|
|
104
160
|
this._castShadow = true;
|
|
161
|
+
this._sdfMode = 'auto';
|
|
105
162
|
this._skinnedBoundingInfo = null;
|
|
106
163
|
this._animatedBoundingBox = null;
|
|
107
164
|
this._boneMatrices = new DRef();
|
|
165
|
+
this._skinBinding = new DWeakRef();
|
|
166
|
+
this._skinSpaceMatrix = new Matrix4x4();
|
|
167
|
+
this._skinPaletteOverride = null;
|
|
168
|
+
this._appliedSkinPaletteBase = 0;
|
|
169
|
+
this._skinnedBoundsVersion = {
|
|
170
|
+
binding: null,
|
|
171
|
+
version: -1
|
|
172
|
+
};
|
|
108
173
|
this._skinInfluenceData = null;
|
|
109
174
|
this._morphData = null;
|
|
110
175
|
this._morphInfo = null;
|
|
@@ -120,7 +185,7 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
120
185
|
this._pickTarget = {
|
|
121
186
|
node: this
|
|
122
187
|
};
|
|
123
|
-
this._batchable =
|
|
188
|
+
this._batchable = true;
|
|
124
189
|
this.primitive = primitive ?? null;
|
|
125
190
|
this.material = material ?? Mesh._getDefaultMaterial();
|
|
126
191
|
this._suspendSkinning = false;
|
|
@@ -130,11 +195,29 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
130
195
|
this._materialChangeTag = null;
|
|
131
196
|
this._primitiveChangeTag = null;
|
|
132
197
|
this._postUpdateCallbacks = new Set();
|
|
198
|
+
this._forcedLod = -1;
|
|
199
|
+
this._minLod = 0;
|
|
200
|
+
this._lodByCamera = null;
|
|
133
201
|
}
|
|
134
202
|
/**
|
|
135
203
|
* Returns the batch instance ID for the current render pass.
|
|
136
204
|
*/ getInstanceId(_renderPass) {
|
|
137
|
-
|
|
205
|
+
const id = `${this._instanceHash}:${this.worldMatrixDet >= 0}`;
|
|
206
|
+
return this._boneMatrices.get() ? `${id}:skin:${this.getSkinSpaceKey()}` : id;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Key of the skin space matrix, equal for meshes that may share one in a batch.
|
|
210
|
+
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* A batch transforms the palettes of all its instances by the skin space matrix of its first
|
|
213
|
+
* mesh. Instances of one model share it up to rounding, so the key is quantized.
|
|
214
|
+
*/ getSkinSpaceKey() {
|
|
215
|
+
const m = this.getSkinSpaceMatrix();
|
|
216
|
+
let key = '';
|
|
217
|
+
for(let i = 0; i < 16; i++){
|
|
218
|
+
key += `${Math.round(m[i] * 1e4)},`;
|
|
219
|
+
}
|
|
220
|
+
return key;
|
|
138
221
|
}
|
|
139
222
|
/**
|
|
140
223
|
* Returns the packed instance-uniform buffer used for batching.
|
|
@@ -180,6 +263,12 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
180
263
|
return this._suspendSkinning;
|
|
181
264
|
}
|
|
182
265
|
/** @internal */ set suspendSkinning(val) {
|
|
266
|
+
if (val && !this._suspendSkinning) {
|
|
267
|
+
this.setAnimatedBoundingBox(null);
|
|
268
|
+
} else if (!val && this._suspendSkinning) {
|
|
269
|
+
// Skinned meshes sleep until their pose changes, so wake this one to pick skinning up again
|
|
270
|
+
this.scene?.queueUpdateNode(this);
|
|
271
|
+
}
|
|
183
272
|
this._suspendSkinning = !!val;
|
|
184
273
|
}
|
|
185
274
|
/** Wether the mesh node casts shadows */ get castShadow() {
|
|
@@ -188,6 +277,83 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
188
277
|
set castShadow(b) {
|
|
189
278
|
this._castShadow = b;
|
|
190
279
|
}
|
|
280
|
+
/** How the mesh takes part in the scene's signed distance field. */ get sdfMode() {
|
|
281
|
+
return this._sdfMode;
|
|
282
|
+
}
|
|
283
|
+
set sdfMode(val) {
|
|
284
|
+
if (val !== this._sdfMode) {
|
|
285
|
+
this._sdfMode = val;
|
|
286
|
+
this.dispatchEvent('sdfmode_changed', this);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/** {@link Mesh.sdfMode} with `auto` resolved. */ get effectiveSDFMode() {
|
|
290
|
+
if (this._sdfMode !== 'auto') {
|
|
291
|
+
return this._sdfMode;
|
|
292
|
+
}
|
|
293
|
+
if (this._skinBindingName || this._morphData) {
|
|
294
|
+
return 'dynamic';
|
|
295
|
+
}
|
|
296
|
+
for(let node = this; node; node = node.parent){
|
|
297
|
+
const physics = node.physics;
|
|
298
|
+
const body = physics?.body;
|
|
299
|
+
if (body && body.motionType !== 'static' || physics?.character) {
|
|
300
|
+
return 'dynamic';
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return 'static';
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Level of detail to always draw, or -1 to select it by the projected size.
|
|
307
|
+
* Clamped to the levels of the primitive.
|
|
308
|
+
*/ get forcedLod() {
|
|
309
|
+
return this._forcedLod;
|
|
310
|
+
}
|
|
311
|
+
set forcedLod(val) {
|
|
312
|
+
val = Math.max(-1, Math.floor(val));
|
|
313
|
+
if (val !== this._forcedLod) {
|
|
314
|
+
this._forcedLod = val;
|
|
315
|
+
this.dispatchEvent('lod_changed', this);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Finest level of detail drawn when selecting by the projected size.
|
|
320
|
+
* Clamped to the levels of the primitive.
|
|
321
|
+
*/ get minLod() {
|
|
322
|
+
return this._minLod;
|
|
323
|
+
}
|
|
324
|
+
set minLod(val) {
|
|
325
|
+
val = Math.max(0, Math.floor(val));
|
|
326
|
+
if (val !== this._minLod) {
|
|
327
|
+
this._minLod = val;
|
|
328
|
+
this.dispatchEvent('lod_changed', this);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Selects the level of detail of the primitive for a view: forced, or picked from the projected
|
|
333
|
+
* size of the world bounds. Always 0 for a primitive without levels.
|
|
334
|
+
*
|
|
335
|
+
* @param camera - The view's camera
|
|
336
|
+
* @returns The level of detail, 0 being the finest
|
|
337
|
+
*/ selectLod(camera) {
|
|
338
|
+
const lods = this._primitive.get()?.lods;
|
|
339
|
+
if (!lods || lods.length === 0) {
|
|
340
|
+
return 0;
|
|
341
|
+
}
|
|
342
|
+
if (this._forcedLod >= 0) {
|
|
343
|
+
return Math.min(this._forcedLod, lods.length);
|
|
344
|
+
}
|
|
345
|
+
const bv = this.getWorldBoundingVolume();
|
|
346
|
+
if (!bv) {
|
|
347
|
+
return Math.min(this._minLod, lods.length);
|
|
348
|
+
}
|
|
349
|
+
const screenRadiusSquared = computeAABBScreenRadiusSquared(bv.toAABB(), camera, tmpLodCenter);
|
|
350
|
+
if (!this._lodByCamera) {
|
|
351
|
+
this._lodByCamera = new WeakMap();
|
|
352
|
+
}
|
|
353
|
+
const lod = selectLod(lods, screenRadiusSquared, camera.lodDistanceScale, this._lodByCamera.get(camera) ?? 0, this._minLod);
|
|
354
|
+
this._lodByCamera.set(camera, lod);
|
|
355
|
+
return lod;
|
|
356
|
+
}
|
|
191
357
|
/** Primitive of the mesh */ get primitive() {
|
|
192
358
|
return this._primitive?.get() ?? null;
|
|
193
359
|
}
|
|
@@ -205,12 +371,6 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
205
371
|
this.invalidateBoundingVolume();
|
|
206
372
|
RenderBundleWrapper.drawableChanged(this);
|
|
207
373
|
this._primitiveChangeTag = null;
|
|
208
|
-
if (this._morphData) {
|
|
209
|
-
this._ensureWebGLVertexIndexAttribute('morphing');
|
|
210
|
-
}
|
|
211
|
-
if (this._skinInfluenceData && this._skinInfluenceData.influenceCount > 4) {
|
|
212
|
-
this._ensureWebGLVertexIndexAttribute('skinning');
|
|
213
|
-
}
|
|
214
374
|
this.dispatchEvent('primitive_changed', prim);
|
|
215
375
|
}
|
|
216
376
|
}
|
|
@@ -267,6 +427,7 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
267
427
|
*/ setBoneMatrices(matrices) {
|
|
268
428
|
if (this._boneMatrices.get() !== matrices) {
|
|
269
429
|
this._boneMatrices.set(matrices);
|
|
430
|
+
Mesh._trackBoneMatrices(this, !!matrices);
|
|
270
431
|
this._renderBundle = {};
|
|
271
432
|
RenderBundleWrapper.drawableChanged(this);
|
|
272
433
|
}
|
|
@@ -316,7 +477,6 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
316
477
|
}
|
|
317
478
|
tex.update(data.data, 0, 0, data.width, data.height);
|
|
318
479
|
}
|
|
319
|
-
this._ensureWebGLVertexIndexAttribute('skinning');
|
|
320
480
|
this._renderBundle = {};
|
|
321
481
|
RenderBundleWrapper.drawableChanged(this);
|
|
322
482
|
}
|
|
@@ -358,7 +518,6 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
358
518
|
}
|
|
359
519
|
tex.update(data.data, 0, 0, data.width, data.height);
|
|
360
520
|
}
|
|
361
|
-
this._ensureWebGLVertexIndexAttribute('morphing');
|
|
362
521
|
this._renderBundle = {};
|
|
363
522
|
RenderBundleWrapper.drawableChanged(this);
|
|
364
523
|
if (this._morphInfo && !this._morphSourceData) {
|
|
@@ -383,6 +542,54 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
383
542
|
return this._skinInfluenceData;
|
|
384
543
|
}
|
|
385
544
|
/**
|
|
545
|
+
* Gets the slot index of the skinning palette header in the bone matrix texture.
|
|
546
|
+
*
|
|
547
|
+
* @internal
|
|
548
|
+
*/ getSkinPaletteBase() {
|
|
549
|
+
return this._skinPaletteOverride?.paletteBase ?? this._skinBinding.get()?.paletteBase ?? 0;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Gets the palette that skins this mesh in place of its skin binding's, if any.
|
|
553
|
+
*
|
|
554
|
+
* @internal
|
|
555
|
+
*/ getSkinPaletteOverride() {
|
|
556
|
+
return this._skinPaletteOverride;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Skins this mesh by a palette written elsewhere instead of by its skin binding.
|
|
560
|
+
*
|
|
561
|
+
* @remarks
|
|
562
|
+
* The palette must be laid out like the binding's: same joints, relative to the same
|
|
563
|
+
* reference node. The mesh then neither reads the binding's palette nor computes its bounds
|
|
564
|
+
* from the binding's joints each frame; the override supplies its animated bounds.
|
|
565
|
+
*
|
|
566
|
+
* @param override - The palette and bounds, or null to skin by the binding again
|
|
567
|
+
* @internal
|
|
568
|
+
*/ setSkinPaletteOverride(override) {
|
|
569
|
+
this._skinPaletteOverride = override;
|
|
570
|
+
this.updateSkeletonState();
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Gets the matrix transforming skinning palette output to the local space of this mesh.
|
|
574
|
+
*
|
|
575
|
+
* @remarks
|
|
576
|
+
* Palette matrices are relative to the reference node of the skin binding, so this is
|
|
577
|
+
* `inverse(worldMatrix) * referenceNode.worldMatrix`.
|
|
578
|
+
*
|
|
579
|
+
* @param binding - Skin binding the palette belongs to. Defaults to the binding last resolved
|
|
580
|
+
* for this mesh, which is not resolved yet before the first update after deserialization,
|
|
581
|
+
* since the children of a node are deserialized before its skin bindings
|
|
582
|
+
* @internal
|
|
583
|
+
*/ getSkinSpaceMatrix(binding) {
|
|
584
|
+
const reference = (binding ?? this._skinBinding.get())?.referenceNode;
|
|
585
|
+
if (reference) {
|
|
586
|
+
Matrix4x4.multiplyAffine(this.invWorldMatrix, reference.worldMatrix, this._skinSpaceMatrix);
|
|
587
|
+
} else {
|
|
588
|
+
this._skinSpaceMatrix.set(this.invWorldMatrix);
|
|
589
|
+
}
|
|
590
|
+
return this._skinSpaceMatrix;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
386
593
|
* Gets the external morph source descriptor.
|
|
387
594
|
*/ getMorphSource() {
|
|
388
595
|
return this._morphSource;
|
|
@@ -663,7 +870,7 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
663
870
|
});
|
|
664
871
|
}
|
|
665
872
|
/** @internal */ resolveAnimatedBoundingBox(morphBoundingBox) {
|
|
666
|
-
const skinnedBoundingBox = this._boneMatrices.get()
|
|
873
|
+
const skinnedBoundingBox = !this._boneMatrices.get() ? null : this._skinPaletteOverride ? this._skinPaletteOverride.boundingBox : this._skinnedBoundingInfo?.boundingBox?.isValid() ? this._skinnedBoundingInfo.boundingBox : null;
|
|
667
874
|
if (skinnedBoundingBox && morphBoundingBox) {
|
|
668
875
|
// Skinning and morphing both active. The two boxes live in different
|
|
669
876
|
// frames: the skinned box already reflects where the geometry actually
|
|
@@ -795,6 +1002,7 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
795
1002
|
/** @internal */ addPostUpdateCallback(callback) {
|
|
796
1003
|
if (callback) {
|
|
797
1004
|
this._postUpdateCallbacks.add(callback);
|
|
1005
|
+
this.scene?.queueUpdateNode(this);
|
|
798
1006
|
}
|
|
799
1007
|
}
|
|
800
1008
|
/** @internal */ removePostUpdateCallback(callback) {
|
|
@@ -805,7 +1013,8 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
805
1013
|
/**
|
|
806
1014
|
* {@inheritDoc Drawable.isBatchable}
|
|
807
1015
|
*/ isBatchable() {
|
|
808
|
-
return this._batchable && !this.
|
|
1016
|
+
return this._batchable && !this._morphData && // Extra skin influences are read from a texture of each mesh, which a batch cannot vary
|
|
1017
|
+
!(this._boneMatrices.get() && (this._skinInfluenceData?.influenceCount ?? 4) > 4) && (this._material.get()?.isBatchable() ?? false);
|
|
809
1018
|
}
|
|
810
1019
|
/**
|
|
811
1020
|
* {@inheritDoc Drawable.getQueueType}
|
|
@@ -878,34 +1087,81 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
878
1087
|
}
|
|
879
1088
|
/** @internal */ updateSkeletonState() {
|
|
880
1089
|
if (this._suspendSkinning) {
|
|
1090
|
+
if (this._skinnedBoundsVersion) {
|
|
1091
|
+
this._skinnedBoundsVersion.binding = null;
|
|
1092
|
+
}
|
|
881
1093
|
this.setBoneMatrices(null);
|
|
882
|
-
this.setAnimatedBoundingBox(null);
|
|
883
1094
|
return;
|
|
884
1095
|
}
|
|
885
|
-
|
|
1096
|
+
// Looking a binding up walks the model, so the one found last time is kept while it matches
|
|
1097
|
+
const cached = this._skinBinding.get();
|
|
1098
|
+
const binding = this._skinBindingName && (cached && !cached.disposed && cached.persistentId === this._skinBindingName ? cached : this.findSkinBindingById(this._skinBindingName));
|
|
1099
|
+
this._skinBinding.set(binding || null);
|
|
1100
|
+
const paletteBase = this.getSkinPaletteBase();
|
|
1101
|
+
if (paletteBase !== this._appliedSkinPaletteBase) {
|
|
1102
|
+
// Instance data and drawable uniforms hold the palette base and are not rewritten every
|
|
1103
|
+
// frame; it changes with the binding, with palette overrides, and with a binding's palette
|
|
1104
|
+
// being allocated again after a suspension
|
|
1105
|
+
this._appliedSkinPaletteBase = paletteBase;
|
|
1106
|
+
this.applyTransformUniformsAll();
|
|
1107
|
+
RenderBundleWrapper.drawableChanged(this);
|
|
1108
|
+
}
|
|
886
1109
|
if (binding) {
|
|
887
1110
|
this.setBoneMatrices(binding.jointTexture);
|
|
888
|
-
|
|
889
|
-
this.
|
|
1111
|
+
const bounds = this._skinnedBoundsVersion;
|
|
1112
|
+
if (this._skinPaletteOverride) {
|
|
1113
|
+
bounds.binding = null;
|
|
1114
|
+
this.refreshAnimatedBoundingBox();
|
|
1115
|
+
} else if (bounds.binding !== binding || bounds.version !== binding.paletteVersion) {
|
|
1116
|
+
// Bounds follow the pose, which only changes with the joint matrices
|
|
1117
|
+
bounds.binding = binding;
|
|
1118
|
+
bounds.version = binding.paletteVersion;
|
|
1119
|
+
binding.computeBoundingBox(this._skinnedBoundingInfo, this.getSkinSpaceMatrix(binding));
|
|
1120
|
+
this.refreshAnimatedBoundingBox();
|
|
1121
|
+
}
|
|
890
1122
|
} else {
|
|
1123
|
+
this._skinnedBoundsVersion.binding = null;
|
|
891
1124
|
this.setBoneMatrices(null);
|
|
892
1125
|
this.refreshAnimatedBoundingBox();
|
|
893
1126
|
}
|
|
894
|
-
|
|
895
|
-
|
|
1127
|
+
// Bounds of an overriding palette only change when the override is set again, and bounds
|
|
1128
|
+
// of the binding's palette when its pose does, which wakes the mesh up
|
|
1129
|
+
if (this._postUpdateCallbacks.size > 0 || this._skinBindingName && !binding) {
|
|
1130
|
+
// Post update callbacks (GPU cloth) run every frame, and the binding may not be loaded yet
|
|
1131
|
+
this.scene?.queueUpdateNode(this);
|
|
1132
|
+
} else if (binding && !this._skinPaletteOverride) {
|
|
1133
|
+
binding.sleepUntilPoseChanges(this);
|
|
896
1134
|
}
|
|
897
1135
|
}
|
|
898
1136
|
/**
|
|
899
1137
|
* {@inheritDoc Drawable.draw}
|
|
900
1138
|
*/ draw(ctx, renderQueue, hash) {
|
|
901
|
-
const
|
|
902
|
-
const
|
|
903
|
-
if (
|
|
904
|
-
|
|
905
|
-
|
|
1139
|
+
const ownMaterial = this.material;
|
|
1140
|
+
const solid = this.primitive;
|
|
1141
|
+
if (ownMaterial && solid) {
|
|
1142
|
+
const coloration = this.getLodColorationMaterial(ctx);
|
|
1143
|
+
// Render passes apply the materials of their item lists before drawing, which the
|
|
1144
|
+
// coloration material is not part of
|
|
1145
|
+
if (coloration && !coloration.apply(ctx)) {
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
const material = coloration ?? ownMaterial;
|
|
1149
|
+
const primitive = solid;
|
|
1150
|
+
// Edges of a wireframe view are built asynchronously, a bundle recorded before would keep
|
|
1151
|
+
// drawing the triangles
|
|
1152
|
+
if (this._useRenderBundle && !ctx.instanceData && hash && !isWireframeActive()) {
|
|
1153
|
+
// Each level of detail records its own draw range
|
|
1154
|
+
const lod = ctx.primitiveLod ?? 0;
|
|
1155
|
+
if (lod > 0) {
|
|
1156
|
+
hash = `${hash}:lod${lod}`;
|
|
1157
|
+
}
|
|
1158
|
+
if (coloration) {
|
|
1159
|
+
hash = `${hash}:lodcolor`;
|
|
1160
|
+
}
|
|
1161
|
+
if (this._primitiveChangeTag !== solid.changeTag || this._materialChangeTag !== ownMaterial.changeTag) {
|
|
906
1162
|
this._renderBundle = {};
|
|
907
|
-
this._primitiveChangeTag =
|
|
908
|
-
this._materialChangeTag =
|
|
1163
|
+
this._primitiveChangeTag = solid.changeTag;
|
|
1164
|
+
this._materialChangeTag = ownMaterial.changeTag;
|
|
909
1165
|
}
|
|
910
1166
|
const renderBundle = this._renderBundle[hash];
|
|
911
1167
|
if (!renderBundle) {
|
|
@@ -923,6 +1179,25 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
923
1179
|
}
|
|
924
1180
|
}
|
|
925
1181
|
/**
|
|
1182
|
+
* The material shading the level of detail in its color in the light pass
|
|
1183
|
+
* of a camera showing it, null otherwise. Depth, shadow and picking passes keep the
|
|
1184
|
+
* mesh's own material.
|
|
1185
|
+
* @internal
|
|
1186
|
+
*/ getLodColorationMaterial(ctx) {
|
|
1187
|
+
if (!ctx.camera?.lodColoration || ctx.renderPass?.type !== RENDER_PASS_TYPE_LIGHT) {
|
|
1188
|
+
return null;
|
|
1189
|
+
}
|
|
1190
|
+
const lod = Math.min(ctx.primitiveLod ?? 0, LOD_COLORATION_COLORS.length - 1);
|
|
1191
|
+
let material = Mesh._lodColorationMaterials[lod];
|
|
1192
|
+
if (!material) {
|
|
1193
|
+
material = new LambertMaterial();
|
|
1194
|
+
const [r, g, b] = LOD_COLORATION_COLORS[lod];
|
|
1195
|
+
material.albedoColor = new Vector4(r, g, b, 1);
|
|
1196
|
+
Mesh._lodColorationMaterials[lod] = material;
|
|
1197
|
+
}
|
|
1198
|
+
return material;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
926
1201
|
* {@inheritDoc Drawable.getMaterial}
|
|
927
1202
|
*/ getMaterial() {
|
|
928
1203
|
return this.material;
|
|
@@ -958,6 +1233,8 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
958
1233
|
this._primitive.dispose();
|
|
959
1234
|
this._material.dispose();
|
|
960
1235
|
this._boneMatrices.dispose();
|
|
1236
|
+
Mesh._trackBoneMatrices(this, false);
|
|
1237
|
+
this._skinBinding.dispose();
|
|
961
1238
|
this.setSkinInfluenceData(null);
|
|
962
1239
|
this.setMorphData(null);
|
|
963
1240
|
this.setRenderMorphInfo(null);
|
|
@@ -970,26 +1247,31 @@ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
|
|
|
970
1247
|
/** @internal */ _onBoundingboxChange() {
|
|
971
1248
|
this.invalidateBoundingVolume();
|
|
972
1249
|
}
|
|
973
|
-
/** @internal */
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
if (numVertices <= 0) {
|
|
1250
|
+
/** @internal */ static _defaultMaterial = null;
|
|
1251
|
+
/** Meshes holding a joint texture, rebound when the skin palette atlas replaces it */ static _skinnedMeshes = new Set();
|
|
1252
|
+
static _listeningAtlas = false;
|
|
1253
|
+
/**
|
|
1254
|
+
* Keep the joint textures of skinned meshes current when the atlas grows: a mesh only picks the
|
|
1255
|
+
* texture up in update(), which a mesh posed by an animation bank track no longer runs
|
|
1256
|
+
*/ static _trackBoneMatrices(mesh, skinned) {
|
|
1257
|
+
if (!skinned) {
|
|
1258
|
+
this._skinnedMeshes.delete(mesh);
|
|
983
1259
|
return;
|
|
984
1260
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1261
|
+
this._skinnedMeshes.add(mesh);
|
|
1262
|
+
if (!this._listeningAtlas) {
|
|
1263
|
+
this._listeningAtlas = true;
|
|
1264
|
+
SkinPaletteAtlas.addTextureReplacedListener(()=>{
|
|
1265
|
+
for (const m of this._skinnedMeshes){
|
|
1266
|
+
const binding = m._skinBinding.get();
|
|
1267
|
+
if (binding && !binding.disposed) {
|
|
1268
|
+
m.setBoneMatrices(binding.jointTexture);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
988
1272
|
}
|
|
989
|
-
primitive.createAndSetVertexBuffer('tex7_f32', vertexIndices);
|
|
990
|
-
console.info(`Injected texCoord7 vertex indices for WebGL ${feature} on mesh "${this.name ?? ''}"`);
|
|
991
1273
|
}
|
|
992
|
-
/** @internal */ static
|
|
1274
|
+
/** @internal Materials of the LOD coloration view, by level */ static _lodColorationMaterials = [];
|
|
993
1275
|
/** @internal */ static _getDefaultMaterial() {
|
|
994
1276
|
if (!this._defaultMaterial) {
|
|
995
1277
|
this._defaultMaterial = new LambertMaterial();
|