Files
junisaber/src/components/wall.js

25 lines
513 B
JavaScript
Raw Normal View History

2018-10-11 22:15:41 -10:00
AFRAME.registerComponent('wall', {
schema: {
speed: {default: 1.0}
},
init: function () {
this.maxZ = 10;
},
2018-10-12 03:51:04 -07:00
pause: function () {
this.el.object3D.visible = false;
},
2018-10-11 22:15:41 -10:00
tock: function (time, delta) {
this.el.object3D.position.z += this.data.speed * (delta / 1000);
this.returnToPool();
},
returnToPool: function () {
if (this.el.object3D.position.z < this.maxZ) { return; }
this.el.sceneEl.components.pool__wall.returnEntity(this.el);
this.el.pause();
},
});