Created
July 23, 2019 10:19
-
-
Save jiyeonseo/0a802ce6d251b8b4782c5e36da00a05a to your computer and use it in GitHub Desktop.
toggle_script.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//============================================================================== | |
// Welcome to scripting in Spark AR Studio! Helpful links: | |
// | |
// Scripting Basics - https://fb.me/spark-scripting-basics | |
// Reactive Programming - https://fb.me/spark-reactive-programming | |
// Scripting Object Reference - https://fb.me/spark-scripting-reference | |
// Changelogs - https://fb.me/spark-changelog | |
//============================================================================== | |
// How to load in modules | |
const Diagnostics = require('Diagnostics'); | |
const TouchGestures = require('TouchGestures'); | |
const Scene = require('Scene'); | |
const FaceTracking = require('FaceTracking'); | |
const FaceGestures = require('FaceGestures'); | |
const appleNode = Scene.root.find('Apple'); | |
const menuNode1 = Scene.root.find('rectangle0'); | |
const menuNode2 = Scene.root.find('rectangle1'); | |
const opt1TextNode = Scene.root.find('text0'); | |
const opt2TextNode = Scene.root.find('text1'); | |
let showMenu = false; | |
function toggleMenu() { | |
showMenu = !showMenu; | |
menuNode1.hidden = showMenu; | |
menuNode2.hidden = showMenu; | |
} | |
TouchGestures.onTap(appleNode).subscribe(function (gesture) { | |
Diagnostics.log('onTap'); | |
toggleMenu(); | |
const face = FaceTracking.face(0); | |
FaceGestures.isTurnedLeft(face).monitor().subscribe(function (changedValue) { | |
opt1TextNode.text = 'choosen'; | |
opt2TextNode.text = 'Opt2'; | |
}); | |
FaceGestures.isTurnedRight(face).monitor().subscribe(function (changedValue) { | |
opt1TextNode.text = 'Opt1'; | |
opt2TextNode.text = 'choosen'; | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment