Changing Point of Rotation of a Bone

Basically I have the head bone and i apply a rotation to it using where the player is looking at.

Now the issue is that I can’t seem to figure out how to move the pivot of rotation of the bone from its center to below its starting position (where it touches the body). Below I have attached the loader code + code I use to rotate head of player. Hope you guys can help!

``````playerDraw[i].mesh.children[0].children[3].lookAt(
playerRot[i].position.x * 100,
playerRot[i].position.y * 100,
playerRot[i].position.z * 100);

"/Models/Character/originalplayer.glb",
function (gltf, mat) {
mesh0 = gltf.scene;
mesh0.scale.set (scale,scale,scale);
mesh0.position.set ( 0, -10, 0 );
var newMaterial = new THREE.MeshStandardMaterial({color: 0x005555});
mesh0.traverse((o) => {
if (o.isMesh) o.material = newMaterial;
});
console.log(mesh0.children[0].children[3])
playerDraw.push({mesh: mesh0, r: 0});
},
(xhr) => {
},
(error) => {
console.log(error);
}
);``````

I don’t understand the `* 100` bits in your `lookAt` code
I rotate a head bone in this example without much problem. The head always looks at the camera in my case.

1 Like

Thank you for the reply! Rotation of bone is fine, however, it rotates at the center of the cube rather than the location underneath the cube. Below I have attached a video of 2 different players connected to a server

The lookAt code simply rotates the cube to the desired location and seems to work properly, except that the pivot is not at the intended location.

I’m sure there is a more mathematical way to to do this,
But when I need a pivot point I usually add an object3d specifically for it.

Eg,
Create a neck,
and then change the heads parent from the torso to the neck.

Eg pseudo code, (I haven’t debugged or tested it works)

``````var torso = mesh0.children[0]  // I am guessing here
var neck = new THREE.Object3D();
neck.position.set(0,1,0)  //another guess where it might be relative the torso
head.position.set(0,.25,0)  //another guess where it might be relative the neck
``````