-
-
Save tomaspietravallo/55e03e4742d1760880a5e24705d31d32 to your computer and use it in GitHub Desktop.
See line number 5
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
const Scene = require('Scene'); | |
const TG = require('TouchGestures'); | |
const Diagnostics = require('Diagnostics'); | |
const NAMEOFYOURPLANE = 'plane0'; // change plane0 to the name of your plane (leave the quotes) | |
const Filter = { | |
/** @type {SceneObjectBase} */ | |
plane: null, | |
init(assets = []) { | |
Promise.all(assets).then((assets) => this.onLoad(assets)); | |
}, | |
onLoad(assets) { | |
try { | |
this.plane = assets[0]; | |
this.plane.hidden = true; // will throw error if not loaded properly | |
Diagnostics.log('Plane loaded correctly'); | |
TG.onPan().subscribe((gesture) => { | |
gesture.state | |
.monitor() | |
.select('newValue') | |
.subscribe((state) => { | |
if (state != 'BEGAN' && state != 'CHANGED') { | |
this.plane.hidden = true; | |
} else { | |
this.plane.hidden = false; | |
} | |
}); | |
}); | |
} catch (error) { | |
throw 'Plane not found, please check for typos (case sensitive)'; | |
} | |
}, | |
}; | |
Filter.init([Scene.root.findFirst(NAMEOFYOURPLANE)]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment