1
0
Fork 0
firefox/testing/web-platform/tests/webxr/depth-sensing/matchDepthViewValues.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

39 lines
1.6 KiB
JavaScript

'use strict';
// import * as XrConstants from 'resources/webxr_test_constants.js'
// import * as XrAsserts from 'resources/webxr_test_asserts.js'
// TODO: Expand the WebXrTestApi to specify a viewGeometry that this can validate
// as well.
const depthViewGeometryTestGenerator = (matchDepthView) => {
return (session, controller, t, sessionObjects) => {
return session.requestReferenceSpace('viewer').then((viewerSpace) => new Promise((resolve) => {
const isCpuOptimized = session.depthUsage === 'cpu-optimized';
const glBinding = new XRWebGLBinding(session, sessionObjects.gl);
const rafCb = function(time, frame) {
const pose = frame.getViewerPose(viewerSpace);
for(const view of pose.views) {
const depthInformation = isCpuOptimized ? frame.getDepthInformation(view)
: glBinding.getDepthInformation(view);
if (matchDepthView) {
t.step(()=> {
assert_matrix_approx_equals(view.projectionMatrix, depthInformation.projectionMatrix);
assert_transform_approx_equals(view.transform, depthInformation.transform);
});
} else {
t.step(() => {
assert_matrix_significantly_not_equals(view.projectionMatrix, depthInformation.projectionMatrix);
assert_transform_significantly_not_equals(view.transform, depthInformation.transform);
});
}
}
resolve();
}
session.requestAnimationFrame(rafCb);
})); // Promise
}; // Test Func
}; // Generator Func