@zephyr3d/scene 0.9.25 → 0.9.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationset.js +92 -30
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/hair/gpu_hair_simulation.js +1090 -0
- package/dist/animation/hair/gpu_hair_simulation.js.map +1 -0
- package/dist/animation/joint_dynamics/controller.js +7 -5
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +81 -5
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -4
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +79 -25
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/multi_chain_spring_system.js +577 -179
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +4 -3
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_node_pose_tracker.js +40 -0
- package/dist/animation/spring/spring_node_pose_tracker.js.map +1 -0
- package/dist/animation/spring/spring_particle.js +2 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +11 -3
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +10 -0
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/engine.js +53 -43
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptingsystem.js +119 -6
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +3 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +284 -67
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/zhair/zhair_format.js +288 -0
- package/dist/asset/loaders/zhair/zhair_format.js.map +1 -0
- package/dist/asset/loaders/zhair/zhair_loader.js +221 -0
- package/dist/asset/loaders/zhair/zhair_loader.js.map +1 -0
- package/dist/asset/model.js +184 -69
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +268 -44
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +3 -1
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +9044 -5139
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/material/eye.js +932 -0
- package/dist/material/eye.js.map +1 -0
- package/dist/material/hair.js +917 -0
- package/dist/material/hair.js.map +1 -0
- package/dist/material/hairstrand.js +842 -0
- package/dist/material/hairstrand.js.map +1 -0
- package/dist/material/hairstrand_data.js +162 -0
- package/dist/material/hairstrand_data.js.map +1 -0
- package/dist/material/lambert.js +5 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +48 -10
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +120 -19
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +1 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +5 -3
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +5 -4
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +3 -3
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +106 -19
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +4 -4
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +48 -11
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mtoon.js +6 -5
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrblueprint.js +146 -28
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrblueprint_instance.js +501 -0
- package/dist/material/pbrblueprint_instance.js.map +1 -0
- package/dist/material/pbrmr.js +15 -16
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/shader/helper.js +734 -23
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +55 -0
- package/dist/material/shader/terrain_blend.js.map +1 -0
- package/dist/material/skin.js +192 -32
- package/dist/material/skin.js.map +1 -1
- package/dist/material/spriteblueprint.js +16 -1
- package/dist/material/spriteblueprint.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +86 -23
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/water.js +2059 -72
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/bloom.js +167 -7
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/coloradjust.js +2 -1
- package/dist/posteffect/coloradjust.js.map +1 -1
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +2 -1
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -1
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js +664 -56
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js +12 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +46 -44
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +368 -69
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +16 -9
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +121 -36
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/posteffect/tonemap.js +44 -1
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +8 -2
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +156 -5
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cull_visitor.js +20 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +36 -2
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +26 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +3 -2
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +1 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +6 -3
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +57 -15
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +130 -20
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +3 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +80 -22
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +6 -3
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/oit.js +29 -0
- package/dist/render/oit.js.map +1 -0
- package/dist/render/render_queue.js +39 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +4 -0
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +1 -0
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +2 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +379 -10
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
- package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +8 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/shadow_mask_pass.js +73 -8
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/sky.js +166 -126
- package/dist/render/sky.js.map +1 -1
- package/dist/render/underwater.js +624 -0
- package/dist/render/underwater.js.map +1 -0
- package/dist/render/water_caustics.js +1380 -0
- package/dist/render/water_caustics.js.map +1 -0
- package/dist/render/weightedblended_oit.js +3 -2
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +8 -0
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -0
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +4 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/hair.js +963 -0
- package/dist/scene/hair.js.map +1 -0
- package/dist/scene/light.js +5 -1
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +481 -47
- 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 +3 -0
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +3 -0
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +6 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +3 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -1
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +3 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +3 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +6 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/texture_cache.js +309 -0
- package/dist/scene/terrain-cm/texture_cache.js.map +1 -0
- package/dist/scene/water.js +546 -4
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/diffusion.js +54 -0
- package/dist/shaders/diffusion.js.map +1 -0
- package/dist/shaders/shadow.js +33 -21
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/temporal.js +71 -33
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +22 -19
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +56 -0
- package/dist/shaders/water_medium.js.map +1 -0
- package/dist/shadow/dom.js +546 -0
- package/dist/shadow/dom.js.map +1 -0
- package/dist/shadow/pcf_opt.js +3 -5
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +1 -1
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/receiver_bias.js +41 -0
- package/dist/shadow/receiver_bias.js.map +1 -0
- package/dist/shadow/shader.js +20 -60
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +89 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +1 -1
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +150 -37
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/shape.js +11 -2
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +50 -9
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +112 -2
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/func.js +142 -49
- package/dist/utility/blueprint/material/func.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +490 -25
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +898 -4
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +434 -101
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +401 -5
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +186 -26
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +26 -5
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/hair.js +1141 -0
- package/dist/utility/serialization/scene/hair.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +84 -4
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1867 -166
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +231 -14
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +141 -7
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +18 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +4 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +4 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +4 -0
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +1105 -21
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +9 -8
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/values.js +49 -2
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- package/dist/render/rendergraph/frame_graph_context.js +0 -41
- package/dist/render/rendergraph/frame_graph_context.js.map +0 -1
- package/dist/shaders/ssgi.js +0 -63
- package/dist/shaders/ssgi.js.map +0 -1
- package/dist/shaders/ssgi_reprojection.js +0 -118
- package/dist/shaders/ssgi_reprojection.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu_hair_simulation.js","sources":["../../../src/animation/hair/gpu_hair_simulation.ts"],"sourcesContent":["/*\r\n * The solver below is a port of AMD's TressFX hair simulation, reimplemented\r\n * for WebGPU compute. The five simulation stages, the quaternion helpers they\r\n * use, and the tuning defaults follow TressFXSimulation.hlsl and\r\n * TressFXSettings.h; the deviations are noted at the points where they occur.\r\n *\r\n * TressFX is distributed under the MIT license, reproduced here in full as that\r\n * license requires:\r\n *\r\n * Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved.\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n\r\n/**\r\n * GPU strand dynamics.\r\n *\r\n * @remarks\r\n * A port of TressFX. TressFX gives a thread to each vertex and needs shared\r\n * memory, barriers and a uniform vertex count per strand; a groom imported from\r\n * an archive has no uniform vertex count, so a thread here owns a whole strand\r\n * instead. That also buys a serial root-to-tip walk, which is what lets the\r\n * length constraint be exact in one pass. See\r\n * {@link createHairSimulationProgram} for the stages.\r\n *\r\n * Everything is solved in the node's local space, because\r\n * {@link HairStrandMaterial} applies the world matrix itself and a world-space\r\n * solver would have it applied twice. Node motion is reproduced through the\r\n * frame-to-frame transform `inverse(world) * prevWorld`: a point that stood\r\n * still in the world has moved in local space by exactly that, so carrying both\r\n * stored positions through it leaves the strand where it was and the pinned\r\n * roots drag it along. Gravity and colliders come the other way, on the CPU.\r\n *\r\n * WebGPU only, like the rendering path it feeds.\r\n */\r\nimport type { AbstractDevice, BindGroup, GPUDataBuffer, GPUProgram } from '@zephyr3d/device';\r\nimport type { Nullable } from '@zephyr3d/base';\r\nimport { Matrix4x4, Quaternion, Vector3, Disposable } from '@zephyr3d/base';\r\nimport { getDevice } from '../../app/api';\r\nimport type { HairStrandData, HairStrandSource } from '../../material/hairstrand_data';\r\nimport type {\r\n CapsuleCollider,\r\n PlaneCollider,\r\n SphereCollider,\r\n SpringCollider\r\n} from '../spring/spring_collider';\r\nimport { updateColliderFromNode } from '../spring/spring_collider';\r\n\r\n/** Simulation step, in seconds. @internal */\r\nconst FIXED_SIMULATION_TIME_STEP = 1 / 60;\r\n/** Largest backlog the accumulator will carry, in seconds. @internal */\r\nconst MAX_ACCUMULATED_SIMULATION_TIME = 1 / 20;\r\n/** Threads per workgroup; one thread owns one strand. @internal */\r\nconst DEFAULT_WORKGROUP_SIZE = 64;\r\n/** Length below which a direction is treated as degenerate. @internal */\r\nconst MIN_DISTANCE = 1e-7;\r\n/** Floats per collider entry, matching the layouts the shader indexes. @internal */\r\nconst SPHERE_STRIDE = 4;\r\nconst CAPSULE_STRIDE = 8;\r\nconst PLANE_STRIDE = 8;\r\n/** Colliders of one kind the buffers make room for. @internal */\r\nconst MAX_COLLIDERS = 16;\r\n/** Solver defaults, from TressFXSimulationSettings. @internal */\r\nconst DEFAULT_DAMPING = 0.08;\r\nconst DEFAULT_GLOBAL_STIFFNESS = 0;\r\nconst DEFAULT_GLOBAL_RANGE = 0;\r\nconst DEFAULT_LOCAL_STIFFNESS = 0.9;\r\nconst DEFAULT_LOCAL_ITERATIONS = 2;\r\nconst DEFAULT_FTL_DAMPING = 0.7;\r\nconst DEFAULT_VSP_COEFF = 0.8;\r\n/**\r\n * Roughly five gravities. TressFX compares a per-frame second difference\r\n * against 1.4 in its own units; as an acceleration it survives a unit change.\r\n * @internal\r\n */\r\nconst DEFAULT_VSP_ACCEL_THRESHOLD = 50;\r\n/** Default per-substep speed ceiling, in segment lengths. @internal */\r\nconst DEFAULT_MAX_SPEED_FACTOR = 4;\r\n/**\r\n * Node motion beyond this many strand lengths in one frame is treated as a\r\n * teleport and snaps the pose instead of swinging it.\r\n * @internal\r\n */\r\nconst TELEPORT_DISTANCE_FACTOR = 4;\r\n\r\n/**\r\n * Tuning for {@link GPUHairSimulation}.\r\n *\r\n * @public\r\n */\r\nexport type GPUHairSimulationOptions = {\r\n /** World-space gravity. Defaults to earth gravity along -Y. */\r\n gravity?: Vector3;\r\n /**\r\n * Velocity lost per fixed 1/60 s step, in [0, 1]. 0 keeps full inertia.\r\n *\r\n * @remarks\r\n * An exponential decay, so the dial means the same thing whatever\r\n * {@link GPUHairSimulationOptions.substeps} is.\r\n */\r\n damping?: number;\r\n /**\r\n * How strongly a strand is pulled back to its authored pose, in [0, 1].\r\n *\r\n * @remarks\r\n * Off by default, as in TressFX. It anchors a point to a fixed place rather\r\n * than to its neighbours, which is a spring, and a groom held by springs reads\r\n * as one. {@link GPUHairSimulationOptions.localStiffness} is what holds\r\n * styling without that; pair this with\r\n * {@link GPUHairSimulationOptions.globalRange} where a groom genuinely should\r\n * not move far from how it was authored.\r\n */\r\n globalStiffness?: number;\r\n /**\r\n * Fraction of each strand, from the root, that\r\n * {@link GPUHairSimulationOptions.globalStiffness} acts on, in [0, 1].\r\n *\r\n * @remarks\r\n * 0 disables the pull outright - both have to be non-zero for it to do\r\n * anything.\r\n */\r\n globalRange?: number;\r\n /**\r\n * How strongly a strand keeps the shape it was authored with, in [0, 1].\r\n *\r\n * @remarks\r\n * The dial to reach for first. It holds the angle each segment makes with the\r\n * one before it, measured against that segment's current direction rather than\r\n * a fixed pose, so a strand keeps its curl while remaining free to hang and\r\n * swing. It is also what damps a groom: a chain with no bending resistance\r\n * carries a disturbance up and down its length for seconds.\r\n */\r\n localStiffness?: number;\r\n /**\r\n * Times the local shape constraint is applied per substep, in [1, 8].\r\n *\r\n * @remarks\r\n * The constraint moves both points it touches, so one pass falls short of the\r\n * shape it aims for. More passes converge, at proportional cost.\r\n */\r\n localIterations?: number;\r\n /**\r\n * Share of a point's length correction fed back into its parent, in [0, 1].\r\n *\r\n * @remarks\r\n * The length constraint satisfies a segment by moving the child alone, which\r\n * leaves the momentum that correction represents unaccounted for. Unaccounted\r\n * it accumulates: every root movement pumps the chain, and because the\r\n * segments are coupled in series it collects at the free end and the groom\r\n * whips. Handing it back as reverse momentum - Mueller's FTL damping - is what\r\n * prevents that; 0 reproduces the uncorrected behaviour.\r\n */\r\n ftlDamping?: number;\r\n /**\r\n * How much of the node's motion a strand is carried along by, in [0, 1].\r\n *\r\n * @remarks\r\n * Velocity shock propagation. 0 leaves a strand where it was in the world and\r\n * lets the pinned roots drag it through the constraints, which is what\r\n * produces lag - but a root moving fast enough outruns its strand within a\r\n * step and the length constraint has to snap it back. 1 carries the strand\r\n * rigidly with the node. Lower values give a livelier, floppier groom.\r\n */\r\n vspCoeff?: number;\r\n /**\r\n * Node acceleration above which a strand is carried rigidly, in world units\r\n * per second squared.\r\n *\r\n * @remarks\r\n * Past this, {@link GPUHairSimulationOptions.vspCoeff} is treated as 1 for the\r\n * step, since a hard shove is where lag turns into over-stretching. The\r\n * default is around five gravities.\r\n */\r\n vspAccelThreshold?: number;\r\n /** Integration substeps per fixed step, in [1, 8]. */\r\n substeps?: number;\r\n /** Colliders the strands are pushed out of. */\r\n colliders?: SpringCollider[];\r\n /** Friction applied to the tangential motion of a contact, in [0, 1]. */\r\n friction?: number;\r\n /**\r\n * Per-substep ceiling on how far a point may travel, in segment lengths.\r\n *\r\n * @remarks\r\n * A backstop, not a dial: at the default it never engages during ordinary\r\n * motion. Measured in segment lengths, so it is unit-independent.\r\n */\r\n maxSpeedFactor?: number;\r\n};\r\n\r\n/**\r\n * Whether GPU hair dynamics can run on a device.\r\n *\r\n * @remarks\r\n * WebGPU only: the solver is a compute pass. Strand rendering carries the same\r\n * requirement, so there is no configuration where the hair draws but cannot\r\n * simulate.\r\n *\r\n * @param device - Device to test, or the current one when omitted.\r\n * @returns True when the simulation can run.\r\n *\r\n * @public\r\n */\r\nexport function isHairSimulationSupported(device?: Nullable<AbstractDevice>) {\r\n const resolved = device ?? getDevice();\r\n return resolved?.type === 'webgpu';\r\n}\r\n\r\nfunction clamp(value: number, min: number, max: number) {\r\n return value < min ? min : value > max ? max : value;\r\n}\r\n\r\n/** Exact element-wise matrix comparison, for skipping the interpolation. @internal */\r\nfunction matrixEquals(a: Matrix4x4, b: Matrix4x4) {\r\n for (let i = 0; i < 16; i++) {\r\n if (a[i] !== b[i]) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Strand dynamics on the GPU.\r\n *\r\n * @remarks\r\n * Created by {@link HairNode} when simulation is switched on; it writes the\r\n * strand point buffer in place, so nothing about the draw call changes.\r\n *\r\n * @public\r\n */\r\nexport class GPUHairSimulation extends Disposable {\r\n /** @internal */\r\n private readonly _device: Nullable<AbstractDevice>;\r\n /** @internal */\r\n private _enabled: boolean;\r\n /** @internal */\r\n private _disabledReason: Nullable<string>;\r\n /** @internal */\r\n private _program: Nullable<GPUProgram>;\r\n /** @internal */\r\n private _bindGroup: Nullable<BindGroup>;\r\n /** @internal Live point positions; the same buffer the vertex shader reads. */\r\n private _pointBuffer: Nullable<GPUDataBuffer>;\r\n /** @internal Previous positions, for Verlet integration and motion vectors. */\r\n private _prevPointBuffer: Nullable<GPUDataBuffer>;\r\n /** @internal Authored positions, the target the pose pull reaches for. */\r\n private _restPointBuffer: Nullable<GPUDataBuffer>;\r\n /**\r\n * @internal Local positions as of the previously rendered frame, which is what\r\n * a motion vector needs. Distinct from the Verlet history: that is one substep\r\n * old, sits in the current frame's local space, and has the length, contact and\r\n * friction corrections folded into it to encode velocity, so it is not a\r\n * position anything was ever drawn at.\r\n */\r\n private _framePointBuffer: Nullable<GPUDataBuffer>;\r\n /** @internal Authored distance between consecutive control points. */\r\n private _restLengthBuffer: Nullable<GPUDataBuffer>;\r\n /** @internal */\r\n private _sphereBuffer: Nullable<GPUDataBuffer>;\r\n /** @internal */\r\n private _capsuleBuffer: Nullable<GPUDataBuffer>;\r\n /** @internal */\r\n private _planeBuffer: Nullable<GPUDataBuffer>;\r\n /** @internal */\r\n private readonly _strandCount: number;\r\n /** @internal */\r\n private readonly _workgroupCount: number;\r\n /** @internal */\r\n private _gravity: Vector3;\r\n /** @internal */\r\n private _damping: number;\r\n /** @internal */\r\n private _globalStiffness: number;\r\n /** @internal */\r\n private _globalRange: number;\r\n /** @internal */\r\n private _localStiffness: number;\r\n /** @internal */\r\n private _localIterations: number;\r\n /** @internal */\r\n private _ftlDamping: number;\r\n /** @internal */\r\n private _vspCoeff: number;\r\n /** @internal */\r\n private _vspAccelThreshold: number;\r\n /** @internal */\r\n private _substeps: number;\r\n /** @internal */\r\n private _friction: number;\r\n /** @internal */\r\n private _maxSpeedFactor: number;\r\n /** @internal */\r\n private _colliders: SpringCollider[];\r\n /** @internal */\r\n private _timeAccumulator: number;\r\n /** @internal Scratch, so stepping allocates nothing. */\r\n private readonly _sphereData: Float32Array<ArrayBuffer>;\r\n private readonly _capsuleData: Float32Array<ArrayBuffer>;\r\n private readonly _planeData: Float32Array<ArrayBuffer>;\r\n private readonly _relativeTransform: Matrix4x4;\r\n private readonly _invWorldMatrix: Matrix4x4;\r\n private readonly _prevWorldMatrix: Matrix4x4;\r\n /** @internal Bound while the node stands still, so those frames upload nothing new. */\r\n private readonly _identity: Matrix4x4;\r\n private readonly _localGravity: Vector3;\r\n private readonly _scratchVec: Vector3;\r\n private readonly _scratchVec2: Vector3;\r\n /** @internal Endpoints and scratch of the per-substep transform interpolation. */\r\n private readonly _scaleFrom: Vector3;\r\n private readonly _scaleTo: Vector3;\r\n private readonly _translationFrom: Vector3;\r\n private readonly _translationTo: Vector3;\r\n private readonly _rotationFrom: Quaternion;\r\n private readonly _rotationTo: Quaternion;\r\n private readonly _rotationLerp: Quaternion;\r\n private readonly _stepFrom: Matrix4x4;\r\n private readonly _stepTo: Matrix4x4;\r\n /** @internal True until the first step has seen a world matrix. */\r\n private _hasPrevWorldMatrix: boolean;\r\n /** @internal Length of the longest strand, for the teleport threshold. */\r\n private _maxStrandLength: number;\r\n /** @internal Centre of the rest pose, whose world motion detects teleports. */\r\n private readonly _restCenter: Vector3;\r\n /**\r\n * @internal Where the rest centre stood in the world last frame and how fast\r\n * it was moving. The roots are pinned in local space, so their acceleration is\r\n * the node's, which is what the shock propagation threshold tests.\r\n */\r\n private readonly _prevRootWorld: Vector3;\r\n private readonly _prevRootVelocity: Vector3;\r\n /** @internal Frames seen so far, capped at 2; acceleration needs three. */\r\n private _rootHistoryDepth: number;\r\n /**\r\n * Creates a simulation over an uploaded strand set.\r\n *\r\n * @param strands - GPU strand data; its point buffer is written in place.\r\n * @param source - The control points the strands were built from, used to\r\n * derive rest lengths and the rest pose.\r\n * @param options - Tuning.\r\n */\r\n constructor(strands: HairStrandData, source: HairStrandSource, options?: GPUHairSimulationOptions) {\r\n super();\r\n this._device = getDevice();\r\n this._enabled = false;\r\n this._disabledReason = null;\r\n this._program = null;\r\n this._bindGroup = null;\r\n this._pointBuffer = null;\r\n this._prevPointBuffer = null;\r\n this._restPointBuffer = null;\r\n this._framePointBuffer = null;\r\n this._restLengthBuffer = null;\r\n this._sphereBuffer = null;\r\n this._capsuleBuffer = null;\r\n this._planeBuffer = null;\r\n this._strandCount = strands.strandCount;\r\n this._gravity = options?.gravity ? new Vector3(options.gravity) : new Vector3(0, -9.8, 0);\r\n this._damping = clamp(options?.damping ?? DEFAULT_DAMPING, 0, 1);\r\n this._globalStiffness = clamp(options?.globalStiffness ?? DEFAULT_GLOBAL_STIFFNESS, 0, 1);\r\n this._globalRange = clamp(options?.globalRange ?? DEFAULT_GLOBAL_RANGE, 0, 1);\r\n this._localStiffness = clamp(options?.localStiffness ?? DEFAULT_LOCAL_STIFFNESS, 0, 1);\r\n this._localIterations = clamp(options?.localIterations ?? DEFAULT_LOCAL_ITERATIONS, 1, 8) | 0;\r\n this._ftlDamping = clamp(options?.ftlDamping ?? DEFAULT_FTL_DAMPING, 0, 1);\r\n this._vspCoeff = clamp(options?.vspCoeff ?? DEFAULT_VSP_COEFF, 0, 1);\r\n this._vspAccelThreshold = Math.max(0, options?.vspAccelThreshold ?? DEFAULT_VSP_ACCEL_THRESHOLD);\r\n this._substeps = clamp(options?.substeps ?? 1, 1, 8) | 0;\r\n this._friction = clamp(options?.friction ?? 0.2, 0, 1);\r\n this._maxSpeedFactor = Math.max(0, options?.maxSpeedFactor ?? DEFAULT_MAX_SPEED_FACTOR);\r\n this._colliders = options?.colliders ? [...options.colliders] : [];\r\n this._timeAccumulator = 0;\r\n this._sphereData = new Float32Array(MAX_COLLIDERS * SPHERE_STRIDE);\r\n this._capsuleData = new Float32Array(MAX_COLLIDERS * CAPSULE_STRIDE);\r\n this._planeData = new Float32Array(MAX_COLLIDERS * PLANE_STRIDE);\r\n this._relativeTransform = Matrix4x4.identity();\r\n this._invWorldMatrix = Matrix4x4.identity();\r\n this._prevWorldMatrix = Matrix4x4.identity();\r\n this._identity = Matrix4x4.identity();\r\n this._localGravity = new Vector3();\r\n this._scratchVec = new Vector3();\r\n this._scratchVec2 = new Vector3();\r\n this._scaleFrom = new Vector3();\r\n this._scaleTo = new Vector3();\r\n this._translationFrom = new Vector3();\r\n this._translationTo = new Vector3();\r\n this._rotationFrom = new Quaternion();\r\n this._rotationTo = new Quaternion();\r\n this._rotationLerp = new Quaternion();\r\n this._stepFrom = Matrix4x4.identity();\r\n this._stepTo = Matrix4x4.identity();\r\n this._hasPrevWorldMatrix = false;\r\n this._maxStrandLength = 0;\r\n this._restCenter = new Vector3();\r\n this._prevRootWorld = new Vector3();\r\n this._prevRootVelocity = new Vector3();\r\n this._rootHistoryDepth = 0;\r\n this._workgroupCount = Math.ceil(this._strandCount / DEFAULT_WORKGROUP_SIZE);\r\n\r\n if (!isHairSimulationSupported(this._device)) {\r\n this._disabledReason = 'GPU hair simulation is disabled: current backend is not WebGPU.';\r\n return;\r\n }\r\n if (!strands.pointBuffer || !strands.headerBuffer) {\r\n this._disabledReason = 'GPU hair simulation is disabled: strand data has no GPU buffers.';\r\n return;\r\n }\r\n try {\r\n this._init(strands, source);\r\n this._enabled = true;\r\n } catch (err) {\r\n this._disabledReason = `GPU hair simulation is disabled: ${err}`;\r\n this._releaseResources();\r\n }\r\n }\r\n /** Whether the simulation is running. */\r\n get enabled() {\r\n return this._enabled;\r\n }\r\n /** Why the simulation is not running, when it is not. */\r\n get disabledReason() {\r\n return this._disabledReason;\r\n }\r\n /** World-space gravity. */\r\n get gravity() {\r\n return this._gravity;\r\n }\r\n set gravity(value: Vector3) {\r\n this._gravity = new Vector3(value);\r\n }\r\n /** Velocity lost per step, in [0, 1]. */\r\n get damping() {\r\n return this._damping;\r\n }\r\n set damping(value: number) {\r\n this._damping = clamp(value, 0, 1);\r\n }\r\n /** Per-substep ceiling on point travel, in segment lengths. */\r\n get maxSpeedFactor() {\r\n return this._maxSpeedFactor;\r\n }\r\n set maxSpeedFactor(value: number) {\r\n this._maxSpeedFactor = Math.max(0, value);\r\n }\r\n /** Pull back to the authored pose per fixed step, in [0, 1]. Off by default. */\r\n get globalStiffness() {\r\n return this._globalStiffness;\r\n }\r\n set globalStiffness(value: number) {\r\n this._globalStiffness = clamp(value, 0, 1);\r\n }\r\n /** Fraction of a strand, from the root, the pose pull acts on, in [0, 1]. */\r\n get globalRange() {\r\n return this._globalRange;\r\n }\r\n set globalRange(value: number) {\r\n this._globalRange = clamp(value, 0, 1);\r\n }\r\n /** How strongly a strand keeps its authored shape, in [0, 1]. */\r\n get localStiffness() {\r\n return this._localStiffness;\r\n }\r\n set localStiffness(value: number) {\r\n this._localStiffness = clamp(value, 0, 1);\r\n }\r\n /** Local shape constraint passes per substep. */\r\n get localIterations() {\r\n return this._localIterations;\r\n }\r\n set localIterations(value: number) {\r\n this._localIterations = clamp(value, 1, 8) | 0;\r\n }\r\n /** Share of a point's length correction fed back into its parent, in [0, 1]. */\r\n get ftlDamping() {\r\n return this._ftlDamping;\r\n }\r\n set ftlDamping(value: number) {\r\n this._ftlDamping = clamp(value, 0, 1);\r\n }\r\n /** How much of the node's motion a strand is carried along by, in [0, 1]. */\r\n get vspCoeff() {\r\n return this._vspCoeff;\r\n }\r\n set vspCoeff(value: number) {\r\n this._vspCoeff = clamp(value, 0, 1);\r\n }\r\n /** Node acceleration above which a strand is carried rigidly, in units/s². */\r\n get vspAccelThreshold() {\r\n return this._vspAccelThreshold;\r\n }\r\n set vspAccelThreshold(value: number) {\r\n this._vspAccelThreshold = Math.max(0, value);\r\n }\r\n /** Integration substeps per fixed step. */\r\n get substeps() {\r\n return this._substeps;\r\n }\r\n set substeps(value: number) {\r\n this._substeps = clamp(value, 1, 8) | 0;\r\n }\r\n /** Friction on tangential contact motion, in [0, 1]. */\r\n get friction() {\r\n return this._friction;\r\n }\r\n set friction(value: number) {\r\n this._friction = clamp(value, 0, 1);\r\n }\r\n /** Colliders the strands are pushed out of. */\r\n get colliders(): readonly SpringCollider[] {\r\n return this._colliders;\r\n }\r\n set colliders(value: readonly SpringCollider[]) {\r\n this._colliders = [...value];\r\n }\r\n /** Verlet history. Not a previous-frame position - see the field remarks. */\r\n get prevPointBuffer() {\r\n return this._prevPointBuffer;\r\n }\r\n /** Local positions as of the previously rendered frame, for motion vectors. */\r\n get framePointBuffer() {\r\n return this._framePointBuffer;\r\n }\r\n /**\r\n * Discards accumulated motion and returns every strand to its rest pose.\r\n *\r\n * @remarks\r\n * Wanted whenever a node is moved rather than animated: a teleport would\r\n * otherwise register as one enormous frame of inertia and fling the hair.\r\n * {@link GPUHairSimulation.update} calls this itself when the groom jumps\r\n * farther in one frame than a few times its own strand length.\r\n */\r\n reset(worldMatrix: Matrix4x4) {\r\n if (!this._enabled) {\r\n return;\r\n }\r\n this._timeAccumulator = 0;\r\n this._prevWorldMatrix.set(worldMatrix);\r\n this._hasPrevWorldMatrix = true;\r\n this._rootHistoryDepth = 0;\r\n this._resetLivePoints();\r\n }\r\n /**\r\n * Advances the simulation.\r\n *\r\n * @param deltaTime - Seconds since the last update.\r\n * @param worldMatrix - The drawing node's current world matrix.\r\n */\r\n update(deltaTime: number, worldMatrix: Matrix4x4) {\r\n if (!this._enabled) {\r\n return;\r\n }\r\n if (!this._hasPrevWorldMatrix) {\r\n this._prevWorldMatrix.set(worldMatrix);\r\n this._hasPrevWorldMatrix = true;\r\n } else if (this._maxStrandLength > 0) {\r\n // A jump larger than a few times the hair itself is a teleport rather than\r\n // motion; fed to the solver it would fling the strands. The rest centre\r\n // stands in for the groom, so a rotation around a distant pivot counts as\r\n // the displacement it actually produces.\r\n this._prevWorldMatrix.transformPointAffine(this._restCenter, this._scratchVec);\r\n worldMatrix.transformPointAffine(this._restCenter, this._scratchVec2);\r\n const dx = this._scratchVec.x - this._scratchVec2.x;\r\n const dy = this._scratchVec.y - this._scratchVec2.y;\r\n const dz = this._scratchVec.z - this._scratchVec2.z;\r\n const threshold = this._maxStrandLength * TELEPORT_DISTANCE_FACTOR;\r\n if (dx * dx + dy * dy + dz * dz > threshold * threshold) {\r\n this.reset(worldMatrix);\r\n return;\r\n }\r\n }\r\n // Before anything moves: put aside the points the last frame was drawn with,\r\n // which is what the material differences against to build a motion vector.\r\n // Unconditional, and ahead of the early returns below - a frame that takes no\r\n // step still has to advance the snapshot, or it would report the previous\r\n // frame's motion a second time and smear rather than sharpen.\r\n this._snapshotFramePoints();\r\n const frameDt = clamp(Number(deltaTime) || 0, 0, MAX_ACCUMULATED_SIMULATION_TIME);\r\n if (frameDt <= 0) {\r\n return;\r\n }\r\n this._timeAccumulator = Math.min(this._timeAccumulator + frameDt, MAX_ACCUMULATED_SIMULATION_TIME);\r\n const stepCount = Math.floor((this._timeAccumulator + 1e-8) / FIXED_SIMULATION_TIME_STEP);\r\n if (stepCount <= 0) {\r\n return;\r\n }\r\n this._timeAccumulator = Math.max(0, this._timeAccumulator - stepCount * FIXED_SIMULATION_TIME_STEP);\r\n\r\n // Whether the node is being shoved hard enough to suspend strand lag.\r\n const rigid = this._measureRootAcceleration(worldMatrix, frameDt);\r\n\r\n // Gravity and colliders come into local space from the frame-end transform;\r\n // they change too slowly for the substep interpolation below to matter.\r\n this._invWorldMatrix.set(worldMatrix);\r\n this._invWorldMatrix.inplaceInvert();\r\n this._invWorldMatrix.transformVectorAffine(this._gravity, this._localGravity);\r\n this._uploadColliders(this._invWorldMatrix);\r\n\r\n const bindGroup = this._bindGroup!;\r\n const substepTime = FIXED_SIMULATION_TIME_STEP / this._substeps;\r\n bindGroup.setValue('strandCount', this._strandCount);\r\n // An exponential decay rather than a linear scale, so halving the substep\r\n // and applying it twice as often leaves the same velocity behind.\r\n bindGroup.setValue('dampingDecay', Math.exp(-this._damping * substepTime * 60));\r\n // The dial is the fraction removed per fixed step; the shader applies it\r\n // once per substep, so convert it to the fraction that compounds back to it.\r\n bindGroup.setValue('globalStiffness', 1 - Math.pow(1 - this._globalStiffness, 1 / this._substeps));\r\n bindGroup.setValue('globalRange', this._globalRange);\r\n bindGroup.setValue('localStiffness', this._localStiffness);\r\n bindGroup.setValue('localIterations', this._localIterations);\r\n bindGroup.setValue('ftlDamping', this._ftlDamping);\r\n bindGroup.setValue('vspCoeff', rigid ? 1 : this._vspCoeff);\r\n bindGroup.setValue('friction', this._friction);\r\n bindGroup.setValue('maxSpeedFactor', this._maxSpeedFactor);\r\n bindGroup.setValue('gravity', this._localGravity);\r\n bindGroup.setValue('minDistance', MIN_DISTANCE);\r\n bindGroup.setValue('deltaTime', substepTime);\r\n\r\n const totalSubsteps = stepCount * this._substeps;\r\n this._device!.pushDeviceStates();\r\n try {\r\n this._device!.setProgram(this._program!);\r\n this._device!.setBindGroup(0, bindGroup);\r\n if (matrixEquals(this._prevWorldMatrix, worldMatrix)) {\r\n // The node stood still; nothing to distribute.\r\n bindGroup.setValue('relativeTransform', this._identity);\r\n for (let i = 0; i < totalSubsteps; i++) {\r\n this._device!.compute(this._workgroupCount, 1, 1);\r\n }\r\n } else {\r\n // The node's frame motion, spread evenly over the substeps. Lumping it\r\n // into the first one would let a frame-time hitch move roots by more\r\n // than a segment length in what the solver treats as a single substep.\r\n this._prevWorldMatrix.decompose(this._scaleFrom, this._rotationFrom, this._translationFrom);\r\n worldMatrix.decompose(this._scaleTo, this._rotationTo, this._translationTo);\r\n this._stepFrom.set(this._prevWorldMatrix);\r\n for (let i = 1; i <= totalSubsteps; i++) {\r\n if (i === totalSubsteps) {\r\n // The exact endpoint, so decompose round-tripping cannot leave the\r\n // solver's idea of the transform drifting from the node's.\r\n this._stepTo.set(worldMatrix);\r\n } else {\r\n const t = i / totalSubsteps;\r\n this._scratchVec.setXYZ(\r\n this._scaleFrom.x + (this._scaleTo.x - this._scaleFrom.x) * t,\r\n this._scaleFrom.y + (this._scaleTo.y - this._scaleFrom.y) * t,\r\n this._scaleFrom.z + (this._scaleTo.z - this._scaleFrom.z) * t\r\n );\r\n this._scratchVec2.setXYZ(\r\n this._translationFrom.x + (this._translationTo.x - this._translationFrom.x) * t,\r\n this._translationFrom.y + (this._translationTo.y - this._translationFrom.y) * t,\r\n this._translationFrom.z + (this._translationTo.z - this._translationFrom.z) * t\r\n );\r\n Quaternion.slerp(this._rotationFrom, this._rotationTo, t, this._rotationLerp);\r\n this._stepTo.compose(this._scratchVec, this._rotationLerp, this._scratchVec2);\r\n }\r\n this._invWorldMatrix.set(this._stepTo);\r\n this._invWorldMatrix.inplaceInvert();\r\n Matrix4x4.multiply(this._invWorldMatrix, this._stepFrom, this._relativeTransform);\r\n bindGroup.setValue('relativeTransform', this._relativeTransform);\r\n this._device!.compute(this._workgroupCount, 1, 1);\r\n this._stepFrom.set(this._stepTo);\r\n }\r\n }\r\n } finally {\r\n this._device!.popDeviceStates();\r\n }\r\n this._prevWorldMatrix.set(worldMatrix);\r\n }\r\n protected onDispose() {\r\n this._releaseResources();\r\n }\r\n /**\r\n * Whether the node is accelerating hard enough to suspend strand lag.\r\n *\r\n * @remarks\r\n * Differentiated over the frame intervals actually spanned rather than the\r\n * fixed step: a second difference of position is only an acceleration when\r\n * the samples are evenly spaced, and frame times are not.\r\n * @internal\r\n */\r\n private _measureRootAcceleration(worldMatrix: Matrix4x4, frameDt: number) {\r\n worldMatrix.transformPointAffine(this._restCenter, this._scratchVec);\r\n let rigid = false;\r\n if (this._rootHistoryDepth > 0) {\r\n const vx = (this._scratchVec.x - this._prevRootWorld.x) / frameDt;\r\n const vy = (this._scratchVec.y - this._prevRootWorld.y) / frameDt;\r\n const vz = (this._scratchVec.z - this._prevRootWorld.z) / frameDt;\r\n if (this._rootHistoryDepth > 1) {\r\n const ax = (vx - this._prevRootVelocity.x) / frameDt;\r\n const ay = (vy - this._prevRootVelocity.y) / frameDt;\r\n const az = (vz - this._prevRootVelocity.z) / frameDt;\r\n const threshold = this._vspAccelThreshold;\r\n rigid = ax * ax + ay * ay + az * az > threshold * threshold;\r\n }\r\n this._prevRootVelocity.setXYZ(vx, vy, vz);\r\n }\r\n this._prevRootWorld.set(this._scratchVec);\r\n if (this._rootHistoryDepth < 2) {\r\n this._rootHistoryDepth++;\r\n }\r\n return rigid;\r\n }\r\n /**\r\n * Copies the live points into the frame snapshot the material differences\r\n * against.\r\n *\r\n * @remarks\r\n * A dispatch of its own rather than a stage of the solve, because it has to\r\n * happen on every frame while the solve only happens on frames that take a\r\n * step, and because it has to see the points before the first substep touches\r\n * them.\r\n * @internal\r\n */\r\n private _snapshotFramePoints() {\r\n this._bindGroup!.setValue('strandCount', this._strandCount);\r\n this._bindGroup!.setValue('snapshotFrame', 1);\r\n this._device!.pushDeviceStates();\r\n try {\r\n this._device!.setProgram(this._program!);\r\n this._device!.setBindGroup(0, this._bindGroup!);\r\n this._device!.compute(this._workgroupCount, 1, 1);\r\n } finally {\r\n this._device!.popDeviceStates();\r\n }\r\n this._bindGroup!.setValue('snapshotFrame', 0);\r\n }\r\n /** Copies the rest pose over the live points. @internal */\r\n private _resetLivePoints() {\r\n // Rest points are xyz only while the live buffer interleaves width, so this\r\n // cannot be a straight buffer copy; the shader does it instead.\r\n this._bindGroup!.setValue('strandCount', this._strandCount);\r\n this._bindGroup!.setValue('resetPose', 1);\r\n this._device!.pushDeviceStates();\r\n try {\r\n this._device!.setProgram(this._program!);\r\n this._device!.setBindGroup(0, this._bindGroup!);\r\n this._device!.compute(this._workgroupCount, 1, 1);\r\n } finally {\r\n this._device!.popDeviceStates();\r\n }\r\n this._bindGroup!.setValue('resetPose', 0);\r\n }\r\n /** Builds buffers and the compute pipeline. @internal */\r\n private _init(strands: HairStrandData, source: HairStrandSource) {\r\n const device = this._device!;\r\n const pointCount = strands.pointCount;\r\n const scale = source.scale ?? 1;\r\n\r\n // Rest pose and rest lengths, in the same units the strand data uploaded in\r\n // - it applies the scale, so this has to as well or every constraint is\r\n // wrong by it. The same pass measures the longest strand and the rest\r\n // centre, which the teleport guard in update() works from.\r\n const restPoints = new Float32Array(pointCount * 3) as Float32Array<ArrayBuffer>;\r\n const restLengths = new Float32Array(pointCount) as Float32Array<ArrayBuffer>;\r\n const counts = source.pointCounts;\r\n let first = 0;\r\n let maxStrandLength = 0;\r\n let minX = Infinity;\r\n let minY = Infinity;\r\n let minZ = Infinity;\r\n let maxX = -Infinity;\r\n let maxY = -Infinity;\r\n let maxZ = -Infinity;\r\n for (let s = 0; s < counts.length; s++) {\r\n const count = counts[s];\r\n let strandLength = 0;\r\n for (let i = 0; i < count; i++) {\r\n const src = (first + i) * 3;\r\n const dst = (first + i) * 3;\r\n const x = source.positions[src] * scale;\r\n const y = source.positions[src + 1] * scale;\r\n const z = source.positions[src + 2] * scale;\r\n restPoints[dst] = x;\r\n restPoints[dst + 1] = y;\r\n restPoints[dst + 2] = z;\r\n minX = x < minX ? x : minX;\r\n minY = y < minY ? y : minY;\r\n minZ = z < minZ ? z : minZ;\r\n maxX = x > maxX ? x : maxX;\r\n maxY = y > maxY ? y : maxY;\r\n maxZ = z > maxZ ? z : maxZ;\r\n if (i > 0) {\r\n const dx = x - restPoints[dst - 3];\r\n const dy = y - restPoints[dst - 2];\r\n const dz = z - restPoints[dst - 1];\r\n const len = Math.sqrt(dx * dx + dy * dy + dz * dz);\r\n restLengths[first + i] = len;\r\n strandLength += len;\r\n }\r\n }\r\n if (strandLength > maxStrandLength) {\r\n maxStrandLength = strandLength;\r\n }\r\n first += count;\r\n }\r\n this._maxStrandLength = maxStrandLength;\r\n if (pointCount > 0) {\r\n this._restCenter.setXYZ((minX + maxX) * 0.5, (minY + maxY) * 0.5, (minZ + maxZ) * 0.5);\r\n }\r\n\r\n this._pointBuffer = strands.pointBuffer;\r\n this._restPointBuffer = this._createStorage(restPoints);\r\n this._prevPointBuffer = this._createStorage(restPoints);\r\n this._framePointBuffer = this._createStorage(restPoints);\r\n this._restLengthBuffer = this._createStorage(restLengths);\r\n this._sphereBuffer = this._createStorage(this._sphereData);\r\n this._capsuleBuffer = this._createStorage(this._capsuleData);\r\n this._planeBuffer = this._createStorage(this._planeData);\r\n\r\n this._program = createHairSimulationProgram(device, DEFAULT_WORKGROUP_SIZE);\r\n if (!this._program) {\r\n throw new Error('failed to create the compute program');\r\n }\r\n this._bindGroup = device.createBindGroup(this._program.bindGroupLayouts[0]);\r\n this._bindGroup.setBuffer('points', this._pointBuffer!);\r\n this._bindGroup.setBuffer('prevPoints', this._prevPointBuffer);\r\n this._bindGroup.setBuffer('framePoints', this._framePointBuffer);\r\n this._bindGroup.setBuffer('restPoints', this._restPointBuffer);\r\n this._bindGroup.setBuffer('restLengths', this._restLengthBuffer);\r\n this._bindGroup.setBuffer('headers', strands.headerBuffer!);\r\n this._bindGroup.setBuffer('sphereData', this._sphereBuffer);\r\n this._bindGroup.setBuffer('capsuleData', this._capsuleBuffer);\r\n this._bindGroup.setBuffer('planeData', this._planeBuffer);\r\n this._bindGroup.setValue('strandCount', this._strandCount);\r\n this._bindGroup.setValue('resetPose', 0);\r\n this._bindGroup.setValue('relativeTransform', Matrix4x4.identity());\r\n this._bindGroup.setValue('sphereCount', 0);\r\n this._bindGroup.setValue('capsuleCount', 0);\r\n this._bindGroup.setValue('planeCount', 0);\r\n this._bindGroup.setValue('minDistance', MIN_DISTANCE);\r\n this._bindGroup.setValue('snapshotFrame', 0);\r\n this._bindGroup.setValue('maxSpeedFactor', this._maxSpeedFactor);\r\n this._bindGroup.setValue('globalStiffness', this._globalStiffness);\r\n this._bindGroup.setValue('globalRange', this._globalRange);\r\n this._bindGroup.setValue('localStiffness', this._localStiffness);\r\n this._bindGroup.setValue('localIterations', this._localIterations);\r\n this._bindGroup.setValue('ftlDamping', this._ftlDamping);\r\n this._bindGroup.setValue('vspCoeff', this._vspCoeff);\r\n }\r\n /** @internal */\r\n private _createStorage(data: Float32Array<ArrayBuffer>) {\r\n const buffer = this._device!.createBuffer(data.byteLength, {\r\n usage: 'uniform',\r\n storage: true,\r\n dynamic: false,\r\n managed: false\r\n });\r\n if (!buffer) {\r\n throw new Error('failed to allocate a simulation buffer');\r\n }\r\n buffer.bufferSubData(0, data);\r\n return buffer;\r\n }\r\n /** Brings colliders into local space and uploads them. @internal */\r\n private _uploadColliders(invWorldMatrix: Matrix4x4) {\r\n let spheres = 0;\r\n let capsules = 0;\r\n let planes = 0;\r\n for (const collider of this._colliders) {\r\n if (!collider.enabled) {\r\n continue;\r\n }\r\n // Node-tracking colliders are world-space and refreshed here.\r\n updateColliderFromNode(collider);\r\n if (collider.type === 'sphere' && spheres < MAX_COLLIDERS) {\r\n const sphere = collider as SphereCollider;\r\n invWorldMatrix.transformPointAffine(sphere.center, this._scratchVec);\r\n const base = spheres * SPHERE_STRIDE;\r\n this._sphereData[base] = this._scratchVec.x;\r\n this._sphereData[base + 1] = this._scratchVec.y;\r\n this._sphereData[base + 2] = this._scratchVec.z;\r\n this._sphereData[base + 3] = sphere.radius * localRadiusScale(invWorldMatrix);\r\n spheres++;\r\n } else if (collider.type === 'capsule' && capsules < MAX_COLLIDERS) {\r\n const capsule = collider as CapsuleCollider;\r\n invWorldMatrix.transformPointAffine(capsule.start, this._scratchVec);\r\n invWorldMatrix.transformPointAffine(capsule.end, this._scratchVec2);\r\n const base = capsules * CAPSULE_STRIDE;\r\n this._capsuleData[base] = this._scratchVec.x;\r\n this._capsuleData[base + 1] = this._scratchVec.y;\r\n this._capsuleData[base + 2] = this._scratchVec.z;\r\n this._capsuleData[base + 3] = capsule.radius * localRadiusScale(invWorldMatrix);\r\n this._capsuleData[base + 4] = this._scratchVec2.x;\r\n this._capsuleData[base + 5] = this._scratchVec2.y;\r\n this._capsuleData[base + 6] = this._scratchVec2.z;\r\n this._capsuleData[base + 7] = 0;\r\n capsules++;\r\n } else if (collider.type === 'plane' && planes < MAX_COLLIDERS) {\r\n const plane = collider as PlaneCollider;\r\n invWorldMatrix.transformPointAffine(plane.point, this._scratchVec);\r\n // A normal transforms by the inverse transpose, and the inverse is to hand.\r\n transformNormal(invWorldMatrix, plane.normal, this._scratchVec2);\r\n const base = planes * PLANE_STRIDE;\r\n this._planeData[base] = this._scratchVec.x;\r\n this._planeData[base + 1] = this._scratchVec.y;\r\n this._planeData[base + 2] = this._scratchVec.z;\r\n this._planeData[base + 3] = 0;\r\n this._planeData[base + 4] = this._scratchVec2.x;\r\n this._planeData[base + 5] = this._scratchVec2.y;\r\n this._planeData[base + 6] = this._scratchVec2.z;\r\n this._planeData[base + 7] = 0;\r\n planes++;\r\n }\r\n }\r\n this._sphereBuffer!.bufferSubData(0, this._sphereData);\r\n this._capsuleBuffer!.bufferSubData(0, this._capsuleData);\r\n this._planeBuffer!.bufferSubData(0, this._planeData);\r\n this._bindGroup!.setValue('sphereCount', spheres);\r\n this._bindGroup!.setValue('capsuleCount', capsules);\r\n this._bindGroup!.setValue('planeCount', planes);\r\n }\r\n /** @internal */\r\n private _releaseResources() {\r\n this._enabled = false;\r\n this._bindGroup?.dispose();\r\n this._bindGroup = null;\r\n this._program?.dispose();\r\n this._program = null;\r\n // The point buffer belongs to the strand data, not here.\r\n this._pointBuffer = null;\r\n this._prevPointBuffer?.dispose();\r\n this._prevPointBuffer = null;\r\n this._restPointBuffer?.dispose();\r\n this._restPointBuffer = null;\r\n this._framePointBuffer?.dispose();\r\n this._framePointBuffer = null;\r\n this._restLengthBuffer?.dispose();\r\n this._restLengthBuffer = null;\r\n this._sphereBuffer?.dispose();\r\n this._sphereBuffer = null;\r\n this._capsuleBuffer?.dispose();\r\n this._capsuleBuffer = null;\r\n this._planeBuffer?.dispose();\r\n this._planeBuffer = null;\r\n }\r\n}\r\n\r\n/** Mean axis scale of a matrix, for converting a radius. @internal */\r\nfunction localRadiusScale(matrix: Matrix4x4) {\r\n const sx = Math.hypot(matrix.m00, matrix.m10, matrix.m20);\r\n const sy = Math.hypot(matrix.m01, matrix.m11, matrix.m21);\r\n const sz = Math.hypot(matrix.m02, matrix.m12, matrix.m22);\r\n return (sx + sy + sz) / 3;\r\n}\r\n\r\n/**\r\n * Transforms a normal by the transpose of the inverse world matrix, which is the\r\n * inverse-transpose a normal needs.\r\n * @internal\r\n */\r\nfunction transformNormal(invWorldMatrix: Matrix4x4, normal: Vector3, out: Vector3) {\r\n out.setXYZ(\r\n invWorldMatrix.m00 * normal.x + invWorldMatrix.m10 * normal.y + invWorldMatrix.m20 * normal.z,\r\n invWorldMatrix.m01 * normal.x + invWorldMatrix.m11 * normal.y + invWorldMatrix.m21 * normal.z,\r\n invWorldMatrix.m02 * normal.x + invWorldMatrix.m12 * normal.y + invWorldMatrix.m22 * normal.z\r\n );\r\n const len = out.magnitude;\r\n if (len > MIN_DISTANCE) {\r\n out.scaleBy(1 / len);\r\n } else {\r\n out.setXYZ(0, 1, 0);\r\n }\r\n}\r\n\r\n/**\r\n * Builds the solver pass.\r\n *\r\n * @remarks\r\n * TressFX's five simulation stages, run back to back inside one kernel with a\r\n * thread per strand instead of five dispatches with a thread per vertex. The\r\n * rearrangement keeps them numerically equivalent: integration, the global shape\r\n * constraint and shock propagation are per-vertex with no cross-vertex\r\n * dependency, and the local shape constraint is already a serial walk over a\r\n * strand in TressFX. Solved in local space, where the bind-pose skinning\r\n * quaternion is the identity and shock propagation reduces to a blend.\r\n *\r\n * Exported for shader-generation tests only.\r\n * @internal\r\n */\r\nexport function createHairSimulationProgram(device: AbstractDevice, workgroupSize: number) {\r\n const program = device.buildComputeProgram({\r\n workgroupSize: [workgroupSize, 1, 1],\r\n compute(pb) {\r\n // Positions and widths interleave, four floats per point; the solver\r\n // writes xyz and leaves w alone, which is why they share a buffer.\r\n this.points = pb.float[0]().storageBuffer(0);\r\n this.prevPoints = pb.float[0]().storageBuffer(0);\r\n this.framePoints = pb.float[0]().storageBuffer(0);\r\n this.restPoints = pb.float[0]().storageBufferReadonly(0);\r\n this.restLengths = pb.float[0]().storageBufferReadonly(0);\r\n this.headers = pb.uint[0]().storageBufferReadonly(0);\r\n this.sphereData = pb.float[0]().storageBufferReadonly(0);\r\n this.capsuleData = pb.float[0]().storageBufferReadonly(0);\r\n this.planeData = pb.float[0]().storageBufferReadonly(0);\r\n this.strandCount = pb.uint().uniform(0);\r\n this.deltaTime = pb.float().uniform(0);\r\n this.dampingDecay = pb.float().uniform(0);\r\n this.globalStiffness = pb.float().uniform(0);\r\n this.globalRange = pb.float().uniform(0);\r\n this.localStiffness = pb.float().uniform(0);\r\n this.localIterations = pb.uint().uniform(0);\r\n this.ftlDamping = pb.float().uniform(0);\r\n this.vspCoeff = pb.float().uniform(0);\r\n this.friction = pb.float().uniform(0);\r\n this.maxSpeedFactor = pb.float().uniform(0);\r\n this.gravity = pb.vec3().uniform(0);\r\n this.relativeTransform = pb.mat4().uniform(0);\r\n this.sphereCount = pb.uint().uniform(0);\r\n this.capsuleCount = pb.uint().uniform(0);\r\n this.planeCount = pb.uint().uniform(0);\r\n this.minDistance = pb.float().uniform(0);\r\n this.resetPose = pb.uint().uniform(0);\r\n this.snapshotFrame = pb.uint().uniform(0);\r\n\r\n // Pushes a point out of every collider. Position only; friction and\r\n // carrying the history along are the caller's job, since both need the\r\n // history it is still assembling.\r\n pb.func('Z_hairResolveContacts', [pb.vec3('position')], function () {\r\n this.$l.result = this.position;\r\n this.$for(pb.uint('i'), 0, this.sphereCount, function () {\r\n this.$l.base = pb.mul(this.i, 4);\r\n this.$l.centre = pb.vec3(\r\n this.sphereData.at(this.base),\r\n this.sphereData.at(pb.add(this.base, 1)),\r\n this.sphereData.at(pb.add(this.base, 2))\r\n );\r\n this.$l.radius = this.sphereData.at(pb.add(this.base, 3));\r\n this.$l.delta = pb.sub(this.result, this.centre);\r\n this.$l.dist = pb.length(this.delta);\r\n this.$if(pb.lessThan(this.dist, this.radius), function () {\r\n this.$l.normal = pb.vec3(0, 1, 0);\r\n this.$if(pb.greaterThan(this.dist, this.minDistance), function () {\r\n this.normal = pb.div(this.delta, this.dist);\r\n });\r\n this.result = pb.add(this.centre, pb.mul(this.normal, this.radius));\r\n });\r\n });\r\n this.$for(pb.uint('j'), 0, this.capsuleCount, function () {\r\n this.$l.cbase = pb.mul(this.j, 8);\r\n this.$l.start = pb.vec3(\r\n this.capsuleData.at(this.cbase),\r\n this.capsuleData.at(pb.add(this.cbase, 1)),\r\n this.capsuleData.at(pb.add(this.cbase, 2))\r\n );\r\n this.$l.cradius = this.capsuleData.at(pb.add(this.cbase, 3));\r\n this.$l.end = pb.vec3(\r\n this.capsuleData.at(pb.add(this.cbase, 4)),\r\n this.capsuleData.at(pb.add(this.cbase, 5)),\r\n this.capsuleData.at(pb.add(this.cbase, 6))\r\n );\r\n this.$l.axis = pb.sub(this.end, this.start);\r\n this.$l.axisLenSq = pb.dot(this.axis, this.axis);\r\n this.$l.t = pb.float(0);\r\n this.$if(pb.greaterThan(this.axisLenSq, this.minDistance), function () {\r\n this.t = pb.clamp(\r\n pb.div(pb.dot(pb.sub(this.result, this.start), this.axis), this.axisLenSq),\r\n 0,\r\n 1\r\n );\r\n });\r\n this.$l.closest = pb.add(this.start, pb.mul(this.axis, this.t));\r\n this.$l.cdelta = pb.sub(this.result, this.closest);\r\n this.$l.cdist = pb.length(this.cdelta);\r\n this.$if(pb.lessThan(this.cdist, this.cradius), function () {\r\n this.$l.cnormal = pb.vec3(0, 1, 0);\r\n this.$if(pb.greaterThan(this.cdist, this.minDistance), function () {\r\n this.cnormal = pb.div(this.cdelta, this.cdist);\r\n });\r\n this.result = pb.add(this.closest, pb.mul(this.cnormal, this.cradius));\r\n });\r\n });\r\n this.$for(pb.uint('k'), 0, this.planeCount, function () {\r\n this.$l.pbase = pb.mul(this.k, 8);\r\n this.$l.point = pb.vec3(\r\n this.planeData.at(this.pbase),\r\n this.planeData.at(pb.add(this.pbase, 1)),\r\n this.planeData.at(pb.add(this.pbase, 2))\r\n );\r\n this.$l.pnormal = pb.vec3(\r\n this.planeData.at(pb.add(this.pbase, 4)),\r\n this.planeData.at(pb.add(this.pbase, 5)),\r\n this.planeData.at(pb.add(this.pbase, 6))\r\n );\r\n this.$l.signedDist = pb.dot(pb.sub(this.result, this.point), this.pnormal);\r\n this.$if(pb.lessThan(this.signedDist, 0), function () {\r\n this.result = pb.sub(this.result, pb.mul(this.pnormal, this.signedDist));\r\n });\r\n });\r\n this.$return(this.result);\r\n });\r\n\r\n // Accessors for the interleaved point buffer.\r\n pb.func('Z_hairGetPoint', [pb.uint('index')], function () {\r\n this.$l.base = pb.mul(this.index, 4);\r\n this.$return(\r\n pb.vec3(\r\n this.points.at(this.base),\r\n this.points.at(pb.add(this.base, 1)),\r\n this.points.at(pb.add(this.base, 2))\r\n )\r\n );\r\n });\r\n pb.func('Z_hairSetPoint', [pb.uint('index'), pb.vec3('value')], function () {\r\n this.$l.base = pb.mul(this.index, 4);\r\n this.points.setAt(this.base, this.value.x);\r\n this.points.setAt(pb.add(this.base, 1), this.value.y);\r\n this.points.setAt(pb.add(this.base, 2), this.value.z);\r\n this.$return(pb.float(0));\r\n });\r\n pb.func('Z_hairGetRest', [pb.uint('index')], function () {\r\n this.$l.base = pb.mul(this.index, 3);\r\n this.$return(\r\n pb.vec3(\r\n this.restPoints.at(this.base),\r\n this.restPoints.at(pb.add(this.base, 1)),\r\n this.restPoints.at(pb.add(this.base, 2))\r\n )\r\n );\r\n });\r\n pb.func('Z_hairGetHistory', [pb.uint('index')], function () {\r\n this.$l.base = pb.mul(this.index, 3);\r\n this.$return(\r\n pb.vec3(\r\n this.prevPoints.at(this.base),\r\n this.prevPoints.at(pb.add(this.base, 1)),\r\n this.prevPoints.at(pb.add(this.base, 2))\r\n )\r\n );\r\n });\r\n pb.func('Z_hairSetHistory', [pb.uint('index'), pb.vec3('value')], function () {\r\n this.$l.base = pb.mul(this.index, 3);\r\n this.prevPoints.setAt(this.base, this.value.x);\r\n this.prevPoints.setAt(pb.add(this.base, 1), this.value.y);\r\n this.prevPoints.setAt(pb.add(this.base, 2), this.value.z);\r\n this.$return(pb.float(0));\r\n });\r\n pb.func('Z_hairSetFramePoint', [pb.uint('index'), pb.vec3('value')], function () {\r\n this.$l.base = pb.mul(this.index, 3);\r\n this.framePoints.setAt(this.base, this.value.x);\r\n this.framePoints.setAt(pb.add(this.base, 1), this.value.y);\r\n this.framePoints.setAt(pb.add(this.base, 2), this.value.z);\r\n this.$return(pb.float(0));\r\n });\r\n\r\n // Rotates a vector by a quaternion.\r\n pb.func('Z_hairQuatRotate', [pb.vec4('q'), pb.vec3('v')], function () {\r\n this.$l.uv = pb.cross(this.q.xyz, this.v);\r\n this.$l.uuv = pb.cross(this.q.xyz, this.uv);\r\n this.$return(pb.add(this.v, pb.mul(this.uv, pb.mul(this.q.w, 2)), pb.mul(this.uuv, 2)));\r\n });\r\n\r\n // Shortest-arc rotation taking unit u onto unit v. Antiparallel inputs\r\n // leave the axis undefined, so any perpendicular of u will do.\r\n pb.func('Z_hairQuatFromUnitVectors', [pb.vec3('u'), pb.vec3('v')], function () {\r\n this.$l.r = pb.add(1, pb.dot(this.u, this.v));\r\n this.$l.axis = pb.cross(this.u, this.v);\r\n this.$if(pb.lessThan(this.r, 1e-7), function () {\r\n this.r = pb.float(0);\r\n this.axis = this.$choice(\r\n pb.greaterThan(pb.abs(this.u.x), pb.abs(this.u.z)),\r\n pb.vec3(pb.neg(this.u.y), this.u.x, 0),\r\n pb.vec3(0, pb.neg(this.u.z), this.u.y)\r\n );\r\n });\r\n this.$l.q = pb.vec4(this.axis, this.r);\r\n this.$l.lengthSq = pb.dot(this.q, this.q);\r\n this.$l.result = pb.vec4(0, 0, 0, 1);\r\n this.$if(pb.greaterThan(this.lengthSq, 1e-10), function () {\r\n this.result = pb.mul(this.q, pb.inverseSqrt(this.lengthSq));\r\n });\r\n this.$return(this.result);\r\n });\r\n\r\n // Bounds the velocity a stored history implies, so that one bad substep\r\n // cannot hand the next a velocity damping will never recover from.\r\n pb.func('Z_hairClampHistory', [pb.uint('index'), pb.vec3('position'), pb.vec3('history')], function () {\r\n this.$l.result = this.history;\r\n this.$l.delta = pb.sub(this.position, this.result);\r\n this.$l.speed = pb.length(this.delta);\r\n this.$l.limit = pb.mul(this.restLengths.at(this.index), this.maxSpeedFactor);\r\n this.$if(pb.greaterThan(this.speed, this.limit), function () {\r\n this.result = pb.sub(this.position, pb.mul(this.delta, pb.div(this.limit, this.speed)));\r\n });\r\n this.$return(this.result);\r\n });\r\n\r\n pb.main(function () {\r\n this.$l.strand = this.$builtins.globalInvocationId.x;\r\n this.$if(pb.lessThan(this.strand, this.strandCount), function () {\r\n this.$l.hbase = pb.mul(this.strand, 4);\r\n this.$l.firstPoint = this.headers.at(this.hbase);\r\n this.$l.pointCount = this.headers.at(pb.add(this.hbase, 1));\r\n\r\n this.$if(pb.notEqual(this.snapshotFrame, 0), function () {\r\n // Copy the points the last frame was drawn with aside, before this\r\n // frame's substeps overwrite them. Run once per frame from update(),\r\n // including on frames that take no step - skipping those would leave\r\n // the snapshot a frame stale and report motion that already happened.\r\n this.$for(pb.uint('i'), 0, this.pointCount, function () {\r\n this.$l.idx = pb.add(this.firstPoint, this.i);\r\n this.Z_hairSetFramePoint(this.idx, this.Z_hairGetPoint(this.idx));\r\n });\r\n })\r\n .$elseif(pb.notEqual(this.resetPose, 0), function () {\r\n // Rest into all three, so the strand is still as well as in place\r\n // and the frame it snaps on reports no motion of its own.\r\n this.$for(pb.uint('i'), 0, this.pointCount, function () {\r\n this.$l.idx = pb.add(this.firstPoint, this.i);\r\n this.$l.rest = this.Z_hairGetRest(this.idx);\r\n this.Z_hairSetPoint(this.idx, this.rest);\r\n this.Z_hairSetHistory(this.idx, this.rest);\r\n this.Z_hairSetFramePoint(this.idx, this.rest);\r\n });\r\n })\r\n .$else(function () {\r\n // Two pinned points, not one: one fixes where a strand hangs from but\r\n // leaves the direction it leaves the scalp in free, so the root end\r\n // flops and can invert. The second gives every strand the root frame\r\n // the local shape constraint is defined against. In local space\r\n // \"pinned\" means unchanged - node motion rides the transform.\r\n this.$l.rootRest = this.Z_hairGetRest(this.firstPoint);\r\n this.Z_hairSetPoint(this.firstPoint, this.rootRest);\r\n this.Z_hairSetHistory(this.firstPoint, this.rootRest);\r\n this.$if(pb.greaterThan(this.pointCount, 1), function () {\r\n this.$l.nextIdx = pb.add(this.firstPoint, 1);\r\n this.$l.nextRest = this.Z_hairGetRest(this.nextIdx);\r\n this.Z_hairSetPoint(this.nextIdx, this.nextRest);\r\n this.Z_hairSetHistory(this.nextIdx, this.nextRest);\r\n });\r\n\r\n this.$l.dt2 = pb.mul(this.deltaTime, this.deltaTime);\r\n this.$l.rangeLimit = pb.mul(this.globalRange, pb.float(this.pointCount));\r\n\r\n // Stage 1 - integration, shock propagation, global shape constraint.\r\n this.$for(pb.uint('i'), 2, this.pointCount, function () {\r\n this.$l.idx = pb.add(this.firstPoint, this.i);\r\n this.$l.current = this.Z_hairGetPoint(this.idx);\r\n this.$l.previous = this.Z_hairGetHistory(this.idx);\r\n // Both stored positions go through the node's frame-to-frame\r\n // motion: transforming only one would read that motion as strand\r\n // velocity and throw the hair ahead of the movement.\r\n this.$l.lagged = pb.mul(this.relativeTransform, pb.vec4(this.current, 1)).xyz;\r\n this.$l.laggedPrev = pb.mul(this.relativeTransform, pb.vec4(this.previous, 1)).xyz;\r\n // Shock propagation. Leaving a point untransformed is exactly\r\n // carrying it rigidly with the node, so the coefficient blends\r\n // between the two ends TressFX interpolates: 0 lags fully, 1\r\n // follows. It stops a fast root outrunning its strand in one step.\r\n this.current = pb.mix(this.lagged, this.current, this.vspCoeff);\r\n this.previous = pb.mix(this.laggedPrev, this.previous, this.vspCoeff);\r\n this.$l.velocity = pb.mul(pb.sub(this.current, this.previous), this.dampingDecay);\r\n this.$l.next = pb.add(this.current, this.velocity, pb.mul(this.gravity, this.dt2));\r\n // Pull toward the authored pose, over the range's fraction of the\r\n // strand. Off by default - anchoring a point to a fixed place is a\r\n // spring, and the local shape constraint holds styling without it.\r\n this.$if(\r\n pb.and(\r\n pb.greaterThan(this.globalStiffness, 0),\r\n pb.lessThan(pb.float(this.i), this.rangeLimit)\r\n ),\r\n function () {\r\n this.$l.rest = this.Z_hairGetRest(this.idx);\r\n this.next = pb.add(this.next, pb.mul(pb.sub(this.rest, this.next), this.globalStiffness));\r\n }\r\n );\r\n this.Z_hairSetHistory(this.idx, this.current);\r\n this.Z_hairSetPoint(this.idx, this.next);\r\n });\r\n\r\n // Stage 2 - local shape constraint, what makes a groom read as hair\r\n // rather than as a chain. It holds each segment's angle to the one\r\n // before it in that segment's *current* frame, so a strand keeps its\r\n // curl while free to hang and swing, and resists bending - which is\r\n // also what stops a disturbance ringing for seconds. Stiffness is\r\n // halved and capped below 1 as in TressFX, since the constraint\r\n // moves both points it touches and would otherwise overshoot.\r\n this.$l.localStrength = pb.mul(pb.min(this.localStiffness, 0.95), 0.5);\r\n this.$if(pb.greaterThan(this.pointCount, 2), function () {\r\n this.$for(pb.uint('iter'), 0, this.localIterations, function () {\r\n this.$for(pb.uint('i'), 1, pb.sub(this.pointCount, 1), function () {\r\n this.$l.idx = pb.add(this.firstPoint, this.i);\r\n this.$l.pos = this.Z_hairGetPoint(this.idx);\r\n this.$l.posPlus = this.Z_hairGetPoint(pb.add(this.idx, 1));\r\n this.$l.posMinus = this.Z_hairGetPoint(pb.sub(this.idx, 1));\r\n this.$l.bind = this.Z_hairGetRest(this.idx);\r\n this.$l.bindPlus = this.Z_hairGetRest(pb.add(this.idx, 1));\r\n this.$l.bindMinus = this.Z_hairGetRest(pb.sub(this.idx, 1));\r\n // Where the next point sits if its bend still matches the bind\r\n // pose, carried into the previous segment's current direction.\r\n this.$l.lastVec = pb.sub(this.pos, this.posMinus);\r\n this.$l.bindVec = pb.sub(this.bindPlus, this.bind);\r\n this.$l.lastBindVec = pb.sub(this.bind, this.bindMinus);\r\n this.$l.rotation = this.Z_hairQuatFromUnitVectors(\r\n pb.normalize(this.lastBindVec),\r\n pb.normalize(this.lastVec)\r\n );\r\n this.$l.bendTarget = pb.add(this.Z_hairQuatRotate(this.rotation, this.bindVec), this.pos);\r\n this.$l.del = pb.mul(pb.sub(this.bendTarget, this.posPlus), this.localStrength);\r\n // Shared between both ends, unless one is a pinned root.\r\n this.$if(pb.greaterThan(this.i, 1), function () {\r\n this.Z_hairSetPoint(this.idx, pb.sub(this.pos, this.del));\r\n });\r\n this.Z_hairSetPoint(pb.add(this.idx, 1), pb.add(this.posPlus, this.del));\r\n });\r\n });\r\n });\r\n\r\n // Stage 3 - length constraints, root to tip. Placing each point at\r\n // its authored distance from an already-final parent leaves the\r\n // strand inextensible in one pass.\r\n //\r\n // The one place the port leaves TressFX, which sweeps even and odd\r\n // segments Jacobi-style because a thread there owns a single vertex\r\n // and cannot walk a strand. Jacobi transports tension one segment\r\n // per sweep, so a hanging strand stretches until the residual\r\n // balances: 22% on a 24-point strand under earth gravity at its two\r\n // sweeps, still 4.5% at sixteen. TressFX's own default gravity is\r\n // zero, so it never sees this.\r\n //\r\n // Moving the child alone leaves that correction's momentum\r\n // unaccounted for, and unaccounted it pumps the chain until the\r\n // groom whips; handing it back to the parent is Mueller's FTL\r\n // damping.\r\n this.$if(pb.greaterThan(this.pointCount, 2), function () {\r\n this.$for(pb.uint('j'), 1, pb.sub(this.pointCount, 1), function () {\r\n this.$l.parentIdx = pb.add(this.firstPoint, this.j);\r\n this.$l.childIdx = pb.add(this.parentIdx, 1);\r\n this.$l.parent = this.Z_hairGetPoint(this.parentIdx);\r\n this.$l.predicted = this.Z_hairGetPoint(this.childIdx);\r\n // Rest lengths are indexed by the far end of a segment.\r\n this.$l.restLength = this.restLengths.at(this.childIdx);\r\n this.$l.offset = pb.sub(this.predicted, this.parent);\r\n this.$l.dist = pb.length(this.offset);\r\n // Coincident with the parent leaves the direction undefined; any\r\n // offset of the right length will do.\r\n this.$l.projected = pb.add(this.parent, pb.vec3(0, this.restLength, 0));\r\n this.$if(pb.greaterThan(this.dist, this.minDistance), function () {\r\n this.projected = pb.add(\r\n this.parent,\r\n pb.mul(pb.div(this.offset, this.dist), this.restLength)\r\n );\r\n });\r\n this.Z_hairSetPoint(this.childIdx, this.projected);\r\n // The parent takes the reverse momentum, unless it is pinned.\r\n this.$if(pb.greaterThan(this.j, 1), function () {\r\n this.$l.correction = pb.sub(this.projected, this.predicted);\r\n this.Z_hairSetHistory(\r\n this.parentIdx,\r\n pb.add(this.Z_hairGetHistory(this.parentIdx), pb.mul(this.correction, this.ftlDamping))\r\n );\r\n });\r\n });\r\n });\r\n\r\n // Stage 4 - contacts, and the ceiling on this substep's travel.\r\n this.$for(pb.uint('i'), 2, this.pointCount, function () {\r\n this.$l.idx = pb.add(this.firstPoint, this.i);\r\n this.$l.position = this.Z_hairGetPoint(this.idx);\r\n this.$l.history = this.Z_hairGetHistory(this.idx);\r\n this.$l.resolved = this.Z_hairResolveContacts(this.position);\r\n // A push out is a position fix, not a shove: the history follows\r\n // it so the point keeps the velocity it arrived with, and friction\r\n // then takes its share of the tangential part.\r\n this.$l.push = pb.sub(this.resolved, this.position);\r\n this.$l.pushDist = pb.length(this.push);\r\n this.history = pb.add(this.history, this.push);\r\n this.$if(pb.greaterThan(this.pushDist, this.minDistance), function () {\r\n this.$l.normalDir = pb.div(this.push, this.pushDist);\r\n this.$l.contactVelocity = pb.sub(this.resolved, this.history);\r\n this.$l.tangential = pb.sub(\r\n this.contactVelocity,\r\n pb.mul(this.normalDir, pb.dot(this.contactVelocity, this.normalDir))\r\n );\r\n this.history = pb.add(this.history, pb.mul(this.tangential, this.friction));\r\n });\r\n this.Z_hairSetHistory(\r\n this.idx,\r\n this.Z_hairClampHistory(this.idx, this.resolved, this.history)\r\n );\r\n this.Z_hairSetPoint(this.idx, this.resolved);\r\n });\r\n });\r\n });\r\n });\r\n }\r\n });\r\n if (program) {\r\n program.name = '@GPUHair_Simulate';\r\n }\r\n return program;\r\n}\r\n"],"names":["FIXED_SIMULATION_TIME_STEP","MAX_ACCUMULATED_SIMULATION_TIME","DEFAULT_WORKGROUP_SIZE","MIN_DISTANCE","SPHERE_STRIDE","CAPSULE_STRIDE","PLANE_STRIDE","MAX_COLLIDERS","DEFAULT_DAMPING","DEFAULT_GLOBAL_STIFFNESS","DEFAULT_GLOBAL_RANGE","DEFAULT_LOCAL_STIFFNESS","DEFAULT_LOCAL_ITERATIONS","DEFAULT_FTL_DAMPING","DEFAULT_VSP_COEFF","DEFAULT_VSP_ACCEL_THRESHOLD","DEFAULT_MAX_SPEED_FACTOR","TELEPORT_DISTANCE_FACTOR","isHairSimulationSupported","device","resolved","getDevice","type","clamp","value","min","max","matrixEquals","a","b","i","GPUHairSimulation","Disposable","_capsuleData","_planeData","_relativeTransform","_invWorldMatrix","_prevWorldMatrix","_localGravity","_scratchVec","_scratchVec2","_scaleTo","_translationFrom","_translationTo","_rotationFrom","_rotationTo","_rotationLerp","_stepFrom","_stepTo","_prevRootVelocity","strands","source","options","_device","_enabled","_disabledReason","_program","_bindGroup","_pointBuffer","_prevPointBuffer","_restPointBuffer","_framePointBuffer","_restLengthBuffer","_sphereBuffer","_capsuleBuffer","_planeBuffer","_strandCount","strandCount","_gravity","gravity","Vector3","_damping","damping","_globalStiffness","globalStiffness","_globalRange","globalRange","_localStiffness","localStiffness","_localIterations","localIterations","_ftlDamping","ftlDamping","_vspCoeff","vspCoeff","_vspAccelThreshold","Math","vspAccelThreshold","_substeps","substeps","_friction","friction","_maxSpeedFactor","maxSpeedFactor","_colliders","colliders","_timeAccumulator","_sphereData","Float32Array","Matrix4x4","identity","_identity","_scaleFrom","Quaternion","_hasPrevWorldMatrix","_maxStrandLength","_restCenter","_prevRootWorld","_rootHistoryDepth","_workgroupCount","ceil","pointBuffer","headerBuffer","_init","err","_releaseResources","enabled","disabledReason","prevPointBuffer","framePointBuffer","reset","worldMatrix","set","_resetLivePoints","update","deltaTime","transformPointAffine","dx","x","dy","y","dz","z","threshold","_snapshotFramePoints","frameDt","Number","stepCount","floor","rigid","_measureRootAcceleration","inplaceInvert","transformVectorAffine","_uploadColliders","bindGroup","substepTime","setValue","exp","pow","totalSubsteps","pushDeviceStates","setProgram","setBindGroup","compute","decompose","t","setXYZ","slerp","compose","multiply","popDeviceStates","onDispose","vx","vy","vz","ax","ay","az","pointCount","scale","restPoints","restLengths","counts","pointCounts","first","maxStrandLength","minX","Infinity","minY","minZ","maxX","maxY","maxZ","s","length","count","strandLength","src","dst","positions","len","sqrt","_createStorage","createHairSimulationProgram","Error","createBindGroup","bindGroupLayouts","setBuffer","data","buffer","createBuffer","byteLength","usage","storage","dynamic","managed","bufferSubData","invWorldMatrix","spheres","capsules","planes","collider","updateColliderFromNode","sphere","center","base","radius","localRadiusScale","capsule","start","end","plane","point","transformNormal","normal","dispose","matrix","sx","hypot","m00","m10","m20","sy","m01","m11","m21","sz","m02","m12","m22","out","magnitude","scaleBy","workgroupSize","program","buildComputeProgram","pb","points","float","storageBuffer","prevPoints","framePoints","storageBufferReadonly","headers","uint","sphereData","capsuleData","planeData","uniform","dampingDecay","vec3","relativeTransform","mat4","sphereCount","capsuleCount","planeCount","minDistance","resetPose","snapshotFrame","func","$l","result","position","$for","mul","centre","at","add","delta","sub","dist","$if","lessThan","greaterThan","div","cbase","j","cradius","axis","axisLenSq","dot","closest","cdelta","cdist","cnormal","pbase","k","pnormal","signedDist","$return","index","setAt","vec4","uv","cross","q","xyz","v","uuv","w","r","u","$choice","abs","neg","lengthSq","inverseSqrt","history","speed","limit","main","strand","$builtins","globalInvocationId","hbase","firstPoint","notEqual","idx","Z_hairSetFramePoint","Z_hairGetPoint","$elseif","rest","Z_hairGetRest","Z_hairSetPoint","Z_hairSetHistory","$else","rootRest","nextIdx","nextRest","dt2","rangeLimit","current","previous","Z_hairGetHistory","lagged","laggedPrev","mix","velocity","next","and","localStrength","pos","posPlus","posMinus","bind","bindPlus","bindMinus","lastVec","bindVec","lastBindVec","rotation","Z_hairQuatFromUnitVectors","normalize","bendTarget","Z_hairQuatRotate","del","parentIdx","childIdx","parent","predicted","restLength","offset","projected","correction","Z_hairResolveContacts","push","pushDist","normalDir","contactVelocity","tangential","Z_hairClampHistory","name"],"mappings":";;;;AAgEA,8CACA,MAAMA,0BAAAA,GAA6B,CAAI,GAAA,EAAA;AACvC,yEACA,MAAMC,+BAAAA,GAAkC,CAAI,GAAA,EAAA;AAC5C,oEACA,MAAMC,sBAAyB,GAAA,EAAA;AAC/B,0EACA,MAAMC,YAAe,GAAA,IAAA;AAC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AA,GAAG,CAAC,IAAI,CAACuG,SAAS,EAAEnI,EAAAA,CAAG4C,GAAG,CAAC,IAAI,CAACwF,eAAe,EAAE,IAAI,CAACD,SAAS,CAAA,CAAA,CAAA;AAEpE,gCAAA,IAAI,CAAC5D,OAAO,GAAGvE,GAAG+B,GAAG,CAAC,IAAI,CAACwC,OAAO,EAAEvE,EAAG4B,CAAAA,GAAG,CAAC,IAAI,CAACyG,UAAU,EAAE,IAAI,CAAChS,QAAQ,CAAA,CAAA;AAC3E,6BAAA,CAAA;4BACA,IAAI,CAACmP,gBAAgB,CACnB,IAAI,CAACP,GAAG,EACR,IAAI,CAACqD,kBAAkB,CAAC,IAAI,CAACrD,GAAG,EAAE,IAAI,CAACnT,QAAQ,EAAE,IAAI,CAACyS,OAAO,CAAA,CAAA;4BAE/D,IAAI,CAACgB,cAAc,CAAC,IAAI,CAACN,GAAG,EAAE,IAAI,CAACnT,QAAQ,CAAA;AAC7C,yBAAA,CAAA;AACF,qBAAA,CAAA;AACJ,iBAAA,CAAA;AACF,aAAA,CAAA;AACF;AACF,KAAA,CAAA;AACA,IAAA,IAAIgO,OAAS,EAAA;AACXA,QAAAA,OAAAA,CAAQyI,IAAI,GAAG,mBAAA;AACjB;IACA,OAAOzI,OAAAA;AACT;;;;"}
|
|
@@ -38,6 +38,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
38
38
|
_parentMap = new Map();
|
|
39
39
|
_maxPointDepth = 0;
|
|
40
40
|
_pointTransforms = [];
|
|
41
|
+
_pointInputTransforms = [];
|
|
41
42
|
_colliderTransforms = [];
|
|
42
43
|
_grabberTransforms = [];
|
|
43
44
|
_colliderHandleIds = [];
|
|
@@ -70,7 +71,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
70
71
|
* @param colliders - Collider array (spheres/capsules).
|
|
71
72
|
* @param grabbers - Grabber array used for interactions such as mouse dragging.
|
|
72
73
|
* @param flatPlanes - Plane limiters such as the floor to prevent penetration.
|
|
73
|
-
*/ initialize(rootTransform, rootPoints, pointTransforms, colliders, grabbers, flatPlanes) {
|
|
74
|
+
*/ initialize(rootTransform, rootPoints, pointTransforms, pointInputTransforms, colliders, grabbers, flatPlanes) {
|
|
74
75
|
this._rootTransform = rootTransform;
|
|
75
76
|
this._baseSystemScale = this._getSystemUniformScale();
|
|
76
77
|
this._currentSystemScale = this._baseSystemScale;
|
|
@@ -78,6 +79,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
78
79
|
...rootPoints
|
|
79
80
|
];
|
|
80
81
|
this._pointTransforms = pointTransforms;
|
|
82
|
+
this._pointInputTransforms = pointInputTransforms.length > 0 ? pointInputTransforms : pointTransforms;
|
|
81
83
|
this._colliderTransforms = colliders.map((c)=>c.transform);
|
|
82
84
|
this._grabberTransforms = grabbers.map((g)=>g.transform);
|
|
83
85
|
this._rebuildConstraints();
|
|
@@ -145,7 +147,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
145
147
|
this._previousRootPosition = rootTransform.getWorldPosition();
|
|
146
148
|
this._previousRootRotation = rootTransform.getWorldRotation();
|
|
147
149
|
for(let i = 0; i < this._pointsRW.length; i++){
|
|
148
|
-
const pos =
|
|
150
|
+
const pos = this._pointInputTransforms[i].getWorldPosition();
|
|
149
151
|
this._pointsRW[i].positionCurrent = pos.clone();
|
|
150
152
|
this._pointsRW[i].positionPrevious = pos.clone();
|
|
151
153
|
this._pointsRW[i].positionCurrentTransform = pos.clone();
|
|
@@ -183,7 +185,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
183
185
|
const inputLocalRotations = this._getInputLocalRotations();
|
|
184
186
|
for(let i = 0; i < this._pointsRW.length; i++){
|
|
185
187
|
this._pointsRW[i].positionPreviousTransform = this._pointsRW[i].positionCurrentTransform.clone();
|
|
186
|
-
this._pointsRW[i].positionCurrentTransform = this.
|
|
188
|
+
this._pointsRW[i].positionCurrentTransform = this._pointInputTransforms[i].getWorldPosition();
|
|
187
189
|
}
|
|
188
190
|
for(let i = 0; i < this._collidersRW.length; i++){
|
|
189
191
|
const t = this._colliderTransforms[i];
|
|
@@ -450,7 +452,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
450
452
|
* point weights are preserved.
|
|
451
453
|
*/ reset() {
|
|
452
454
|
for(let i = 0; i < this._pointsRW.length; i++){
|
|
453
|
-
const pos = this.
|
|
455
|
+
const pos = this._pointInputTransforms[i].getWorldPosition();
|
|
454
456
|
const ptRW = this._pointsRW[i];
|
|
455
457
|
ptRW.positionCurrent = pos.clone();
|
|
456
458
|
ptRW.positionPrevious = pos.clone();
|
|
@@ -504,7 +506,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
504
506
|
return;
|
|
505
507
|
}
|
|
506
508
|
this._pointsR[index].weight = 1;
|
|
507
|
-
const pos = this.
|
|
509
|
+
const pos = this._pointInputTransforms[index].getWorldPosition();
|
|
508
510
|
this._pointsRW[index].positionCurrent = pos.clone();
|
|
509
511
|
this._pointsRW[index].positionPrevious = pos.clone();
|
|
510
512
|
this._pointsRW[index].grabberIndex = -1;
|