Skip to content

Instantly share code, notes, and snippets.

@tomaspietravallo
Created September 19, 2020 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaspietravallo/55e03e4742d1760880a5e24705d31d32 to your computer and use it in GitHub Desktop.
Save tomaspietravallo/55e03e4742d1760880a5e24705d31d32 to your computer and use it in GitHub Desktop.
See line number 5
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