| <!DOCTYPE html> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="resources/webxr_util.js"></script> |
| <script src="resources/webxr_test_constants_single_view.js"></script> |
| <script src="../../webxr/resources/webxr_test_asserts.js"></script> |
| |
| <script> |
| let testName = "Test XRFrame.fillPoses"; |
| |
| let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE_WITH_HAND_TRACKING; |
| |
| let testFunction = function(session, fakeDeviceController, t, sessionObjects) { |
| |
| let input_source = fakeDeviceController.simulateInputSourceConnection({ |
| handedness: "none", |
| targetRayMode: "tracked-pointer", |
| pointerOrigin: VALID_POINTER_TRANSFORM, |
| profiles: [], |
| handJoints: VALID_HAND_JOINTS, |
| }); |
| |
| return session.requestReferenceSpace('local') |
| .then((referenceSpace) => new Promise((resolve) => { |
| |
| function onFrame(time, xrFrame) { |
| assert_not_equals(session.inputSources.length, 0); |
| let hand = session.inputSources[0].hand |
| assert_not_equals(hand, null); |
| |
| const floatsPerTransform = 16; |
| assert_throws_js(TypeError, function() { |
| let transformsArrayWithWrongSize = new Float32Array(JOINT_COUNT * floatsPerTransform - 1); |
| xrFrame.fillPoses(hand.values(), transformsArrayWithWrongSize); |
| }); |
| |
| let transforms = new Float32Array(JOINT_COUNT * floatsPerTransform); |
| let allValid = xrFrame.fillPoses(hand.values(), referenceSpace, transforms); |
| assert_true(allValid); |
| |
| for (var i = 0; i < JOINT_COUNT; ++i) { |
| let transformStartIndex = i * floatsPerTransform; |
| for (var j = 0; j < floatsPerTransform; ++j) { |
| assert_approx_equals(transforms[transformStartIndex + j], VALID_POSE_MATRIX[j], FLOAT_EPSILON); |
| } |
| } |
| |
| resolve(); |
| } |
| session.requestAnimationFrame(onFrame); |
| })); |
| }; |
| |
| xr_session_promise_test( |
| testName, testFunction, fakeDeviceInitParams, 'immersive-vr', { optionalFeatures: ["hand-tracking"] }); |
| |
| </script> |