Skip to content

Instantly share code, notes, and snippets.

@yearofthewhopper
Last active February 14, 2020 01:05
Show Gist options
  • Save yearofthewhopper/e5f7ba9f9fec607441ace6906dde7855 to your computer and use it in GitHub Desktop.
Save yearofthewhopper/e5f7ba9f9fec607441ace6906dde7855 to your computer and use it in GitHub Desktop.
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