Created
July 25, 2020 06:02
-
-
Save tomaspietravallo/231f5ba4584d90c72148e1e89c39e1d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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