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...
You need to go to the menu Edit -> Edit Properties -> Capabilities -> Touch Gestures and enable the option "Tap Gesture"
Since old API has been deprecated you'll probably need the new code:
// How to load in modules
const Scene = require('Scene');
const Patches = require('Patches');
export const Diagnostics = require('Diagnostics');
Promise.all([
Scene.root.findFirst('number',{recursive:true})
]).then(function(results){
const textHolder = results[0];
Patches.outputs.getScalar('score').then(scoreValue =>{
textHolder.text =scoreValue.toString()
})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.