1

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);
    })
JackKalish
  • 1,555
  • 2
  • 15
  • 24
James
  • 1,355
  • 3
  • 14
  • 38

1 Answers1

5
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/

JackKalish
  • 1,555
  • 2
  • 15
  • 24
  • Thanks Jack. Love your portfolio. Could you share any favourite AR Spark resources, learning hubs? – James Aug 21 '20 at 13:19
  • BTW I presumed gt was get . Duh! – James Aug 21 '20 at 13:38
  • Hey @James thanks! If the answer worked for you, could you please mark it as accepted? Best way to learn is do the tutorials on the Spark site, read the documentation pages, and make stuff. See the documentation pages on ScalarSignal for more info on all the different available methods - including lt and gt https://sparkar.facebook.com/ar-studio/learn/reference/classes/reactivemodule.scalarsignal/ – JackKalish Aug 21 '20 at 21:16