I have the following function trying to rotate the last joint of a finger using mediapipe results. However, the joint rotates even when the actual joint has remained straight, but one other in its parents chain has moved. Any ideas on how to combat this?
<code>function updateHand(results) {
let landmarks = results.landmarks[0];
let localVector7 = new THREE.Vector3(landmarks[7].x, - landmarks[7].y, - landmarks[7].z);
let localVector8 = new THREE.Vector3(landmarks[8].x, - landmarks[8].y, - landmarks[8].z);
localVector7 = localVector7.normalize();
let vector8relativeTo7 = new THREE.Vector3().subVectors(localVector8, localVector7);
vector8relativeTo7 = vector8relativeTo7.normalize();
let quaternion = new THREE.Quaternion();
quaternion.setFromUnitVectors(hand.index[2].position, vector8relativeTo7);
hand.index[2].setRotationFromQuaternion(quaternion);
console.log("vector8relativeTo7: ", vector8relativeTo7);
}
</code>
<code>function updateHand(results) {
let landmarks = results.landmarks[0];
let localVector7 = new THREE.Vector3(landmarks[7].x, - landmarks[7].y, - landmarks[7].z);
let localVector8 = new THREE.Vector3(landmarks[8].x, - landmarks[8].y, - landmarks[8].z);
localVector7 = localVector7.normalize();
let vector8relativeTo7 = new THREE.Vector3().subVectors(localVector8, localVector7);
vector8relativeTo7 = vector8relativeTo7.normalize();
let quaternion = new THREE.Quaternion();
quaternion.setFromUnitVectors(hand.index[2].position, vector8relativeTo7);
hand.index[2].setRotationFromQuaternion(quaternion);
console.log("vector8relativeTo7: ", vector8relativeTo7);
}
</code>
function updateHand(results) {
let landmarks = results.landmarks[0];
let localVector7 = new THREE.Vector3(landmarks[7].x, - landmarks[7].y, - landmarks[7].z);
let localVector8 = new THREE.Vector3(landmarks[8].x, - landmarks[8].y, - landmarks[8].z);
localVector7 = localVector7.normalize();
let vector8relativeTo7 = new THREE.Vector3().subVectors(localVector8, localVector7);
vector8relativeTo7 = vector8relativeTo7.normalize();
let quaternion = new THREE.Quaternion();
quaternion.setFromUnitVectors(hand.index[2].position, vector8relativeTo7);
hand.index[2].setRotationFromQuaternion(quaternion);
console.log("vector8relativeTo7: ", vector8relativeTo7);
}