Last active
February 14, 2020 01:05
-
-
Save yearofthewhopper/e5f7ba9f9fec607441ace6906dde7855 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const Scene = require('Scene'); | |
const Diagnostics = require('Diagnostics'); | |
const Instruction = require('Instruction'); | |
const CameraInfo = require('CameraInfo'); | |
const Time = require('Time'); | |
var instructionTimeloss; | |
function setInstruction(time, token){ | |
if(instructionTimeloss != null){ | |
Time.clearTimeout(instructionTimeloss); | |
} | |
Instruction.bind(true, token); | |
if(time != null){ | |
instructionTimeloss = Time.setTimeout( | |
function(){ | |
Instruction.bind(false, token); | |
}, time); | |
} | |
} | |
function clearInstruction(){ | |
if(instructionTimeloss != null){ | |
Time.clearTimeout(instructionTimeloss); | |
} | |
Instruction.bind(false, ''); | |
} | |
var cameraSwitched = false; | |
CameraInfo.captureDevicePosition.monitor({fireOnInitialValue: true}).subscribe( | |
function(pos){ | |
switch(pos.newValue) { | |
case 'FRONT': | |
Diagnostics.log('front!'); | |
setInstruction(3000, 'open_your_mouth'); | |
break; | |
case 'BACK': | |
Diagnostics.log('back!'); | |
cameraSwitched = true; | |
setInstruction(3000, 'flip_camera'); | |
break; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment