Add Walls
This commit is contained in:
20
src/components/wall.js
Normal file
20
src/components/wall.js
Normal 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();
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user