I started experimenting the ARStudio from Facebook but I couldn't figure out how can I set the position of the object from a script.
I tried something like down below but seems like object.transform.x(or y, z)
takes "ScalarSignal" instead of numeric value. How do I set the positions of objects in ARStudio?
class Vector3{
constructor(xPos = 0, yPos = 0, zPos = 0){
var x = xPos;
var y = yPos;
var z = zPos;
}
}
const FaceTracking = require("FaceTracking");
const Diagnostics = require("Diagnostics");
const Scene = require("Scene");
var sphere = Scene.root.child("sphere");
var spherePosition = new Vector3()
var mouthCenter = FaceTracking.face(0).mouth.center;
var mouthCenterPosition = new Vector3();
mouthCenter.x.monitor().subscribe(function(e){
if(e.newValue){
mouthCenterPosition.x = mouthCenter.x.lastValue;
}
});
mouthCenter.y.monitor().subscribe(function(e){
if(e.newValue){
mouthCenterPosition.y = mouthCenter.y.lastValue;
}
});
mouthCenter.z.monitor().subscribe(function(e){
if(e.newValue){
mouthCenterPosition.z = mouthCenter.z.lastValue;
}
// Diagnostics.log(mouthCenterPosition);
SetSpherePosition(mouthCenterPosition);
});
function SetSpherePosition(pos){
//This part is causing error...
sphere.transform.x = pos.x;
sphere.transform.y = pos.y;
sphere.transform.z = pos.z;
}