From 6226bbfc504518569f097a7020c233cefffac856 Mon Sep 17 00:00:00 2001 From: Diego Marcos Date: Mon, 29 Oct 2018 15:59:26 -0700 Subject: [PATCH] Measuting strokeAngle no longer necesssary with new score system --- src/components/saber-controls.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/components/saber-controls.js b/src/components/saber-controls.js index 2ec4999..c5378d7 100644 --- a/src/components/saber-controls.js +++ b/src/components/saber-controls.js @@ -26,7 +26,6 @@ AFRAME.registerComponent('saber-controls', { this.bladeTipPreviousPosition = new THREE.Vector3(); this.saberPosition = new THREE.Vector3(); this.swinging = false; - this.strokeAngle = 0; this.strokeCount = 0; this.distanceSamples = []; this.accumulatedDistance = 0; @@ -88,17 +87,10 @@ AFRAME.registerComponent('saber-controls', { // Filter out saber movements that are too slow. Too slow or small angle is considered wrong hit. // Cap stroke to 180 degrees. - if (this.accumulatedDistance > this.data.strokeMinSpeed && this.strokeAngle < 180) { - // Calculate angle covered by the saber in one frame and accumulate. - // Trig: Triangle formed by the saber and the linear distance covered by its tip - // Arcsin((distanceCoveredByTip / 2.0) / Length of the blade) * 2 - // This is not exact becasuse assumes wrist as pivot point, ignoring elbow and shoulder. - // It seems to work well in practice but might need tweaking. - this.strokeAngle += ((Math.asin(((distance / 1000000) / 2.0) / 0.9)) / - (2 * Math.PI)) * 360 * 2; + if (this.accumulatedDistance > this.data.strokeMinSpeed) { // Saber has to move more than strokeMinAngle to consider a swing. // This filters out unintentional swings. - if (!this.swinging && this.strokeAngle > data.strokeMinAngle) { + if (!this.swinging) { startSpeed = this.accumulatedDistance; this.swinging = true; this.maxAnglePlaneX = 0; @@ -114,7 +106,6 @@ AFRAME.registerComponent('saber-controls', { // console.log("MaxAngle " + this.maxAnglePlaneX * 180 / Math.PI); this.el.emit('strokeend'); this.swinging = false; - this.strokeAngle = 0; this.accumulatedDistance = 0; for (let i = 0; i < this.distanceSamples.length; i++) { this.distanceSamples[i] = 0; } }