diff --git a/src/components/beat.js b/src/components/beat.js index a97d136..7d9a456 100644 --- a/src/components/beat.js +++ b/src/components/beat.js @@ -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. diff --git a/src/components/stage-colors.js b/src/components/stage-colors.js index da75f55..149df91 100644 --- a/src/components/stage-colors.js +++ b/src/components/stage-colors.js @@ -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');