Skip to content
Snippets Groups Projects
Commit 121fafdb authored by Marshall Quander's avatar Marshall Quander
Browse files

Don't use A-Frame PolyfillControls helper

The PolyfillControls helper has some breakage where it doesn't
always use the polyfilled VRFrameData class. Also, we don't even
want the pose data to be applied to an Object3D, so it seems a
little bit silly to use.
parent 4d5559d2
No related branches found
No related tags found
No related merge requests found
const PolyfillControls = AFRAME.utils.device.PolyfillControls;
const TWOPI = Math.PI * 2; const TWOPI = Math.PI * 2;
class CircularBuffer { class CircularBuffer {
...@@ -50,24 +49,23 @@ AFRAME.registerComponent("look-on-mobile", { ...@@ -50,24 +49,23 @@ AFRAME.registerComponent("look-on-mobile", {
init() { init() {
this.hmdEuler = new THREE.Euler(); this.hmdEuler = new THREE.Euler();
this.hmdQuaternion = new THREE.Quaternion();
this.prevX = this.hmdEuler.x; this.prevX = this.hmdEuler.x;
this.prevY = this.hmdEuler.y; this.prevY = this.hmdEuler.y;
this.pendingLookX = 0; this.pendingLookX = 0;
this.onRotateX = this.onRotateX.bind(this); this.onRotateX = this.onRotateX.bind(this);
this.dXBuffer = new CircularBuffer(6); this.dXBuffer = new CircularBuffer(6);
this.dYBuffer = new CircularBuffer(6); this.dYBuffer = new CircularBuffer(6);
this.vrDisplay = window.webvrpolyfill.getPolyfillDisplays()[0];
this.frameData = new window.webvrpolyfill.constructor.VRFrameData();
}, },
play() { play() {
this.el.addEventListener("rotateX", this.onRotateX); this.el.addEventListener("rotateX", this.onRotateX);
this.polyfillObject = new THREE.Object3D();
this.polyfillControls = new PolyfillControls(this.polyfillObject);
}, },
pause() { pause() {
this.el.removeEventListener("rotateX", this.onRotateX); this.el.removeEventListener("rotateX", this.onRotateX);
this.polyfillControls = null;
this.polyfillObject = null;
}, },
update() { update() {
...@@ -81,8 +79,11 @@ AFRAME.registerComponent("look-on-mobile", { ...@@ -81,8 +79,11 @@ AFRAME.registerComponent("look-on-mobile", {
tick() { tick() {
const hmdEuler = this.hmdEuler; const hmdEuler = this.hmdEuler;
const { horizontalLookSpeedRatio, verticalLookSpeedRatio } = this.data; const { horizontalLookSpeedRatio, verticalLookSpeedRatio } = this.data;
this.polyfillControls.update(); this.vrDisplay.getFrameData(this.frameData);
hmdEuler.setFromQuaternion(this.polyfillObject.quaternion, "YXZ"); if (this.frameData.pose.orientation !== null) {
this.hmdQuaternion.fromArray(this.frameData.pose.orientation);
hmdEuler.setFromQuaternion(this.hmdQuaternion, "YXZ");
}
const dX = THREE.Math.RAD2DEG * difference(hmdEuler.x, this.prevX); const dX = THREE.Math.RAD2DEG * difference(hmdEuler.x, this.prevX);
const dY = THREE.Math.RAD2DEG * difference(hmdEuler.y, this.prevY); const dY = THREE.Math.RAD2DEG * difference(hmdEuler.y, this.prevY);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment