fix beat warmup

This commit is contained in:
Kevin Ngo
2018-11-08 14:31:35 +08:00
parent 3312846fd5
commit 468cc89f6b
2 changed files with 12 additions and 5 deletions

View File

@@ -12,7 +12,6 @@ const SIGN_MATERIAL = {shader: 'flat', color: '#88f'};
*/
AFRAME.registerComponent('beat', {
schema: {
warmupPosition: {default: 0},
anticipationPosition: {default: 0},
color: {default: 'red', oneOf: ['red', 'blue']},
cutDirection: {default: 'down'},
@@ -21,7 +20,8 @@ AFRAME.registerComponent('beat', {
size: {default: 0.35},
speed: {default: 1.0},
type: {default: 'arrow', oneOf: ['arrow', 'dot', 'mine']},
verticalPosition: {default: 'middle', oneOf: ['bottom', 'middle', 'top']}
verticalPosition: {default: 'middle', oneOf: ['bottom', 'middle', 'top']},
warmupPosition: {default: 0},
},
materialColor: {
@@ -174,11 +174,11 @@ AFRAME.registerComponent('beat', {
if (position.z < data.anticipationPosition) {
let newPositionZ = position.z + BEAT_WARMUP_SPEED * (timeDelta / 1000);
// Warm up / warp in.
if (newPositionZ < data.warmupPosition) {
this.beams.newBeam(this.data.color, position);
if (newPositionZ < data.anticipationPosition) {
position.z = newPositionZ;
} else {
position.z = data.anticipationPosition;
this.beams.newBeam(this.data.color, position);
}
} else {
// Standard moving.

View File

@@ -75,7 +75,14 @@ AFRAME.registerComponent('stage-colors', {
const red = color === 'red';
// Init or reset.
this.backglow.getObject3D('mesh').material.color.set(red ? '#f10' : '#00acfc');
try {
this.backglow.getObject3D('mesh').material.color.set(red ? '#f10' : '#00acfc');
} catch (e) {
this.backglow.addEventListener('object3dset', () => {
this.backglow.getObject3D('mesh').material.color.set(red ? '#f10' : '#00acfc');
});
}
this.sky.getObject3D('mesh').material.color.set(red ? '#f10' : '#00acfc');
this.el.sceneEl.object3D.background.set(red ? '#770100' : '#15252d');
this.el.sceneEl.object3D.fog.color.set(red ? '#a00' : '#007cb9');