immersive-web / webxr-polyfill

Use the WebXR Device API today, providing fallbacks to native WebVR 1.1 and Cardboard
Apache License 2.0
381 stars 84 forks source link

Fix XRSession.updateRenderState() bug #110

Closed takahirox closed 4 years ago

takahirox commented 4 years ago

XRSession.updateRenderState() has a bug that properties which are not passed via .updateRenderState() will be overridden with the default values.

For example if you call session.updateRenderState({ inlineVerticalFieldOfView: Math.PI }) where session.renderState is already initialized with certain values, session.renderState.depthNear/depthFar/baseLayer will be overridden with the default values 0.1/1000.0/null in next frame

The root issue is the following line in XRSession.updateRenderState().

this[PRIVATE].pendingRenderState = Object.assign({}, this[PRIVATE].activeRenderState);

.acriveRenderState properties are hidden behind private .activeRenderState[PRIVATE] and getter methods so they can't be copied with Object.assign({}, this[PRIVATE].activeRenderState).

This PR fixes it.

/CC @lojjic

lojjic commented 4 years ago

Ah yes, that makes sense, good catch.

toji commented 4 years ago

Good catch indeed. Thanks!