From 8fdd9238cfe83d0424bd2864bda40e0a1aab4425 Mon Sep 17 00:00:00 2001
From: joni <johnfshaughnessy@gmail.com>
Date: Tue, 21 Nov 2017 14:44:30 -0800
Subject: [PATCH] Remove unnecessary code from character controller.

---
 src/components/character-controller.js | 108 +------------------------
 1 file changed, 3 insertions(+), 105 deletions(-)

diff --git a/src/components/character-controller.js b/src/components/character-controller.js
index 4d73bb9d9..b92077fc9 100644
--- a/src/components/character-controller.js
+++ b/src/components/character-controller.js
@@ -8,33 +8,19 @@ AFRAME.registerComponent("character-controller", {
     easing: { default: 10 },
     pivot: { type: "selector" },
     snapRotationRadian: { default: THREE.Math.DEG2RAD * 45 },
-    wasdSpeed: { default: 0.8 },
     rotationSpeed: { default: -3 }
   },
 
   init: function() {
     this.velocity = new THREE.Vector3(0, 0, 0);
     this.accelerationInput = new THREE.Vector3(0, 0, 0);
-    this.onStopMoving = this.onStopMoving.bind(this);
-    this.onMove = this.onMove.bind(this);
-    this.onTranslateX = this.onTranslateX.bind(this);
-    this.onTranslateY = this.onTranslateY.bind(this);
-    this.onTranslateZ = this.onTranslateZ.bind(this);
-    this.onMoveForward = this.onMoveForward.bind(this);
-    this.onDontMoveForward = this.onDontMoveForward.bind(this);
-    this.onMoveBackward = this.onMoveBackward.bind(this);
-    this.onDontMoveBackward = this.onDontMoveBackward.bind(this);
-    this.onMoveLeft = this.onMoveLeft.bind(this);
-    this.onDontMoveLeft = this.onDontMoveLeft.bind(this);
-    this.onMoveRight = this.onMoveRight.bind(this);
-    this.onDontMoveRight = this.onDontMoveRight.bind(this);
     this.boost = 1.0;
-    this.onBoost = this.onBoost.bind(this);
-
     this.pendingSnapRotationMatrix = new THREE.Matrix4();
+    this.angularVelocity = 0; // Scalar value because we only allow rotation around Y
+    this.onMove = this.onMove.bind(this);
+    this.onBoost = this.onBoost.bind(this);
     this.onSnapRotateLeft = this.onSnapRotateLeft.bind(this);
     this.onSnapRotateRight = this.onSnapRotateRight.bind(this);
-    this.angularVelocity = 0; // Scalar value because we only allow rotation around Y
     this.onRotateY = this.onRotateY.bind(this);
   },
 
@@ -50,25 +36,6 @@ AFRAME.registerComponent("character-controller", {
   play: function() {
     const eventSrc = this.el.sceneEl;
     eventSrc.addEventListener("move", this.onMove);
-    eventSrc.addEventListener("stop_moving", this.onStopMoving);
-    eventSrc.addEventListener("translateX", this.onTranslateX);
-    eventSrc.addEventListener("translateY", this.onTranslateY);
-    eventSrc.addEventListener("translateZ", this.onTranslateZ);
-    eventSrc.addEventListener("action_move_forward", this.onMoveForward);
-    eventSrc.addEventListener(
-      "action_dont_move_forward",
-      this.onDontMoveForward
-    );
-    eventSrc.addEventListener("action_move_backward", this.onMoveBackward);
-    eventSrc.addEventListener(
-      "action_dont_move_backward",
-      this.onDontMoveBackward
-    );
-    eventSrc.addEventListener("action_move_left", this.onMoveLeft);
-    eventSrc.addEventListener("action_dont_move_left", this.onDontMoveLeft);
-    eventSrc.addEventListener("action_move_right", this.onMoveRight);
-    eventSrc.addEventListener("action_dont_move_right", this.onDontMoveRight);
-
     eventSrc.addEventListener("rotateY", this.onRotateY);
     eventSrc.addEventListener("action_snap_rotate_left", this.onSnapRotateLeft);
     eventSrc.addEventListener(
@@ -81,27 +48,6 @@ AFRAME.registerComponent("character-controller", {
   pause: function() {
     const eventSrc = this.el.sceneEl;
     eventSrc.removeEventListener("move", this.onMove);
-    eventSrc.removeEventListener("stop_moving", this.onStopMoving);
-    eventSrc.removeEventListener("translateX", this.onTranslateX);
-    eventSrc.removeEventListener("translateY", this.onTranslateY);
-    eventSrc.removeEventListener("translateZ", this.onTranslateZ);
-    eventSrc.removeEventListener("action_move_forward", this.onMoveForward);
-    eventSrc.removeEventListener(
-      "action_dont_move_forward",
-      this.onDontMoveForward
-    );
-    eventSrc.removeEventListener("action_move_backward", this.onMoveBackward);
-    eventSrc.removeEventListener(
-      "action_dont_move_backward",
-      this.onDontMoveBackward
-    );
-    eventSrc.removeEventListener("action_move_left", this.onMoveLeft);
-    eventSrc.removeEventListener("action_dont_move_left", this.onDontMoveLeft);
-    eventSrc.removeEventListener("action_move_right", this.onMoveRight);
-    eventSrc.removeEventListener(
-      "action_dont_move_right",
-      this.onDontMoveRight
-    );
     eventSrc.removeEventListener("rotateY", this.onRotateY);
     eventSrc.removeEventListener(
       "action_snap_rotate_left",
@@ -118,54 +64,6 @@ AFRAME.registerComponent("character-controller", {
     this.accelerationInput.set(axes[0], 0, axes[1]);
   },
 
-  onStopMoving: function(event) {
-    this.accelerationInput.set(0, 0, 0);
-  },
-
-  onTranslateX: function(event) {
-    this.accelerationInput.setX(event.detail.value);
-  },
-
-  onTranslateY: function(event) {
-    this.accelerationInput.setY(event.detail.value);
-  },
-
-  onTranslateZ: function(event) {
-    this.accelerationInput.setZ(event.detail.value);
-  },
-
-  onMoveForward: function(event) {
-    this.accelerationInput.z = this.data.wasdSpeed;
-  },
-
-  onDontMoveForward: function(event) {
-    this.accelerationInput.z = 0;
-  },
-
-  onMoveBackward: function(event) {
-    this.accelerationInput.z = -this.data.wasdSpeed;
-  },
-
-  onDontMoveBackward: function(event) {
-    this.accelerationInput.z = 0;
-  },
-
-  onMoveLeft: function(event) {
-    this.accelerationInput.x = -this.data.wasdSpeed;
-  },
-
-  onDontMoveLeft: function(event) {
-    this.accelerationInput.x = 0;
-  },
-
-  onMoveRight: function(event) {
-    this.accelerationInput.x = this.data.wasdSpeed;
-  },
-
-  onDontMoveRight: function(event) {
-    this.accelerationInput.x = 0;
-  },
-
   onRotateY: function(event) {
     this.angularVelocity = event.detail.value;
   },
-- 
GitLab