summaryrefslogtreecommitdiffstats
path: root/modules/webxr/native
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webxr/native')
-rw-r--r--modules/webxr/native/library_godot_webxr.js25
-rw-r--r--modules/webxr/native/webxr.externs.js56
2 files changed, 75 insertions, 6 deletions
diff --git a/modules/webxr/native/library_godot_webxr.js b/modules/webxr/native/library_godot_webxr.js
index fe47de02b0..c048bb2197 100644
--- a/modules/webxr/native/library_godot_webxr.js
+++ b/modules/webxr/native/library_godot_webxr.js
@@ -318,9 +318,11 @@ const GodotWebXR = {
// callback don't bubble up here and cause Godot to try the
// next reference space.
window.setTimeout(function () {
- const c_str = GodotRuntime.allocString(reference_space_type);
- onstarted(c_str);
- GodotRuntime.free(c_str);
+ const reference_space_c_str = GodotRuntime.allocString(reference_space_type);
+ const enabled_features_c_str = GodotRuntime.allocString(Array.from(session.enabledFeatures).join(","));
+ onstarted(reference_space_c_str, enabled_features_c_str);
+ GodotRuntime.free(reference_space_c_str);
+ GodotRuntime.free(enabled_features_c_str);
}, 0);
}
@@ -479,8 +481,8 @@ const GodotWebXR = {
},
godot_webxr_update_input_source__proxy: 'sync',
- godot_webxr_update_input_source__sig: 'iiiiiiiiiiii',
- godot_webxr_update_input_source: function (p_input_source_id, r_target_pose, r_target_ray_mode, r_touch_index, r_has_grip_pose, r_grip_pose, r_has_standard_mapping, r_button_count, r_buttons, r_axes_count, r_axes) {
+ godot_webxr_update_input_source__sig: 'iiiiiiiiiiiiiii',
+ godot_webxr_update_input_source: function (p_input_source_id, r_target_pose, r_target_ray_mode, r_touch_index, r_has_grip_pose, r_grip_pose, r_has_standard_mapping, r_button_count, r_buttons, r_axes_count, r_axes, r_has_hand_data, r_hand_joints, r_hand_radii) {
if (!GodotWebXR.session || !GodotWebXR.frame) {
return 0;
}
@@ -563,6 +565,19 @@ const GodotWebXR = {
GodotRuntime.setHeapValue(r_button_count, button_count, 'i32');
GodotRuntime.setHeapValue(r_axes_count, axes_count, 'i32');
+ // Hand tracking data.
+ let has_hand_data = false;
+ if (input_source.hand && r_hand_joints != 0 && r_hand_radii != 0) {
+ const hand_joint_array = new Float32Array(25 * 16);
+ const hand_radii_array = new Float32Array(25);
+ if (frame.fillPoses(input_source.hand.values(), space, hand_joint_array) && frame.fillJointRadii(input_source.hand.values(), hand_radii_array)) {
+ GodotRuntime.heapCopy(HEAPF32, hand_joint_array, r_hand_joints);
+ GodotRuntime.heapCopy(HEAPF32, hand_radii_array, r_hand_radii);
+ has_hand_data = true;
+ }
+ }
+ GodotRuntime.setHeapValue(r_has_hand_data, has_hand_data ? 1 : 0, 'i32');
+
return true;
},
diff --git a/modules/webxr/native/webxr.externs.js b/modules/webxr/native/webxr.externs.js
index 7f7c297acc..35ad33fa93 100644
--- a/modules/webxr/native/webxr.externs.js
+++ b/modules/webxr/native/webxr.externs.js
@@ -229,7 +229,6 @@ XRFrame.prototype.session;
XRFrame.prototype.getViewerPose = function (referenceSpace) {};
/**
- *
* @param {XRSpace} space
* @param {XRSpace} baseSpace
* @return {XRPose}
@@ -237,6 +236,21 @@ XRFrame.prototype.getViewerPose = function (referenceSpace) {};
XRFrame.prototype.getPose = function (space, baseSpace) {};
/**
+ * @param {Array<XRSpace>} spaces
+ * @param {XRSpace} baseSpace
+ * @param {Float32Array} transforms
+ * @return {boolean}
+ */
+XRFrame.prototype.fillPoses = function (spaces, baseSpace, transforms) {};
+
+/**
+ * @param {Array<XRJointSpace>} jointSpaces
+ * @param {Float32Array} radii
+ * @return {boolean}
+ */
+XRFrame.prototype.fillJointRadii = function (jointSpaces, radii) {};
+
+/**
* @constructor
*/
function XRReferenceSpace() {};
@@ -499,12 +513,52 @@ XRInputSource.prototype.targetRayMode;
XRInputSource.prototype.targetRaySpace;
/**
+ * @type {?XRHand}
+ */
+XRInputSource.prototype.hand;
+
+/**
+ * @constructor
+ */
+function XRHand() {};
+
+/**
+ * Note: In fact, XRHand acts like a Map<string, XRJointSpace>, but I don't know
+ * how to represent that here. So, we're just giving the one method we call.
+ *
+ * @return {Array<XRJointSpace>}
+ */
+XRHand.prototype.values = function () {};
+
+/**
+ * @type {number}
+ */
+XRHand.prototype.size;
+
+/**
+ * @param {string} key
+ * @return {XRJointSpace}
+ */
+XRHand.prototype.get = function (key) {};
+
+/**
* @constructor
*/
function XRSpace() {};
/**
* @constructor
+ * @extends {XRSpace}
+ */
+function XRJointSpace() {};
+
+/**
+ * @type {string}
+ */
+XRJointSpace.prototype.jointName;
+
+/**
+ * @constructor
*/
function XRPose() {};