Commit d145058d authored by Lachlan Ford's avatar Lachlan Ford Committed by Chromium LUCI CQ

WebXR Hand Input: Flags, IDL and Blink stubs.

This change contains the flags, IDL definitions and blink stubs for the
WebXR Hand Input module.

https://immersive-web.github.io/webxr-hand-input/
https://github.com/immersive-web/webxr-hand-input/issues/

Subsequent changes will provide the Blink implementation, OpenXR device
implementation and test code.

Change-Id: I90169c4be02cf5daa29283a3fdf7fda6a4a2c319
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623532
Commit-Queue: Lachlan Ford <laford@microsoft.com>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844283}
parent bf2991fb
...@@ -80,6 +80,7 @@ void WebXRSessionTracker::ReportFeatureUsed( ...@@ -80,6 +80,7 @@ void WebXRSessionTracker::ReportFeatureUsed(
case XRSessionFeature::PLANE_DETECTION: case XRSessionFeature::PLANE_DETECTION:
case XRSessionFeature::DEPTH: case XRSessionFeature::DEPTH:
case XRSessionFeature::IMAGE_TRACKING: case XRSessionFeature::IMAGE_TRACKING:
case XRSessionFeature::HAND_INPUT:
// Not recording metrics for these features currently. // Not recording metrics for these features currently.
// TODO(https://crbug.com/965729): Add metrics for the AR-related features // TODO(https://crbug.com/965729): Add metrics for the AR-related features
// that are enabled by default. // that are enabled by default.
...@@ -121,6 +122,7 @@ void WebXRSessionTracker::SetFeatureRequest( ...@@ -121,6 +122,7 @@ void WebXRSessionTracker::SetFeatureRequest(
case XRSessionFeature::PLANE_DETECTION: case XRSessionFeature::PLANE_DETECTION:
case XRSessionFeature::DEPTH: case XRSessionFeature::DEPTH:
case XRSessionFeature::IMAGE_TRACKING: case XRSessionFeature::IMAGE_TRACKING:
case XRSessionFeature::HAND_INPUT:
// Not recording metrics for these features currently. // Not recording metrics for these features currently.
// TODO(https://crbug.com/965729): Add metrics for the AR-related features // TODO(https://crbug.com/965729): Add metrics for the AR-related features
// that are enabled by default. // that are enabled by default.
......
...@@ -213,6 +213,7 @@ void SetRuntimeFeaturesFromChromiumFeatures() { ...@@ -213,6 +213,7 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
{wf::EnablePeriodicBackgroundSync, features::kPeriodicBackgroundSync}, {wf::EnablePeriodicBackgroundSync, features::kPeriodicBackgroundSync},
{wf::EnableWebXR, features::kWebXr}, {wf::EnableWebXR, features::kWebXr},
{wf::EnableWebXRARModule, features::kWebXrArModule}, {wf::EnableWebXRARModule, features::kWebXrArModule},
{wf::EnableWebXRHandInput, features::kWebXrHandInput},
{wf::EnableWebXRHitTest, features::kWebXrHitTest}, {wf::EnableWebXRHitTest, features::kWebXrHitTest},
{wf::EnableWebXRAnchors, features::kWebXrIncubations}, {wf::EnableWebXRAnchors, features::kWebXrIncubations},
{wf::EnableWebXRCameraAccess, features::kWebXrIncubations}, {wf::EnableWebXRCameraAccess, features::kWebXrIncubations},
......
...@@ -856,6 +856,10 @@ const base::Feature kWebXr{"WebXR", base::FEATURE_ENABLED_BY_DEFAULT}; ...@@ -856,6 +856,10 @@ const base::Feature kWebXr{"WebXR", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kWebXrArModule{"WebXRARModule", const base::Feature kWebXrArModule{"WebXRARModule",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
// Enables access to articulated hand tracking sensor input.
const base::Feature kWebXrHandInput{"WebXRHandInput",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables access to raycasting against estimated XR scene geometry. // Enables access to raycasting against estimated XR scene geometry.
const base::Feature kWebXrHitTest{"WebXRHitTest", const base::Feature kWebXrHitTest{"WebXRHitTest",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
......
...@@ -193,6 +193,7 @@ CONTENT_EXPORT extern const base::Feature kWebUIReportOnlyTrustedTypes; ...@@ -193,6 +193,7 @@ CONTENT_EXPORT extern const base::Feature kWebUIReportOnlyTrustedTypes;
CONTENT_EXPORT extern const base::Feature kWebUsb; CONTENT_EXPORT extern const base::Feature kWebUsb;
CONTENT_EXPORT extern const base::Feature kWebXr; CONTENT_EXPORT extern const base::Feature kWebXr;
CONTENT_EXPORT extern const base::Feature kWebXrArModule; CONTENT_EXPORT extern const base::Feature kWebXrArModule;
CONTENT_EXPORT extern const base::Feature kWebXrHandInput;
CONTENT_EXPORT extern const base::Feature kWebXrHitTest; CONTENT_EXPORT extern const base::Feature kWebXrHitTest;
CONTENT_EXPORT extern const base::Feature kWebXrIncubations; CONTENT_EXPORT extern const base::Feature kWebXrIncubations;
......
...@@ -66,6 +66,7 @@ enum XRSessionFeature { ...@@ -66,6 +66,7 @@ enum XRSessionFeature {
PLANE_DETECTION = 11, // Experimental feature. PLANE_DETECTION = 11, // Experimental feature.
DEPTH = 12, // Experimental feature. DEPTH = 12, // Experimental feature.
IMAGE_TRACKING = 13, // Experimental feature. IMAGE_TRACKING = 13, // Experimental feature.
HAND_INPUT = 14, // Experimental feature.
}; };
// These values are persisted to logs. Entries should not be renumbered and // These values are persisted to logs. Entries should not be renumbered and
......
...@@ -173,6 +173,7 @@ class WebRuntimeFeatures { ...@@ -173,6 +173,7 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableWebXRARModule(bool); BLINK_PLATFORM_EXPORT static void EnableWebXRARModule(bool);
BLINK_PLATFORM_EXPORT static void EnableWebXRCameraAccess(bool); BLINK_PLATFORM_EXPORT static void EnableWebXRCameraAccess(bool);
BLINK_PLATFORM_EXPORT static void EnableWebXRDepth(bool); BLINK_PLATFORM_EXPORT static void EnableWebXRDepth(bool);
BLINK_PLATFORM_EXPORT static void EnableWebXRHandInput(bool);
BLINK_PLATFORM_EXPORT static void EnableWebXRHitTest(bool); BLINK_PLATFORM_EXPORT static void EnableWebXRHitTest(bool);
BLINK_PLATFORM_EXPORT static void EnableWebXRImageTracking(bool); BLINK_PLATFORM_EXPORT static void EnableWebXRImageTracking(bool);
BLINK_PLATFORM_EXPORT static void EnableWebXRLightEstimation(bool); BLINK_PLATFORM_EXPORT static void EnableWebXRLightEstimation(bool);
......
...@@ -1204,6 +1204,8 @@ generated_enumeration_sources_in_modules = [ ...@@ -1204,6 +1204,8 @@ generated_enumeration_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_environment_blend_mode.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_environment_blend_mode.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_eye.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_eye.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_eye.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_eye.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hand_joint.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hand_joint.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_handedness.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_handedness.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_handedness.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_handedness.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hit_test_trackable_type.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hit_test_trackable_type.cc",
...@@ -2209,6 +2211,8 @@ generated_interface_sources_in_modules = [ ...@@ -2209,6 +2211,8 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_dom_overlay_state.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_dom_overlay_state.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_frame.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_frame.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_frame.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_frame.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hand.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hand.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hit_test_result.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hit_test_result.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hit_test_result.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hit_test_result.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hit_test_source.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_hit_test_source.cc",
...@@ -2223,6 +2227,10 @@ generated_interface_sources_in_modules = [ ...@@ -2223,6 +2227,10 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_input_source_event.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_input_source_event.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_input_sources_change_event.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_input_sources_change_event.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_input_sources_change_event.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_input_sources_change_event.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_joint_pose.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_joint_pose.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_joint_space.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_joint_space.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_layer.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_layer.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_layer.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_layer.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_light_estimate.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_light_estimate.cc",
......
...@@ -1008,6 +1008,9 @@ static_idl_files_in_modules = get_path_info( ...@@ -1008,6 +1008,9 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/xr/xr_dom_overlay_state.idl", "//third_party/blink/renderer/modules/xr/xr_dom_overlay_state.idl",
"//third_party/blink/renderer/modules/xr/xr_frame.idl", "//third_party/blink/renderer/modules/xr/xr_frame.idl",
"//third_party/blink/renderer/modules/xr/xr_frame_request_callback.idl", "//third_party/blink/renderer/modules/xr/xr_frame_request_callback.idl",
"//third_party/blink/renderer/modules/xr/xr_hand.idl",
"//third_party/blink/renderer/modules/xr/xr_joint_pose.idl",
"//third_party/blink/renderer/modules/xr/xr_joint_space.idl",
"//third_party/blink/renderer/modules/xr/xr_hit_test_options_init.idl", "//third_party/blink/renderer/modules/xr/xr_hit_test_options_init.idl",
"//third_party/blink/renderer/modules/xr/xr_hit_test_result.idl", "//third_party/blink/renderer/modules/xr/xr_hit_test_result.idl",
"//third_party/blink/renderer/modules/xr/xr_hit_test_source.idl", "//third_party/blink/renderer/modules/xr/xr_hit_test_source.idl",
......
...@@ -33,6 +33,8 @@ blink_modules_sources("xr") { ...@@ -33,6 +33,8 @@ blink_modules_sources("xr") {
"xr_frame_request_callback_collection.h", "xr_frame_request_callback_collection.h",
"xr_grip_space.cc", "xr_grip_space.cc",
"xr_grip_space.h", "xr_grip_space.h",
"xr_hand.cc",
"xr_hand.h",
"xr_hit_test_result.cc", "xr_hit_test_result.cc",
"xr_hit_test_result.h", "xr_hit_test_result.h",
"xr_hit_test_source.cc", "xr_hit_test_source.cc",
...@@ -47,6 +49,10 @@ blink_modules_sources("xr") { ...@@ -47,6 +49,10 @@ blink_modules_sources("xr") {
"xr_input_source_event.h", "xr_input_source_event.h",
"xr_input_sources_change_event.cc", "xr_input_sources_change_event.cc",
"xr_input_sources_change_event.h", "xr_input_sources_change_event.h",
"xr_joint_pose.cc",
"xr_joint_pose.h",
"xr_joint_space.cc",
"xr_joint_space.h",
"xr_layer.cc", "xr_layer.cc",
"xr_layer.h", "xr_layer.h",
"xr_light_estimate.cc", "xr_light_estimate.cc",
......
...@@ -11,6 +11,9 @@ modules_idl_files = [ ...@@ -11,6 +11,9 @@ modules_idl_files = [
"xr_depth_information.idl", "xr_depth_information.idl",
"xr_dom_overlay_state.idl", "xr_dom_overlay_state.idl",
"xr_frame.idl", "xr_frame.idl",
"xr_hand.idl",
"xr_joint_pose.idl",
"xr_joint_space.idl",
"xr_image_tracking_result.idl", "xr_image_tracking_result.idl",
"xr_input_source.idl", "xr_input_source.idl",
"xr_input_source_array.idl", "xr_input_source_array.idl",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/modules/xr/xr_hit_test_source.h" #include "third_party/blink/renderer/modules/xr/xr_hit_test_source.h"
#include "third_party/blink/renderer/modules/xr/xr_input_source.h" #include "third_party/blink/renderer/modules/xr/xr_input_source.h"
#include "third_party/blink/renderer/modules/xr/xr_joint_space.h"
#include "third_party/blink/renderer/modules/xr/xr_light_estimate.h" #include "third_party/blink/renderer/modules/xr/xr_light_estimate.h"
#include "third_party/blink/renderer/modules/xr/xr_light_probe.h" #include "third_party/blink/renderer/modules/xr/xr_light_probe.h"
#include "third_party/blink/renderer/modules/xr/xr_plane_set.h" #include "third_party/blink/renderer/modules/xr/xr_plane_set.h"
...@@ -381,6 +382,28 @@ HeapVector<Member<XRImageTrackingResult>> XRFrame::getImageTrackingResults( ...@@ -381,6 +382,28 @@ HeapVector<Member<XRImageTrackingResult>> XRFrame::getImageTrackingResults(
return session_->ImageTrackingResults(exception_state); return session_->ImageTrackingResults(exception_state);
} }
XRJointPose* XRFrame::getJointPose(XRJointSpace* joint,
XRSpace* baseSpace,
ExceptionState& exception_state) {
NOTIMPLEMENTED();
return nullptr;
}
bool XRFrame::fillJointRadii(HeapVector<Member<XRJointSpace>>& jointSpaces,
NotShared<DOMFloat32Array> radii,
ExceptionState& exception_state) {
NOTIMPLEMENTED();
return false;
}
bool XRFrame::fillPoses(HeapVector<Member<XRSpace>>& spaces,
XRSpace* baseSpace,
NotShared<DOMFloat32Array> transforms,
ExceptionState& exception_state) {
NOTIMPLEMENTED();
return false;
}
void XRFrame::Trace(Visitor* visitor) const { void XRFrame::Trace(Visitor* visitor) const {
visitor->Trace(session_); visitor->Trace(session_);
ScriptWrappable::Trace(visitor); ScriptWrappable::Trace(visitor);
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "device/vr/public/mojom/vr_service.mojom-blink-forward.h" #include "device/vr/public/mojom/vr_service.mojom-blink-forward.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_matrix.h"
#include "third_party/blink/renderer/modules/xr/xr_joint_pose.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
...@@ -24,8 +26,10 @@ class XRHitTestResult; ...@@ -24,8 +26,10 @@ class XRHitTestResult;
class XRHitTestSource; class XRHitTestSource;
class XRImageTrackingResult; class XRImageTrackingResult;
class XRInputSource; class XRInputSource;
class XRJointPose;
class XRLightEstimate; class XRLightEstimate;
class XRLightProbe; class XRLightProbe;
class XRJointSpace;
class XRPlaneSet; class XRPlaneSet;
class XRPose; class XRPose;
class XRReferenceSpace; class XRReferenceSpace;
...@@ -79,6 +83,17 @@ class XRFrame final : public ScriptWrappable { ...@@ -79,6 +83,17 @@ class XRFrame final : public ScriptWrappable {
HeapVector<Member<XRImageTrackingResult>> getImageTrackingResults( HeapVector<Member<XRImageTrackingResult>> getImageTrackingResults(
ExceptionState&); ExceptionState&);
XRJointPose* getJointPose(XRJointSpace* joint,
XRSpace* baseSpace,
ExceptionState& exception_state);
bool fillJointRadii(HeapVector<Member<XRJointSpace>>& jointSpaces,
NotShared<DOMFloat32Array> radii,
ExceptionState& exception_state);
bool fillPoses(HeapVector<Member<XRSpace>>& spaces,
XRSpace* baseSpace,
NotShared<DOMFloat32Array> transforms,
ExceptionState& exception_state);
private: private:
std::unique_ptr<TransformationMatrix> GetAdjustedPoseMatrix(XRSpace*) const; std::unique_ptr<TransformationMatrix> GetAdjustedPoseMatrix(XRSpace*) const;
XRPose* GetTargetRayPose(XRInputSource*, XRSpace*) const; XRPose* GetTargetRayPose(XRInputSource*, XRSpace*) const;
......
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
[RuntimeEnabled=WebXRImageTracking, RaisesException] [RuntimeEnabled=WebXRImageTracking, RaisesException]
FrozenArray<XRImageTrackingResult> getImageTrackingResults(); FrozenArray<XRImageTrackingResult> getImageTrackingResults();
[RuntimeEnabled=WebXRHandInput, RaisesException]
XRJointPose? getJointPose(XRJointSpace joint, XRSpace baseSpace);
[RuntimeEnabled=WebXRHandInput, RaisesException]
boolean fillJointRadii(sequence<XRJointSpace> jointSpaces, Float32Array radii);
[RuntimeEnabled=WebXRHandInput, RaisesException]
boolean fillPoses(sequence<XRSpace> spaces, XRSpace baseSpace, Float32Array transforms);
// More details about the real-world understanding APIs can be found here: // More details about the real-world understanding APIs can be found here:
// https://github.com/immersive-web/real-world-geometry/blob/master/plane-detection-explainer.md // https://github.com/immersive-web/real-world-geometry/blob/master/plane-detection-explainer.md
[RuntimeEnabled=WebXRPlaneDetection, RaisesException] [RuntimeEnabled=WebXRPlaneDetection, RaisesException]
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/xr/xr_hand.h"
#include "third_party/blink/renderer/modules/xr/xr_input_source.h"
#include "third_party/blink/renderer/modules/xr/xr_joint_pose.h"
#include "third_party/blink/renderer/modules/xr/xr_joint_space.h"
namespace blink {
unsigned int XRHand::size() const {
NOTIMPLEMENTED();
return 0;
}
XRJointSpace* XRHand::get(const String& key) {
NOTIMPLEMENTED();
return nullptr;
}
XRHand::IterationSource* XRHand::StartIteration(ScriptState*, ExceptionState&) {
NOTIMPLEMENTED();
return nullptr;
}
void XRHand::Trace(Visitor* visitor) const {
ScriptWrappable::Trace(visitor);
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_HAND_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_HAND_H_
#include "device/vr/public/mojom/vr_service.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/iterable.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class XRJointSpace;
class XRHand : public ScriptWrappable,
public PairIterable<String, Member<XRJointSpace>> {
DEFINE_WRAPPERTYPEINFO();
public:
XRHand() = default;
~XRHand() override = default;
unsigned int size() const;
XRJointSpace* get(const String& key);
void Trace(Visitor*) const override;
private:
using Iterationsource =
PairIterable<String, Member<XRJointSpace>>::IterationSource;
IterationSource* StartIteration(ScriptState*, ExceptionState&) override;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_HAND_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//https://immersive-web.github.io/webxr-hand-input/#idl-index
enum XRHandJoint {
"wrist",
"thumb-metacarpal",
"thumb-phalanx-proximal",
"thumb-phalanx-distal",
"thumb-tip",
"index-finger-metacarpal",
"index-finger-phalanx-proximal",
"index-finger-phalanx-intermediate",
"index-finger-phalanx-distal",
"index-finger-tip",
"middle-finger-metacarpal",
"middle-finger-phalanx-proximal",
"middle-finger-phalanx-intermediate",
"middle-finger-phalanx-distal",
"middle-finger-tip",
"ring-finger-metacarpal",
"ring-finger-phalanx-proximal",
"ring-finger-phalanx-intermediate",
"ring-finger-phalanx-distal",
"ring-finger-tip",
"pinky-finger-metacarpal",
"pinky-finger-phalanx-proximal",
"pinky-finger-phalanx-intermediate",
"pinky-finger-phalanx-distal",
"pinky-finger-tip"
};
//https://immersive-web.github.io/webxr-hand-input/#idl-index
[
SecureContext,
Exposed=Window,
RuntimeEnabled=WebXRHandInput
] interface XRHand {
iterable<XRHandJoint, XRJointSpace>;
readonly attribute unsigned long size;
XRJointSpace get(XRHandJoint key);
};
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "third_party/blink/renderer/core/input/event_handling_util.h" #include "third_party/blink/renderer/core/input/event_handling_util.h"
#include "third_party/blink/renderer/core/layout/hit_test_location.h" #include "third_party/blink/renderer/core/layout/hit_test_location.h"
#include "third_party/blink/renderer/modules/xr/xr_grip_space.h" #include "third_party/blink/renderer/modules/xr/xr_grip_space.h"
#include "third_party/blink/renderer/modules/xr/xr_hand.h"
#include "third_party/blink/renderer/modules/xr/xr_input_source_event.h" #include "third_party/blink/renderer/modules/xr/xr_input_source_event.h"
#include "third_party/blink/renderer/modules/xr/xr_session.h" #include "third_party/blink/renderer/modules/xr/xr_session.h"
#include "third_party/blink/renderer/modules/xr/xr_session_event.h" #include "third_party/blink/renderer/modules/xr/xr_session_event.h"
...@@ -129,6 +130,7 @@ XRInputSource::XRInputSource(const XRInputSource& other) ...@@ -129,6 +130,7 @@ XRInputSource::XRInputSource(const XRInputSource& other)
MakeGarbageCollected<XRTargetRaySpace>(other.session_, this)), MakeGarbageCollected<XRTargetRaySpace>(other.session_, this)),
grip_space_(MakeGarbageCollected<XRGripSpace>(other.session_, this)), grip_space_(MakeGarbageCollected<XRGripSpace>(other.session_, this)),
gamepad_(other.gamepad_), gamepad_(other.gamepad_),
hand_(other.hand_),
mojo_from_input_( mojo_from_input_(
TryGetTransformationMatrix(other.mojo_from_input_.get())), TryGetTransformationMatrix(other.mojo_from_input_.get())),
input_from_pointer_( input_from_pointer_(
...@@ -614,6 +616,7 @@ void XRInputSource::Trace(Visitor* visitor) const { ...@@ -614,6 +616,7 @@ void XRInputSource::Trace(Visitor* visitor) const {
visitor->Trace(target_ray_space_); visitor->Trace(target_ray_space_);
visitor->Trace(grip_space_); visitor->Trace(grip_space_);
visitor->Trace(gamepad_); visitor->Trace(gamepad_);
visitor->Trace(hand_);
ScriptWrappable::Trace(visitor); ScriptWrappable::Trace(visitor);
} }
......
...@@ -23,6 +23,7 @@ namespace blink { ...@@ -23,6 +23,7 @@ namespace blink {
class Element; class Element;
class XRGripSpace; class XRGripSpace;
class XRHand;
class XRInputSourceEvent; class XRInputSourceEvent;
class XRSession; class XRSession;
class XRSpace; class XRSpace;
...@@ -49,6 +50,8 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client { ...@@ -49,6 +50,8 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client {
XRSession* session() const { return session_; } XRSession* session() const { return session_; }
XRHand* hand() const { return hand_; }
const String handedness() const; const String handedness() const;
const String targetRayMode() const; const String targetRayMode() const;
bool emulatedPosition() const { return state_.emulated_position; } bool emulatedPosition() const { return state_.emulated_position; }
...@@ -161,6 +164,7 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client { ...@@ -161,6 +164,7 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client {
Member<XRTargetRaySpace> target_ray_space_; Member<XRTargetRaySpace> target_ray_space_;
Member<XRGripSpace> grip_space_; Member<XRGripSpace> grip_space_;
Member<Gamepad> gamepad_; Member<Gamepad> gamepad_;
Member<XRHand> hand_{nullptr};
// Input device pose in mojo space. This is the grip pose for // Input device pose in mojo space. This is the grip pose for
// tracked controllers, and the viewer pose for screen input. // tracked controllers, and the viewer pose for screen input.
......
...@@ -24,5 +24,6 @@ enum XRTargetRayMode { ...@@ -24,5 +24,6 @@ enum XRTargetRayMode {
[SameObject] readonly attribute XRSpace targetRaySpace; [SameObject] readonly attribute XRSpace targetRaySpace;
[SameObject] readonly attribute XRSpace? gripSpace; [SameObject] readonly attribute XRSpace? gripSpace;
[SameObject, Measure] readonly attribute Gamepad? gamepad; [SameObject, Measure] readonly attribute Gamepad? gamepad;
[SameObject, RuntimeEnabled=WebXRHandInput] readonly attribute XRHand? hand;
[SameObject, SaveSameObject] readonly attribute FrozenArray<DOMString> profiles; [SameObject, SaveSameObject] readonly attribute FrozenArray<DOMString> profiles;
}; };
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/xr/xr_joint_pose.h"
#include "third_party/blink/renderer/modules/xr/xr_pose.h"
namespace blink {
XRJointPose::XRJointPose(const TransformationMatrix& transform,
bool emulatedPosition,
float radius)
: XRPose(transform, emulatedPosition), radius_(radius) {}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_JOINT_POSE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_JOINT_POSE_H_
#include "device/vr/public/mojom/vr_service.mojom-blink.h"
#include "third_party/blink/renderer/modules/xr/xr_pose.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
namespace blink {
class XRJointPose : public XRPose {
DEFINE_WRAPPERTYPEINFO();
public:
XRJointPose(const TransformationMatrix& transform,
bool emulatedPosition,
float radius);
float radius() const { return radius_; }
private:
float radius_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_JOINT_POSE_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
SecureContext,
Exposed=Window,
RuntimeEnabled=WebXRHandInput
] interface XRJointPose : XRPose {
readonly attribute float radius;
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/xr/xr_joint_space.h"
#include "third_party/blink/renderer/modules/xr/xr_space.h"
namespace blink {
XRJointSpace::XRJointSpace(
XRSession* session,
std::unique_ptr<TransformationMatrix> mojo_from_joint,
String joint_name,
float radius)
: XRSpace(session),
mojo_from_joint_space_(std::move(mojo_from_joint)),
joint_name_(joint_name),
radius_(radius) {}
base::Optional<TransformationMatrix> XRJointSpace::MojoFromNative() {
return *mojo_from_joint_space_.get();
}
bool XRJointSpace::EmulatedPosition() const {
NOTIMPLEMENTED();
return false;
}
base::Optional<device::mojom::blink::XRNativeOriginInformation>
XRJointSpace::NativeOrigin() const {
NOTIMPLEMENTED();
return base::nullopt;
}
bool XRJointSpace::IsStationary() const {
return false;
}
std::string XRJointSpace::ToString() const {
return "XRJointSpace";
}
void XRJointSpace::Trace(Visitor* visitor) const {
XRSpace::Trace(visitor);
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_JOINT_SPACE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_JOINT_SPACE_H_
#include "base/optional.h"
#include "device/vr/public/mojom/vr_service.mojom-blink.h"
#include "third_party/blink/renderer/modules/xr/xr_native_origin_information.h"
#include "third_party/blink/renderer/modules/xr/xr_space.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
namespace blink {
class XRSession;
class XRJointSpace : public XRSpace {
DEFINE_WRAPPERTYPEINFO();
public:
XRJointSpace(XRSession* session,
std::unique_ptr<TransformationMatrix> mojo_from_joint,
String joint_name,
float radius);
float GetRadius() const { return radius_; }
const String& jointName() const { return joint_name_; }
base::Optional<TransformationMatrix> MojoFromNative() override;
bool EmulatedPosition() const override;
base::Optional<device::mojom::blink::XRNativeOriginInformation> NativeOrigin()
const override;
bool IsStationary() const override;
std::string ToString() const override;
void Trace(Visitor*) const override;
private:
const std::unique_ptr<TransformationMatrix> mojo_from_joint_space_;
const String joint_name_;
const float radius_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_JOINT_SPACE_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
SecureContext,
Exposed=Window,
RuntimeEnabled=WebXRHandInput
] interface XRJointSpace : XRSpace {
readonly attribute XRHandJoint jointName;
};
...@@ -304,6 +304,7 @@ void XRSession::MetricsReporter::ReportFeatureUsed( ...@@ -304,6 +304,7 @@ void XRSession::MetricsReporter::ReportFeatureUsed(
case XRSessionFeature::PLANE_DETECTION: case XRSessionFeature::PLANE_DETECTION:
case XRSessionFeature::DEPTH: case XRSessionFeature::DEPTH:
case XRSessionFeature::IMAGE_TRACKING: case XRSessionFeature::IMAGE_TRACKING:
case XRSessionFeature::HAND_INPUT:
// Not recording metrics for these features currently. // Not recording metrics for these features currently.
break; break;
} }
......
...@@ -150,6 +150,9 @@ base::Optional<device::mojom::XRSessionFeature> StringToXRSessionFeature( ...@@ -150,6 +150,9 @@ base::Optional<device::mojom::XRSessionFeature> StringToXRSessionFeature(
} else if (RuntimeEnabledFeatures::WebXRImageTrackingEnabled(context) && } else if (RuntimeEnabledFeatures::WebXRImageTrackingEnabled(context) &&
feature_string == "image-tracking") { feature_string == "image-tracking") {
return device::mojom::XRSessionFeature::IMAGE_TRACKING; return device::mojom::XRSessionFeature::IMAGE_TRACKING;
} else if (RuntimeEnabledFeatures::WebXRHandInputEnabled(context) &&
feature_string == "hand-tracking") {
return device::mojom::XRSessionFeature::HAND_INPUT;
} }
return base::nullopt; return base::nullopt;
...@@ -169,6 +172,7 @@ bool IsFeatureValidForMode(device::mojom::XRSessionFeature feature, ...@@ -169,6 +172,7 @@ bool IsFeatureValidForMode(device::mojom::XRSessionFeature feature,
case device::mojom::XRSessionFeature::REF_SPACE_UNBOUNDED: case device::mojom::XRSessionFeature::REF_SPACE_UNBOUNDED:
case device::mojom::XRSessionFeature::HIT_TEST: case device::mojom::XRSessionFeature::HIT_TEST:
case device::mojom::XRSessionFeature::ANCHORS: case device::mojom::XRSessionFeature::ANCHORS:
case device::mojom::XRSessionFeature::HAND_INPUT:
return mode == device::mojom::blink::XRSessionMode::kImmersiveVr || return mode == device::mojom::blink::XRSessionMode::kImmersiveVr ||
mode == device::mojom::blink::XRSessionMode::kImmersiveAr; mode == device::mojom::blink::XRSessionMode::kImmersiveAr;
case device::mojom::XRSessionFeature::DOM_OVERLAY: case device::mojom::XRSessionFeature::DOM_OVERLAY:
...@@ -223,6 +227,7 @@ bool HasRequiredFeaturePolicy(const ExecutionContext* context, ...@@ -223,6 +227,7 @@ bool HasRequiredFeaturePolicy(const ExecutionContext* context,
case device::mojom::XRSessionFeature::PLANE_DETECTION: case device::mojom::XRSessionFeature::PLANE_DETECTION:
case device::mojom::XRSessionFeature::DEPTH: case device::mojom::XRSessionFeature::DEPTH:
case device::mojom::XRSessionFeature::IMAGE_TRACKING: case device::mojom::XRSessionFeature::IMAGE_TRACKING:
case device::mojom::XRSessionFeature::HAND_INPUT:
return context->IsFeatureEnabled( return context->IsFeatureEnabled(
mojom::blink::FeaturePolicyFeature::kWebXr, mojom::blink::FeaturePolicyFeature::kWebXr,
ReportOptions::kReportOnFailure); ReportOptions::kReportOnFailure);
......
...@@ -393,6 +393,10 @@ void WebRuntimeFeatures::EnableWebXRDepth(bool enable) { ...@@ -393,6 +393,10 @@ void WebRuntimeFeatures::EnableWebXRDepth(bool enable) {
RuntimeEnabledFeatures::SetWebXRDepthEnabled(enable); RuntimeEnabledFeatures::SetWebXRDepthEnabled(enable);
} }
void WebRuntimeFeatures::EnableWebXRHandInput(bool enable) {
RuntimeEnabledFeatures::SetWebXRHandInputEnabled(enable);
}
void WebRuntimeFeatures::EnableWebXRHitTest(bool enable) { void WebRuntimeFeatures::EnableWebXRHitTest(bool enable) {
RuntimeEnabledFeatures::SetWebXRHitTestEnabled(enable); RuntimeEnabledFeatures::SetWebXRHitTestEnabled(enable);
} }
......
...@@ -2250,6 +2250,11 @@ ...@@ -2250,6 +2250,11 @@
depends_on: ["WebXRARModule"], depends_on: ["WebXRARModule"],
status: "experimental", status: "experimental",
}, },
{
name: "WebXRHandInput",
depends_on: ["WebXRARModule"],
status: "experimental"
},
{ {
name: "WebXRHitTest", name: "WebXRHitTest",
depends_on: ["WebXRARModule"], depends_on: ["WebXRARModule"],
......
This is a testharness.js-based test.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface XRInputSource: original interface defined
PASS Partial interface XRInputSource: member names are unique
PASS Partial interface XRFrame: original interface defined
PASS Partial interface XRFrame: member names are unique
FAIL XRHand interface: existence and properties of interface object assert_own_property: self does not have own property "XRHand" expected property "XRHand" missing
FAIL XRHand interface object length assert_own_property: self does not have own property "XRHand" expected property "XRHand" missing
FAIL XRHand interface object name assert_own_property: self does not have own property "XRHand" expected property "XRHand" missing
FAIL XRHand interface: existence and properties of interface prototype object assert_own_property: self does not have own property "XRHand" expected property "XRHand" missing
FAIL XRHand interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "XRHand" expected property "XRHand" missing
FAIL XRHand interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "XRHand" expected property "XRHand" missing
FAIL XRHand interface: iterable<XRHandJoint, XRJointSpace> Cannot read property 'prototype' of undefined
FAIL XRHand interface: attribute size assert_own_property: self does not have own property "XRHand" expected property "XRHand" missing
FAIL XRHand interface: operation get(XRHandJoint) assert_own_property: self does not have own property "XRHand" expected property "XRHand" missing
FAIL XRJointSpace interface: existence and properties of interface object assert_own_property: self does not have own property "XRJointSpace" expected property "XRJointSpace" missing
FAIL XRJointSpace interface object length assert_own_property: self does not have own property "XRJointSpace" expected property "XRJointSpace" missing
FAIL XRJointSpace interface object name assert_own_property: self does not have own property "XRJointSpace" expected property "XRJointSpace" missing
FAIL XRJointSpace interface: existence and properties of interface prototype object assert_own_property: self does not have own property "XRJointSpace" expected property "XRJointSpace" missing
FAIL XRJointSpace interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "XRJointSpace" expected property "XRJointSpace" missing
FAIL XRJointSpace interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "XRJointSpace" expected property "XRJointSpace" missing
FAIL XRJointSpace interface: attribute jointName assert_own_property: self does not have own property "XRJointSpace" expected property "XRJointSpace" missing
FAIL XRJointPose interface: existence and properties of interface object assert_own_property: self does not have own property "XRJointPose" expected property "XRJointPose" missing
FAIL XRJointPose interface object length assert_own_property: self does not have own property "XRJointPose" expected property "XRJointPose" missing
FAIL XRJointPose interface object name assert_own_property: self does not have own property "XRJointPose" expected property "XRJointPose" missing
FAIL XRJointPose interface: existence and properties of interface prototype object assert_own_property: self does not have own property "XRJointPose" expected property "XRJointPose" missing
FAIL XRJointPose interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "XRJointPose" expected property "XRJointPose" missing
FAIL XRJointPose interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "XRJointPose" expected property "XRJointPose" missing
FAIL XRJointPose interface: attribute radius assert_own_property: self does not have own property "XRJointPose" expected property "XRJointPose" missing
FAIL XRFrame interface: operation getJointPose(XRJointSpace, XRSpace) assert_own_property: interface prototype object missing non-static operation expected property "getJointPose" missing
FAIL XRFrame interface: operation fillJointRadii(sequence<XRJointSpace>, Float32Array) assert_own_property: interface prototype object missing non-static operation expected property "fillJointRadii" missing
FAIL XRFrame interface: operation fillPoses(sequence<XRSpace>, XRSpace, Float32Array) assert_own_property: interface prototype object missing non-static operation expected property "fillPoses" missing
FAIL XRInputSource interface: attribute hand assert_true: The prototype object must have a property "hand" expected true got false
Harness: the test ran to completion.
...@@ -10502,13 +10502,26 @@ interface XRFrame ...@@ -10502,13 +10502,26 @@ interface XRFrame
getter trackedAnchors getter trackedAnchors
method constructor method constructor
method createAnchor method createAnchor
method fillJointRadii
method fillPoses
method getDepthInformation method getDepthInformation
method getHitTestResults method getHitTestResults
method getHitTestResultsForTransientInput method getHitTestResultsForTransientInput
method getImageTrackingResults method getImageTrackingResults
method getJointPose
method getLightEstimate method getLightEstimate
method getPose method getPose
method getViewerPose method getViewerPose
interface XRHand
attribute @@toStringTag
getter size
method @@iterator
method constructor
method entries
method forEach
method get
method keys
method values
interface XRHitTestResult interface XRHitTestResult
attribute @@toStringTag attribute @@toStringTag
method constructor method constructor
...@@ -10529,6 +10542,7 @@ interface XRInputSource ...@@ -10529,6 +10542,7 @@ interface XRInputSource
attribute @@toStringTag attribute @@toStringTag
getter gamepad getter gamepad
getter gripSpace getter gripSpace
getter hand
getter handedness getter handedness
getter profiles getter profiles
getter targetRayMode getter targetRayMode
...@@ -10554,6 +10568,14 @@ interface XRInputSourcesChangeEvent : Event ...@@ -10554,6 +10568,14 @@ interface XRInputSourcesChangeEvent : Event
getter removed getter removed
getter session getter session
method constructor method constructor
interface XRJointPose : XRPose
attribute @@toStringTag
getter radius
method constructor
interface XRJointSpace : XRSpace
attribute @@toStringTag
getter jointName
method constructor
interface XRLayer : EventTarget interface XRLayer : EventTarget
attribute @@toStringTag attribute @@toStringTag
method constructor method constructor
......
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