Add Walls

This commit is contained in:
Diego Marcos
2018-10-11 22:15:41 -10:00
parent 8159e18bcb
commit 65cb45590f
4 changed files with 108 additions and 19 deletions

20
src/components/wall.js Normal file
View File

@@ -0,0 +1,20 @@
AFRAME.registerComponent('wall', {
schema: {
speed: {default: 1.0}
},
init: function () {
this.maxZ = 10;
},
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();
},
});