예제 #1
0
        public static Vector3 GetHitPosition(this Bezier3 bezier, Segment3 ray, out float rayT, out float bezierT, out Vector3 position)
        {
            var hitPos = ray.GetRayPosition(bezier.Position(0.5f).y, out rayT);

            bezier.ClosestPositionAndDirection(hitPos, out position, out _, out bezierT);

            for (var i = 0; i < 3 && Mathf.Abs(hitPos.y - position.y) > 1f; i += 1)
            {
                hitPos = ray.GetRayPosition(position.y, out rayT);
                bezier.ClosestPositionAndDirection(hitPos, out position, out _, out bezierT);
            }

            return(hitPos);
        }
예제 #2
0
 public static Vector3 ClosestDirection(this Bezier3 bezier, Vector3 point)
 {
     bezier.ClosestPositionAndDirection(point, out _, out var direction, out _);
     return(direction);
 }