Files
junisaber/src/components/visible-raycastable.js
2018-11-20 03:56:37 -08:00

18 lines
346 B
JavaScript

/**
* Couple visibility and raycastability.
*/
AFRAME.registerComponent('visible-raycastable', {
schema: {
default: true
},
update: function () {
this.el.object3D.visible = this.data;
if (this.data) {
this.el.setAttribute('raycastable', '');
} else {
this.el.removeAttribute('raycastable', '');
}
}
});