unexpected Lens error - face trigger

  • Hi Zeno,

    Happy to look into this issue for you. If you're comfortable sharing over the forum, could you send me the script and video asset you are using? If not comfortable sharing here, I can setup another thread for us to chat privately on.

    Cheers,
    Kaitlyn

    0
    Comment actions Permalink
  • Hi Kaitlyn, 

    Thanks!  I used the standard FaceAnimTrigger script found in the template..  

    Also while we're at it is there a maximum number of effects and script you can trigger with your face or tapping for example? 

    this is the mp4 - https://we.tl/Qx6YTBeOZ9 

    Thanks! 

     

    // FaceTriggerAnim.js

    // Version: 0.0.2

    // Event: Lens Initialized

    // Description: Plays an animation layer, sound, sprite, on trigger

     

    // @input string AnimationTrigger = MouthOpenedEvent { "widget": "combobox", "values": [ { "label": "Brows Lowered", "value": "BrowsLoweredEvent" }, { "label": "Brows Raised", "value": "BrowsRaisedEvent" }, { "label": "Brows Returned To Normal", "value": "BrowsReturnedToNormalEvent" }, { "label": "Face Found", "value": "FaceFoundEvent" }, { "label": "Face Lost", "value": "FaceLostEvent" }, { "label": "Kiss Finished", "value": "KissFinishedEvent" }, { "label": "Kiss Started", "value": "KissStartedEvent" }, { "label": "Mouth Closed", "value": "MouthClosedEvent" }, { "label": "Mouth Opened", "value": "MouthOpenedEvent" }, { "label": "Smile Finished", "value": "SmileFinishedEvent" }, { "label": "Smile Started", "value": "SmileStartedEvent" }, { "label": "Touch Start", "value": "TouchStartEvent" }, { "label": "Touch End", "value": "TouchEndEvent" }, { "label": "Tap", "value": "TapEvent" } ] }

    // @input int faceIndex = 0

     

    // @ui {"widget":"separator"}

     

    // @ui {"widget": "group_start", "label": "3D Anim Control"}

    // @input Component.AnimationMixer AnimationMixer

    // @input string LayerName

    // @input int animationPlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1} // How many times to play the animation, -1 for infinite

    // @ui {"widget": "group_end"}

     

    // @ui {"widget":"group_start", "label":"2D Anim Control"}

    // @input Component.SpriteVisual[] play2dSprites {"label": "Play Animations"}

    // @input int texturePlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1}

    // @input float texturePlayOffset = 0 {"label": "Play Offset", "min":0.0, "max":99999.0, "step":1}

    // @ui {"widget":"group_end"}

     

    // @ui {"widget":"group_start", "label":"Sound Control"}

    // @input Asset.AudioTrackAsset[] playAudios {"label": "Play Sounds"}

    // @input int audioPlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1}

    // @ui {"widget":"group_end"}

     

    // @ui {"widget":"separator"}

     

    // @input float TriggerDisableTime = 0

     

    var triggerStartTime = getTime() - script.TriggerDisableTime;

     

    // What happens when event is triggered

    function onTriggered()

    {

    print("FaceTriggerAnim: " + script.AnimationTrigger + " triggered");

     

    // Called when animation ends

    function animationCallback()

    {

    script.AnimationMixer.setWeight(script.LayerName, 0.0);

    }

     

    // Play animation layer with sound (if available)

    if (script.AnimationMixer && script.LayerName)

    {

    script.AnimationMixer.startWithCallback(script.LayerName, 0.0, script.animationPlayCount, animationCallback);

    script.AnimationMixer.setWeight(script.LayerName, 1.0);

    }

     

    for (var i = 0; i < script.play2dSprites.length; i++)

    {

    if (script.play2dSprites[i]

    && script.play2dSprites[i].mainPass.baseTex

    && script.play2dSprites[i].mainPass.baseTex.control

    && script.play2dSprites[i].mainPass.baseTex.control.play)

    {

    script.play2dSprites[i].getSceneObject().enabled = true;

    script.play2dSprites[i].mainPass.baseTex.control.play(script.texturePlayCount, script.texturePlayOffset);

    }

    }

     

    for (var i = 0; i < script.playAudios.length; i++)

    {

    if (script.playAudios[i])

    {

    var audioComponent = getAudioComponentForTrack(script.playAudios[i]);

    audioComponent.play(script.audioPlayCount);

    }

    }

     

    }

     

    // Trigger an action if not in cooldown period

    function triggerCallback()

    {

    if (getTime() >= triggerStartTime + script.TriggerDisableTime) {

    triggerStartTime = getTime();

    onTriggered();

    }

    }

     

    // Setup the audio component if audio track defined

    function getAudioComponentForTrack ( audioTrackAsset )

    {

    var trackName = audioTrackAsset.name;

     

    if (!global.ftAudioComponents)

    {

    global.ftAudioComponents = {};

    }

     

    if (!global.ftAudioComponents[trackName])

    {

    var audioComponent = script.getSceneObject().createComponent("Component.AudioComponent");

    audioComponent.audioTrack = audioTrackAsset;

     

    global.ftAudioComponents[trackName] = audioComponent;

    }

     

    return global.ftAudioComponents[trackName];

    }

     

    // Allow fullscreen tapping if trigger is touch based

    if (script.AnimationTrigger == "TouchStartEvent"

    || script.AnimationTrigger == "TouchStartEvent"

    || script.AnimationTrigger == "TapEvent")

    {

    global.touchSystem.touchBlocking = true;

    global.touchSystem.enableTouchBlockingException("TouchTypeDoubleTap", true);

    global.touchSystem.enableTouchBlockingException("TouchTypeSwipe", true);

    }

     

    var event = script.createEvent(script.AnimationTrigger);

    event.faceIndex = script.faceIndex;

    event.bind(triggerCallback);

    0
    Comment actions Permalink
  • Hi Zeno,

    I tried to open the video, but it says the page is not found. Can you resend?

    Thanks,
    Kaitlyn

    0
    Comment actions Permalink
  • Hi Zeno,

    We actually don't need your video because I found the bug in the FaceAnimTrigger script. For video textures, the API is slightly different than the animated textures. It will report an error if you try to play the video while it is already playing. Also, it does not support playOffset. If you make these changes for the 2D Sprite portion in the FaceAnimTrigger Script: 

     for (var i = 0; i < script.play2dSprites.length; i++)
    {
    if (script.play2dSprites[i]
    && script.play2dSprites[i].mainPass.baseTex
    && script.play2dSprites[i].mainPass.baseTex.control
    && script.play2dSprites[i].mainPass.baseTex.control.play)
    {
    script.play2dSprites[i].getSceneObject().enabled = true;

    //for video texture provider
    if (script.play2dSprites[i].mainPass.baseTex.control.getStatus){
    var videoStatus = script.play2dSprites[i].mainPass.baseTex.control.getStatus();
    if (videoStatus == VideoStatus.Playing){
    //stop the video if it is still playing
    script.play2dSprites[i].mainPass.baseTex.control.stop();
    }
    script.play2dSprites[i].mainPass.baseTex.control.play(script.texturePlayCount);
    }
    else{
    script.play2dSprites[i].mainPass.baseTex.control.play(script.texturePlayCount, script.texturePlayOffset);
    }
    }
    }

    the lens error you were seeing before should be fixed! Let me know if you have any questions! 

    1
    Comment actions Permalink
  • Weeeew! Thank you so much!!  that did the trick :D I'll share when its finished 

    0
    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?

Version

Graphics

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:

Name:

Email:

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!