4 using System.Collections.Generic;
7 namespace HoloToolkit.Unity.InputModule.Utilities.Interactions
20 private Vector3 m_startObjectScale;
21 private float m_startHandDistanceMeters;
28 public virtual void Setup(Dictionary<uint, Vector3> handsPressedMap, Transform manipulationRoot)
30 m_startHandDistanceMeters = GetMinDistanceBetweenHands(handsPressedMap);
31 m_startObjectScale = manipulationRoot.transform.localScale;
39 public virtual Vector3
UpdateMap(Dictionary<uint, Vector3> handsPressedMap)
41 var ratioMultiplier = GetMinDistanceBetweenHands(handsPressedMap) / m_startHandDistanceMeters;
42 return m_startObjectScale * ratioMultiplier;
45 private float GetMinDistanceBetweenHands(Dictionary<uint, Vector3> handsPressedMap)
47 var result =
float.MaxValue;
48 Vector3[] handLocations =
new Vector3[handsPressedMap.Values.Count];
49 handsPressedMap.Values.CopyTo(handLocations, 0);
50 for (
int i = 0; i < handLocations.Length; i++)
52 for (
int j = i + 1; j < handLocations.Length; j++)
54 var distance = Vector3.Distance(handLocations[i], handLocations[j]);
55 if (distance < result)