summaryrefslogtreecommitdiffstats
path: root/modules/webxr/native/library_godot_webxr.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webxr/native/library_godot_webxr.js')
-rw-r--r--modules/webxr/native/library_godot_webxr.js25
1 files changed, 20 insertions, 5 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;
},