@zephyr3d/scene 0.9.27 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -27
- package/dist/animation/animation_bank.js +634 -0
- package/dist/animation/animation_bank.js.map +1 -0
- package/dist/animation/animation_bank_gpu.js +256 -0
- package/dist/animation/animation_bank_gpu.js.map +1 -0
- package/dist/animation/animationset.js +54 -0
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_component.js +406 -0
- package/dist/animation/cloth/gpu_cloth_component.js.map +1 -0
- package/dist/animation/cloth/gpu_cloth_system.js +332 -202
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/gpu_animation_driver.js +289 -0
- package/dist/animation/gpu_animation_driver.js.map +1 -0
- package/dist/animation/joint_dynamics/collision.js +112 -1
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +6 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +11 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +50 -12
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/skeleton.js +279 -55
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skin_palette_atlas.js +252 -0
- package/dist/animation/skin_palette_atlas.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +298 -38
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +2 -0
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +159 -21
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_solver.js +173 -0
- package/dist/animation/spring/spring_solver.js.map +1 -0
- package/dist/animation/spring/spring_system.js +249 -24
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +32 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/app.js +26 -0
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +86 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/gamepad.js +191 -0
- package/dist/app/gamepad.js.map +1 -0
- package/dist/app/inputactions.js +271 -0
- package/dist/app/inputactions.js.map +1 -0
- package/dist/app/inputmgr.js +331 -22
- package/dist/app/inputmgr.js.map +1 -1
- package/dist/app/loading.js +138 -0
- package/dist/app/loading.js.map +1 -0
- package/dist/app/pipelinecache.js +209 -0
- package/dist/app/pipelinecache.js.map +1 -0
- package/dist/app/runtimescript.js +25 -0
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/scriptingsystem.js +54 -0
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +7 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/asset_manifest.js +59 -0
- package/dist/asset/asset_manifest.js.map +1 -0
- package/dist/asset/asset_preload.js +258 -0
- package/dist/asset/asset_preload.js.map +1 -0
- package/dist/asset/assetmanager.js +117 -65
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/dist/asset/loaders/ktx2/basis_location.js +17 -0
- package/dist/asset/loaders/ktx2/basis_location.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js +88 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js +118 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js.map +1 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js +259 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js.map +1 -0
- package/dist/asset/mesh_lod_builder.js +104 -0
- package/dist/asset/mesh_lod_builder.js.map +1 -0
- package/dist/asset/mesh_settings.js +111 -0
- package/dist/asset/mesh_settings.js.map +1 -0
- package/dist/asset/meshopt_decoder.js +18 -0
- package/dist/asset/meshopt_decoder.js.map +1 -0
- package/dist/asset/meshopt_simplifier.js +26 -0
- package/dist/asset/meshopt_simplifier.js.map +1 -0
- package/dist/asset/model.js +171 -1
- package/dist/asset/model.js.map +1 -1
- package/dist/asset/texture_settings.js +231 -0
- package/dist/asset/texture_settings.js.map +1 -0
- package/dist/asset/zmsh_binary.js +131 -0
- package/dist/asset/zmsh_binary.js.map +1 -0
- package/dist/asset/zsdf_binary.js +111 -0
- package/dist/asset/zsdf_binary.js.map +1 -0
- package/dist/blitter/bilateralblur.js +1 -2
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/gaussianblur.js +1 -6
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +31 -10
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +104 -178
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/follow.js +342 -0
- package/dist/camera/follow.js.map +1 -0
- package/dist/camera/fps.js +9 -7
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +46 -19
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +25436 -15990
- package/dist/index.js +65 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +3 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/eye.js +1 -1
- package/dist/material/eye.js.map +1 -1
- package/dist/material/hair.js +2 -3
- package/dist/material/hair.js.map +1 -1
- package/dist/material/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +66 -4
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +118 -45
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +1 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +34 -61
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -2
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +2 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +191 -83
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +31 -206
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mtoon.js +1 -1
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrmr.js +3 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +3 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/sdf_debug.js +78 -0
- package/dist/material/sdf_debug.js.map +1 -0
- package/dist/material/shader/helper.js +333 -191
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +204 -43
- package/dist/material/shader/terrain_blend.js.map +1 -1
- package/dist/material/skin.js +331 -297
- package/dist/material/skin.js.map +1 -1
- package/dist/material/skinprofile.js +1058 -0
- package/dist/material/skinprofile.js.map +1 -0
- package/dist/material/sss.js +353 -0
- package/dist/material/sss.js.map +1 -0
- package/dist/material/sss_kernel.js +265 -0
- package/dist/material/sss_kernel.js.map +1 -0
- package/dist/material/sssprofile.js +879 -0
- package/dist/material/sssprofile.js.map +1 -0
- package/dist/material/subsurfaceprofile.js +4 -8
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/terrain-cm.js +464 -188
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/material/unlit.js +3 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +1261 -1438
- package/dist/material/water.js.map +1 -1
- package/dist/node_modules/meshoptimizer/LICENSE +21 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js +197 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js.map +1 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js +677 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js.map +1 -0
- package/dist/physics/character.js +226 -0
- package/dist/physics/character.js.map +1 -0
- package/dist/physics/collider.js +209 -0
- package/dist/physics/collider.js.map +1 -0
- package/dist/physics/events.js +79 -0
- package/dist/physics/events.js.map +1 -0
- package/dist/physics/joint.js +272 -0
- package/dist/physics/joint.js.map +1 -0
- package/dist/physics/node_physics.js +234 -0
- package/dist/physics/node_physics.js.map +1 -0
- package/dist/physics/part.js +91 -0
- package/dist/physics/part.js.map +1 -0
- package/dist/physics/rigid_body.js +379 -0
- package/dist/physics/rigid_body.js.map +1 -0
- package/dist/physics/vehicle.js +335 -0
- package/dist/physics/vehicle.js.map +1 -0
- package/dist/physics/world.js +25 -0
- package/dist/physics/world.js.map +1 -0
- package/dist/posteffect/bloom.js +49 -14
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/motionblur.js +106 -106
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +2 -6
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +605 -355
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +91 -162
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -11
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +4 -13
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js +1 -0
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +3 -2
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +179 -64
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +958 -224
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +25 -5
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/debug_views.js +37 -0
- package/dist/render/debug_views.js.map +1 -0
- package/dist/render/depthpass.js +5 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +53 -6
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +5 -5
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +196 -113
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +5 -10
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +247 -157
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +16 -38
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/gi/probe_volume.js +1334 -0
- package/dist/render/gi/probe_volume.js.map +1 -0
- package/dist/render/gi/scene_gi.js +282 -0
- package/dist/render/gi/scene_gi.js.map +1 -0
- package/dist/render/gi/voxel_atlas.js +198 -0
- package/dist/render/gi/voxel_atlas.js.map +1 -0
- package/dist/render/gi/voxel_lighting.js +652 -0
- package/dist/render/gi/voxel_lighting.js.map +1 -0
- package/dist/render/gi/voxel_scene.js +642 -0
- package/dist/render/gi/voxel_scene.js.map +1 -0
- package/dist/render/gi/voxelize_pass.js +223 -0
- package/dist/render/gi/voxelize_pass.js.map +1 -0
- package/dist/render/globalbindgroup_allocator.js +3 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/gpu_picking.js +9 -36
- package/dist/render/gpu_picking.js.map +1 -1
- package/dist/render/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +19 -8
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/lod.js +46 -0
- package/dist/render/lod.js.map +1 -0
- package/dist/render/primitive.js +301 -9
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/primitive_readback.js +209 -0
- package/dist/render/primitive_readback.js.map +1 -0
- package/dist/render/render_queue.js +162 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +10 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +14 -1
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/executor.js +136 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +272 -55
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_graph_context.js +41 -0
- package/dist/render/rendergraph/frame_graph_context.js.map +1 -0
- package/dist/render/rendergraph/scene_render_context.js +31 -2
- package/dist/render/rendergraph/scene_render_context.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +28 -5
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sdf/box_allocator.js +98 -0
- package/dist/render/sdf/box_allocator.js.map +1 -0
- package/dist/render/sdf/global_sdf.js +865 -0
- package/dist/render/sdf/global_sdf.js.map +1 -0
- package/dist/render/sdf/scene_sdf.js +562 -0
- package/dist/render/sdf/scene_sdf.js.map +1 -0
- package/dist/render/sdf/sdf_atlas.js +227 -0
- package/dist/render/sdf/sdf_atlas.js.map +1 -0
- package/dist/render/sdf/sdf_programs.js +42 -0
- package/dist/render/sdf/sdf_programs.js.map +1 -0
- package/dist/render/sdf/sdf_view.js +199 -0
- package/dist/render/sdf/sdf_view.js.map +1 -0
- package/dist/render/sdf/waterline.js +610 -0
- package/dist/render/sdf/waterline.js.map +1 -0
- package/dist/render/shadow_mask_pass.js +142 -25
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/shore_wave_generator.js +1193 -0
- package/dist/render/shore_wave_generator.js.map +1 -0
- package/dist/render/sky.js +516 -86
- package/dist/render/sky.js.map +1 -1
- package/dist/render/transmission_thickness_pass.js +477 -0
- package/dist/render/transmission_thickness_pass.js.map +1 -0
- package/dist/render/underwater.js +58 -158
- package/dist/render/underwater.js.map +1 -1
- package/dist/render/virtualtexture/virtual_texture.js +1214 -0
- package/dist/render/virtualtexture/virtual_texture.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_common.js +472 -0
- package/dist/render/volumetric_cloud/cloud_common.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_noise.js +189 -0
- package/dist/render/volumetric_cloud/cloud_noise.js.map +1 -0
- package/dist/render/volumetric_cloud/debug_view.js +131 -0
- package/dist/render/volumetric_cloud/debug_view.js.map +1 -0
- package/dist/render/volumetric_cloud/resources.js +380 -0
- package/dist/render/volumetric_cloud/resources.js.map +1 -0
- package/dist/render/volumetric_cloud/sky_cache.js +380 -0
- package/dist/render/volumetric_cloud/sky_cache.js.map +1 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js +318 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js.map +1 -0
- package/dist/render/water_caustics.js +134 -319
- package/dist/render/water_caustics.js.map +1 -1
- package/dist/render/water_foam.js +627 -0
- package/dist/render/water_foam.js.map +1 -0
- package/dist/render/water_interaction.js +1795 -0
- package/dist/render/water_interaction.js.map +1 -0
- package/dist/render/weightedblended_oit.js +3 -3
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +9 -4
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +108 -12
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +28 -7
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/foliage.js +1020 -0
- package/dist/scene/foliage.js.map +1 -0
- package/dist/scene/foliage_buckets.js +147 -0
- package/dist/scene/foliage_buckets.js.map +1 -0
- package/dist/scene/foliage_mask.js +358 -0
- package/dist/scene/foliage_mask.js.map +1 -0
- package/dist/scene/hair.js +15 -4
- package/dist/scene/hair.js.map +1 -1
- package/dist/scene/light.js +179 -13
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +327 -45
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +9 -3
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +9 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +8 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/physics_settings.js +157 -0
- package/dist/scene/physics_settings.js.map +1 -0
- package/dist/scene/scene.js +190 -44
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +147 -6
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/bladegrassmaterial.js +735 -0
- package/dist/scene/terrain-cm/bladegrassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +881 -42
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grass_gpu.js +929 -0
- package/dist/scene/terrain-cm/grass_gpu.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +180 -9
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +465 -36
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/terrain_gi_albedo.js +257 -0
- package/dist/scene/terrain-cm/terrain_gi_albedo.js.map +1 -0
- package/dist/scene/terrain-cm/terrain_rvt.js +395 -0
- package/dist/scene/terrain-cm/terrain_rvt.js.map +1 -0
- package/dist/scene/update_queue.js +54 -0
- package/dist/scene/update_queue.js.map +1 -0
- package/dist/scene/water.js +633 -268
- package/dist/scene/water.js.map +1 -1
- package/dist/scene/water_surface_sampler.js +324 -0
- package/dist/scene/water_surface_sampler.js.map +1 -0
- package/dist/scene/wind.js +317 -0
- package/dist/scene/wind.js.map +1 -0
- package/dist/shaders/atmosphere.js +388 -166
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/fog.js +100 -32
- package/dist/shaders/fog.js.map +1 -1
- package/dist/shaders/gi.js +365 -0
- package/dist/shaders/gi.js.map +1 -0
- package/dist/shaders/ltc_rect.js +202 -0
- package/dist/shaders/ltc_rect.js.map +1 -0
- package/dist/shaders/misc.js +1 -10
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +5 -1
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/probes.js +309 -0
- package/dist/shaders/probes.js.map +1 -0
- package/dist/shaders/sdf.js +537 -0
- package/dist/shaders/sdf.js.map +1 -0
- package/dist/shaders/shadow.js +104 -70
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/skin_brdf.js +243 -0
- package/dist/shaders/skin_brdf.js.map +1 -0
- package/dist/shaders/ssgi.js +63 -0
- package/dist/shaders/ssgi.js.map +1 -0
- package/dist/shaders/ssgi_reprojection.js +118 -0
- package/dist/shaders/ssgi_reprojection.js.map +1 -0
- package/dist/shaders/ssr.js +6 -159
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +38 -27
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +32 -82
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +7 -21
- package/dist/shaders/water_medium.js.map +1 -1
- package/dist/shadow/dom.js +110 -19
- package/dist/shadow/dom.js.map +1 -1
- package/dist/shadow/esm.js +3 -3
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +15 -48
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +15 -53
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/pcss.js +34 -9
- package/dist/shadow/pcss.js.map +1 -1
- package/dist/shadow/shadow_impl.js +3 -8
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +40 -2
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +93 -53
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +18 -72
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +3 -3
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/shape.js +44 -1
- package/dist/shapes/shape.js.map +1 -1
- package/dist/utility/buoyancy.js +287 -0
- package/dist/utility/buoyancy.js.map +1 -0
- package/dist/utility/physical.js +10 -1
- package/dist/utility/physical.js.map +1 -1
- package/dist/utility/pmrem.js +17 -43
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/sdf/bake.js +435 -0
- package/dist/utility/sdf/bake.js.map +1 -0
- package/dist/utility/sdf/bvh.js +576 -0
- package/dist/utility/sdf/bvh.js.map +1 -0
- package/dist/utility/serialization/manager.js +34 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +46 -5
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +11 -4
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +87 -254
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth.js +25 -0
- package/dist/utility/serialization/scene/cloth.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +14 -6
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/foliage.js +821 -0
- package/dist/utility/serialization/scene/foliage.js.map +1 -0
- package/dist/utility/serialization/scene/hair.js +11 -4
- package/dist/utility/serialization/scene/hair.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +115 -7
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +388 -220
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +69 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +140 -5
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/node_physics.js +1318 -0
- package/dist/utility/serialization/scene/node_physics.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +11 -4
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/physics.js +120 -0
- package/dist/utility/serialization/scene/physics.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +124 -10
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +1687 -51
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +11 -4
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +163 -33
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +11 -4
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +1543 -264
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +10 -22
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/utility/textures/foam.js +170 -0
- package/dist/utility/textures/foam.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +17 -43
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +4 -4
- package/dist/utility/textures/ltcdata.js.map +1 -1
- package/dist/utility/textures/ltclut.js +16 -6
- package/dist/utility/textures/ltclut.js.map +1 -1
- package/dist/utility/unsupported.js +24 -0
- package/dist/utility/unsupported.js.map +1 -0
- package/dist/values.js +13 -1
- package/dist/values.js.map +1 -1
- package/package.json +25 -12
- package/src/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/src/asset/meshoptimizer/LICENSE +21 -0
- package/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Vector3, Quaternion } from '@zephyr3d/base';
|
|
2
2
|
import { IKUtils } from '../ik/ik_utils.js';
|
|
3
|
-
import { updateColliderFromNode, resolveSphereCollision, resolveCapsuleCollision, resolvePlaneCollision } from './spring_collider.js';
|
|
3
|
+
import { updateColliderFromNode, resolveSphereCollision, resolveCapsuleCollision, resolvePlaneCollision, resolveBoxCollision } from './spring_collider.js';
|
|
4
4
|
import { SpringNodePoseTracker } from './spring_node_pose_tracker.js';
|
|
5
|
+
import { DEFAULT_INITIAL_COLLISION_PENETRATION_RELEASE_TIME, getSpringPoseTopology, getKawaiiPoseTarget, interpolateSpringValue, solveAngleLimit, resolveInelasticCollision, solveDistanceConstraint, measureCollisionPenetration, INITIAL_COLLISION_PENETRATION_SLOP, getReleasedCollisionPenetration, getIterationStrength } from './spring_solver.js';
|
|
5
6
|
|
|
6
7
|
const FIXED_SIMULATION_TIME_STEP = 1 / 60;
|
|
7
8
|
const MAX_ACCUMULATED_SIMULATION_TIME = 1 / 20;
|
|
@@ -31,10 +32,19 @@ class MultiChainSpringSystem {
|
|
|
31
32
|
_smoothedSphereCenters;
|
|
32
33
|
_smoothedCapsuleEndpoints;
|
|
33
34
|
_smoothedPlaneData;
|
|
35
|
+
_smoothedBoxData;
|
|
34
36
|
_runtimeNodeMap;
|
|
35
37
|
_runtimeAnchorOffsets;
|
|
36
38
|
_runtimeRestLengths;
|
|
37
39
|
_nodePoseTracker;
|
|
40
|
+
_motionModel;
|
|
41
|
+
_angleLimitRoot;
|
|
42
|
+
_angleLimitTip;
|
|
43
|
+
_constraintVelocityHistoryRetention;
|
|
44
|
+
_preserveInitialCollisionPenetration;
|
|
45
|
+
_initialCollisionPenetrationReleaseTime;
|
|
46
|
+
_initialCollisionPenetrationElapsed;
|
|
47
|
+
_initialCollisionPenetration;
|
|
38
48
|
constructor(options){
|
|
39
49
|
this._chains = [];
|
|
40
50
|
this._interChainConstraints = [];
|
|
@@ -58,10 +68,19 @@ class MultiChainSpringSystem {
|
|
|
58
68
|
this._smoothedSphereCenters = new WeakMap();
|
|
59
69
|
this._smoothedCapsuleEndpoints = new WeakMap();
|
|
60
70
|
this._smoothedPlaneData = new WeakMap();
|
|
71
|
+
this._smoothedBoxData = new WeakMap();
|
|
61
72
|
this._runtimeNodeMap = null;
|
|
62
73
|
this._runtimeAnchorOffsets = new WeakMap();
|
|
63
74
|
this._runtimeRestLengths = new WeakMap();
|
|
64
75
|
this._nodePoseTracker = new SpringNodePoseTracker();
|
|
76
|
+
this._motionModel = options?.motionModel ?? 'kawaii';
|
|
77
|
+
this._angleLimitRoot = Math.max(0, options?.angleLimitRoot ?? 0);
|
|
78
|
+
this._angleLimitTip = Math.max(0, options?.angleLimitTip ?? this._angleLimitRoot);
|
|
79
|
+
this._constraintVelocityHistoryRetention = Math.max(0, Math.min(1, options?.constraintVelocityHistoryRetention ?? 0.35));
|
|
80
|
+
this._preserveInitialCollisionPenetration = options?.preserveInitialCollisionPenetration ?? this._motionModel === 'kawaii';
|
|
81
|
+
this._initialCollisionPenetrationReleaseTime = Math.max(0, options?.initialCollisionPenetrationReleaseTime ?? DEFAULT_INITIAL_COLLISION_PENETRATION_RELEASE_TIME);
|
|
82
|
+
this._initialCollisionPenetrationElapsed = 0;
|
|
83
|
+
this._initialCollisionPenetration = new WeakMap();
|
|
65
84
|
}
|
|
66
85
|
addChain(chain) {
|
|
67
86
|
this._chains.push(chain);
|
|
@@ -113,7 +132,7 @@ class MultiChainSpringSystem {
|
|
|
113
132
|
}
|
|
114
133
|
this._timeAccumulator = Math.max(0, this._timeAccumulator - stepCount * FIXED_SIMULATION_TIME_STEP);
|
|
115
134
|
for(let i = 0; i < stepCount; i++){
|
|
116
|
-
this.simulateStep(FIXED_SIMULATION_TIME_STEP, i === 0 ? frameDt : 0);
|
|
135
|
+
this.simulateStep(FIXED_SIMULATION_TIME_STEP, i === 0 ? frameDt : 0, i, stepCount);
|
|
117
136
|
}
|
|
118
137
|
}
|
|
119
138
|
applyToNodes(weight = 1.0) {
|
|
@@ -164,6 +183,9 @@ class MultiChainSpringSystem {
|
|
|
164
183
|
this._smoothedSphereCenters = new WeakMap();
|
|
165
184
|
this._smoothedCapsuleEndpoints = new WeakMap();
|
|
166
185
|
this._smoothedPlaneData = new WeakMap();
|
|
186
|
+
this._smoothedBoxData = new WeakMap();
|
|
187
|
+
this._initialCollisionPenetrationElapsed = 0;
|
|
188
|
+
this._initialCollisionPenetration = new WeakMap();
|
|
167
189
|
}
|
|
168
190
|
get chains() {
|
|
169
191
|
return this._chains;
|
|
@@ -218,6 +240,57 @@ class MultiChainSpringSystem {
|
|
|
218
240
|
}
|
|
219
241
|
}
|
|
220
242
|
}
|
|
243
|
+
get motionModel() {
|
|
244
|
+
return this._motionModel;
|
|
245
|
+
}
|
|
246
|
+
set motionModel(value) {
|
|
247
|
+
if (value !== 'legacy' && value !== 'kawaii') {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (this._motionModel !== value) {
|
|
251
|
+
this._motionModel = value;
|
|
252
|
+
this.reset();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
get angleLimitRoot() {
|
|
256
|
+
return this._angleLimitRoot;
|
|
257
|
+
}
|
|
258
|
+
set angleLimitRoot(value) {
|
|
259
|
+
this._angleLimitRoot = Math.max(0, Number(value) || 0);
|
|
260
|
+
}
|
|
261
|
+
get angleLimitTip() {
|
|
262
|
+
return this._angleLimitTip;
|
|
263
|
+
}
|
|
264
|
+
set angleLimitTip(value) {
|
|
265
|
+
this._angleLimitTip = Math.max(0, Number(value) || 0);
|
|
266
|
+
}
|
|
267
|
+
get constraintVelocityHistoryRetention() {
|
|
268
|
+
return this._constraintVelocityHistoryRetention;
|
|
269
|
+
}
|
|
270
|
+
set constraintVelocityHistoryRetention(value) {
|
|
271
|
+
this._constraintVelocityHistoryRetention = Math.max(0, Math.min(1, Number(value) || 0));
|
|
272
|
+
}
|
|
273
|
+
get preserveInitialCollisionPenetration() {
|
|
274
|
+
return this._preserveInitialCollisionPenetration;
|
|
275
|
+
}
|
|
276
|
+
set preserveInitialCollisionPenetration(value) {
|
|
277
|
+
if (this._preserveInitialCollisionPenetration !== value) {
|
|
278
|
+
this._preserveInitialCollisionPenetration = value;
|
|
279
|
+
this._initialCollisionPenetrationElapsed = 0;
|
|
280
|
+
this._initialCollisionPenetration = new WeakMap();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
get initialCollisionPenetrationReleaseTime() {
|
|
284
|
+
return this._initialCollisionPenetrationReleaseTime;
|
|
285
|
+
}
|
|
286
|
+
set initialCollisionPenetrationReleaseTime(value) {
|
|
287
|
+
const duration = Math.max(0, Number(value) || 0);
|
|
288
|
+
if (this._initialCollisionPenetrationReleaseTime !== duration) {
|
|
289
|
+
this._initialCollisionPenetrationReleaseTime = duration;
|
|
290
|
+
this._initialCollisionPenetrationElapsed = 0;
|
|
291
|
+
this._initialCollisionPenetration = new WeakMap();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
221
294
|
get poseFollow() {
|
|
222
295
|
return this._poseFollow;
|
|
223
296
|
}
|
|
@@ -271,6 +344,9 @@ class MultiChainSpringSystem {
|
|
|
271
344
|
this._smoothedSphereCenters = new WeakMap();
|
|
272
345
|
this._smoothedCapsuleEndpoints = new WeakMap();
|
|
273
346
|
this._smoothedPlaneData = new WeakMap();
|
|
347
|
+
this._smoothedBoxData = new WeakMap();
|
|
348
|
+
this._initialCollisionPenetrationElapsed = 0;
|
|
349
|
+
this._initialCollisionPenetration = new WeakMap();
|
|
274
350
|
}
|
|
275
351
|
removeCollider(collider) {
|
|
276
352
|
const index = this._colliders.indexOf(collider);
|
|
@@ -279,6 +355,9 @@ class MultiChainSpringSystem {
|
|
|
279
355
|
this._smoothedSphereCenters = new WeakMap();
|
|
280
356
|
this._smoothedCapsuleEndpoints = new WeakMap();
|
|
281
357
|
this._smoothedPlaneData = new WeakMap();
|
|
358
|
+
this._smoothedBoxData = new WeakMap();
|
|
359
|
+
this._initialCollisionPenetrationElapsed = 0;
|
|
360
|
+
this._initialCollisionPenetration = new WeakMap();
|
|
282
361
|
return true;
|
|
283
362
|
}
|
|
284
363
|
return false;
|
|
@@ -288,6 +367,9 @@ class MultiChainSpringSystem {
|
|
|
288
367
|
this._smoothedSphereCenters = new WeakMap();
|
|
289
368
|
this._smoothedCapsuleEndpoints = new WeakMap();
|
|
290
369
|
this._smoothedPlaneData = new WeakMap();
|
|
370
|
+
this._smoothedBoxData = new WeakMap();
|
|
371
|
+
this._initialCollisionPenetrationElapsed = 0;
|
|
372
|
+
this._initialCollisionPenetration = new WeakMap();
|
|
291
373
|
}
|
|
292
374
|
get colliders() {
|
|
293
375
|
return this._colliders;
|
|
@@ -357,7 +439,7 @@ class MultiChainSpringSystem {
|
|
|
357
439
|
}
|
|
358
440
|
this.clearRuntimeCaches();
|
|
359
441
|
}
|
|
360
|
-
simulateStep(dt, inputDeltaTime) {
|
|
442
|
+
simulateStep(dt, inputDeltaTime, stepIndex, stepCount) {
|
|
361
443
|
if (this._enableInertialForces) {
|
|
362
444
|
for (const chain of this._chains){
|
|
363
445
|
for (const particle of chain.particles){
|
|
@@ -365,7 +447,8 @@ class MultiChainSpringSystem {
|
|
|
365
447
|
}
|
|
366
448
|
}
|
|
367
449
|
}
|
|
368
|
-
|
|
450
|
+
const substepBlend = 1 / Math.max(1, stepCount - stepIndex);
|
|
451
|
+
this.updateFixedParticles(inputDeltaTime, substepBlend);
|
|
369
452
|
let rotationCenter = null;
|
|
370
453
|
let angularVelocity = null;
|
|
371
454
|
if (this._enableInertialForces && dt > 0.0001) {
|
|
@@ -394,9 +477,14 @@ class MultiChainSpringSystem {
|
|
|
394
477
|
if (this._solver === 'xpbd') {
|
|
395
478
|
this.resetConstraintLambdas();
|
|
396
479
|
}
|
|
480
|
+
if (this._motionModel === 'kawaii') {
|
|
481
|
+
this.solvePosePreservation(1, true);
|
|
482
|
+
}
|
|
397
483
|
for(let iter = 0; iter < this._iterations; iter++){
|
|
398
484
|
for (const chain of this._chains){
|
|
399
|
-
|
|
485
|
+
const reverse = this._motionModel === 'kawaii' && !!(iter & 1);
|
|
486
|
+
for(let constraintIndex = 0; constraintIndex < chain.constraints.length; constraintIndex++){
|
|
487
|
+
const constraint = chain.constraints[reverse ? chain.constraints.length - 1 - constraintIndex : constraintIndex];
|
|
400
488
|
if (this._solver === 'xpbd') {
|
|
401
489
|
this.solveConstraintXPBD(chain, constraint, dt);
|
|
402
490
|
} else {
|
|
@@ -404,19 +492,74 @@ class MultiChainSpringSystem {
|
|
|
404
492
|
}
|
|
405
493
|
}
|
|
406
494
|
}
|
|
407
|
-
|
|
495
|
+
const reverse = this._motionModel === 'kawaii' && !!(iter & 1);
|
|
496
|
+
for(let constraintIndex = 0; constraintIndex < this._interChainConstraints.length; constraintIndex++){
|
|
497
|
+
const constraint = this._interChainConstraints[reverse ? this._interChainConstraints.length - 1 - constraintIndex : constraintIndex];
|
|
408
498
|
if (this._solver === 'xpbd') {
|
|
409
499
|
this.solveInterChainConstraintXPBD(constraint, dt);
|
|
410
500
|
} else {
|
|
411
501
|
this.solveInterChainConstraint(constraint);
|
|
412
502
|
}
|
|
413
503
|
}
|
|
414
|
-
|
|
415
|
-
|
|
504
|
+
if (this._motionModel === 'legacy') {
|
|
505
|
+
this.solvePosePreservation(this._iterations, false);
|
|
506
|
+
this.solveCollisions(inputDeltaTime);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (this._motionModel === 'kawaii') {
|
|
510
|
+
this.solveCollisions(inputDeltaTime, substepBlend);
|
|
511
|
+
this.solveAngleLimits();
|
|
512
|
+
if (this._solver === 'xpbd') {
|
|
513
|
+
this.solveCollisions(0, 0);
|
|
514
|
+
this.resetConstraintLambdas();
|
|
515
|
+
const closureIterations = Math.min(16, Math.max(4, this._iterations));
|
|
516
|
+
for(let iteration = 0; iteration < closureIterations; iteration++){
|
|
517
|
+
const reverse = !!(iteration & 1);
|
|
518
|
+
for (const chain of this._chains){
|
|
519
|
+
for(let constraintIndex = 0; constraintIndex < chain.constraints.length; constraintIndex++){
|
|
520
|
+
const constraint = chain.constraints[reverse ? chain.constraints.length - 1 - constraintIndex : constraintIndex];
|
|
521
|
+
this.solveConstraintXPBD(chain, constraint, dt);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
for(let constraintIndex = 0; constraintIndex < this._interChainConstraints.length; constraintIndex++){
|
|
525
|
+
const constraint = this._interChainConstraints[reverse ? this._interChainConstraints.length - 1 - constraintIndex : constraintIndex];
|
|
526
|
+
this.solveInterChainConstraintXPBD(constraint, dt);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (this._colliders.some((collider)=>collider.enabled)) {
|
|
530
|
+
this.resetConstraintLambdas();
|
|
531
|
+
const contactClosureIterations = Math.min(4, closureIterations);
|
|
532
|
+
for(let iteration = 0; iteration < contactClosureIterations; iteration++){
|
|
533
|
+
const reverse = !!(iteration & 1);
|
|
534
|
+
for (const chain of this._chains){
|
|
535
|
+
for(let constraintIndex = 0; constraintIndex < chain.constraints.length; constraintIndex++){
|
|
536
|
+
const constraint = chain.constraints[reverse ? chain.constraints.length - 1 - constraintIndex : constraintIndex];
|
|
537
|
+
this.solveConstraintXPBD(chain, constraint, dt);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
for(let constraintIndex = 0; constraintIndex < this._interChainConstraints.length; constraintIndex++){
|
|
541
|
+
const constraint = this._interChainConstraints[reverse ? this._interChainConstraints.length - 1 - constraintIndex : constraintIndex];
|
|
542
|
+
this.solveInterChainConstraintXPBD(constraint, dt);
|
|
543
|
+
}
|
|
544
|
+
this.solveCollisions(0, 0);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
} else {
|
|
548
|
+
for (const chain of this._chains){
|
|
549
|
+
for (const constraint of chain.constraints){
|
|
550
|
+
this.solveConstraint(chain, constraint);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
for (const constraint of this._interChainConstraints){
|
|
554
|
+
this.solveInterChainConstraint(constraint);
|
|
555
|
+
}
|
|
556
|
+
this.solveCollisions(0, 0);
|
|
557
|
+
}
|
|
416
558
|
}
|
|
559
|
+
this.advanceInitialCollisionPenetrationRelease(dt);
|
|
417
560
|
}
|
|
418
|
-
updateFixedParticles(deltaTime) {
|
|
419
|
-
const blend = this.getTemporalBlendFactor(deltaTime, DEFAULT_PARTICLE_TARGET_SMOOTHING_TIME);
|
|
561
|
+
updateFixedParticles(deltaTime, substepBlend) {
|
|
562
|
+
const blend = this._motionModel === 'kawaii' ? substepBlend : this.getTemporalBlendFactor(deltaTime, DEFAULT_PARTICLE_TARGET_SMOOTHING_TIME);
|
|
420
563
|
for (const chain of this._chains){
|
|
421
564
|
for (const particle of chain.particles){
|
|
422
565
|
const sourceNode = this.resolveRuntimeNode(particle.anchorNode ?? particle.node);
|
|
@@ -443,40 +586,54 @@ class MultiChainSpringSystem {
|
|
|
443
586
|
}
|
|
444
587
|
}
|
|
445
588
|
}
|
|
446
|
-
solvePosePreservation(totalIterations) {
|
|
589
|
+
solvePosePreservation(totalIterations, parentRelative) {
|
|
447
590
|
if (this._poseFollowRoot <= 0 && this._poseFollowTip <= 0) {
|
|
448
591
|
return;
|
|
449
592
|
}
|
|
450
593
|
for (const chain of this._chains){
|
|
451
|
-
const
|
|
594
|
+
const topology = getSpringPoseTopology(chain.particles);
|
|
452
595
|
for(let i = 0; i < chain.particles.length; i++){
|
|
453
596
|
const particle = chain.particles[i];
|
|
454
597
|
if (particle.fixed) {
|
|
455
598
|
continue;
|
|
456
599
|
}
|
|
457
|
-
const t = Math.pow(i
|
|
600
|
+
const t = Math.pow(topology[i].normalizedDistance, this._poseFollowExponent);
|
|
458
601
|
const particlePoseFollow = this.lerp(this._poseFollowRoot, this._poseFollowTip, t);
|
|
459
|
-
const iterationFollow =
|
|
460
|
-
const
|
|
602
|
+
const iterationFollow = getIterationStrength(particlePoseFollow, totalIterations);
|
|
603
|
+
const poseTarget = parentRelative ? getKawaiiPoseTarget(particle, topology[i]) : particle.animPosition;
|
|
604
|
+
const toAnim = Vector3.sub(poseTarget, particle.position, new Vector3());
|
|
461
605
|
const correction = Vector3.scale(toAnim, iterationFollow, new Vector3());
|
|
462
606
|
Vector3.add(particle.position, correction, particle.position);
|
|
463
607
|
const particleMaxPoseOffset = this.lerp(this._maxPoseOffsetRoot, this._maxPoseOffsetTip, t);
|
|
464
608
|
if (particleMaxPoseOffset > 0) {
|
|
465
|
-
const offset = Vector3.sub(particle.position,
|
|
609
|
+
const offset = Vector3.sub(particle.position, poseTarget, new Vector3());
|
|
466
610
|
const offsetLen = offset.magnitude;
|
|
467
611
|
if (offsetLen > particleMaxPoseOffset && offsetLen > 1e-6) {
|
|
468
612
|
offset.scaleBy(particleMaxPoseOffset / offsetLen);
|
|
469
|
-
Vector3.add(
|
|
613
|
+
Vector3.add(poseTarget, offset, particle.position);
|
|
470
614
|
}
|
|
471
615
|
}
|
|
472
616
|
}
|
|
473
617
|
}
|
|
474
618
|
}
|
|
475
|
-
|
|
476
|
-
|
|
619
|
+
solveAngleLimits() {
|
|
620
|
+
if (this._angleLimitRoot <= 0 && this._angleLimitTip <= 0) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
for (const chain of this._chains){
|
|
624
|
+
const particles = chain.particles;
|
|
625
|
+
for(let i = 1; i < particles.length; i++){
|
|
626
|
+
const limit = interpolateSpringValue(this._angleLimitRoot, this._angleLimitTip, this._poseFollowExponent, i, particles.length);
|
|
627
|
+
solveAngleLimit(particles[i - 1], particles[i], limit, this._solver === 'xpbd');
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
solveCollisions(deltaTime, blendOverride) {
|
|
632
|
+
const blend = blendOverride ?? this.getTemporalBlendFactor(deltaTime, DEFAULT_COLLIDER_SMOOTHING_TIME);
|
|
477
633
|
const spheres = [];
|
|
478
634
|
const capsules = [];
|
|
479
635
|
const planes = [];
|
|
636
|
+
const boxes = [];
|
|
480
637
|
for (const collider of this._colliders){
|
|
481
638
|
const colliderNode = this.resolveRuntimeNode(collider.node);
|
|
482
639
|
if (colliderNode) {
|
|
@@ -490,8 +647,11 @@ class MultiChainSpringSystem {
|
|
|
490
647
|
{
|
|
491
648
|
const source = collider;
|
|
492
649
|
spheres.push({
|
|
493
|
-
|
|
494
|
-
|
|
650
|
+
source,
|
|
651
|
+
collider: {
|
|
652
|
+
...source,
|
|
653
|
+
center: this.getSmoothedSphereCenter(source, blend)
|
|
654
|
+
}
|
|
495
655
|
});
|
|
496
656
|
break;
|
|
497
657
|
}
|
|
@@ -500,9 +660,12 @@ class MultiChainSpringSystem {
|
|
|
500
660
|
const source = collider;
|
|
501
661
|
const endpoints = this.getSmoothedCapsuleEndpoints(source, blend);
|
|
502
662
|
capsules.push({
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
663
|
+
source,
|
|
664
|
+
collider: {
|
|
665
|
+
...source,
|
|
666
|
+
start: endpoints.start,
|
|
667
|
+
end: endpoints.end
|
|
668
|
+
}
|
|
506
669
|
});
|
|
507
670
|
break;
|
|
508
671
|
}
|
|
@@ -511,9 +674,24 @@ class MultiChainSpringSystem {
|
|
|
511
674
|
const source = collider;
|
|
512
675
|
const plane = this.getSmoothedPlaneData(source, blend);
|
|
513
676
|
planes.push({
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
677
|
+
source,
|
|
678
|
+
collider: {
|
|
679
|
+
...source,
|
|
680
|
+
point: plane.point,
|
|
681
|
+
normal: plane.normal
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
break;
|
|
685
|
+
}
|
|
686
|
+
case 'box':
|
|
687
|
+
{
|
|
688
|
+
const source = collider;
|
|
689
|
+
boxes.push({
|
|
690
|
+
source,
|
|
691
|
+
collider: {
|
|
692
|
+
...source,
|
|
693
|
+
...this.getSmoothedBoxData(source, blend)
|
|
694
|
+
}
|
|
517
695
|
});
|
|
518
696
|
break;
|
|
519
697
|
}
|
|
@@ -524,19 +702,33 @@ class MultiChainSpringSystem {
|
|
|
524
702
|
if (particle.fixed) {
|
|
525
703
|
continue;
|
|
526
704
|
}
|
|
527
|
-
const positionBeforeCollision = particle.position.clone();
|
|
528
|
-
let collided = false;
|
|
529
705
|
for (const collider of spheres){
|
|
530
|
-
|
|
706
|
+
if (this._motionModel === 'kawaii') {
|
|
707
|
+
resolveInelasticCollision(particle, collider.collider, resolveSphereCollision, this.getInitialCollisionPenetration(particle, collider.source, collider.collider, resolveSphereCollision));
|
|
708
|
+
} else {
|
|
709
|
+
resolveSphereCollision(particle.position, collider.collider, particle.collisionRadius);
|
|
710
|
+
}
|
|
531
711
|
}
|
|
532
712
|
for (const collider of capsules){
|
|
533
|
-
|
|
713
|
+
if (this._motionModel === 'kawaii') {
|
|
714
|
+
resolveInelasticCollision(particle, collider.collider, resolveCapsuleCollision, this.getInitialCollisionPenetration(particle, collider.source, collider.collider, resolveCapsuleCollision));
|
|
715
|
+
} else {
|
|
716
|
+
resolveCapsuleCollision(particle.position, collider.collider, particle.collisionRadius);
|
|
717
|
+
}
|
|
534
718
|
}
|
|
535
719
|
for (const collider of planes){
|
|
536
|
-
|
|
720
|
+
if (this._motionModel === 'kawaii') {
|
|
721
|
+
resolveInelasticCollision(particle, collider.collider, resolvePlaneCollision, this.getInitialCollisionPenetration(particle, collider.source, collider.collider, resolvePlaneCollision));
|
|
722
|
+
} else {
|
|
723
|
+
resolvePlaneCollision(particle.position, collider.collider, particle.collisionRadius);
|
|
724
|
+
}
|
|
537
725
|
}
|
|
538
|
-
|
|
539
|
-
|
|
726
|
+
for (const collider of boxes){
|
|
727
|
+
if (this._motionModel === 'kawaii') {
|
|
728
|
+
resolveInelasticCollision(particle, collider.collider, resolveBoxCollision, this.getInitialCollisionPenetration(particle, collider.source, collider.collider, resolveBoxCollision));
|
|
729
|
+
} else {
|
|
730
|
+
resolveBoxCollision(particle.position, collider.collider, particle.collisionRadius);
|
|
731
|
+
}
|
|
540
732
|
}
|
|
541
733
|
}
|
|
542
734
|
}
|
|
@@ -657,6 +849,10 @@ class MultiChainSpringSystem {
|
|
|
657
849
|
solveConstraint(chain, constraint) {
|
|
658
850
|
const pA = chain.particles[constraint.particleA];
|
|
659
851
|
const pB = chain.particles[constraint.particleB];
|
|
852
|
+
if (this._motionModel === 'kawaii') {
|
|
853
|
+
solveDistanceConstraint(pA, pB, this.getRuntimeRestLength(constraint), constraint.stiffness);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
660
856
|
const delta = Vector3.sub(pB.position, pA.position, new Vector3());
|
|
661
857
|
const currentLength = delta.magnitude;
|
|
662
858
|
if (currentLength < 0.0001) {
|
|
@@ -676,6 +872,10 @@ class MultiChainSpringSystem {
|
|
|
676
872
|
const chainB = this._chains[constraint.chainBIndex];
|
|
677
873
|
const pA = chainA.particles[constraint.particleAIndex];
|
|
678
874
|
const pB = chainB.particles[constraint.particleBIndex];
|
|
875
|
+
if (this._motionModel === 'kawaii') {
|
|
876
|
+
solveDistanceConstraint(pA, pB, this.getRuntimeRestLength(constraint), constraint.stiffness);
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
679
879
|
const delta = Vector3.sub(pB.position, pA.position, new Vector3());
|
|
680
880
|
const currentLength = delta.magnitude;
|
|
681
881
|
if (currentLength < 0.0001) {
|
|
@@ -710,10 +910,18 @@ class MultiChainSpringSystem {
|
|
|
710
910
|
constraint.lambda += deltaLambda;
|
|
711
911
|
const n = Vector3.scale(delta, 1.0 / currentLength, new Vector3());
|
|
712
912
|
if (!pA.fixed) {
|
|
713
|
-
|
|
913
|
+
const correction = Vector3.scale(n, -wA * deltaLambda, new Vector3());
|
|
914
|
+
Vector3.add(pA.position, correction, pA.position);
|
|
915
|
+
if (this._motionModel === 'kawaii') {
|
|
916
|
+
Vector3.add(pA.prevPosition, Vector3.scale(correction, this._constraintVelocityHistoryRetention, new Vector3()), pA.prevPosition);
|
|
917
|
+
}
|
|
714
918
|
}
|
|
715
919
|
if (!pB.fixed) {
|
|
716
|
-
|
|
920
|
+
const correction = Vector3.scale(n, wB * deltaLambda, new Vector3());
|
|
921
|
+
Vector3.add(pB.position, correction, pB.position);
|
|
922
|
+
if (this._motionModel === 'kawaii') {
|
|
923
|
+
Vector3.add(pB.prevPosition, Vector3.scale(correction, this._constraintVelocityHistoryRetention, new Vector3()), pB.prevPosition);
|
|
924
|
+
}
|
|
717
925
|
}
|
|
718
926
|
}
|
|
719
927
|
solveInterChainConstraintXPBD(constraint, dt) {
|
|
@@ -738,10 +946,18 @@ class MultiChainSpringSystem {
|
|
|
738
946
|
constraint.lambda += deltaLambda;
|
|
739
947
|
const n = Vector3.scale(delta, 1.0 / currentLength, new Vector3());
|
|
740
948
|
if (!pA.fixed) {
|
|
741
|
-
|
|
949
|
+
const correction = Vector3.scale(n, -wA * deltaLambda, new Vector3());
|
|
950
|
+
Vector3.add(pA.position, correction, pA.position);
|
|
951
|
+
if (this._motionModel === 'kawaii') {
|
|
952
|
+
Vector3.add(pA.prevPosition, Vector3.scale(correction, this._constraintVelocityHistoryRetention, new Vector3()), pA.prevPosition);
|
|
953
|
+
}
|
|
742
954
|
}
|
|
743
955
|
if (!pB.fixed) {
|
|
744
|
-
|
|
956
|
+
const correction = Vector3.scale(n, wB * deltaLambda, new Vector3());
|
|
957
|
+
Vector3.add(pB.position, correction, pB.position);
|
|
958
|
+
if (this._motionModel === 'kawaii') {
|
|
959
|
+
Vector3.add(pB.prevPosition, Vector3.scale(correction, this._constraintVelocityHistoryRetention, new Vector3()), pB.prevPosition);
|
|
960
|
+
}
|
|
745
961
|
}
|
|
746
962
|
}
|
|
747
963
|
collectChainNodeRotations(chain, weight, baseNodeStates, desiredWorldRotations) {
|
|
@@ -830,6 +1046,31 @@ class MultiChainSpringSystem {
|
|
|
830
1046
|
this._smoothedSphereCenters = new WeakMap();
|
|
831
1047
|
this._smoothedCapsuleEndpoints = new WeakMap();
|
|
832
1048
|
this._smoothedPlaneData = new WeakMap();
|
|
1049
|
+
this._smoothedBoxData = new WeakMap();
|
|
1050
|
+
this._initialCollisionPenetrationElapsed = 0;
|
|
1051
|
+
this._initialCollisionPenetration = new WeakMap();
|
|
1052
|
+
}
|
|
1053
|
+
getInitialCollisionPenetration(particle, sourceCollider, collider, resolveCollision) {
|
|
1054
|
+
if (!this._preserveInitialCollisionPenetration) {
|
|
1055
|
+
return 0;
|
|
1056
|
+
}
|
|
1057
|
+
let particlePenetrations = this._initialCollisionPenetration.get(particle);
|
|
1058
|
+
if (!particlePenetrations) {
|
|
1059
|
+
particlePenetrations = new WeakMap();
|
|
1060
|
+
this._initialCollisionPenetration.set(particle, particlePenetrations);
|
|
1061
|
+
}
|
|
1062
|
+
let penetration = particlePenetrations.get(sourceCollider);
|
|
1063
|
+
if (penetration === undefined) {
|
|
1064
|
+
penetration = measureCollisionPenetration(particle.animPosition, collider, resolveCollision, particle.collisionRadius) + INITIAL_COLLISION_PENETRATION_SLOP;
|
|
1065
|
+
particlePenetrations.set(sourceCollider, penetration);
|
|
1066
|
+
}
|
|
1067
|
+
return getReleasedCollisionPenetration(penetration, this._initialCollisionPenetrationElapsed, this._initialCollisionPenetrationReleaseTime);
|
|
1068
|
+
}
|
|
1069
|
+
advanceInitialCollisionPenetrationRelease(deltaTime) {
|
|
1070
|
+
if (!this._preserveInitialCollisionPenetration) {
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
this._initialCollisionPenetrationElapsed = Math.min(this._initialCollisionPenetrationReleaseTime, this._initialCollisionPenetrationElapsed + Math.max(0, deltaTime));
|
|
833
1074
|
}
|
|
834
1075
|
lerp(a, b, t) {
|
|
835
1076
|
return a + (b - a) * t;
|
|
@@ -897,6 +1138,25 @@ class MultiChainSpringSystem {
|
|
|
897
1138
|
cached.normal.inplaceNormalize();
|
|
898
1139
|
return cached;
|
|
899
1140
|
}
|
|
1141
|
+
getSmoothedBoxData(collider, blend) {
|
|
1142
|
+
const current = {
|
|
1143
|
+
center: collider.center.clone(),
|
|
1144
|
+
halfExtents: collider.halfExtents.clone(),
|
|
1145
|
+
axes: collider.axes.map((axis)=>axis.clone())
|
|
1146
|
+
};
|
|
1147
|
+
const cached = this._smoothedBoxData.get(collider);
|
|
1148
|
+
if (!cached || blend >= 1) {
|
|
1149
|
+
this._smoothedBoxData.set(collider, current);
|
|
1150
|
+
return current;
|
|
1151
|
+
}
|
|
1152
|
+
Vector3.lerp(cached.center, current.center, blend, cached.center);
|
|
1153
|
+
Vector3.lerp(cached.halfExtents, current.halfExtents, blend, cached.halfExtents);
|
|
1154
|
+
for(let i = 0; i < 3; i++){
|
|
1155
|
+
Vector3.lerp(cached.axes[i], current.axes[i], blend, cached.axes[i]);
|
|
1156
|
+
cached.axes[i].inplaceNormalize();
|
|
1157
|
+
}
|
|
1158
|
+
return cached;
|
|
1159
|
+
}
|
|
900
1160
|
}
|
|
901
1161
|
|
|
902
1162
|
export { MultiChainSpringSystem };
|