Skip to content

Instantly share code, notes, and snippets.

@thenayr
Created November 17, 2016 23:59
Show Gist options
  • Save thenayr/9857d8573369e64a04e8aea286d639ab to your computer and use it in GitHub Desktop.
Save thenayr/9857d8573369e64a04e8aea286d639ab to your computer and use it in GitHub Desktop.
A-frame component to check current height position of an object
/**
* Simple y position tracker to determine if an object has fallen off the platform
*/
module.exports = {
schema: {type: 'vec3'},
init: function() {
this.timeout = setInterval(this.checkPosition.bind(this), 5000);
},
update: function() {
var object3D = this.el.object3D;
var data = this.data;
},
remove: function() {
clearInterval(this.timeout);
this.el.removeObject3D(this.object3D);
},
checkPosition: function() {
if(this.el.body.position.y > -50) {
return;
} else {
this.el.emit('destroy');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment