Skip to content

Instantly share code, notes, and snippets.

@tomaspietravallo
Created July 25, 2020 06:02
Show Gist options
  • Save tomaspietravallo/231f5ba4584d90c72148e1e89c39e1d2 to your computer and use it in GitHub Desktop.
Save tomaspietravallo/231f5ba4584d90c72148e1e89c39e1d2 to your computer and use it in GitHub Desktop.
const Scene = require('Scene');
const FaceTracking = require('FaceTracking');
const Diagnostics = require('Diagnostics');
const Reactive = require('Reactive');
Promise.all([
Scene.root.findByPath('**/meshes0/*'),
]).then((result)=>{
let meshes = result[0];
let transform = FaceTracking.face(0).cameraTransform;
let maxSmooth = 350;
let maxDelay = 0.5;
for (let index = 0; index < meshes.length; index++) {
let mesh = meshes[index];
let smoothBy = (maxSmooth/meshes.length) * index + 1;
let delayBy = (maxDelay/meshes.length) * index + 1;
mesh.transform.x = Reactive.expSmooth((transform.x.delayBy({milliseconds: delayBy})), smoothBy);
mesh.transform.y = Reactive.expSmooth((transform.y.delayBy({milliseconds: delayBy})), smoothBy);
mesh.transform.z = Reactive.expSmooth((transform.z.delayBy({milliseconds: delayBy * 10})), smoothBy);
mesh.transform.rotationX = transform.rotationX;
mesh.transform.rotationY = transform.rotationY;
mesh.transform.rotationZ = transform.rotationZ;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment