FaceGesturesModule
The FaceGesturesModule class enables face orientation detection.
Example
//==============================================================================
// The following example demonstrates how to hide an object when winking and
// rotate an object when blinking.
//
// Project setup:
// - Insert a plane
//==============================================================================
// Load in the required modules
const FaceGestures = require('FaceGestures');
const FaceTracking = require('FaceTracking');
const Reactive = require('Reactive');
const Scene = require('Scene');
// Locate the plane in the Scene
const plane = Scene.root.find('plane0');
// Store a reference to a detected face
const face = FaceTracking.face(0);
//==============================================================================
// Hide the plane when winking with either eye
//==============================================================================
// Store references for when the left and right eye are closed
const hasLeftEyeClosed = FaceGestures.hasLeftEyeClosed(face);
const hasRightEyeClosed = FaceGestures.hasRightEyeClosed(face);
// Create a signal that returns true when one of the eye booleans is true
const winking = hasLeftEyeClosed.xor(hasRightEyeClosed);
// Bind the winking signal to the hidden property of the plane
plane.hidden = winking;
//==============================================================================
// Rotate the plane by 45 degrees when blinking
//==============================================================================
// Register a blink event
FaceGestures.onBlink(face).subscribe(function() {
// Store the last known z-axis rotation value
const lastRotationZ = plane.transform.rotationZ.pinLastValue();
// Add 45 degrees (0.7853981634 radians = 45 degrees)
const newRotationZ = Reactive.add(lastRotationZ, 0.7853981634);
// Bind the new z-axis rotation signal to the plane's Z-axis rotation signal
plane.transform.rotationZ = newRotationZ;
});Properties
This module exposes no properties.
Methods
| Method | Description |
|---|---|
|
There is no explicit underlying driver signal for this face gesture. |
|
There is no explicit underlying driver signal for this face gesture. |
|
A signal goes ON when |
|
A signal goes ON when |
|
A signal goes ON when |
|
|
|
|
|
A signal goes ON when angle reaches |
|
A signal goes ON when angle reaches |
|
A signal goes ON when angle reaches |
|
A signal goes ON when angle reaches |
|
A signal goes ON when |
|
|
|
Returns a
A signal goes ON when angle reaches |
|
Returns a
A signal goes ON when angle reaches |
|
Returns an
|
|
Returns an
|
|
Returns an
|
Classes
This module exposes no classes.