diff --git a/src/api/XRSession.js b/src/api/XRSession.js index f585175..ecf81d0 100644 --- a/src/api/XRSession.js +++ b/src/api/XRSession.js @@ -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} */ diff --git a/src/devices/PolyfilledXRDevice.js b/src/devices/PolyfilledXRDevice.js index bd7e05a..840bd58 100644 --- a/src/devices/PolyfilledXRDevice.js +++ b/src/devices/PolyfilledXRDevice.js @@ -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'; } /** diff --git a/test/api/test-xr-session.js b/test/api/test-xr-session.js index 35e81c3..f71f496 100644 --- a/test/api/test-xr-session.js +++ b/test/api/test-xr-session.js @@ -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();