Combining Trigger script with Fullscreen script

  • Hey Bram!

    That's a great idea. We can take code from FullscreenTemplateState.js to help us with this.

    First we need to get a list of the objects we want to enable from the Inspector panel. So at the top of FaceTriggerAnim.js add 

    // @input SceneObject[] enableObjects

    what we're saying here is basically we want to be able to add objects in the Inspector panel when we use FaceTriggerAnim.js

    Then, from FullscreenTemplateState.js we can take the code to enable or disable a list of objects. You can put this at the end of FaceTriggerAnim.js. The function is below for convenience. 

    function setObjectsEnabled ( sceneObjects, status, onModifyObject )
    for (var i = 0; i < sceneObjects.length; i++)
    if ( sceneObjects[i] )
    sceneObjects[i].enabled = status;

    if (onModifyObject) onModifyObject(sceneObjects[i]);

    What we're saying here is given a list of objects, go through it and set its "enabled" property to "status". the enabled property is like clicking the checkbox in the Objects panel. We don't have to worry about onModifyObject here since it's optional (notice the if statement).

    Now all we need to do is call this function when we want to enable or disable objects!

    So when we start the lens, we want to disable all listed objects so we can enable them later. 

    So after all the //@input at the top of the file, we can start writing our code. Add

    setObjectsEnabled (script.enableObjects, false);

    which is basically saying set all the objects listed in script.enableObjects to false (disabled). 

    When a trigger happens in the lens, the function onTriggered gets called. So, at the bottom of the onTriggered function we can say:

    setObjectsEnabled (script.enableObjects, true);


    Similar to earlier, we're telling every object under script.enableObjects to true (enabled). 

    Now, when you use FaceTriggerAnim.js, you should see an Enable Objects field where you can add the objects you want to enable!

    Can't wait to see what you make!


    Comment actions Permalink
  • Thanks for the amazing help again Jon! I was able to get it to work, but now it only enables the objects. I understand that with a trigger, there is no 'end' like there is in a State. But is there a way to Enable some objects on MouthOpen and then disable them on MouthClose?

    Thanks again!

    Comment actions Permalink
  • Hi Bram,

    No problem! Remember how the second flag in setObjectsEnabled defines whether the function enables or disables?

    So in order to get a trigger that disables the object, similar to above, add an input at the top of the file to get a list of objects you want to disable on trigger: 

    // @input SceneObject[] disableObjects

    then at the bottom of onTriggered, we'll pass those objects and set it to disabled by by setting the second flag to false.

    setObjectsEnabled (script.disableObjects, false);

    Finally, to use the script, you can add another Script component with FaceTriggerAnim.js and add an object to disable, and set it's animation trigger!



    Comment actions Permalink
  • Jon, you absolute hero!

    Here's a little progress

    Comment actions Permalink
  • Looking great! Glad I could help.

    Can't wait to see the final Lens!

    Comment actions Permalink
Have a comment?

Please sign in to leave a comment.

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?



Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:



What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!