hand_info.gd 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. extends Node3D
  2. @export_enum("Left", "Right") var hand : int = 0
  3. # Called every frame. 'delta' is the elapsed time since the previous frame.
  4. func _process(delta):
  5. var text = ""
  6. if hand == 0:
  7. text += "Left hand\n"
  8. else:
  9. text += "Right hand\n"
  10. var controller_tracker : XRPositionalTracker = XRServer.get_tracker("left_hand" if hand == 0 else "right_hand")
  11. if controller_tracker:
  12. var profile = controller_tracker.profile.replace("/interaction_profiles/", "").replace("/", " ")
  13. text += "\nProfile: " + profile + "\n"
  14. var pose : XRPose = controller_tracker.get_pose("pose")
  15. if pose:
  16. if pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_NONE:
  17. text += "- No tracking data\n"
  18. elif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_LOW:
  19. text += "- Low confidence tracking data\n"
  20. elif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_HIGH:
  21. text += "- High confidence tracking data\n"
  22. else:
  23. text += "- Unknown tracking data %d \n" % [ pose.tracking_confidence ]
  24. else:
  25. text += "- No pose data\n"
  26. else:
  27. text += "\nNo controller tracker found!\n"
  28. var hand_tracker : XRHandTracker = XRServer.get_tracker("/user/hand_tracker/left" if hand == 0 else "/user/hand_tracker/right")
  29. if hand_tracker:
  30. text += "\nHand tracker found\n"
  31. if hand_tracker.has_tracking_data:
  32. if hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_UNKNOWN:
  33. text += "- Source: unknown\n"
  34. elif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_UNOBSTRUCTED:
  35. text += "- Source: optical hand tracking\n"
  36. elif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_CONTROLLER:
  37. text += "- Source: inferred from controller\n"
  38. else:
  39. text += "- Source: %d\n" % [ hand_tracker.hand_tracking_source ]
  40. else:
  41. text += "- No tracking data\n"
  42. else:
  43. text += "\nNo hand tracker found!\n"
  44. $Info.text = text