From b683ece3221d4ef9f2d9d1acdb51d3de122533af Mon Sep 17 00:00:00 2001 From: Diego Marcos Date: Tue, 23 Oct 2018 11:46:46 -0700 Subject: [PATCH] Revert "beat warp in" This reverts commit 3f63300e4a3e6ebde96b71ac928b3266d155651e. --- src/components/beat-loader.js | 11 ++++------- src/components/beat.js | 24 ++++-------------------- src/constants/beat.js | 2 -- 3 files changed, 8 insertions(+), 29 deletions(-) delete mode 100644 src/constants/beat.js diff --git a/src/components/beat-loader.js b/src/components/beat-loader.js index 03f2df0..0dfee2a 100644 --- a/src/components/beat-loader.js +++ b/src/components/beat-loader.js @@ -1,7 +1,4 @@ -import {BEAT_WARMUP_OFFSET, BEAT_WARMUP_SPEED} from '../constants/beat'; -import utils from '../utils'; - -const WARMUP_TIME = (BEAT_WARMUP_OFFSET / BEAT_WARMUP_SPEED) * 1000; // ms. +var utils = require('../utils'); /** * Load beat data (all the beats and such). @@ -33,6 +30,7 @@ AFRAME.registerComponent('beat-loader', { init: function () { this.audioAnalyserEl = document.getElementById('audioanalyser'); + this.beams = document.getElementById('beams').components.beams; this.beatData = null; this.beatDataProcessed = false; this.beatContainer = document.getElementById('beatContainer'); @@ -150,8 +148,7 @@ AFRAME.registerComponent('beat-loader', { if (this.beatsTimeOffset !== undefined && this.songCurrentTime !== this.el.components.song.context.currentTime) { this.songCurrentTime = this.el.components.song.context.currentTime; - this.beatsTime = (this.songCurrentTime + this.data.beatAnticipationTime) * 1000 + - WARMUP_TIME; + this.beatsTime = (this.songCurrentTime + this.data.beatAnticipationTime) * 1000; } notes = this.beatData._notes; @@ -231,7 +228,7 @@ AFRAME.registerComponent('beat-loader', { this.orientations[noteInfo._cutDirection]); beatEl.play(); - beatEl.components.beat.onGenerate(); + this.beams.newBeam(color, beatEl.object3D.position); }; })(), diff --git a/src/components/beat.js b/src/components/beat.js index c6a3818..342d6e7 100644 --- a/src/components/beat.js +++ b/src/components/beat.js @@ -1,7 +1,6 @@ -import {BEAT_WARMUP_OFFSET, BEAT_WARMUP_SPEED} from '../constants/beat'; +var SIGN_MATERIAL = {shader: 'flat', color: '#88f'}; -const auxObj3D = new THREE.Object3D(); -const SIGN_MATERIAL = {shader: 'flat', color: '#88f'}; +var auxObj3D = new THREE.Object3D(); /** * Create beat from pool, collision detection, clipping planes. @@ -39,7 +38,6 @@ AFRAME.registerComponent('beat', { init: function () { this.backToPool = false; - this.beams = document.getElementById('beams').components.beams; this.beatBoundingBox = new THREE.Box3(); this.cutDirection = new THREE.Vector3(); this.destroyed = false; @@ -49,7 +47,6 @@ AFRAME.registerComponent('beat', { this.returnToPoolTimer = 800; this.rotationAxis = new THREE.Vector3(); this.saberEls = this.el.sceneEl.querySelectorAll('[saber-controls]'); - this.startPositionZ = undefined; this.rightCutPlanePoints = [ new THREE.Vector3(), new THREE.Vector3(), @@ -100,9 +97,9 @@ AFRAME.registerComponent('beat', { }, play: function () { - this.blockEl.object3D.visible = true; this.destroyed = false; this.el.object3D.visible = true; + this.blockEl.object3D.visible = true; }, tock: function (time, timeDelta) { @@ -112,20 +109,7 @@ AFRAME.registerComponent('beat', { // Only check collisions when close. const collisionZThreshold = -4; if (this.el.object3D.position.z > collisionZThreshold) { this.checkCollisions(); } - - // Move. - if (this.el.object3D.position.z < this.startPositionZ) { - // Warm up / warp in. - this.el.object3D.position.z += BEAT_WARMUP_SPEED * (timeDelta / 1000); - if (this.el.object3D.position.z >= this.startPositionZ) { - this.beams.newBeam(this.data.color, this.el.object3D.position); - } - } else { - // Standard moving. - this.el.object3D.position.z += this.data.speed * (timeDelta / 1000); - } - - // Check. + this.el.object3D.position.z += this.data.speed * (timeDelta / 1000); this.backToPool = this.el.object3D.position.z >= 2; if (this.backToPool) { this.missHit(); } } diff --git a/src/constants/beat.js b/src/constants/beat.js deleted file mode 100644 index c5edc83..0000000 --- a/src/constants/beat.js +++ /dev/null @@ -1,2 +0,0 @@ -export const BEAT_WARMUP_OFFSET = 100; -export const BEAT_WARMUP_SPEED = 250;