From f62817b5dd7f3e1d951808f67afe72001cd299a8 Mon Sep 17 00:00:00 2001 From: Diego Marcos Date: Tue, 23 Oct 2018 11:43:48 -0700 Subject: [PATCH] Revert "beat warmup rotation / twist" This reverts commit 620f0a284635c4975c5f2aa260de75d272de9fda. --- src/components/beat-loader.js | 6 ++++-- src/components/beat.js | 38 ++++++++--------------------------- src/constants/beat.js | 1 - 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/components/beat-loader.js b/src/components/beat-loader.js index c2d5e47..03f2df0 100644 --- a/src/components/beat-loader.js +++ b/src/components/beat-loader.js @@ -1,6 +1,8 @@ -import {BEAT_WARMUP_OFFSET, BEAT_WARMUP_SPEED, BEAT_WARMUP_TIME} from '../constants/beat'; +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. + /** * Load beat data (all the beats and such). */ @@ -149,7 +151,7 @@ AFRAME.registerComponent('beat-loader', { this.songCurrentTime !== this.el.components.song.context.currentTime) { this.songCurrentTime = this.el.components.song.context.currentTime; this.beatsTime = (this.songCurrentTime + this.data.beatAnticipationTime) * 1000 + - BEAT_WARMUP_TIME; + WARMUP_TIME; } notes = this.beatData._notes; diff --git a/src/components/beat.js b/src/components/beat.js index b17223a..c6a3818 100644 --- a/src/components/beat.js +++ b/src/components/beat.js @@ -1,9 +1,6 @@ -import {BEAT_WARMUP_OFFSET, BEAT_WARMUP_SPEED, BEAT_WARMUP_TIME} from '../constants/beat'; +import {BEAT_WARMUP_OFFSET, BEAT_WARMUP_SPEED} from '../constants/beat'; const auxObj3D = new THREE.Object3D(); -const BEAT_WARMUP_ROTATION_CHANGE = Math.PI / 5; -const BEAT_WARMUP_ROTATION_OFFSET = 0.4; -const BEAT_WARMUP_ROTATION_TIME = 750; const SIGN_MATERIAL = {shader: 'flat', color: '#88f'}; /** @@ -44,7 +41,6 @@ AFRAME.registerComponent('beat', { this.backToPool = false; this.beams = document.getElementById('beams').components.beams; this.beatBoundingBox = new THREE.Box3(); - this.currentRotationWarmupTime = 0; this.cutDirection = new THREE.Vector3(); this.destroyed = false; this.gravityVelocity = 0; @@ -110,38 +106,27 @@ AFRAME.registerComponent('beat', { }, tock: function (time, timeDelta) { - const el = this.el; - const position = el.object3D.position; - if (this.destroyed) { this.tockDestroyed(timeDelta); } else { // Only check collisions when close. const collisionZThreshold = -4; - if (position.z > collisionZThreshold) { this.checkCollisions(); } + if (this.el.object3D.position.z > collisionZThreshold) { this.checkCollisions(); } // Move. - if (position.z < this.startPositionZ) { + if (this.el.object3D.position.z < this.startPositionZ) { // Warm up / warp in. - position.z += BEAT_WARMUP_SPEED * (timeDelta / 1000); - if (position.z >= this.startPositionZ) { - this.beams.newBeam(this.data.color, position); + 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. - position.z += this.data.speed * (timeDelta / 1000); - } - - if (position.z > (this.startPositionZ - BEAT_WARMUP_ROTATION_OFFSET) && - this.currentRotationWarmupTime < BEAT_WARMUP_ROTATION_TIME) { - const progress = AFRAME.ANIME.easings.easeOutBack( - this.currentRotationWarmupTime / BEAT_WARMUP_ROTATION_TIME); - el.object3D.rotation.z = this.rotationZStart + (progress * this.rotationZChange); - this.currentRotationWarmupTime += timeDelta; + this.el.object3D.position.z += this.data.speed * (timeDelta / 1000); } // Check. - this.backToPool = position.z >= 2; + this.backToPool = this.el.object3D.position.z >= 2; if (this.backToPool) { this.missHit(); } } this.returnToPool(); @@ -153,13 +138,6 @@ AFRAME.registerComponent('beat', { onGenerate: function () { this.startPositionZ = this.el.object3D.position.z; this.el.object3D.position.z -= BEAT_WARMUP_OFFSET; - - // Set up rotation warmup. - this.currentRotationWarmupTime = 0; - this.rotationZChange = BEAT_WARMUP_ROTATION_CHANGE; - if (Math.random > 0.5) { this.rotationZChange *= -1; } - this.el.object3D.rotation.z -= this.rotationZChange; - this.rotationZStart = this.el.object3D.rotation.z; }, initBlock: function () { diff --git a/src/constants/beat.js b/src/constants/beat.js index 92be36c..c7a36a0 100644 --- a/src/constants/beat.js +++ b/src/constants/beat.js @@ -1,3 +1,2 @@ export const BEAT_WARMUP_OFFSET = 25; export const BEAT_WARMUP_SPEED = 155; -export const BEAT_WARMUP_TIME = (BEAT_WARMUP_OFFSET / BEAT_WARMUP_SPEED) * 1000;