@@ -20,10 +20,9 @@ import android.app.Activity
2020import androidx.activity.ComponentActivity
2121import androidx.lifecycle.lifecycleScope
2222import androidx.xr.arcore.Hand
23+ import androidx.xr.arcore.HandJointType
2324import androidx.xr.runtime.Config
24- import androidx.xr.runtime.HandJointType
2525import androidx.xr.runtime.Session
26- import androidx.xr.runtime.SessionConfigureConfigurationNotSupported
2726import androidx.xr.runtime.SessionConfigureSuccess
2827import androidx.xr.runtime.math.Pose
2928import androidx.xr.runtime.math.Quaternion
@@ -40,11 +39,9 @@ fun ComponentActivity.configureSession(session: Session) {
4039 handTracking = Config .HandTrackingMode .BOTH
4140 )
4241 when (val result = session.configure(newConfig)) {
43- is SessionConfigureConfigurationNotSupported ->
44- TODO (/* Some combinations of configurations are not valid. Handle this failure case. */ )
4542 is SessionConfigureSuccess -> TODO (/* Success! */ )
4643 else ->
47- TODO (/* A different unhandled exception was thrown . */ )
44+ TODO (/* The session could not be configured. See SessionConfigureResult for possible causes . */ )
4845 }
4946 // [END androidxr_arcore_hand_configure]
5047}
@@ -80,7 +77,7 @@ fun ComponentActivity.renderPlanetAtHandPalm(leftHandState: Hand.State) {
8077 val session: Session = null !!
8178 val palmEntity: GltfModelEntity = null !!
8279 // [START androidxr_arcore_hand_entityAtHandPalm]
83- val palmPose = leftHandState.handJoints[HandJointType .PALM ] ? : return
80+ val palmPose = leftHandState.handJoints[HandJointType .HAND_JOINT_TYPE_PALM ] ? : return
8481
8582 // the down direction points in the same direction as the palm
8683 val angle = Vector3 .angleBetween(palmPose.rotation * Vector3 .Down , Vector3 .Up )
@@ -101,7 +98,7 @@ fun ComponentActivity.renderPlanetAtFingerTip(rightHandState: Hand.State) {
10198 val indexFingerEntity: GltfModelEntity = null !!
10299
103100 // [START androidxr_arcore_hand_entityAtIndexFingerTip]
104- val tipPose = rightHandState.handJoints[HandJointType .INDEX_TIP ] ? : return
101+ val tipPose = rightHandState.handJoints[HandJointType .HAND_JOINT_TYPE_INDEX_TIP ] ? : return
105102
106103 // the forward direction points towards the finger tip.
107104 val angle = Vector3 .angleBetween(tipPose.rotation * Vector3 .Forward , Vector3 .Up )
@@ -120,9 +117,9 @@ fun ComponentActivity.renderPlanetAtFingerTip(rightHandState: Hand.State) {
120117
121118private fun detectPinch (session : Session , handState : Hand .State ): Boolean {
122119 // [START androidxr_arcore_hand_pinch_gesture]
123- val thumbTip = handState.handJoints[HandJointType .THUMB_TIP ] ? : return false
120+ val thumbTip = handState.handJoints[HandJointType .HAND_JOINT_TYPE_THUMB_TIP ] ? : return false
124121 val thumbTipPose = session.scene.perceptionSpace.transformPoseTo(thumbTip, session.scene.activitySpace)
125- val indexTip = handState.handJoints[HandJointType .INDEX_TIP ] ? : return false
122+ val indexTip = handState.handJoints[HandJointType .HAND_JOINT_TYPE_INDEX_TIP ] ? : return false
126123 val indexTipPose = session.scene.perceptionSpace.transformPoseTo(indexTip, session.scene.activitySpace)
127124 return Vector3 .distance(thumbTipPose.translation, indexTipPose.translation) < 0.05
128125 // [END androidxr_arcore_hand_pinch_gesture]
@@ -136,8 +133,8 @@ private fun detectStop(session: Session, handState: Hand.State): Boolean {
136133 val forward2 = handState.handJoints[joint2]?.forward ? : return false
137134 return Vector3 .angleBetween(forward1, forward2) < threshold
138135 }
139- return pointingInSameDirection(HandJointType .INDEX_PROXIMAL , HandJointType .INDEX_TIP ) &&
140- pointingInSameDirection(HandJointType .MIDDLE_PROXIMAL , HandJointType .MIDDLE_TIP ) &&
141- pointingInSameDirection(HandJointType .RING_PROXIMAL , HandJointType .RING_TIP )
136+ return pointingInSameDirection(HandJointType .HAND_JOINT_TYPE_INDEX_PROXIMAL , HandJointType .HAND_JOINT_TYPE_INDEX_TIP ) &&
137+ pointingInSameDirection(HandJointType .HAND_JOINT_TYPE_MIDDLE_PROXIMAL , HandJointType .HAND_JOINT_TYPE_MIDDLE_TIP ) &&
138+ pointingInSameDirection(HandJointType .HAND_JOINT_TYPE_RING_PROXIMAL , HandJointType .HAND_JOINT_TYPE_RING_TIP )
142139 // [END androidxr_arcore_hand_stop_gesture]
143140}
0 commit comments