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

XRFrame.getViewerPose() always returns the same XRViewerPose instance #97

Closed takahirox closed 4 years ago

takahirox commented 4 years ago

.getViewerPose() of a XRFrame instance always returns the same XRViewerPose instance.

getViewerPose(space) {
  this[PRIVATE].viewerPose._updateFromReferenceSpace(space);
  return this[PRIVATE].viewerPose;
}

https://github.com/immersive-web/webxr-polyfill/blob/master/src/api/XRFrame.js#L55-L58

So if I get two or more viewer poses of difference reference spaces in an animation frame, the returned viewer poses instances are identical and overridden by the last .getViewerPose() call.

const viewerSpaceViewerPose = frame.getViewrPose(viewerReferenceSpace);
const localSpaceViewerPose = frame.getViewerPose(localReferenceSpace);
// viewerSpaceViewerPose === localSpaceViewerPose is true

Is this design intentional? (Sorry if I'm missing something in the spec.)

If not I think .getViewerPose() should create a new XRViewerPose instance for each call.

lojjic commented 4 years ago

Looks like PR #122 takes care of this.

toji commented 4 years ago

Yes, it will.

takahirox commented 4 years ago

Closing in favor of #122, thanks!