@zephyr3d/scene 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationmask.js +224 -0
- package/dist/animation/animationmask.js.map +1 -0
- package/dist/animation/animationset.js +268 -67
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +3 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +7 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +6 -4
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +390 -43
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +4 -3
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +2 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/morphtarget.js +3 -72
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -0
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +3 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/proptrack.js +3 -0
- package/dist/animation/proptrack.js.map +1 -1
- package/dist/animation/rotationtrack.js +3 -0
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +3 -0
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +254 -79
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/animation/translationtrack.js +3 -0
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/engine.js +171 -107
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +251 -80
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +344 -365
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/loader.js +1 -6
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
- package/dist/asset/model.js +1000 -131
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +474 -0
- package/dist/avatar/wardrobe.js.map +1 -0
- package/dist/index.d.ts +1126 -199
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/msdf_text.js +3 -3
- package/dist/material/msdf_text.js.map +1 -1
- package/dist/material/msdf_text_sprite.js +4 -4
- package/dist/material/msdf_text_sprite.js.map +1 -1
- package/dist/material/pbrblueprint.js +102 -102
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/render/envlight.js +54 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/sky.js +9 -0
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/batchgroup.js +11 -13
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +15 -2
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +79 -16
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/scene.js +1 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +203 -2
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/text/font/cff_font.js +890 -0
- package/dist/text/font/cff_font.js.map +1 -0
- package/dist/text/font/font_asset.js +17 -3
- package/dist/text/font/font_asset.js.map +1 -1
- package/dist/text/msdf/generator.js.map +1 -1
- package/dist/text/msdf/shape.js +4 -1
- package/dist/text/msdf/shape.js.map +1 -1
- package/dist/text/runtime/msdf_text_atlas_manager.js +4 -1
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -1
- package/dist/utility/blueprint/material/inputs.js +1157 -1154
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/pmrem.js +34 -8
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/serialization/manager.js +22 -9
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +700 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +64 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +187 -8
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/textures/sheenlut.js +138 -0
- package/dist/utility/textures/sheenlut.js.map +1 -0
- package/package.json +2 -2
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.js.map +0 -1
- package/dist/animation/ik/ik_pole_constraint.js +0 -123
- package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
- package/dist/animation/ik/ik_track.js +0 -96
- package/dist/animation/ik/ik_track.js.map +0 -1
- package/dist/animation/ik_postprocessor.js +0 -71
- package/dist/animation/ik_postprocessor.js.map +0 -1
- package/dist/animation/joint_dynamics/math.js +0 -16
- package/dist/animation/joint_dynamics/math.js.map +0 -1
- package/dist/animation/manual_transform_processor.js +0 -156
- package/dist/animation/manual_transform_processor.js.map +0 -1
- package/dist/animation/skeleton_postprocessor.js +0 -50
- package/dist/animation/skeleton_postprocessor.js.map +0 -1
- package/dist/animation/spring2/collision.js +0 -469
- package/dist/animation/spring2/collision.js.map +0 -1
- package/dist/animation/spring2/constraints.js +0 -329
- package/dist/animation/spring2/constraints.js.map +0 -1
- package/dist/animation/spring2/controller.js +0 -434
- package/dist/animation/spring2/controller.js.map +0 -1
- package/dist/animation/spring2/math.js +0 -16
- package/dist/animation/spring2/math.js.map +0 -1
- package/dist/animation/spring2/solver.js +0 -624
- package/dist/animation/spring2/solver.js.map +0 -1
- package/dist/animation/spring2/spring_system.js +0 -118
- package/dist/animation/spring2/spring_system.js.map +0 -1
- package/dist/animation/spring2/types.js +0 -19
- package/dist/animation/spring2/types.js.map +0 -1
- package/dist/animation/spring_postprocessor.js +0 -54
- package/dist/animation/spring_postprocessor.js.map +0 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +0 -1273
- package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/asset/loaders/gltf/helpers.js +0 -331
- package/dist/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/material/sprite3d.js +0 -301
- package/dist/material/sprite3d.js.map +0 -1
- package/dist/material/sprite3d_std.js +0 -116
- package/dist/material/sprite3d_std.js.map +0 -1
- package/dist/material/sprite3dblueprint.js +0 -235
- package/dist/material/sprite3dblueprint.js.map +0 -1
- package/dist/material/sprite_sdf.js +0 -106
- package/dist/material/sprite_sdf.js.map +0 -1
- package/dist/material/terrainmaterial.js +0 -368
- package/dist/material/terrainmaterial.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
- package/dist/render/deferredlightpass.js +0 -510
- package/dist/render/deferredlightpass.js.map +0 -1
- package/dist/render/deferredshadowlightpass.js +0 -428
- package/dist/render/deferredshadowlightpass.js.map +0 -1
- package/dist/render/gbufferpass.js +0 -50
- package/dist/render/gbufferpass.js.map +0 -1
- package/dist/scene/sdftextsprite.js +0 -322
- package/dist/scene/sdftextsprite.js.map +0 -1
- package/dist/scene/sprite3d.js +0 -18
- package/dist/scene/sprite3d.js.map +0 -1
- package/dist/scene/terrain/grass.js +0 -280
- package/dist/scene/terrain/grass.js.map +0 -1
- package/dist/scene/terrain/heightfield.js +0 -475
- package/dist/scene/terrain/heightfield.js.map +0 -1
- package/dist/scene/terrain/patch.js +0 -532
- package/dist/scene/terrain/patch.js.map +0 -1
- package/dist/scene/terrain/quadtree.js +0 -461
- package/dist/scene/terrain/quadtree.js.map +0 -1
- package/dist/scene/terrain/terrain.js +0 -231
- package/dist/scene/terrain/terrain.js.map +0 -1
- package/dist/src/animation/animation.js +0 -127
- package/dist/src/animation/animation.js.map +0 -1
- package/dist/src/animation/animationset.js +0 -255
- package/dist/src/animation/animationset.js.map +0 -1
- package/dist/src/animation/animationtrack.js +0 -34
- package/dist/src/animation/animationtrack.js.map +0 -1
- package/dist/src/animation/eulerrotationtrack.js +0 -52
- package/dist/src/animation/eulerrotationtrack.js.map +0 -1
- package/dist/src/animation/morphtarget.js +0 -93
- package/dist/src/animation/morphtarget.js.map +0 -1
- package/dist/src/animation/morphtrack.js +0 -70
- package/dist/src/animation/morphtrack.js.map +0 -1
- package/dist/src/animation/proptrack.js +0 -161
- package/dist/src/animation/proptrack.js.map +0 -1
- package/dist/src/animation/rotationtrack.js +0 -51
- package/dist/src/animation/rotationtrack.js.map +0 -1
- package/dist/src/animation/scaletrack.js +0 -50
- package/dist/src/animation/scaletrack.js.map +0 -1
- package/dist/src/animation/skeleton.js +0 -204
- package/dist/src/animation/skeleton.js.map +0 -1
- package/dist/src/animation/translationtrack.js +0 -50
- package/dist/src/animation/translationtrack.js.map +0 -1
- package/dist/src/app/app.js +0 -129
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/inputmgr.js +0 -267
- package/dist/src/app/inputmgr.js.map +0 -1
- package/dist/src/asset/assetmanager.js +0 -404
- package/dist/src/asset/assetmanager.js.map +0 -1
- package/dist/src/asset/builtin.js +0 -337
- package/dist/src/asset/builtin.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds.js +0 -470
- package/dist/src/asset/loaders/dds/dds.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
- package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/helpers.js +0 -327
- package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/src/asset/loaders/hdr/hdr.js +0 -180
- package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
- package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
- package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
- package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
- package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
- package/dist/src/asset/loaders/loader.js +0 -45
- package/dist/src/asset/loaders/loader.js.map +0 -1
- package/dist/src/asset/model.js +0 -414
- package/dist/src/asset/model.js.map +0 -1
- package/dist/src/blitter/bilateralblur.js +0 -221
- package/dist/src/blitter/bilateralblur.js.map +0 -1
- package/dist/src/blitter/blitter.js +0 -390
- package/dist/src/blitter/blitter.js.map +0 -1
- package/dist/src/blitter/box.js +0 -118
- package/dist/src/blitter/box.js.map +0 -1
- package/dist/src/blitter/copy.js +0 -22
- package/dist/src/blitter/copy.js.map +0 -1
- package/dist/src/blitter/gaussianblur.js +0 -228
- package/dist/src/blitter/gaussianblur.js.map +0 -1
- package/dist/src/camera/base.js +0 -92
- package/dist/src/camera/base.js.map +0 -1
- package/dist/src/camera/camera.js +0 -1005
- package/dist/src/camera/camera.js.map +0 -1
- package/dist/src/camera/fps.js +0 -238
- package/dist/src/camera/fps.js.map +0 -1
- package/dist/src/camera/orbit.js +0 -245
- package/dist/src/camera/orbit.js.map +0 -1
- package/dist/src/camera/orthocamera.js +0 -167
- package/dist/src/camera/orthocamera.js.map +0 -1
- package/dist/src/camera/perspectivecamera.js +0 -141
- package/dist/src/camera/perspectivecamera.js.map +0 -1
- package/dist/src/index.js +0 -120
- package/dist/src/index.js.map +0 -1
- package/dist/src/material/blinn.js +0 -81
- package/dist/src/material/blinn.js.map +0 -1
- package/dist/src/material/grassmaterial.js +0 -113
- package/dist/src/material/grassmaterial.js.map +0 -1
- package/dist/src/material/lambert.js +0 -92
- package/dist/src/material/lambert.js.map +0 -1
- package/dist/src/material/material.js +0 -301
- package/dist/src/material/material.js.map +0 -1
- package/dist/src/material/meshmaterial.js +0 -704
- package/dist/src/material/meshmaterial.js.map +0 -1
- package/dist/src/material/mixins/albedocolor.js +0 -76
- package/dist/src/material/mixins/albedocolor.js.map +0 -1
- package/dist/src/material/mixins/foliage.js +0 -47
- package/dist/src/material/mixins/foliage.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
- package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
- package/dist/src/material/mixins/lit.js +0 -476
- package/dist/src/material/mixins/lit.js.map +0 -1
- package/dist/src/material/mixins/pbr/common.js +0 -918
- package/dist/src/material/mixins/pbr/common.js.map +0 -1
- package/dist/src/material/mixins/texture.js +0 -172
- package/dist/src/material/mixins/texture.js.map +0 -1
- package/dist/src/material/mixins/vertexcolor.js +0 -56
- package/dist/src/material/mixins/vertexcolor.js.map +0 -1
- package/dist/src/material/particle.js +0 -178
- package/dist/src/material/particle.js.map +0 -1
- package/dist/src/material/pbrmr.js +0 -97
- package/dist/src/material/pbrmr.js.map +0 -1
- package/dist/src/material/pbrsg.js +0 -97
- package/dist/src/material/pbrsg.js.map +0 -1
- package/dist/src/material/shader/helper.js +0 -1209
- package/dist/src/material/shader/helper.js.map +0 -1
- package/dist/src/material/terrain-cm.js +0 -606
- package/dist/src/material/terrain-cm.js.map +0 -1
- package/dist/src/material/terrainmaterial.js +0 -375
- package/dist/src/material/terrainmaterial.js.map +0 -1
- package/dist/src/material/unlit.js +0 -41
- package/dist/src/material/unlit.js.map +0 -1
- package/dist/src/material/water.js +0 -417
- package/dist/src/material/water.js.map +0 -1
- package/dist/src/posteffect/bloom.js +0 -361
- package/dist/src/posteffect/bloom.js.map +0 -1
- package/dist/src/posteffect/compositor.js +0 -226
- package/dist/src/posteffect/compositor.js.map +0 -1
- package/dist/src/posteffect/fxaa.js +0 -273
- package/dist/src/posteffect/fxaa.js.map +0 -1
- package/dist/src/posteffect/grayscale.js +0 -69
- package/dist/src/posteffect/grayscale.js.map +0 -1
- package/dist/src/posteffect/motionblur.js +0 -96
- package/dist/src/posteffect/motionblur.js.map +0 -1
- package/dist/src/posteffect/posteffect.js +0 -126
- package/dist/src/posteffect/posteffect.js.map +0 -1
- package/dist/src/posteffect/sao.js +0 -324
- package/dist/src/posteffect/sao.js.map +0 -1
- package/dist/src/posteffect/ssr.js +0 -489
- package/dist/src/posteffect/ssr.js.map +0 -1
- package/dist/src/posteffect/taa.js +0 -172
- package/dist/src/posteffect/taa.js.map +0 -1
- package/dist/src/posteffect/tonemap.js +0 -94
- package/dist/src/posteffect/tonemap.js.map +0 -1
- package/dist/src/render/abuffer_oit.js +0 -361
- package/dist/src/render/abuffer_oit.js.map +0 -1
- package/dist/src/render/clipmap.js +0 -851
- package/dist/src/render/clipmap.js.map +0 -1
- package/dist/src/render/cluster_light.js +0 -333
- package/dist/src/render/cluster_light.js.map +0 -1
- package/dist/src/render/cull_visitor.js +0 -187
- package/dist/src/render/cull_visitor.js.map +0 -1
- package/dist/src/render/depthpass.js +0 -68
- package/dist/src/render/depthpass.js.map +0 -1
- package/dist/src/render/drawable_mixin.js +0 -227
- package/dist/src/render/drawable_mixin.js.map +0 -1
- package/dist/src/render/envlight.js +0 -463
- package/dist/src/render/envlight.js.map +0 -1
- package/dist/src/render/fbm_wavegenerator.js +0 -251
- package/dist/src/render/fbm_wavegenerator.js.map +0 -1
- package/dist/src/render/fft_wavegenerator.js +0 -1006
- package/dist/src/render/fft_wavegenerator.js.map +0 -1
- package/dist/src/render/fullscreenquad.js +0 -38
- package/dist/src/render/fullscreenquad.js.map +0 -1
- package/dist/src/render/gerstner_wavegenerator.js +0 -314
- package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
- package/dist/src/render/globalbindgroup_allocator.js +0 -60
- package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
- package/dist/src/render/hzb.js +0 -273
- package/dist/src/render/hzb.js.map +0 -1
- package/dist/src/render/lightpass.js +0 -172
- package/dist/src/render/lightpass.js.map +0 -1
- package/dist/src/render/objectcolorpass.js +0 -51
- package/dist/src/render/objectcolorpass.js.map +0 -1
- package/dist/src/render/primitive.js +0 -364
- package/dist/src/render/primitive.js.map +0 -1
- package/dist/src/render/render_queue.js +0 -467
- package/dist/src/render/render_queue.js.map +0 -1
- package/dist/src/render/renderbundle_wrapper.js +0 -152
- package/dist/src/render/renderbundle_wrapper.js.map +0 -1
- package/dist/src/render/renderer.js +0 -455
- package/dist/src/render/renderer.js.map +0 -1
- package/dist/src/render/renderpass.js +0 -200
- package/dist/src/render/renderpass.js.map +0 -1
- package/dist/src/render/shadowmap_pass.js +0 -56
- package/dist/src/render/shadowmap_pass.js.map +0 -1
- package/dist/src/render/sky.js +0 -1103
- package/dist/src/render/sky.js.map +0 -1
- package/dist/src/render/weightedblended_oit.js +0 -168
- package/dist/src/render/weightedblended_oit.js.map +0 -1
- package/dist/src/scene/batchgroup.js +0 -162
- package/dist/src/scene/batchgroup.js.map +0 -1
- package/dist/src/scene/environment.js +0 -209
- package/dist/src/scene/environment.js.map +0 -1
- package/dist/src/scene/graph_node.js +0 -72
- package/dist/src/scene/graph_node.js.map +0 -1
- package/dist/src/scene/light.js +0 -416
- package/dist/src/scene/light.js.map +0 -1
- package/dist/src/scene/mesh.js +0 -341
- package/dist/src/scene/mesh.js.map +0 -1
- package/dist/src/scene/octree.js +0 -649
- package/dist/src/scene/octree.js.map +0 -1
- package/dist/src/scene/particlesys.js +0 -738
- package/dist/src/scene/particlesys.js.map +0 -1
- package/dist/src/scene/raycast_visitor.js +0 -103
- package/dist/src/scene/raycast_visitor.js.map +0 -1
- package/dist/src/scene/scene.js +0 -284
- package/dist/src/scene/scene.js.map +0 -1
- package/dist/src/scene/scene_node.js +0 -732
- package/dist/src/scene/scene_node.js.map +0 -1
- package/dist/src/scene/terrain/grass.js +0 -278
- package/dist/src/scene/terrain/grass.js.map +0 -1
- package/dist/src/scene/terrain/heightfield.js +0 -475
- package/dist/src/scene/terrain/heightfield.js.map +0 -1
- package/dist/src/scene/terrain/patch.js +0 -530
- package/dist/src/scene/terrain/patch.js.map +0 -1
- package/dist/src/scene/terrain/quadtree.js +0 -461
- package/dist/src/scene/terrain/quadtree.js.map +0 -1
- package/dist/src/scene/terrain/terrain.js +0 -246
- package/dist/src/scene/terrain/terrain.js.map +0 -1
- package/dist/src/scene/terrain-cm/grass.js +0 -594
- package/dist/src/scene/terrain-cm/grass.js.map +0 -1
- package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
- package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
- package/dist/src/scene/water.js +0 -374
- package/dist/src/scene/water.js.map +0 -1
- package/dist/src/shaders/atmosphere.js +0 -957
- package/dist/src/shaders/atmosphere.js.map +0 -1
- package/dist/src/shaders/fog.js +0 -112
- package/dist/src/shaders/fog.js.map +0 -1
- package/dist/src/shaders/misc.js +0 -266
- package/dist/src/shaders/misc.js.map +0 -1
- package/dist/src/shaders/noise.js +0 -222
- package/dist/src/shaders/noise.js.map +0 -1
- package/dist/src/shaders/pbr.js +0 -51
- package/dist/src/shaders/pbr.js.map +0 -1
- package/dist/src/shaders/shadow.js +0 -636
- package/dist/src/shaders/shadow.js.map +0 -1
- package/dist/src/shaders/ssr.js +0 -490
- package/dist/src/shaders/ssr.js.map +0 -1
- package/dist/src/shaders/temporal.js +0 -215
- package/dist/src/shaders/temporal.js.map +0 -1
- package/dist/src/shaders/water.js +0 -756
- package/dist/src/shaders/water.js.map +0 -1
- package/dist/src/shadow/esm.js +0 -237
- package/dist/src/shadow/esm.js.map +0 -1
- package/dist/src/shadow/pcf_opt.js +0 -181
- package/dist/src/shadow/pcf_opt.js.map +0 -1
- package/dist/src/shadow/pcf_pd.js +0 -189
- package/dist/src/shadow/pcf_pd.js.map +0 -1
- package/dist/src/shadow/shader.js +0 -37
- package/dist/src/shadow/shader.js.map +0 -1
- package/dist/src/shadow/shadow_impl.js +0 -15
- package/dist/src/shadow/shadow_impl.js.map +0 -1
- package/dist/src/shadow/shadowmapper.js +0 -790
- package/dist/src/shadow/shadowmapper.js.map +0 -1
- package/dist/src/shadow/ssm.js +0 -159
- package/dist/src/shadow/ssm.js.map +0 -1
- package/dist/src/shadow/vsm.js +0 -297
- package/dist/src/shadow/vsm.js.map +0 -1
- package/dist/src/shapes/box.js +0 -386
- package/dist/src/shapes/box.js.map +0 -1
- package/dist/src/shapes/cylinder.js +0 -125
- package/dist/src/shapes/cylinder.js.map +0 -1
- package/dist/src/shapes/plane.js +0 -88
- package/dist/src/shapes/plane.js.map +0 -1
- package/dist/src/shapes/shape.js +0 -87
- package/dist/src/shapes/shape.js.map +0 -1
- package/dist/src/shapes/sphere.js +0 -114
- package/dist/src/shapes/sphere.js.map +0 -1
- package/dist/src/shapes/tetrahedron.js +0 -188
- package/dist/src/shapes/tetrahedron.js.map +0 -1
- package/dist/src/shapes/torus.js +0 -111
- package/dist/src/shapes/torus.js.map +0 -1
- package/dist/src/utility/aabbtree.js +0 -400
- package/dist/src/utility/aabbtree.js.map +0 -1
- package/dist/src/utility/bounding_volume.js +0 -29
- package/dist/src/utility/bounding_volume.js.map +0 -1
- package/dist/src/utility/debug.js +0 -28
- package/dist/src/utility/debug.js.map +0 -1
- package/dist/src/utility/draco/decoder.js +0 -116
- package/dist/src/utility/draco/decoder.js.map +0 -1
- package/dist/src/utility/misc.js +0 -105
- package/dist/src/utility/misc.js.map +0 -1
- package/dist/src/utility/panorama.js +0 -163
- package/dist/src/utility/panorama.js.map +0 -1
- package/dist/src/utility/pmrem.js +0 -354
- package/dist/src/utility/pmrem.js.map +0 -1
- package/dist/src/utility/rendermipmap.js +0 -115
- package/dist/src/utility/rendermipmap.js.map +0 -1
- package/dist/src/utility/serialization/json.js +0 -402
- package/dist/src/utility/serialization/json.js.map +0 -1
- package/dist/src/utility/serialization/manager.js +0 -623
- package/dist/src/utility/serialization/manager.js.map +0 -1
- package/dist/src/utility/serialization/scene/animation.js +0 -248
- package/dist/src/utility/serialization/scene/animation.js.map +0 -1
- package/dist/src/utility/serialization/scene/batch.js +0 -59
- package/dist/src/utility/serialization/scene/batch.js.map +0 -1
- package/dist/src/utility/serialization/scene/camera.js +0 -790
- package/dist/src/utility/serialization/scene/camera.js.map +0 -1
- package/dist/src/utility/serialization/scene/common.js +0 -222
- package/dist/src/utility/serialization/scene/common.js.map +0 -1
- package/dist/src/utility/serialization/scene/light.js +0 -575
- package/dist/src/utility/serialization/scene/light.js.map +0 -1
- package/dist/src/utility/serialization/scene/material.js +0 -1111
- package/dist/src/utility/serialization/scene/material.js.map +0 -1
- package/dist/src/utility/serialization/scene/mesh.js +0 -148
- package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
- package/dist/src/utility/serialization/scene/misc.js +0 -39
- package/dist/src/utility/serialization/scene/misc.js.map +0 -1
- package/dist/src/utility/serialization/scene/node.js +0 -451
- package/dist/src/utility/serialization/scene/node.js.map +0 -1
- package/dist/src/utility/serialization/scene/particle.js +0 -425
- package/dist/src/utility/serialization/scene/particle.js.map +0 -1
- package/dist/src/utility/serialization/scene/primitive.js +0 -692
- package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
- package/dist/src/utility/serialization/scene/scene.js +0 -704
- package/dist/src/utility/serialization/scene/scene.js.map +0 -1
- package/dist/src/utility/serialization/scene/terrain.js +0 -488
- package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
- package/dist/src/utility/serialization/scene/water.js +0 -465
- package/dist/src/utility/serialization/scene/water.js.map +0 -1
- package/dist/src/utility/shprojector.js +0 -297
- package/dist/src/utility/shprojector.js.map +0 -1
- package/dist/src/utility/textures/ggxlut.js +0 -213
- package/dist/src/utility/textures/ggxlut.js.map +0 -1
- package/dist/src/utility/textures/gradientnoise.js +0 -62
- package/dist/src/utility/textures/gradientnoise.js.map +0 -1
- package/dist/src/utility/textures/randomnoise.js +0 -41
- package/dist/src/utility/textures/randomnoise.js.map +0 -1
- package/dist/src/values.js +0 -162
- package/dist/src/values.js.map +0 -1
- package/dist/utility/blueprint/material/common.js +0 -7
- package/dist/utility/blueprint/material/common.js.map +0 -1
- package/dist/utility/serialization/blueprint/constants.js +0 -255
- package/dist/utility/serialization/blueprint/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/constants.js +0 -203
- package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/texture.js +0 -165
- package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
- package/dist/utility/serialization/scene/cloth_script.js +0 -834
- package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
- package/dist/utility/serialization/scene/spring_script.js +0 -596
- package/dist/utility/serialization/scene/spring_script.js.map +0 -1
|
@@ -1,624 +0,0 @@
|
|
|
1
|
-
import { Vector3, Quaternion, degree2radian, Matrix4x4, radian2degree } from '@zephyr3d/base';
|
|
2
|
-
import { clamp01, smoothStep } from './math.js';
|
|
3
|
-
import { EPSILON, ConstraintType } from './types.js';
|
|
4
|
-
import { checkSurfaceCollision, pushInFromCapsule, pushoutFromCapsule, pushInFromSphere, pushoutFromSphere, collisionDetection } from './collision.js';
|
|
5
|
-
|
|
6
|
-
// Core physics simulation 閳?direct port of JobExecuteSimulation from SPCRJointDynamicsJob.cs
|
|
7
|
-
const AXIS_Y = new Vector3(0, 1, 0);
|
|
8
|
-
const VEC3_ONE = new Vector3(1, 1, 1);
|
|
9
|
-
const _computeCapsuleAxis = new Vector3();
|
|
10
|
-
const _computeCapsuleHalfDir = new Vector3();
|
|
11
|
-
const _applySystemTransformOffset = new Vector3();
|
|
12
|
-
const _applySystemTransformRotated = new Vector3();
|
|
13
|
-
const _broadPhaseSegmentDir = new Vector3();
|
|
14
|
-
const _broadPhaseToCenter = new Vector3();
|
|
15
|
-
const _broadPhaseClosestPoint = new Vector3();
|
|
16
|
-
const _broadPhaseDelta = new Vector3();
|
|
17
|
-
/**
|
|
18
|
-
* Run the full simulation step. Mutates pointsRW and collidersRW in place.
|
|
19
|
-
* Returns { positionsToTransform, fakeWaveCounter }.
|
|
20
|
-
*/ function simulate(params, pointsR, pointsRW, constraints, collidersR, collidersRW, grabbersR, grabbersRW, movableLimitTargets, flatPlanes) {
|
|
21
|
-
const pointCount = pointsR.length;
|
|
22
|
-
const positionsToTransform = new Array(pointCount);
|
|
23
|
-
let subSteps = params.subSteps;
|
|
24
|
-
if (params.isPaused) {
|
|
25
|
-
subSteps = 1;
|
|
26
|
-
}
|
|
27
|
-
let fakeWaveFreq = params.fakeWaveCounter;
|
|
28
|
-
// Root slide offset
|
|
29
|
-
let rootSlideOffset = Vector3.zero();
|
|
30
|
-
const rootDeltaSlide = Vector3.sub(params.rootPosition, params.previousRootPosition);
|
|
31
|
-
const rootDeltaSlideLen = rootDeltaSlide.magnitude;
|
|
32
|
-
if (params.rootSlideLimit >= 0 && rootDeltaSlideLen > params.rootSlideLimit) {
|
|
33
|
-
rootSlideOffset = Vector3.scale(rootDeltaSlide, (1.0 - params.rootSlideLimit / rootDeltaSlideLen) / subSteps);
|
|
34
|
-
}
|
|
35
|
-
// Root rotation offset
|
|
36
|
-
let rootRotationOffset = Quaternion.identity();
|
|
37
|
-
const rootDeltaRot = Quaternion.multiply(params.rootRotation, Quaternion.inverse(params.previousRootRotation));
|
|
38
|
-
let rotateAngle = Math.acos(Math.max(-1, Math.min(1, rootDeltaRot.w))) * 2.0 * (180 / Math.PI);
|
|
39
|
-
if (rotateAngle > 180) {
|
|
40
|
-
rotateAngle -= 360;
|
|
41
|
-
}
|
|
42
|
-
if (params.rootRotateLimit >= 0 && Math.abs(rotateAngle) > params.rootRotateLimit) {
|
|
43
|
-
let rotateAxis = new Vector3();
|
|
44
|
-
if (!isFinite(rotateAxis.x) || !isFinite(rotateAxis.y) || !isFinite(rotateAxis.z)) {
|
|
45
|
-
rotateAxis = Vector3.axisPY();
|
|
46
|
-
}
|
|
47
|
-
let angle = rotateAngle > 0 ? rotateAngle - params.rootRotateLimit : rotateAngle + params.rootRotateLimit;
|
|
48
|
-
angle /= subSteps;
|
|
49
|
-
rootRotationOffset = Quaternion.fromAxisAngle(rotateAxis, degree2radian(angle));
|
|
50
|
-
}
|
|
51
|
-
if (params.isPaused) {
|
|
52
|
-
rootSlideOffset = rootDeltaSlide;
|
|
53
|
-
rootRotationOffset = rootDeltaRot;
|
|
54
|
-
}
|
|
55
|
-
const stepTime = params.stepTime / subSteps;
|
|
56
|
-
for(let iSubStep = 1; iSubStep <= subSteps; iSubStep++){
|
|
57
|
-
const stepDelta = iSubStep / subSteps;
|
|
58
|
-
const stepTime_x2_half = stepTime * stepTime * 0.5;
|
|
59
|
-
colliderUpdate(collidersR, collidersRW, stepDelta, params.collisionScale);
|
|
60
|
-
pointUpdatePass1(pointsR, pointsRW, stepDelta, stepTime_x2_half, rootSlideOffset, rootRotationOffset, params.rootPosition, params.windForce, params.isPaused, grabbersR, grabbersRW, movableLimitTargets, flatPlanes);
|
|
61
|
-
if (!params.isPaused) {
|
|
62
|
-
fakeWaveFreq += params.fakeWaveSpeed * stepTime;
|
|
63
|
-
if (params.enableSurfaceCollision) {
|
|
64
|
-
surfaceCollision(pointsRW, collidersR, collidersRW, params.surfaceConstraints);
|
|
65
|
-
}
|
|
66
|
-
for(let iRelax = params.relaxation - 1; iRelax >= 0; --iRelax){
|
|
67
|
-
constraintUpdate(pointsR, pointsRW, constraints, collidersR, collidersRW, params.constraintShrinkLimit, params.enableBroadPhase);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
pointUpdatePass2(pointsR, pointsRW, positionsToTransform, stepDelta, fakeWaveFreq, params.blendRatio, params.isFakeWave, params.fakeWavePower);
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
positionsToTransform,
|
|
74
|
-
fakeWaveCounter: fakeWaveFreq
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
// 閳光偓閳光偓 Collider interpolation 閳光偓閳光偓
|
|
78
|
-
function computeCapsule(pos, rot, height, head, direction) {
|
|
79
|
-
rot.transform(Vector3.scale(AXIS_Y, height, _computeCapsuleAxis), direction);
|
|
80
|
-
Vector3.scale(direction, 0.5, _computeCapsuleHalfDir);
|
|
81
|
-
Vector3.sub(pos, _computeCapsuleHalfDir, head);
|
|
82
|
-
}
|
|
83
|
-
function colliderUpdate(collidersR, collidersRW, stepDelta, collisionScale) {
|
|
84
|
-
const curPos = new Vector3();
|
|
85
|
-
const curDir = new Quaternion();
|
|
86
|
-
const corner = new Vector3();
|
|
87
|
-
const center = new Vector3();
|
|
88
|
-
const tailCorner = new Vector3();
|
|
89
|
-
const tailCenter = new Vector3();
|
|
90
|
-
for(let i = 0; i < collidersR.length; i++){
|
|
91
|
-
const colR = collidersR[i];
|
|
92
|
-
const colRW = collidersRW[i];
|
|
93
|
-
colRW.radius = colR.radius * collisionScale;
|
|
94
|
-
Vector3.lerp(colRW.positionPreviousTransform, colRW.positionCurrentTransform, stepDelta, curPos);
|
|
95
|
-
Quaternion.slerp(colRW.directionPreviousTransform, colRW.directionCurrentTransform, stepDelta, curDir);
|
|
96
|
-
computeCapsule(curPos, curDir, colR.height, colRW.positionCurrent, colRW.directionCurrent);
|
|
97
|
-
if (colR.height > EPSILON) {
|
|
98
|
-
Vector3.scale(colRW.directionCurrent, 0.5, _computeCapsuleHalfDir);
|
|
99
|
-
Vector3.add(colRW.positionCurrent, _computeCapsuleHalfDir, colRW.boundsCenter);
|
|
100
|
-
colRW.boundsRadius = Math.sqrt(colRW.directionCurrent.magnitudeSq) * 0.5 + Math.max(colRW.radius, colRW.radius * colR.radiusTailScale);
|
|
101
|
-
} else {
|
|
102
|
-
colRW.boundsCenter.set(colRW.positionCurrent);
|
|
103
|
-
colRW.boundsRadius = colRW.radius;
|
|
104
|
-
}
|
|
105
|
-
// Update local bounds
|
|
106
|
-
Vector3.scale(VEC3_ONE, colR.radius, corner);
|
|
107
|
-
colRW.worldToLocal.transformPointAffine(colRW.positionCurrent, center);
|
|
108
|
-
Vector3.sub(center, corner, colRW.localBoundsMin);
|
|
109
|
-
Vector3.add(center, corner, colRW.localBoundsMax);
|
|
110
|
-
if (colR.height > EPSILON) {
|
|
111
|
-
Vector3.scale(VEC3_ONE, colR.radius * colR.radiusTailScale, tailCorner);
|
|
112
|
-
Vector3.add(colRW.positionCurrent, colRW.directionCurrent, tailCenter);
|
|
113
|
-
colRW.worldToLocal.transformPointAffine(tailCenter, tailCenter);
|
|
114
|
-
colRW.localBoundsMin.setXYZ(Math.min(colRW.localBoundsMin.x, tailCenter.x - tailCorner.x), Math.min(colRW.localBoundsMin.y, tailCenter.y - tailCorner.y), Math.min(colRW.localBoundsMin.z, tailCenter.z - tailCorner.z));
|
|
115
|
-
colRW.localBoundsMax.setXYZ(Math.max(colRW.localBoundsMax.x, tailCenter.x + tailCorner.x), Math.max(colRW.localBoundsMax.y, tailCenter.y + tailCorner.y), Math.max(colRW.localBoundsMax.z, tailCenter.z + tailCorner.z));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
// 閳光偓閳光偓 Apply root motion transform 閳光偓閳光偓
|
|
120
|
-
function applySystemTransform(point, pivot, slideOffset, rotOffset, result) {
|
|
121
|
-
const rotated = rotOffset.transform(Vector3.sub(point, pivot, _applySystemTransformOffset), result || _applySystemTransformRotated);
|
|
122
|
-
Vector3.add(rotated, pivot, rotated);
|
|
123
|
-
return Vector3.add(rotated, slideOffset, rotated);
|
|
124
|
-
}
|
|
125
|
-
function pointMayCollideBroadPhase(point, colRW, padding = 0) {
|
|
126
|
-
const radius = colRW.boundsRadius + padding;
|
|
127
|
-
const delta = Vector3.sub(point, colRW.boundsCenter, _broadPhaseDelta);
|
|
128
|
-
return delta.magnitudeSq <= radius * radius;
|
|
129
|
-
}
|
|
130
|
-
function segmentMayCollideBroadPhase(point1, point2, colRW) {
|
|
131
|
-
const segmentDir = Vector3.sub(point2, point1, _broadPhaseSegmentDir);
|
|
132
|
-
const lenSq = segmentDir.magnitudeSq;
|
|
133
|
-
if (lenSq <= EPSILON) {
|
|
134
|
-
return pointMayCollideBroadPhase(point1, colRW);
|
|
135
|
-
}
|
|
136
|
-
const toCenter = Vector3.sub(colRW.boundsCenter, point1, _broadPhaseToCenter);
|
|
137
|
-
const t = clamp01(Vector3.dot(toCenter, segmentDir) / lenSq);
|
|
138
|
-
const closestPoint = Vector3.scale(segmentDir, t, _broadPhaseClosestPoint);
|
|
139
|
-
Vector3.add(point1, closestPoint, closestPoint);
|
|
140
|
-
const delta = Vector3.sub(colRW.boundsCenter, closestPoint, _broadPhaseDelta);
|
|
141
|
-
return delta.magnitudeSq <= colRW.boundsRadius * colRW.boundsRadius;
|
|
142
|
-
}
|
|
143
|
-
// 閳光偓閳光偓 Pass 1: Verlet integration + forces 閳光偓閳光偓
|
|
144
|
-
function pointUpdatePass1(pointsR, pointsRW, stepDelta, stepTime_x2_half, rootSlideOffset, rootRotationOffset, rootPosition, windForce, isPaused, grabbersR, grabbersRW, movableLimitTargets, flatPlanes) {
|
|
145
|
-
const currentTransformPos = new Vector3();
|
|
146
|
-
const moveDir = new Vector3();
|
|
147
|
-
const extForce = new Vector3();
|
|
148
|
-
const displacement = new Vector3();
|
|
149
|
-
const restore = new Vector3();
|
|
150
|
-
const tempVec0 = new Vector3();
|
|
151
|
-
const tempVec1 = new Vector3();
|
|
152
|
-
const planeOffset = new Vector3();
|
|
153
|
-
for(let index = 0; index < pointsR.length; index++){
|
|
154
|
-
const ptR = pointsR[index];
|
|
155
|
-
const ptRW = pointsRW[index];
|
|
156
|
-
Vector3.lerp(ptRW.positionPreviousTransform, ptRW.positionCurrentTransform, stepDelta, currentTransformPos);
|
|
157
|
-
if (ptR.weight <= EPSILON) {
|
|
158
|
-
ptRW.positionPrevious.set(ptRW.positionCurrent);
|
|
159
|
-
ptRW.positionCurrent.set(currentTransformPos);
|
|
160
|
-
} else {
|
|
161
|
-
applySystemTransform(ptRW.positionPrevious, rootPosition, rootSlideOffset, rootRotationOffset, ptRW.positionPrevious);
|
|
162
|
-
applySystemTransform(ptRW.positionCurrent, rootPosition, rootSlideOffset, rootRotationOffset, ptRW.positionCurrent);
|
|
163
|
-
displacement.setXYZ(0, 0, 0);
|
|
164
|
-
if (!isPaused) {
|
|
165
|
-
Vector3.sub(ptRW.positionCurrent, ptRW.positionPrevious, moveDir);
|
|
166
|
-
Vector3.scale(windForce, ptR.windForceScale / ptR.mass, extForce);
|
|
167
|
-
Vector3.add(ptR.gravity, extForce, extForce);
|
|
168
|
-
Vector3.scale(extForce, stepTime_x2_half, extForce);
|
|
169
|
-
Vector3.add(moveDir, extForce, displacement);
|
|
170
|
-
Vector3.scale(displacement, ptR.resistance, displacement);
|
|
171
|
-
Vector3.scale(displacement, 1.0 - clamp01(ptRW.friction * ptR.frictionScale), displacement);
|
|
172
|
-
}
|
|
173
|
-
ptRW.positionPrevious.set(ptRW.positionCurrent);
|
|
174
|
-
Vector3.add(ptRW.positionCurrent, displacement, ptRW.positionCurrent);
|
|
175
|
-
ptRW.friction = 0;
|
|
176
|
-
if (!isPaused) {
|
|
177
|
-
// Hardness restore
|
|
178
|
-
if (ptR.hardness > 0) {
|
|
179
|
-
Vector3.sub(currentTransformPos, ptRW.positionCurrent, restore);
|
|
180
|
-
Vector3.scale(restore, ptR.hardness, restore);
|
|
181
|
-
Vector3.add(ptRW.positionCurrent, restore, ptRW.positionCurrent);
|
|
182
|
-
}
|
|
183
|
-
// Force fade ratio
|
|
184
|
-
if (ptR.forceFadeRatio > 0) {
|
|
185
|
-
Vector3.lerp(ptRW.positionCurrent, currentTransformPos, ptR.forceFadeRatio, ptRW.positionCurrent);
|
|
186
|
-
}
|
|
187
|
-
// Grabber
|
|
188
|
-
if (ptRW.grabberIndex !== -1) {
|
|
189
|
-
const grR = grabbersR[ptRW.grabberIndex];
|
|
190
|
-
const grRW = grabbersRW[ptRW.grabberIndex];
|
|
191
|
-
if (grRW.enabled === 0) {
|
|
192
|
-
ptRW.grabberIndex = -1;
|
|
193
|
-
} else {
|
|
194
|
-
Vector3.sub(ptRW.positionCurrent, grRW.position, tempVec0);
|
|
195
|
-
Vector3.normalize(tempVec0, tempVec0);
|
|
196
|
-
Vector3.scale(tempVec0, ptRW.grabberDistance, tempVec1);
|
|
197
|
-
Vector3.add(grRW.position, tempVec1, tempVec1);
|
|
198
|
-
Vector3.sub(tempVec1, ptRW.positionCurrent, tempVec0);
|
|
199
|
-
Vector3.scale(tempVec0, grR.force, tempVec0);
|
|
200
|
-
Vector3.add(ptRW.positionCurrent, tempVec0, ptRW.positionCurrent);
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
let nearIndex = -1;
|
|
204
|
-
let sqrNearRange = 1000 * 1000;
|
|
205
|
-
for(let ig = 0; ig < grabbersR.length; ig++){
|
|
206
|
-
const grRW = grabbersRW[ig];
|
|
207
|
-
if (grRW.enabled !== 0) {
|
|
208
|
-
const sqrLen = Vector3.sub(grRW.position, ptRW.positionCurrent, tempVec0).magnitudeSq;
|
|
209
|
-
if (sqrLen < grabbersR[ig].radius * grabbersR[ig].radius && sqrLen < sqrNearRange) {
|
|
210
|
-
sqrNearRange = sqrLen;
|
|
211
|
-
nearIndex = ig;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
if (nearIndex !== -1) {
|
|
216
|
-
ptRW.grabberIndex = nearIndex;
|
|
217
|
-
ptRW.grabberDistance = Math.sqrt(sqrNearRange) / 2.0;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
// Movable limit
|
|
221
|
-
if (ptR.movableLimitIndex !== -1) {
|
|
222
|
-
const target = movableLimitTargets[ptR.movableLimitIndex];
|
|
223
|
-
const move = Vector3.sub(ptRW.positionCurrent, target, tempVec0);
|
|
224
|
-
const moveLen = move.magnitude;
|
|
225
|
-
if (moveLen > ptR.movableLimitRadius) {
|
|
226
|
-
Vector3.scale(move, ptR.movableLimitRadius / moveLen, move);
|
|
227
|
-
Vector3.add(target, move, ptRW.positionCurrent);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
// Flat plane collision
|
|
232
|
-
for(let i = 0; i < flatPlanes.length; i++){
|
|
233
|
-
const fp = flatPlanes[i];
|
|
234
|
-
const dist = Vector3.dot(fp.normal, ptRW.positionCurrent) + fp.distance;
|
|
235
|
-
if (dist < 0) {
|
|
236
|
-
Vector3.scale(fp.normal, dist, planeOffset);
|
|
237
|
-
Vector3.sub(ptRW.positionCurrent, planeOffset, ptRW.positionCurrent);
|
|
238
|
-
ptRW.friction = 0.3;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
// 閳光偓閳光偓 Surface collision (triangle-based cloth collision) 閳光偓閳光偓
|
|
245
|
-
function surfaceCollision(pointsRW, collidersR, collidersRW, surfaceConstraints) {
|
|
246
|
-
const surfaceResult = {
|
|
247
|
-
hit: false,
|
|
248
|
-
intersectionPoint: new Vector3(),
|
|
249
|
-
pushOut: new Vector3(),
|
|
250
|
-
pointOnCollider: new Vector3(),
|
|
251
|
-
radius: 0
|
|
252
|
-
};
|
|
253
|
-
const triCenter = new Vector3();
|
|
254
|
-
const pushDir = new Vector3();
|
|
255
|
-
const centerToPt = new Vector3();
|
|
256
|
-
const intersectToPt = new Vector3();
|
|
257
|
-
const pushVec = new Vector3();
|
|
258
|
-
for(let index = 0; index < surfaceConstraints.length; index += 6){
|
|
259
|
-
for(let i = 0; i < collidersR.length; i++){
|
|
260
|
-
const colR = collidersR[i];
|
|
261
|
-
const colRW = collidersRW[i];
|
|
262
|
-
if (colRW.enabled === 0) {
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
const colliderPos = colRW.positionCurrent;
|
|
266
|
-
for(let j = 0; j < 6; j += 3){
|
|
267
|
-
const idxA = surfaceConstraints[index + j + 0];
|
|
268
|
-
const idxB = surfaceConstraints[index + j + 1];
|
|
269
|
-
const idxC = surfaceConstraints[index + j + 2];
|
|
270
|
-
const rwA = pointsRW[idxA];
|
|
271
|
-
const rwB = pointsRW[idxB];
|
|
272
|
-
const rwC = pointsRW[idxC];
|
|
273
|
-
const result = checkSurfaceCollision(rwA.positionCurrent, rwB.positionCurrent, rwC.positionCurrent, colliderPos, colR, colRW, surfaceResult);
|
|
274
|
-
if (result.hit) {
|
|
275
|
-
triCenter.setXYZ((rwA.positionCurrent.x + rwB.positionCurrent.x + rwC.positionCurrent.x) / 3, (rwA.positionCurrent.y + rwB.positionCurrent.y + rwC.positionCurrent.y) / 3, (rwA.positionCurrent.z + rwB.positionCurrent.z + rwC.positionCurrent.z) / 3);
|
|
276
|
-
const pushMag = result.pushOut.magnitude;
|
|
277
|
-
if (pushMag < EPSILON) {
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
Vector3.scale(result.pushOut, 1 / pushMag, pushDir);
|
|
281
|
-
for(let k = 0; k < 3; k++){
|
|
282
|
-
const idxR = surfaceConstraints[index + j + k];
|
|
283
|
-
const rwPt = pointsRW[idxR];
|
|
284
|
-
Vector3.sub(rwPt.positionCurrent, triCenter, centerToPt);
|
|
285
|
-
Vector3.sub(rwPt.positionCurrent, result.intersectionPoint, intersectToPt);
|
|
286
|
-
const intersectLen = intersectToPt.magnitude;
|
|
287
|
-
let rate = intersectLen > EPSILON ? centerToPt.magnitude / intersectLen : 0;
|
|
288
|
-
rate = clamp01(Math.abs(rate));
|
|
289
|
-
Vector3.scale(pushDir, (result.radius - pushMag) * rate, pushVec);
|
|
290
|
-
Vector3.add(rwPt.positionCurrent, pushVec, rwPt.positionCurrent);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
// 閳光偓閳光偓 Constraint relaxation 閳光偓閳光偓
|
|
298
|
-
function constraintUpdate(pointsR, pointsRW, constraints, collidersR, collidersRW, constraintShrinkLimit, enableBroadPhase) {
|
|
299
|
-
const direction = new Vector3();
|
|
300
|
-
const dirN = new Vector3();
|
|
301
|
-
const disp = new Vector3();
|
|
302
|
-
const scaledDisp = new Vector3();
|
|
303
|
-
const pointResultA = {
|
|
304
|
-
hit: false,
|
|
305
|
-
point: new Vector3()
|
|
306
|
-
};
|
|
307
|
-
const pointResultB = {
|
|
308
|
-
hit: false,
|
|
309
|
-
point: new Vector3()
|
|
310
|
-
};
|
|
311
|
-
const lineResult = {
|
|
312
|
-
hit: false,
|
|
313
|
-
pointOnLine: new Vector3(),
|
|
314
|
-
pointOnCollider: new Vector3(),
|
|
315
|
-
radius: 0
|
|
316
|
-
};
|
|
317
|
-
const pushout = new Vector3();
|
|
318
|
-
const segment = new Vector3();
|
|
319
|
-
const pointToA = new Vector3();
|
|
320
|
-
const pointToB = new Vector3();
|
|
321
|
-
const pushN = new Vector3();
|
|
322
|
-
const pushVec = new Vector3();
|
|
323
|
-
for(let index = 0; index < constraints.length; index++){
|
|
324
|
-
const c = constraints[index];
|
|
325
|
-
const ptRA = pointsR[c.indexA];
|
|
326
|
-
const ptRB = pointsR[c.indexB];
|
|
327
|
-
const weightA = ptRA.weight;
|
|
328
|
-
const weightB = ptRB.weight;
|
|
329
|
-
if (weightA <= EPSILON && weightB <= EPSILON) {
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
const rwA = pointsRW[c.indexA];
|
|
333
|
-
const rwB = pointsRW[c.indexB];
|
|
334
|
-
Vector3.sub(rwB.positionCurrent, rwA.positionCurrent, direction);
|
|
335
|
-
const distance = direction.magnitude;
|
|
336
|
-
let shrinkLen = c.length;
|
|
337
|
-
let stretchLen = shrinkLen;
|
|
338
|
-
if (c.type === ConstraintType.Structural_Horizontal || c.type === ConstraintType.Bending_Horizontal || c.type === ConstraintType.Shear) {
|
|
339
|
-
stretchLen += ptRA.sliderJointLength + ptRB.sliderJointLength;
|
|
340
|
-
}
|
|
341
|
-
let force = 0;
|
|
342
|
-
if (distance <= shrinkLen) {
|
|
343
|
-
force = distance - shrinkLen;
|
|
344
|
-
} else if (distance >= stretchLen) {
|
|
345
|
-
force = distance - stretchLen;
|
|
346
|
-
}
|
|
347
|
-
const isShrink = force >= 0;
|
|
348
|
-
let power = 0;
|
|
349
|
-
switch(c.type){
|
|
350
|
-
case ConstraintType.Structural_Vertical:
|
|
351
|
-
power = isShrink ? ptRA.structuralShrinkVertical + ptRB.structuralShrinkVertical : ptRA.structuralStretchVertical + ptRB.structuralStretchVertical;
|
|
352
|
-
break;
|
|
353
|
-
case ConstraintType.Structural_Horizontal:
|
|
354
|
-
power = isShrink ? Math.min(constraintShrinkLimit, ptRA.structuralShrinkHorizontal + ptRB.structuralShrinkHorizontal) : ptRA.structuralStretchHorizontal + ptRB.structuralStretchHorizontal;
|
|
355
|
-
break;
|
|
356
|
-
case ConstraintType.Shear:
|
|
357
|
-
power = isShrink ? Math.min(constraintShrinkLimit, ptRA.shearShrink + ptRB.shearShrink) : ptRA.shearStretch + ptRB.shearStretch;
|
|
358
|
-
break;
|
|
359
|
-
case ConstraintType.Bending_Vertical:
|
|
360
|
-
power = isShrink ? ptRA.bendingShrinkVertical + ptRB.bendingShrinkVertical : ptRA.bendingStretchVertical + ptRB.bendingStretchVertical;
|
|
361
|
-
break;
|
|
362
|
-
case ConstraintType.Bending_Horizontal:
|
|
363
|
-
power = isShrink ? Math.min(constraintShrinkLimit, ptRA.bendingShrinkHorizontal + ptRB.bendingShrinkHorizontal) : ptRA.bendingStretchHorizontal + ptRB.bendingStretchHorizontal;
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
if (power > 0) {
|
|
367
|
-
if (distance > EPSILON) {
|
|
368
|
-
Vector3.scale(direction, 1 / distance, dirN);
|
|
369
|
-
} else {
|
|
370
|
-
dirN.setXYZ(0, 0, 0);
|
|
371
|
-
}
|
|
372
|
-
Vector3.scale(dirN, force * power, disp);
|
|
373
|
-
const wAB = weightA + weightB;
|
|
374
|
-
Vector3.scale(disp, weightA / wAB, scaledDisp);
|
|
375
|
-
Vector3.add(rwA.positionCurrent, scaledDisp, rwA.positionCurrent);
|
|
376
|
-
Vector3.scale(disp, weightB / wAB, scaledDisp);
|
|
377
|
-
Vector3.sub(rwB.positionCurrent, scaledDisp, rwB.positionCurrent);
|
|
378
|
-
}
|
|
379
|
-
// Per-constraint collision
|
|
380
|
-
if (c.isCollision !== 0) {
|
|
381
|
-
let friction = 0;
|
|
382
|
-
for(let i = 0; i < collidersR.length; i++){
|
|
383
|
-
const colRW = collidersRW[i];
|
|
384
|
-
if (colRW.enabled === 0) {
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
const colR = collidersR[i];
|
|
388
|
-
const canPointA = !enableBroadPhase || colR.isInverseCollider || pointMayCollideBroadPhase(rwA.positionCurrent, colRW, ptRA.pointRadius);
|
|
389
|
-
const canPointB = !enableBroadPhase || colR.isInverseCollider || pointMayCollideBroadPhase(rwB.positionCurrent, colRW, ptRB.pointRadius);
|
|
390
|
-
const canLine = !colR.isInverseCollider && (!enableBroadPhase || segmentMayCollideBroadPhase(rwA.positionCurrent, rwB.positionCurrent, colRW));
|
|
391
|
-
if (!canPointA && !canPointB && !canLine) {
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
if (colR.height > EPSILON) {
|
|
395
|
-
if (colR.isInverseCollider) {
|
|
396
|
-
if (ptRA.applyInvertCollision === 1 && canPointA) {
|
|
397
|
-
const res = pushInFromCapsule(colR, colRW, rwA.positionCurrent, pointResultA);
|
|
398
|
-
if (res.hit) {
|
|
399
|
-
rwA.positionCurrent.set(res.point);
|
|
400
|
-
friction = Math.max(friction, colR.friction * 0.25);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
if (ptRB.applyInvertCollision === 1 && canPointB) {
|
|
404
|
-
const res = pushInFromCapsule(colR, colRW, rwB.positionCurrent, pointResultB);
|
|
405
|
-
if (res.hit) {
|
|
406
|
-
rwB.positionCurrent.set(res.point);
|
|
407
|
-
friction = Math.max(friction, colR.friction * 0.25);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
} else {
|
|
411
|
-
if (canPointA) {
|
|
412
|
-
const res = pushoutFromCapsule(colR, colRW, rwA.positionCurrent, ptRA, pointResultA);
|
|
413
|
-
if (res.hit) {
|
|
414
|
-
rwA.positionCurrent.set(res.point);
|
|
415
|
-
friction = Math.max(friction, colR.friction * 0.25);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
if (canPointB) {
|
|
419
|
-
const res = pushoutFromCapsule(colR, colRW, rwB.positionCurrent, ptRB, pointResultB);
|
|
420
|
-
if (res.hit) {
|
|
421
|
-
rwB.positionCurrent.set(res.point);
|
|
422
|
-
friction = Math.max(friction, colR.friction * 0.25);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
} else {
|
|
427
|
-
if (colR.isInverseCollider) {
|
|
428
|
-
if (ptRA.applyInvertCollision === 1 && canPointA) {
|
|
429
|
-
const res = pushInFromSphere(colRW.positionCurrent, colRW.radius, rwA.positionCurrent, pointResultA);
|
|
430
|
-
if (res.hit) {
|
|
431
|
-
rwA.positionCurrent.set(res.point);
|
|
432
|
-
friction = Math.max(friction, colR.friction * 0.25);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
if (ptRB.applyInvertCollision === 1 && canPointB) {
|
|
436
|
-
const res = pushInFromSphere(colRW.positionCurrent, colRW.radius, rwB.positionCurrent, pointResultB);
|
|
437
|
-
if (res.hit) {
|
|
438
|
-
rwB.positionCurrent.set(res.point);
|
|
439
|
-
friction = Math.max(friction, colR.friction * 0.25);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
} else {
|
|
443
|
-
if (canPointA) {
|
|
444
|
-
const res = pushoutFromSphere(colRW.positionCurrent, colRW.radius, ptRA.pointRadius, rwA.positionCurrent, pointResultA);
|
|
445
|
-
if (res.hit) {
|
|
446
|
-
rwA.positionCurrent.set(res.point);
|
|
447
|
-
friction = Math.max(friction, colR.friction * 0.25);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
if (canPointB) {
|
|
451
|
-
const res = pushoutFromSphere(colRW.positionCurrent, colRW.radius, ptRB.pointRadius, rwB.positionCurrent, pointResultB);
|
|
452
|
-
if (res.hit) {
|
|
453
|
-
rwB.positionCurrent.set(res.point);
|
|
454
|
-
friction = Math.max(friction, colR.friction * 0.25);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
// Line segment collision
|
|
460
|
-
if (!colR.isInverseCollider && canLine) {
|
|
461
|
-
const lineRes = collisionDetection(colR, colRW, rwA.positionCurrent, rwB.positionCurrent, lineResult);
|
|
462
|
-
if (lineRes.hit) {
|
|
463
|
-
Vector3.sub(lineRes.pointOnLine, lineRes.pointOnCollider, pushout);
|
|
464
|
-
const pushDist = pushout.magnitude;
|
|
465
|
-
if (pushDist > EPSILON) {
|
|
466
|
-
const ptDist = Vector3.sub(rwB.positionCurrent, rwA.positionCurrent, segment).magnitude * 0.5;
|
|
467
|
-
const rateP1 = ptDist > EPSILON ? clamp01(Vector3.sub(lineRes.pointOnLine, rwA.positionCurrent, pointToA).magnitude / ptDist) : 0;
|
|
468
|
-
const rateP2 = ptDist > EPSILON ? clamp01(Vector3.sub(lineRes.pointOnLine, rwB.positionCurrent, pointToB).magnitude / ptDist) : 0;
|
|
469
|
-
Vector3.scale(pushout, 1 / pushDist, pushN);
|
|
470
|
-
Vector3.scale(pushN, Math.max(lineRes.radius - pushDist, 0), pushVec);
|
|
471
|
-
if (weightA > EPSILON) {
|
|
472
|
-
Vector3.scale(pushVec, rateP2, scaledDisp);
|
|
473
|
-
Vector3.add(rwA.positionCurrent, scaledDisp, rwA.positionCurrent);
|
|
474
|
-
}
|
|
475
|
-
if (weightB > EPSILON) {
|
|
476
|
-
Vector3.scale(pushVec, rateP1, scaledDisp);
|
|
477
|
-
Vector3.add(rwB.positionCurrent, scaledDisp, rwB.positionCurrent);
|
|
478
|
-
}
|
|
479
|
-
const dotUp = Vector3.dot(AXIS_Y, Vector3.normalize(pushout, pushN));
|
|
480
|
-
friction = Math.max(friction, colR.friction * clamp01(dotUp));
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
rwA.friction = Math.max(friction, rwA.friction);
|
|
486
|
-
rwB.friction = Math.max(friction, rwB.friction);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
// 閳光偓閳光偓 Pass 2: blend + fake wave 閳光偓閳光偓
|
|
491
|
-
function pointUpdatePass2(pointsR, pointsRW, positionsToTransform, stepDelta, fakeWaveFreq, blendRatio, isFakeWave, fakeWavePower) {
|
|
492
|
-
let freq = fakeWaveFreq;
|
|
493
|
-
const curTransformPos = new Vector3();
|
|
494
|
-
const fakeWindOffset = new Vector3();
|
|
495
|
-
for(let index = 0; index < pointsR.length; index++){
|
|
496
|
-
const ptR = pointsR[index];
|
|
497
|
-
const ptRW = pointsRW[index];
|
|
498
|
-
Vector3.lerp(ptRW.positionPreviousTransform, ptRW.positionCurrentTransform, stepDelta, curTransformPos);
|
|
499
|
-
const blend = smoothStep(0, 1, Math.max(ptR.forceFadeRatio, blendRatio));
|
|
500
|
-
Vector3.lerp(ptRW.positionCurrent, curTransformPos, blend, ptRW.positionToTransform);
|
|
501
|
-
if (isFakeWave && ptR.child === -1 && ptR.parent !== -1) {
|
|
502
|
-
const A = pointsRW[ptR.parent].positionToTransform;
|
|
503
|
-
const B = ptRW.positionToTransform;
|
|
504
|
-
const mAxis = Matrix4x4.lookAt(A, B, AXIS_Y);
|
|
505
|
-
// Column 1 = up axis of the look-at matrix
|
|
506
|
-
const col1 = mAxis.getCol(1).xyz();
|
|
507
|
-
Vector3.lerp(ptRW.fakeWindDirection, col1, 0.5, ptRW.fakeWindDirection);
|
|
508
|
-
freq += ptR.fakeWaveFreq;
|
|
509
|
-
const power = Math.sin(freq) * fakeWavePower * ptR.fakeWavePower;
|
|
510
|
-
Vector3.scale(ptRW.fakeWindDirection, power, fakeWindOffset);
|
|
511
|
-
Vector3.add(ptRW.positionToTransform, fakeWindOffset, ptRW.positionToTransform);
|
|
512
|
-
}
|
|
513
|
-
positionsToTransform[index] = ptRW.positionToTransform.clone();
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
function applyResult(pointsR, pointsRW, positionsToTransform, blendRatio, // Current transform rotations (world and local) read from engine
|
|
517
|
-
transformRotations, transformLocalRotations) {
|
|
518
|
-
const results = new Array(pointsR.length);
|
|
519
|
-
for(let index = 0; index < pointsR.length; index++){
|
|
520
|
-
const ptR = pointsR[index];
|
|
521
|
-
const ptRW = pointsRW[index];
|
|
522
|
-
let worldRot = transformRotations[index];
|
|
523
|
-
let localRot = transformLocalRotations[index];
|
|
524
|
-
if (ptR.weight >= EPSILON) {
|
|
525
|
-
// Dynamic point
|
|
526
|
-
if (ptR.parent !== -1) {
|
|
527
|
-
const direction = Vector3.sub(ptRW.positionToTransform, positionsToTransform[ptR.parent]);
|
|
528
|
-
const realLen = direction.magnitude;
|
|
529
|
-
if (realLen > EPSILON) {
|
|
530
|
-
ptRW.directionPrevious = direction;
|
|
531
|
-
} else {
|
|
532
|
-
ptRW.positionToTransform = Vector3.add(positionsToTransform[ptR.parent], ptRW.directionPrevious);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
const pos = ptRW.positionToTransform;
|
|
536
|
-
// SetRotation with blendRatio=0 for dynamic points
|
|
537
|
-
// Step 1: Reset localRotation 閳?initialLocalRotation (blendRatio=0 閳?fully initial)
|
|
538
|
-
localRot = ptR.initialLocalRotation.clone();
|
|
539
|
-
// Step 2: Recompute worldRot from the new localRot
|
|
540
|
-
// In C#, setting localRotation immediately updates the world rotation.
|
|
541
|
-
// worldRot = parentWorldRot * localRot
|
|
542
|
-
// We approximate: the parent's current world rotation is in transformRotations[ptR.parent]
|
|
543
|
-
if (ptR.parent !== -1) {
|
|
544
|
-
// Use the parent's OUTPUT rotation (already computed if parent index < current index)
|
|
545
|
-
const parentRot = results[ptR.parent] ? results[ptR.parent].rotation : transformRotations[ptR.parent];
|
|
546
|
-
worldRot = Quaternion.multiply(parentRot, localRot);
|
|
547
|
-
} else {
|
|
548
|
-
worldRot = localRot.clone();
|
|
549
|
-
}
|
|
550
|
-
// Step 3: Aim toward child using updated worldRot
|
|
551
|
-
if (ptR.child !== -1) {
|
|
552
|
-
const childDir = Vector3.sub(positionsToTransform[ptR.child], ptRW.positionToTransform);
|
|
553
|
-
if (childDir.magnitudeSq > EPSILON) {
|
|
554
|
-
const aimVec = worldRot.transform(ptR.boneAxis);
|
|
555
|
-
const aimRot = Quaternion.unitVectorToUnitVector(aimVec, childDir);
|
|
556
|
-
worldRot = Quaternion.multiply(aimRot, worldRot);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
results[index] = {
|
|
560
|
-
position: pos,
|
|
561
|
-
rotation: worldRot,
|
|
562
|
-
localRotation: localRot
|
|
563
|
-
};
|
|
564
|
-
} else {
|
|
565
|
-
// Fixed point 閳?follow transform, blend rotation
|
|
566
|
-
const childBlend = ptR.child !== -1 ? Math.max(pointsR[ptR.child].forceFadeRatio, blendRatio) : blendRatio;
|
|
567
|
-
// Step 1: Blend localRotation
|
|
568
|
-
localRot = Quaternion.slerp(ptR.initialLocalRotation, localRot, childBlend);
|
|
569
|
-
// Step 2: Recompute worldRot from blended localRot
|
|
570
|
-
if (ptR.parent !== -1) {
|
|
571
|
-
const parentRot = results[ptR.parent] ? results[ptR.parent].rotation : transformRotations[ptR.parent];
|
|
572
|
-
worldRot = Quaternion.multiply(parentRot, localRot);
|
|
573
|
-
} else {
|
|
574
|
-
worldRot = localRot.clone();
|
|
575
|
-
}
|
|
576
|
-
// Step 3: Aim toward child with blend
|
|
577
|
-
if (ptR.child !== -1) {
|
|
578
|
-
const childDir = Vector3.sub(positionsToTransform[ptR.child], ptRW.positionToTransform);
|
|
579
|
-
if (childDir.magnitudeSq > EPSILON) {
|
|
580
|
-
const aimVec = worldRot.transform(ptR.boneAxis);
|
|
581
|
-
const aimRot = Quaternion.unitVectorToUnitVector(aimVec, childDir);
|
|
582
|
-
worldRot = Quaternion.slerp(Quaternion.multiply(aimRot, worldRot), worldRot, childBlend);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
results[index] = {
|
|
586
|
-
position: ptRW.positionCurrentTransform,
|
|
587
|
-
rotation: worldRot,
|
|
588
|
-
localRotation: localRot
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
return results;
|
|
593
|
-
}
|
|
594
|
-
// 閳光偓閳光偓 Angle limiting (post-simulation) 閳光偓閳光偓
|
|
595
|
-
function applyAngleLimits(pointsR, pointsRW, config) {
|
|
596
|
-
if (config.angleLimit < 0) {
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
for(let index = 0; index < pointsR.length; index++){
|
|
600
|
-
const ptR = pointsR[index];
|
|
601
|
-
if (ptR.parent === -1) {
|
|
602
|
-
continue;
|
|
603
|
-
}
|
|
604
|
-
const ptRW = pointsRW[index];
|
|
605
|
-
const ptRp = pointsR[ptR.parent];
|
|
606
|
-
const ptRWp = pointsRW[ptR.parent];
|
|
607
|
-
const superParentPos = ptRp.parent !== -1 ? pointsRW[ptRp.parent].positionCurrent : ptRWp.positionCurrent;
|
|
608
|
-
const boneDir = Vector3.sub(ptRW.positionCurrent, ptRWp.positionCurrent);
|
|
609
|
-
let parentBoneDir = Vector3.sub(ptRWp.positionCurrent, superParentPos);
|
|
610
|
-
if (parentBoneDir.magnitude === 0 || config.limitFromRoot) {
|
|
611
|
-
parentBoneDir = Vector3.sub(ptRW.positionCurrentTransform, ptRWp.positionCurrentTransform);
|
|
612
|
-
}
|
|
613
|
-
const angle = Vector3.angleBetween(parentBoneDir, boneDir);
|
|
614
|
-
const remaining = radian2degree(angle) - config.angleLimit;
|
|
615
|
-
if (remaining > 0) {
|
|
616
|
-
const axis = Vector3.cross(parentBoneDir, boneDir);
|
|
617
|
-
const rotated = Quaternion.fromAxisAngle(axis, degree2radian(-remaining)).transform(boneDir);
|
|
618
|
-
ptRW.positionCurrent = Vector3.add(ptRWp.positionCurrent, rotated);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
export { applyAngleLimits, applyResult, simulate };
|
|
624
|
-
//# sourceMappingURL=solver.js.map
|