XRDepthInformation.rawValueToMeters
The read-only rawValueToMeters
property of the XRDepthInformation
interface contains the scale factor by which the raw depth values must be multiplied in order to get the depths in meters.
For CPU depth information, see also the XRCPUDepthInformation.getDepthInMeters()
method.
Value
A number.
Examples
Use XRFrame.getDepthInformation()
(CPU) or XRWebGLBinding.getDepthInformation()
(WebGL) to obtain depth information. The returned objects will contain the rawValueToMeters
scale factor, which can be used for further calculations.
For CPU depth information and a buffer that has "luminance-alpha" format:
const uint16 = new Uint16Array(depthInfo.data); const index = column + row * depthInfo.width; const depthInMeters = uint16[index] * depthInfo.rawValueToMeters;
(Use Float32Array
for a "float32" data format.)
Note that the depth in meters is in depth-buffer coordinates. Additional steps are needed to convert them to normalized view coordinates, or the XRCPUDepthInformation.getDepthInMeters()
method can be used.
Specifications
Specification |
---|
WebXR Depth Sensing Module (WebXR Depth Sensing) # dom-xrdepthinformation-rawvaluetometers |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
rawValueToMeters |
90 |
90 |
No |
No |
76 |
No |
No |
90 |
No |
No |
No |
No |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XRDepthInformation/rawValueToMeters