CCD Ik Solver in Three.js (Not Complete)
function solve(bones, target) {
let effector = bones[bones.length - 1];
for (let j = 2; j < bones.length; j++) {
for (let i = bones.length - 2; i >= bones.length - j; i--) {
let bone = bones[i];
let bonePos = worldPos(bone);
let v1 = worldPos(effector).sub(bonePos);
let v2 = worldPos(target).sub(bonePos);
let angle = v1.angleTo(v2);
let axis = new THREE.Vector3();
axis.crossVectors(v1, v2).normalize();
bone.rotateOnAxis(axis, angle);
}
}
}
Resources⌗
- ik rig: https://youtu.be/KLjTU0yKS00
- ccd ik: https://youtu.be/MA1nT9RAF3k
- Skeletal Animation: https://youtu.be/ZzMnu3v_MOw
- Cyclic Coordonate Descent Inverse Kynematic (CCD IK): http://rodolphe-vaillant.fr/entry/114/cyclic-coordonate-descent-inverse-kynematic-ccd-ik
Read other posts