Skip to content

Commit

Permalink
to fix Nightly issue with null stageParameters,
Browse files Browse the repository at this point in the history
add camera userHeight if null stageParameters;
to keep tests working, only getVRDisplays when VR entered.

(NOTE: tried to move getVRDisplays from system into component where dolly is,
but got weird effect where right hand was applying offset but right hand wasn't,
so there may still be some strange race condition somewhere)
  • Loading branch information
machenmusik committed Mar 21, 2017
1 parent 6059bd0 commit 53d72ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 10 additions & 3 deletions src/components/tracked-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@ module.exports.Component = registerComponent('tracked-controls', {
dolly.updateMatrix();

// Apply transforms.
if (vrDisplay && vrDisplay.stageParameters) {
standingMatrix.fromArray(vrDisplay.stageParameters.sittingToStandingTransform);
dolly.applyMatrix(standingMatrix);
if (vrDisplay) {
if (vrDisplay.stageParameters) {
standingMatrix.fromArray(vrDisplay.stageParameters.sittingToStandingTransform);
dolly.applyMatrix(standingMatrix);
} else {
// Apply default camera height
var userHeight = this.el.sceneEl.camera.el.components.camera.data.userHeight;
dolly.position.y += userHeight;
dolly.updateMatrix();
}
}

// Decompose.
Expand Down
13 changes: 7 additions & 6 deletions src/systems/tracked-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ module.exports.System = registerSystem('tracked-controls', {
this.lastControllersUpdate = 0;
// Throttle the (renamed) tick handler to minimum 10ms interval.
this.tick = utils.throttle(this.throttledTick, 10, this);
if (!navigator.getVRDisplays) { return; }
navigator.getVRDisplays().then(function (displays) {
if (displays.length > 0) {
self.vrDisplay = displays[0];
}
});
if (navigator.getVRDisplays) {
this.sceneEl.addEventListener('enter-vr', function () {
navigator.getVRDisplays().then(function (displays) {
if (displays.length) { self.vrDisplay = displays[0]; }
});
});
}
},

updateControllerList: function () {
Expand Down

0 comments on commit 53d72ca

Please sign in to comment.