33 lines
753 B
JavaScript
33 lines
753 B
JavaScript
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 / 5;
|
|
},
|
|
|
|
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;
|
|
}
|
|
}) |