Commit 6fd71600 authored by Piotr Bialecki's avatar Piotr Bialecki Committed by Commit Bot

Hide entityTypes behind blink flag and change WPTs to match

`entityTypes` are marked as unstable in WebXR Hit Test Module draft spec
and are not to be implemented yet - hide them behind blink flag.

Specification can be found here (note the unstable sections):
https://immersive-web.github.io/hit-test/#hit-test-trackable-type-enum
Introduced by PR https://github.com/immersive-web/hit-test/pull/76

Change-Id: I8041db8c7e0b25f197dfd49c3ceb1b0541004ca7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2023288Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736182}
parent ad90d3c6
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[RuntimeEnabled=WebXRHitTestEntityTypes]
enum XRHitTestTrackableType {
"point",
"plane"
......@@ -9,6 +10,6 @@ enum XRHitTestTrackableType {
dictionary XRHitTestOptionsInit {
required XRSpace space;
FrozenArray<XRHitTestTrackableType> entityTypes;
[RuntimeEnabled=WebXRHitTestEntityTypes] FrozenArray<XRHitTestTrackableType> entityTypes;
XRRay offsetRay;
};
......@@ -171,7 +171,8 @@ Vector<device::mojom::blink::EntityTypeForHitTest> GetEntityTypesForHitTest(
DCHECK(options_init);
HashSet<device::mojom::blink::EntityTypeForHitTest> result_set;
if (options_init->hasEntityTypes()) {
if (RuntimeEnabledFeatures::WebXRHitTestEntityTypesEnabled() &&
options_init->hasEntityTypes()) {
DVLOG(2) << __func__ << ": options_init->entityTypes().size()="
<< options_init->entityTypes().size();
for (const auto& entity_type_string : options_init->entityTypes()) {
......@@ -773,7 +774,8 @@ ScriptPromise XRSession::requestHitTestSource(
TransformationMatrix native_from_offset =
options_init->space()->NativeFromOffsetMatrix();
if (options_init->hasEntityTypes() && options_init->entityTypes().IsEmpty()) {
if (RuntimeEnabledFeatures::WebXRHitTestEntityTypesEnabled() &&
options_init->hasEntityTypes() && options_init->entityTypes().IsEmpty()) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
kEntityTypesNotSpecified);
return {};
......@@ -841,7 +843,8 @@ ScriptPromise XRSession::requestHitTestSourceForTransientInput(
return {};
}
if (options_init->hasEntityTypes() && options_init->entityTypes().IsEmpty()) {
if (RuntimeEnabledFeatures::WebXRHitTestEntityTypesEnabled() &&
options_init->hasEntityTypes() && options_init->entityTypes().IsEmpty()) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
kEntityTypesNotSpecified);
return {};
......
......@@ -4,6 +4,6 @@
dictionary XRTransientInputHitTestOptionsInit {
required DOMString profile;
FrozenArray<XRHitTestTrackableType> entityTypes;
[RuntimeEnabled=WebXRHitTestEntityTypes] FrozenArray<XRHitTestTrackableType> entityTypes;
XRRay offsetRay;
};
......@@ -1878,6 +1878,11 @@
// depends_on: ["WebXRARModule"], // TODO(https://crbug.com/954679): uncomment once bug is fixed
status: "experimental"
},
{
name: "WebXRHitTestEntityTypes",
depends_on: ["WebXRHitTest"],
status: "experimental"
},
{
name: "WebXRIncubations",
// depends_on: ["WebXRARModule"], // TODO(https://crbug.com/954679): uncomment once bug is fixed
......
......@@ -32,11 +32,10 @@ const fakeDeviceInitParams = {
// Generates a test function given the parameters for the hit test.
// |ray| - ray that will be used to subscribe to hit test.
// |entityTypes| - entity types that will be used for the hit test subscription.
// |expectedPoses| - array of expected pose objects. The poses are expected to be expressed in local space.
// Null entries in the array mean that the given entry will not be validated.
// |refSpaceName| - XRReferenceSpaceType - either 'local', 'local-floor' or 'viewer'.
let testFunctionGenerator = function(ray, entityTypes, expectedPoses, refSpaceName) {
let testFunctionGenerator = function(ray, expectedPoses, refSpaceName) {
const testFunction = function(session, fakeDeviceController, t) {
return Promise.all([
session.requestReferenceSpace('local'),
......@@ -53,7 +52,6 @@ let testFunctionGenerator = function(ray, entityTypes, expectedPoses, refSpaceNa
const hitTestOptionsInit = {
space: refSpaceNameToSpace[refSpaceName],
offsetRay: ray,
entityTypes: entityTypes,
};
return session.requestHitTestSource(hitTestOptionsInit).then(
......@@ -90,20 +88,20 @@ let testFunctionGenerator = function(ray, entityTypes, expectedPoses, refSpaceNa
// Generates a test function that will use local space for hit test subscription.
// See testFunctionGenerator for explanation of other parameters.
const localBasedTestFunctionGenerator = function(ray, entityTypes, expectedPoses) {
return testFunctionGenerator(ray, entityTypes, expectedPoses, 'local');
const localBasedTestFunctionGenerator = function(ray, expectedPoses) {
return testFunctionGenerator(ray, expectedPoses, 'local');
};
// Generates a test function that will use viewer space for hit test subscription.
// See testFunctionGenerator for explanation of other parameters.
const viewerBasedTestFunctionGenerator = function(ray, entityTypes, expectedPoses) {
return testFunctionGenerator(ray, entityTypes, expectedPoses, 'viewer');
const viewerBasedTestFunctionGenerator = function(ray, expectedPoses) {
return testFunctionGenerator(ray, expectedPoses, 'viewer');
};
// Generates a test function that will use local-floor space for hit test subscription.
// See testFunctionGenerator for explanation of other parameters.
const localFloorBasedTestFunctionGenerator = function(ray, entityTypes, expectedPoses) {
return testFunctionGenerator(ray, entityTypes, expectedPoses, 'local-floor');
const localFloorBasedTestFunctionGenerator = function(ray, expectedPoses) {
return testFunctionGenerator(ray, expectedPoses, 'local-floor');
};
// All test cases require local-floor and hit-test.
......@@ -124,27 +122,14 @@ const pose_1 = {
xr_session_promise_test(
"Ensures subscription to hit test works with viewer space - straight ahead - plane",
viewerBasedTestFunctionGenerator(new XRRay(), ["plane"], [pose_1]),
viewerBasedTestFunctionGenerator(new XRRay(), [pose_1]),
fakeDeviceInitParams, 'immersive-ar', sessionInit);
xr_session_promise_test("Ensures subscription to hit test works with viewer space - straight up - plane - no results",
viewerBasedTestFunctionGenerator(new XRRay({}, {x: 0.0, y: 1.0, z : 0.0}), ["plane"], []),
xr_session_promise_test("Ensures subscription to hit test works with viewer space - straight up - no results",
viewerBasedTestFunctionGenerator(new XRRay({}, {x: 0.0, y: 1.0, z : 0.0}), []),
fakeDeviceInitParams, 'immersive-ar', sessionInit);
const pose_2 = {
position: {x: 0.0, y: 2.0, z: 0.0, w: 1.0},
orientation: {x: 0.707, y: 0.0, z: 0.707, w: 0.0 },
// See comment for pose_1.orientation for details.
// In this case, the hit test pose will have Y axis facing downward ([0,-1,0]),
// Z axis to the right ([1,0,0]) and X axis towards world's Z axis ([0,0,1]).
// This is equivalent to the rotation around [1, 0, 1] vectir by 180 degrees.
};
xr_session_promise_test("Ensures subscription to hit test works with viewer space - straight up - point",
viewerBasedTestFunctionGenerator(new XRRay({}, {x: 0.0, y: 1.0, z : 0.0}), ["point"], [pose_2]),
fakeDeviceInitParams, 'immersive-ar', sessionInit);
const pose_3 = {
position: {x: 0.0, y: 0.0, z: -2.5, w: 1.0},
orientation: {x: 0.0, y: -0.707, z: -0.707, w: 0.0},
// See comment for pose_1.orientation for details.
......@@ -154,10 +139,10 @@ const pose_3 = {
};
xr_session_promise_test("Ensures subscription to hit test works with local space",
localBasedTestFunctionGenerator(new XRRay(), ["plane"], [pose_3]),
localBasedTestFunctionGenerator(new XRRay(), [pose_2]),
fakeDeviceInitParams, 'immersive-ar', sessionInit);
const pose_4 = {
const pose_3 = {
position: {x: 0.0, y: 0.25, z: -2.5, w: 1.0},
orientation: {x: 0.0, y: -0.707, z: -0.707, w: 0.0},
// See comment for pose_1.orientation for details.
......@@ -167,7 +152,7 @@ const pose_4 = {
};
xr_session_promise_test("Ensures subscription to hit test works with local-floor space",
localFloorBasedTestFunctionGenerator(new XRRay(), ["plane"], [pose_4]),
localFloorBasedTestFunctionGenerator(new XRRay(), [pose_3]),
fakeDeviceInitParams, 'immersive-ar', sessionInit);
</script>
......@@ -8,7 +8,11 @@
// width - X axis, in meters
// height - Y axis, in meters
// length - Z axis, in meters
function createFakeWorld(width, height, length) {
function createFakeWorld(
width, height, length,
front_wall_and_floor_type = "plane",
side_walls_type = "mesh",
ceiling_type = "point") {
// Vertices:
const BOTTOM_LEFT_FRONT = { x: -width/2, y: 0, z: -length/2, w: 1};
const BOTTOM_RIGHT_FRONT = { x: width/2, y: 0, z: -length/2, w: 1};
......@@ -49,17 +53,17 @@ function createFakeWorld(width, height, length) {
// Regions:
const FRONT_WALL_AND_FLOOR_REGION = {
type: "plane",
type: front_wall_and_floor_type,
faces: FRONT_WALL_AND_FLOOR_FACES,
};
const SIDE_WALLS_REGION = {
type: "mesh",
type: side_walls_type,
faces: SIDE_WALLS_FACES,
};
const CEILING_REGION = {
type: "point",
type: ceiling_type,
faces: CEILING_FACES,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment