slow down destroyed beats (restore speed from before beat speed up)

This commit is contained in:
Kevin Ngo
2018-12-10 18:02:52 -08:00
parent 6e126c54b1
commit 48f5fe8e88

View File

@@ -6,6 +6,7 @@ const collisionZThreshold = -1.65;
const BEAT_WARMUP_ROTATION_CHANGE = Math.PI / 5; const BEAT_WARMUP_ROTATION_CHANGE = Math.PI / 5;
const BEAT_WARMUP_ROTATION_OFFSET = 0.4; const BEAT_WARMUP_ROTATION_OFFSET = 0.4;
const BEAT_WARMUP_ROTATION_TIME = 750; const BEAT_WARMUP_ROTATION_TIME = 750;
const DESTROYED_SPEED = 1.0;
const ONCE = {once: true}; const ONCE = {once: true};
const SCORE_POOL = { const SCORE_POOL = {
@@ -27,7 +28,7 @@ AFRAME.registerComponent('beat', {
debug: {default: false}, debug: {default: false},
horizontalPosition: {default: 'middleleft', oneOf: ['left', 'middleleft', 'middleright', 'right']}, horizontalPosition: {default: 'middleleft', oneOf: ['left', 'middleleft', 'middleright', 'right']},
size: {default: 0.40}, size: {default: 0.40},
speed: {default: 1.0}, speed: {default: 8.0},
type: {default: 'arrow', oneOf: ['arrow', 'dot', 'mine']}, type: {default: 'arrow', oneOf: ['arrow', 'dot', 'mine']},
verticalPosition: {default: 'middle', oneOf: ['bottom', 'middle', 'top']}, verticalPosition: {default: 'middle', oneOf: ['bottom', 'middle', 'top']},
warmupPosition: {default: 0}, warmupPosition: {default: 0},
@@ -756,14 +757,14 @@ AFRAME.registerComponent('beat', {
} }
rightCutNormal.copy(this.rightCutPlane.normal) rightCutNormal.copy(this.rightCutPlane.normal)
.multiplyScalar((this.data.speed / 4) * (timeDelta / 500)); .multiplyScalar(DESTROYED_SPEED * (timeDelta / 500));
rightCutNormal.y = 0; // Y handled by gravity. rightCutNormal.y = 0; // Y handled by gravity.
this.partRightEl.object3D.position.add(rightCutNormal); this.partRightEl.object3D.position.add(rightCutNormal);
this.partRightEl.object3D.setRotationFromAxisAngle(this.rotationAxis, rightRotation); this.partRightEl.object3D.setRotationFromAxisAngle(this.rotationAxis, rightRotation);
rightRotation = rightRotation >= 2 * Math.PI ? 0 : rightRotation + rotationStep; rightRotation = rightRotation >= 2 * Math.PI ? 0 : rightRotation + rotationStep;
leftCutNormal.copy(this.leftCutPlane.normal) leftCutNormal.copy(this.leftCutPlane.normal)
.multiplyScalar((this.data.speed / 4) * (timeDelta / 500)); .multiplyScalar(DESTROYED_SPEED * (timeDelta / 500));
leftCutNormal.y = 0; // Y handled by gravity. leftCutNormal.y = 0; // Y handled by gravity.
this.partLeftEl.object3D.position.add(leftCutNormal); this.partLeftEl.object3D.position.add(leftCutNormal);
this.partLeftEl.object3D.setRotationFromAxisAngle(this.rotationAxis, leftRotation); this.partLeftEl.object3D.setRotationFromAxisAngle(this.rotationAxis, leftRotation);