Skip to content

Commit

Permalink
fix(ViewService): Workaround for webvr polyfill behavior when using m…
Browse files Browse the repository at this point in the history
…ultiple layers

Changed _webvrRequestPresentHMD to pass only a single layer to vrDisplay.requestPresent
  • Loading branch information
speigg committed Apr 27, 2017
1 parent 84661e8 commit 7044f57
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
7 changes: 5 additions & 2 deletions dist/argon.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -18086,6 +18086,7 @@ $__System.register('1', ['2', '3', '3d', '4', '9', '10', 'a', '1d', '35', '2d',
* Automatically publish the viewport of the element during PresentationMode.EMBEDDED
*/
this.autoPublishEmbeddedMode = true;
this._layers = [];
this._subviews = [];
this._subviewPose = [];
this._subviewFrustum = [];
Expand Down Expand Up @@ -18318,7 +18319,7 @@ $__System.register('1', ['2', '3', '3d', '4', '9', '10', 'a', '1d', '35', '2d',
ViewService.prototype._updateViewport = function (viewport) {
var _this = this;
var viewportJSON = JSON.stringify(viewport);
if (this.layers && this.autoStyleLayerElements) {
if (this._layers.length && this.autoStyleLayerElements) {
requestAnimationFrame(function () {
var zIndex = -_this._layers.length;
for (var _i = 0, _a = _this._layers; _i < _a.length; _i++) {
Expand Down Expand Up @@ -18914,7 +18915,9 @@ $__System.register('1', ['2', '3', '3d', '4', '9', '10', 'a', '1d', '35', '2d',
DeviceService.prototype._webvrRequestPresentHMD = function () {
if (this._vrDisplay) {
var element = this.viewService.element;
var layers = this.viewService.layers || [{ source: element.querySelector('canvas') || element.lastElementChild }];
var layers = [{
source: this.viewService.layers[0] && this.viewService.layers[0].source || element.querySelector('canvas') || element.lastElementChild
}];
return this._vrDisplay.requestPresent(layers).catch(function (e) {
throw e;
});
Expand Down
7 changes: 5 additions & 2 deletions dist/argon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23666,6 +23666,7 @@ $__System.register('1', ['2', '3', '3d', '4', '9', '10', 'a', '1d', '35', '2d',
* Automatically publish the viewport of the element during PresentationMode.EMBEDDED
*/
this.autoPublishEmbeddedMode = true;
this._layers = [];
this._subviews = [];
this._subviewPose = [];
this._subviewFrustum = [];
Expand Down Expand Up @@ -23898,7 +23899,7 @@ $__System.register('1', ['2', '3', '3d', '4', '9', '10', 'a', '1d', '35', '2d',
ViewService.prototype._updateViewport = function (viewport) {
var _this = this;
var viewportJSON = JSON.stringify(viewport);
if (this.layers && this.autoStyleLayerElements) {
if (this._layers.length && this.autoStyleLayerElements) {
requestAnimationFrame(function () {
var zIndex = -_this._layers.length;
for (var _i = 0, _a = _this._layers; _i < _a.length; _i++) {
Expand Down Expand Up @@ -24494,7 +24495,9 @@ $__System.register('1', ['2', '3', '3d', '4', '9', '10', 'a', '1d', '35', '2d',
DeviceService.prototype._webvrRequestPresentHMD = function () {
if (this._vrDisplay) {
var element = this.viewService.element;
var layers = this.viewService.layers || [{ source: element.querySelector('canvas') || element.lastElementChild }];
var layers = [{
source: this.viewService.layers[0] && this.viewService.layers[0].source || element.querySelector('canvas') || element.lastElementChild
}];
return this._vrDisplay.requestPresent(layers).catch(function (e) {
throw e;
});
Expand Down
4 changes: 2 additions & 2 deletions dist/argon.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,12 @@ export class DeviceService {
if (this._vrDisplay) {
const element = this.viewService.element;
const layers:VRLayer&{}[] =
this.viewService.layers ||
[{source:element.querySelector('canvas') || <HTMLCanvasElement>element.lastElementChild}];
[{
source:
this.viewService.layers[0] && this.viewService.layers[0].source ||
element.querySelector('canvas') ||
<HTMLCanvasElement>element.lastElementChild
}];
return this._vrDisplay.requestPresent(layers).catch((e)=>{
throw e;
});
Expand Down
6 changes: 3 additions & 3 deletions src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class ViewService {
});
}

private _layers:{source:HTMLElement}[]
private _layers:{source:HTMLElement}[] = [];

public setLayers(layers:{source:HTMLElement}[]) {
if (this._layers) {
Expand Down Expand Up @@ -337,8 +337,8 @@ export class ViewService {
// Updates the element, if necessary, and raise a view change event
private _updateViewport(viewport:CanvasViewport) {
const viewportJSON = JSON.stringify(viewport);

if (this.layers && this.autoStyleLayerElements) {
if (this._layers.length && this.autoStyleLayerElements) {
requestAnimationFrame(() => {
let zIndex = -this._layers.length;
for (const layer of this._layers) {
Expand Down

0 comments on commit 7044f57

Please sign in to comment.