xrBoundedReferenceSpace_updates.https.html (2224B)
1 <!DOCTYPE html> 2 <script src=/resources/testharness.js></script> 3 <script src=/resources/testharnessreport.js></script> 4 <script src="resources/webxr_util.js"></script> 5 <script src="resources/webxr_test_constants.js"></script> 6 <script src="resources/webxr_test_asserts.js"></script> 7 8 <script> 9 let testName = 10 "'XRBoundedReferenceSpace updates properly when the changes are applied"; 11 12 let fakeDeviceInitParams = { 13 supportsImmersive: true, 14 supportedModes: ["inline", "immersive-vr"], 15 views: VALID_VIEWS, 16 viewerOrigin: IDENTITY_TRANSFORM, 17 floorOrigin: VALID_FLOOR_ORIGIN, 18 supportedFeatures: ALL_FEATURES 19 }; 20 21 let testFunction = function(session, fakeDeviceController, t) { 22 23 return new Promise((resolve, reject) => { 24 session.requestReferenceSpace('bounded-floor') 25 .then((referenceSpace) => { 26 t.step(() => { 27 // A bounded space may be created if no bounds have been set but the system has the capability to support bounded-floor 28 // A lack of bounds is indicated by an empty boundsGeometry 29 assert_equals(referenceSpace.boundsGeometry.length, 0); 30 }); 31 32 function onFrame(time, xrFrame) { 33 // After the bounds have been explicitly set, they should be what we expect. 34 t.step(() => { 35 assert_equals(referenceSpace.boundsGeometry.length, VALID_BOUNDS.length); 36 for (i = 0; i < VALID_BOUNDS.length; ++i) { 37 let valid_point = VALID_BOUNDS[i]; 38 let bounds_point = referenceSpace.boundsGeometry[i]; 39 assert_equals(valid_point.x, bounds_point.x); 40 assert_equals(bounds_point.y, 0.0); 41 assert_equals(valid_point.z, bounds_point.z); 42 assert_equals(bounds_point.w, 1.0); 43 } 44 }); 45 46 resolve(); 47 } 48 49 // Now set the bounds explicitly and check again on the next frame. 50 fakeDeviceController.setBoundsGeometry(VALID_BOUNDS); 51 requestSkipAnimationFrame(session, onFrame); 52 }); 53 }); 54 }; 55 56 xr_session_promise_test(testName, testFunction, fakeDeviceInitParams, 'immersive-vr', { 'requiredFeatures': ['bounded-floor'] }); 57 58 </script>