I’m having a bit of trouble with this.
I’m trying to create an entity at the center of the face to make it easier to add face masks and objects.
I’ve got it to follow the user’s head movements, yaw and roll. But it doesn’t follow pitch.
This is how I’m doing it:
//Left cheek
pos1 = cubes[205].getPosition();
//Right Cheek
pos2 = cubes[425].getPosition();
dist = pos1.distance(pos2);
dist = dist / 2;
center.setPosition(pos1);
center.lookAt(pos2);
center.translateLocal(0, 0, -dist);
center.rotateLocal(0, 90, 0)
I then tried modifying it but now it only follows yaw and pitch but not roll:
//Left Cheek
pos1 = cubes[205].getPosition();
//Right Cheek
pos2 = cubes[425].getPosition();
dist = pos1.distance(pos2);
dist = dist / 2;
center.setPosition(pos1);
center.lookAt(pos2);
center.translateLocal(0, 0, -dist);
//center.rotateLocal(0, 90, 0);
//Forehead
pos3 = cubes[200].getPosition();
//Chin
pos4 = cubes[9].getPosition();
var ver = new pc.Vec3().sub2(pos3, pos4);
var hor = new pc.Vec3().sub2(pos2, pos1);
var cross = new pc.Vec3().cross(ver, hor);
center.lookAt(cross);
Screenrecorder-2020-11-27-13-05-44-268