Esempio n. 1
0
        public static Vector3 ProjectWorldPositionOnHandle(InteractiveHandle handle, Vector3 position)
        {
            if (handle == null)
            {
                return(Vector3.zero);
            }

            return(handle.GetProjectionPlane(position).ClosestPointOnPlane(position));
        }
Esempio n. 2
0
        public static Vector3 ProjectScreenPositionOnHandle(InteractiveHandle handle, Vector2 screenPosition, Camera camera)
        {
            if (handle == null || camera == null)
            {
                return(Vector3.zero);
            }

            var plane = handle.GetProjectionPlane(camera.transform.position);
            var ray   = camera.ScreenPointToRay(screenPosition);

            float hitDistance;

            if (!plane.Raycast(ray, out hitDistance))
            {
                return(handle.transform.position);
            }

            return(ray.origin + ray.direction * hitDistance);
        }