clamp method

Vector3 clamp(
  1. Vector3 min,
  2. Vector3 max
)

Ensures this 3D vector lies in the given min/max range.

Implementation

Vector3 clamp(Vector3 min, Vector3 max ) {
	x = math.max( min.x, math.min( max.x, x ) );
	y = math.max( min.y, math.min( max.y, y ) );
	z = math.max( min.z, math.min( max.z, z ) );

	return this;
}