stage event synchronization (wip)

This commit is contained in:
Diego F. Goberna
2018-10-12 23:04:58 +02:00
parent 927d0706a5
commit 62aa0e58b8
8 changed files with 534 additions and 23 deletions

View File

@@ -0,0 +1,33 @@
AFRAME.registerComponent('stage-lasers', {
schema: {
enabled: {default: true}
},
init: function () {
this.speed = 0;
this.lasers = [
this.el.children[0].object3D,
this.el.children[1].object3D,
this.el.children[2].object3D
];
},
pulse: function (speed) {
this.speed = speed / 3;
},
tick: function (time, delta) {
if (this.speed === 0) { return; }
delta /= 1000;
if (!this.data.enabled) {
this.speed *= 0.96;
if (Math.abs(this.speed) < 0.01) {
this.speed = 0;
return;
}
}
this.lasers[0].rotation.z += this.speed * delta;
this.lasers[1].rotation.z -= this.speed * delta * 1.04;
this.lasers[2].rotation.z += this.speed * delta * 1.1;
}
})