Exposes details and key points of a three-dimensionally tracked face.
//============================================================================ // Move a plane between the left cheek and right eyebrow face points // when tapped // // Project setup: // - One plane: plane0 // // Required project capabilities: // - Face Tracking (auto added on FaceTracking module import) // - Touch Gestures > Tap Gesture // //============================================================================ // Load in the required modules const Scene = require('Scene'); const FaceTracking = require('FaceTracking'); const TouchGestures = require('TouchGestures'); (async function () { // Enables async/await in JS [part 1] // Locate the plane in the scene and the first detected face const [plane, face] = await Promise.all([ Scene.root.findFirst('plane0'), FaceTracking.face(0) ]); // Get the left cheek and right eyebrow objects from the detected face const leftCheek = face.leftCheek; const rightEyebrow = face.rightEyebrow; // Create a boolean to track which face point the plane is currently tracked to var planeOnCheek = false; // Change the face point the plane is tracked to when the plane is tapped TouchGestures.onTap(plane).subscribe(() => { // If the plane is on the cheek, bind its position to the eyebrow if (planeOnCheek){ plane.transform.x = face.cameraTransform.applyToPoint(rightEyebrow.outsideEnd).x; plane.transform.y = face.cameraTransform.applyToPoint(rightEyebrow.outsideEnd).y; planeOnCheek = false; // If the plane is on the eyebrow, bind its position to the cheek } else { plane.transform.x = face.cameraTransform.applyToPoint(leftCheek.cheekbone).x; plane.transform.y = face.cameraTransform.applyToPoint(leftCheek.cheekbone).y; planeOnCheek = true; } }); })(); // Enables async/await in JS [part 2]
Property | Description |
---|---|
cameraTransform | (get) cameraTransform: TransformSignal The face transform relative to the camera coordinate system, as a TransformSignal .Calling cameraTransform.applyToPoint(point) , where point is a point in the face's local coordinate system, will return a point in the camera's local coordinate system. |
chin | (get) chin: Chin The Chin of the tracked face. |
forehead | (get) forehead: Forehead The Forehead of the tracked face. |
id | (get) id: StringSignal The unique ID assigned to a tracked face, as a StringSignal .A unique ID is generated for every new face detected and tracked in the scene. If a face loses tracking it will be assigned a new unique ID when it is tracked again - the effect will not recognise individual faces. |
isTracked | (get) isTracked: BoolSignal Indicates whether the face is being tracked in the current frame, with a BoolSignal .If false , the value of the Face object's properties represent their value during the frame they were most recently tracked in. |
leftCheek | (get) leftCheek: Cheek The left Cheek of the tracked face. |
leftEye | (get) leftEye: Eye The left Eye of the tracked face. |
leftEyebrow | (get) leftEyebrow: Eyebrow The left Eyebrow of the tracked face. |
mouth | (get) mouth: Mouth The Mouth of the tracked face. |
nose | (get) nose: Nose The Nose of the tracked face. |
rightCheek | (get) rightCheek: Cheek The right Cheek of the tracked face. |
rightEye | (get) rightEye: Eye The right Eye of the tracked face. |
rightEyebrow | (get) rightEyebrow: Eyebrow The right Eyebrow of the tracked face. |
Method | Description |
---|---|
point | point(u: ScalarSignal | number, v: ScalarSignal | number): PointSignal Returns a PointSignal with the point in the face's local coordinate system that corresponds to the specified UV point from the facial mesh texture map.Use the Face.cameraTransform() method to convert the point to the camera coordinate system.* u - the U coordinate from the facial mesh texture map.* v - the V coordinate from the facial mesh texture map. |