I'm using a script in Spark AR Studio to try to show and hide a lightbulb on top of a person's head. The bulb hides with bulb.hidden
I have tried bulb.visible
unsuccessfully. Any Ideas? Code below:
(async function () {
Scene.root.findFirst('Sphere').then(bulb => {
// bulb.hidden = FaceTracking.face(0).mouth.openness
bulb.hidden = true
bulb.visible = FaceTracking.face(0).mouth.openness.gt(0.3);
})
bulb.hidden = true //this will show the bulb
bulb.hidden = false //this will hide the bulb
bulb.visible //this is not a valid property
What you want is:
bulb.hidden = FaceTracking.face(0).mouth.openness.gt(0.3);
This will set bulb.hidden to true when the mouth openness is greater than .3, ie when mouth is open, hide the bulb.
Alternatively, if you want to show the bulb when the mouth is open, use lt (less than) instead of gt (greater than) like this:
bulb.hidden = FaceTracking.face(0).mouth.openness.lt(0.3);
See the ScalarSignal documentation pages for info on what all the different methods available for ScalarSignals... there are many:
https://sparkar.facebook.com/ar-studio/learn/reference/classes/reactivemodule.scalarsignal/