Skip to content

Commit

Permalink
Add XREnvironmentBlendMode, configurable by PolyfilledXRDevice. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsantell committed Jul 17, 2018
1 parent ae61c1f commit 79724f4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/api/XRSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ export default class XRSession extends EventTarget {
*/
set depthFar(value) { this[PRIVATE].polyfill.depthFar = value; }

/**
* @return {XREnvironmentBlendMode}
*/
get environmentBlendMode() {
return this[PRIVATE].polyfill.environmentBlendMode || 'opaque';
}

/**
* @return {XRLayer}
*/
Expand Down
5 changes: 5 additions & 0 deletions src/devices/PolyfilledXRDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export default class PolyfilledXRDevice extends EventTarget {
this.onWindowResize = this.onWindowResize.bind(this);

this.global.window.addEventListener('resize', this.onWindowResize);

// Value is used for `XRSession.prototype.environmentBlendMode`
// and should be one of XREnvironmentBlendMode types: 'opaque', 'additive',
// or 'alpha-blend'.
this.environmentBlendMode = 'opaque';
}

/**
Expand Down
14 changes: 14 additions & 0 deletions test/api/test-xr-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ describe('API - XRSession', () => {
assert.equal(session.immersive, false);
});

it('has `environmentBlendMode` property from polyfill', async function () {
const global = new MockGlobalVR();
const polyfill = new WebVRDevice(global, new MockVRDisplay(global));
const device = new XRDevice(polyfill);
const session = await device.requestSession({ immersive: true });

polyfill.environmentBlendMode = null;
// 'opaque' is default
assert.equal(session.environmentBlendMode, 'opaque');

polyfill.environmentBlendMode = 'alpha-blend';
assert.equal(session.environmentBlendMode, 'alpha-blend');
});

it('has `outputContext` property set to session options', async function () {
let options = { immersive: true, outputContext: new XRPresentationContext() };
let device = createXRDevice();
Expand Down

0 comments on commit 79724f4

Please sign in to comment.