From 66713f2c724753bfb1d36b1dd092968128b97d8b Mon Sep 17 00:00:00 2001 From: johnshaughnessy <johnfshaughnessy@gmail.com> Date: Tue, 13 Nov 2018 17:15:30 -0800 Subject: [PATCH] Get rid of querySelector running every frame --- src/systems/userinput/devices/oculus-touch-controller.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/systems/userinput/devices/oculus-touch-controller.js b/src/systems/userinput/devices/oculus-touch-controller.js index 7ca3e6d2e..207d5af22 100644 --- a/src/systems/userinput/devices/oculus-touch-controller.js +++ b/src/systems/userinput/devices/oculus-touch-controller.js @@ -66,10 +66,10 @@ export class OculusTouchControllerDevice { frame[this.path.axis(axis.name)] = frame[paths.device.gamepad(this.gamepad.index).axis(axis.axisId)]; }); - const rayObject = document.querySelector(this.selector).object3D; - rayObject.updateMatrixWorld(); - this.rayObjectRotation.setFromRotationMatrix(rayObject.matrixWorld); - this.pose.position.setFromMatrixPosition(rayObject.matrixWorld); + this.rayObject = this.rayObject || document.querySelector(this.selector).object3D; + this.rayObject.updateMatrixWorld(); + this.rayObjectRotation.setFromRotationMatrix(this.rayObject.matrixWorld); + this.pose.position.setFromMatrixPosition(this.rayObject.matrixWorld); this.pose.direction.set(0, 0, -1).applyQuaternion(this.rayObjectRotation); this.pose.fromOriginAndDirection(this.pose.position, this.pose.direction); frame[this.path.pose] = this.pose; -- GitLab