stage event synchronization (wip)
This commit is contained in:
33
src/components/stage-lasers.js
Normal file
33
src/components/stage-lasers.js
Normal 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;
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user