webXRCamera.minZ & maxZ to set xrSession depthNear / Far

Was going through some of the webXR classes on the repo, and not directly reading the standard, but something more tutorial.

Seems the initial webXR depth precision is 0.1 meters to 1000 meters. Seem adjusting the depthFar down to what required might be a good idea. Keeping minZ / maxZ in sync with depthNear / depthFar seems also a good idea.

This would probably require passing the session to the camera constructor, and getter / setters for minZ / maxZ. A page I was looking at to control depth did it like:

// This reduces the depth range of the scene to [1, 100] meters.
// The change will take effect on the next XRSession requestAnimationFrame callback.
xrSession.updateRenderState({
  depthNear: 1.0,
  depthFar: 100.0,
});

Not really a big deal, just something I noticed.

pinging @trevordev

@JCPalmer thanks for the heads up, I added this to WebXR · Issue #3899 · BabylonJS/Babylon.js · GitHub so it doesnt get lost when I sync again with the latest spec in the future.

2 Likes

Thanks. BTW this kind of brings home the fact that if you wish to do anything which you might want to run in WebXR, better to do all dev work in Meters. Also glad to see a little better at handling of units in Blender 2.80, (and the default unit is meters).

For me, all work geometry will be scaled in meters from now on. For most people, if they even noticed minZ / maxZ, just thought it was some abstract number & you could make a mesh of any size as long as you were consistent. That 2 by 2 by 2 cube is really the size of a closet. This API changes all that. The default maxZ in Camera.ts is 10 kilometers. Kind of big.

In any doc’s, it would might be a good idea to mention this.

2 Likes