From 4c4d20dc5858a149437a6852cf0300f5ff2125d2 Mon Sep 17 00:00:00 2001 From: joni <johnfshaughnessy@gmail.com> Date: Fri, 1 Jun 2018 19:44:12 -0700 Subject: [PATCH] Remove function since it's only called once. --- src/components/cursor-controller.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/cursor-controller.js b/src/components/cursor-controller.js index 7713b15a8..17ba18290 100644 --- a/src/components/cursor-controller.js +++ b/src/components/cursor-controller.js @@ -40,10 +40,6 @@ AFRAME.registerComponent("cursor-controller", { this.data.cursor.addEventListener("loaded", this._handleCursorLoaded); }, - remove: function() { - this.data.cursor.removeEventListener("loaded", this._handleCursorLoaded); - }, - enable: function() { this.enabled = true; }, @@ -70,7 +66,8 @@ AFRAME.registerComponent("cursor-controller", { } this.el.setAttribute("raycaster", { origin: this.origin, direction: this.direction }); - if (this._isGrabbing()) { + const isGrabbing = this.data.cursor.components["super-hands"].state.has("grab-start"); + if (isGrabbing) { const distance = Math.min( this.data.maxDistance, Math.max(this.data.minDistance, this.currentDistance - this.currentDistanceMod) @@ -114,10 +111,6 @@ AFRAME.registerComponent("cursor-controller", { } }, - _isGrabbing() { - return this.data.cursor.components["super-hands"].state.has("grab-start"); - }, - _isTargetOfType: function(mask) { return (this.currentTargetType & mask) === this.currentTargetType; }, @@ -175,5 +168,9 @@ AFRAME.registerComponent("cursor-controller", { _handleCursorLoaded: function() { this.data.cursor.object3DMap.mesh.renderOrder = window.APP.RENDER_ORDER.CURSOR; this.data.cursor.removeEventListener("loaded", this._handleCursorLoaded); + }, + + remove: function() { + this.data.cursor.removeEventListener("loaded", this._handleCursorLoaded); } }); -- GitLab