Skip to content

Commit 9e9e9da

Browse files
authored
[XR] Implementation of WebXR Depth Sensing Feature (reopen of #13159) (#13563)
* add: definitions of type and interfaces of depth sensing feature * add: native XRFrame method * add: WebXR Depth Sensing Feature class implementation * Add implementations exposing DepthInformation fields and methods * Remove depth information observers * Add an implementation of generate RawTexture from cpu depth information * Add and fix implementations of texture generation * Fix implementations of texture generation of cpu mode * Add process depth information method * Add documentation comments and fix naming * Fix import paths * add: latest depth buffer field * fix: change Texture format to RGBA and create depth texture * add: sandbox impl of luminance-alpha depth image texture * Change Texture format from LuminaceAlpha to RTexture * Fix cpu depth image processings * Change image processing implementations * Rename _latestDepthImageTexture to _cachedDepthImageTexture make a difference between public latest data and provate cached data * Changed depth texture pixel algorithm * small refactor of obtaining rawValueToMeters * Add getDepthInMeters observer to notify active one * Fix comment of webxr.d.ts * Fix formatting errors * Change null union types to Nullable generics * changed to returning InternalTexture instead of WebGLTexture * Define original depth types to avoid using XR native type * Create individual private fields of public fields * add @SInCE to docs comment * detach if depth usage is unknown * throw an error in nativeXRFrame depth method until the functionality is implemented * correct some docs comments
1 parent 34b5180 commit 9e9e9da

File tree

5 files changed

+422
-0
lines changed

5 files changed

+422
-0
lines changed

packages/dev/core/src/LibDeclarations/webxr.d.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,3 +1145,56 @@ interface XRLightProbe extends EventTarget {
11451145
* END: WebXR DOM Overlays Module
11461146
* https://immersive-web.github.io/dom-overlays/
11471147
*/
1148+
1149+
/**
1150+
* BEGIN: WebXR Depth Sensing Moudle
1151+
* https://www.w3.org/TR/webxr-depth-sensing-1/
1152+
*/
1153+
1154+
type XRDepthUsage = "cpu-optimized" | "gpu-optimized";
1155+
type XRDepthDataFormat = "luminance-alpha" | "float32";
1156+
1157+
type XRDepthStateInit = {
1158+
readonly usagePreference: XRDepthUsage[];
1159+
readonly dataFormatPreference: XRDepthDataFormat[];
1160+
};
1161+
1162+
interface XRSessionInit {
1163+
depthSensing?: XRDepthStateInit;
1164+
}
1165+
1166+
interface XRSession {
1167+
readonly depthUsage: XRDepthUsage;
1168+
readonly depthDataFormat: XRDepthDataFormat;
1169+
}
1170+
1171+
interface XRDepthInformation {
1172+
readonly width: number;
1173+
readonly height: number;
1174+
1175+
readonly normDepthBufferFromNormView: XRRigidTransform;
1176+
readonly rawValueToMeters: number;
1177+
}
1178+
1179+
interface XRCPUDepthInformation extends XRDepthInformation {
1180+
readonly data: ArrayBuffer;
1181+
1182+
getDepthInMeters(x: number, y: number): number;
1183+
}
1184+
1185+
interface XRFrame {
1186+
getDepthInformation(view: XRView): ?XRCPUDepthInformation;
1187+
}
1188+
1189+
interface XRWebGLDepthInformation extends XRDepthInformation {
1190+
readonly texture: WebGLTexture;
1191+
}
1192+
1193+
interface XRWebGLBinding {
1194+
getDepthInformation(view: XRView): ?XRWebGLDepthInformation;
1195+
}
1196+
1197+
/**
1198+
* END: WebXR Depth Sensing Moudle
1199+
* https://www.w3.org/TR/webxr-depth-sensing-1/
1200+
*/

0 commit comments

Comments
 (0)