immersive-web / proposals

Initial proposals for future Immersive Web work (see README)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Have support for projection matrix per frame

rcabanier opened this issue · comments

On our platform the projection matrix can change over time but the current spec implies that it is a constant per scene.

Maybe we can extend XRDevicePose by adding a method called 'getProjectionMatrix' that takes an XREye and get rid of XRView.

I apologize that the spec/explainer may be a bit fuzzy on this point (and it looks like you're looking at a slightly older version of the docs), but the API actually does explicitly enable a different set of projection matrices per-frame.

Looking at a partial snippet of the IDL:

interface XRFrame {
  XRViewerPose? getViewerPose(optional XRFrameOfReference frameOfReference);
};

interface XRViewerPose {
  readonly attribute Float32Array poseMatrix;
  readonly attribute FrozenArray<XRView> views;
};

interface XRView {
  readonly attribute XREye eye;
  readonly attribute Float32Array projectionMatrix;
  readonly attribute Float32Array viewMatrix;
};

The above works out like so: You get a new XRFrame object every frame, and from it you query the current tracking data (the XRViewerPose, which was recently renamed from the XRDevicePose you mention.) The viewer pose contains an array of XRViews, each of which describe a view and projection matrix. This chain means that the view and projection matrices may be (and in fact are expected to be) different for each XRFrame. The exact IDL layout is a bit different if you look back a few revisions, but in all cases the projection matrix is retrieved from the XRFrame or one of it's attributes/methods.

So your use case should be well covered! (This is something that we've been handling for a while in various forms, primarily to support HoloLens and zSpace-style hardware.)

Where is the latest spec posted? Do I have to build it?
https://immersive-web.github.io/webxr/ is pointing to an older revision.

Oh, wow. Good catch! Our build step must be broken. I'll look into it. In the meantime the explainer text is up-to-date. https://github.com/immersive-web/webxr/blob/master/explainer.md

Okay, fixed it. https://immersive-web.github.io/webxr/ is now pointing at the most recent build of the bikeshed source and will automatically stay up-to-date moving forward. Thanks for alerting me to that.