Wiggle
This class takes control of a single bone, and makes it behave like a wiggle bone. This class shares API with the WiggleBone class (except the options).
import { WiggleBone } from "wiggle/spring";
const wiggleSpring = new WiggleSpring(targetBone, {
stiffness: 500,
damping: 17,
});
const loop = () => {
requestAnimationFrame(loop);
wiggleBone.update();
};
loop();
WiggleSpring(target: Bone, options: Object)
target (required) – reference to the bone that is going to behave like a wiggle bone.Options:
stiffness (optional, default 500) – The spring stiffness coefficient. Higher values correspond to a stiffer spring that yields a greater amount of force for moving objects.damping (optional, default 17) – the damping force to apply to the spring’s motion..reset()
Resets the bone to its original transform relative to its parent.
.update(dt: Number)
Animates the bone so it aims to its original transform relative to it's parent.
dt (optional) – time delta since the last update. If not provided, this is calculated internally using performance.now().dispose()
Removes the wiggle bone and reverts the hierarchy to the original state.