I'm working on a project with face detection and 3D Graphics in canvas. I was wondering if it's possible to rotate around something according to your face position. To help you understand the problem here is the example im working on:
- Browser: Google Chrome Version: 71.0.3578.98 (Official Build) (64-bit).
- Libraries: p5.js, tracking.js, Three.js
Here is the code i use:
animate() {
myRenderer.render(myScene, myCamera);
//Check if face tracking is activated
if(checkFaceDetection === true) {
var faceCounter = face_counter(); //Count number of faces
var rotateX = face_posX(); //Get position in X Axis
var rotateY = face_posY(); //Get position in Y Axis
var zoomIn_Out = face_size(); //Get face Size (width and height)
//Check if face exactly in the middle
if(rotateX >= 250 && rotateX <=350){
alert("STATE: MIDDLE");
}
else if(rotateX >= 150 && rotateX <=250){
alert("STATE: LEFT");
//Check Direction
}
else if(rotateX >= 350 && rotateX <=450){
alert("STATE: RIGHT");
//Check Direction
}
}
}
Is there a better way to check the face position and also check the direction of the translation?
Also changing the camera position won't work the way I want it:
canvas_3D_Camera.position.set(rotateX,rotateY,zoomIn_Out);

Aucun commentaire:
Enregistrer un commentaire