Search code examples
javascriptspark-ar-studio

Spark AR does not accept any scripting Functions, undefined is not a function


I am trying to develop a simple Instagram Filter and therefore trying to write a simple JS in Spark AR. Here is my code, basically copied from the tutorial https://sparkar.facebook.com/ar-studio/learn/documentation/scripting/reactive:

const Scene = require('Scene');
export const Diagnostics = require('Diagnostics');
const TouchGestures = require('TouchGestures');

// Subscribe to tap gestures
TouchGestures.onTap().subscribe(function (gesture) {
    // Log a message to the console when a tap is detected
    Diagnostics.log('tap gesture detected');
});

Spark AR is giving me an instant error. The message is

Error:undefined is not a function
{
 "line": 6,
 "column": 0,
 "sourceURL": "script.js"
}

Am I missing any librarys or do I have to install anything in a addition than Spark AR? I have absolutely no idea what is going wrong. :/
Thanks in advance...


Solution

  • You need to go to the menu Edit -> Edit Properties -> Capabilities -> Touch Gestures and enable the option "Tap Gesture"