private void updateForHand(Leap.Hand hand, GrabSwitch grabSwitch, ref float lastPinchStrength, ref bool switchWithinRange, InteractionHand optionalIntHand) { if (hand == null) { grabSwitch.grasped = false; lastPinchStrength = 0.0f; return; } var curPinchStrength = hand.PinchStrength; var curPinchPosition = hand.GetPredictedPinchPosition(); switchWithinRange = Vector3.Distance(curPinchPosition, this.transform.position) < _widgetRadius && (optionalIntHand == null || (!optionalIntHand.isGraspingObject && (!optionalIntHand.isPrimaryHovering || optionalIntHand.primaryHoverDistance > 0.05f))); if (curPinchStrength > 0.7f && lastPinchStrength < 0.7f && switchWithinRange) { grabSwitch.grasped = true; } if (curPinchStrength < 0.3f) { grabSwitch.grasped = false; } grabSwitch.Position = curPinchPosition; grabSwitch.Rotation = hand.Rotation.ToQuaternion(); lastPinchStrength = hand.PinchStrength; }
private void transformSingleAnchor(GrabSwitch singlePinch) { _anchor.position = singlePinch.Position; switch (_oneHandedRotationMethod) { case RotationMethod.None: break; case RotationMethod.Single: Vector3 p = singlePinch.Rotation * Vector3.right; p.y = _anchor.position.y; _anchor.LookAt(p); break; case RotationMethod.Full: _anchor.rotation = singlePinch.Rotation; break; } _anchor.localScale = Vector3.one; }