fix clearing walls on restart/pause

This commit is contained in:
Kevin Ngo
2018-10-12 03:51:04 -07:00
parent 79bece00f0
commit e0b312e95e
2 changed files with 11 additions and 1 deletions

View File

@@ -225,7 +225,13 @@ AFRAME.registerComponent('beat-loader', {
this.beatsTime = 0;
this.beatsTimeOffset = undefined;
for (let i = 0; i < this.beatContainer.children.length; i++) {
this.beatContainer.children[i].components.beat.returnToPool(true);
let child = this.beatContainer.children[i];
if (child.components.beat) {
child.components.beat.returnToPool(true);
}
if (child.components.wall) {
child.components.wall.returnToPool(true);
}
}
}
});

View File

@@ -7,6 +7,10 @@ AFRAME.registerComponent('wall', {
this.maxZ = 10;
},
pause: function () {
this.el.object3D.visible = false;
},
tock: function (time, delta) {
this.el.object3D.position.z += this.data.speed * (delta / 1000);
this.returnToPool();