Skip to main content

Line3

A geometric line segment represented by a start and end point.

Constructor

Line3

function Line3( start: Vector3, end: Vector3 ): void;  

start - Start of the line segment. Default is (0, 0, 0).
end - End of the line segment. Default is (0, 0, 0).

Creates a new Line3.

Properties

start

start: Vector3;  

Vector3 representing the start point of the line.

end

end: Vector3;  

Vector3 representing the end point of the line.

Methods

applyMatrix4

function applyMatrix4( matrix: Matrix4 ): this;  

Applies a matrix transform to the line segment.

at

function at( t: Float, target: Vector3 ): Vector3;  

t - Use values 0-1 to return a position along the line segment.
target — the result will be copied into this Vector3.

Returns a vector at a certain position along the line. When t = 0, it returns the start vector, and when t = 1 it returns the end vector.

clone

function clone( ): Line3;  

Returns a new Line3 with the same .start and .end vectors as this one.

closestPointToPoint

function closestPointToPoint( point: Vector3, clampToLine: Boolean, target:
Vector3 ): Vector3;

point - return the closest point on the line to this point.
clampToLine - whether to clamp the returned value to the line segment.
target — the result will be copied into this Vector3.

Returns the closets point on the line. If clampToLine is true, then the returned value will be clamped to the line segment.

closestPointToPointParameter

function closestPointToPointParameter( point: Vector3, clampToLine: Boolean ):
Float;

point - the point for which to return a point parameter.
clampToLine - Whether to clamp the result to the range [0, 1].

Returns a point parameter based on the closest point as projected on the line segment. If clampToLine is true, then the returned value will be between 0 and 1.

copy

function copy( line: Line3 ): this;  

Copies the passed line's .start and .end vectors to this line.

delta

function delta( target: Vector3 ): Vector3;  

target — the result will be copied into this Vector3.

Returns the delta vector of the line segment ( .end vector minus the .start vector).

distance

function distance( ): Float;  

Returns the Euclidean distance (straight-line distance) between the line's .start and .end points.

distanceSq

function distanceSq( ): Float;  

Returns the square of the Euclidean distance (straight-line distance) between the line's .start and .end vectors.

equals

function equals( line: Line3 ): Boolean;  

line - Line3 to compare with this one.

Returns true if both line's .start and .end points are equal.

getCenter

function getCenter( target: Vector3 ): Vector3;  

target — the result will be copied into this Vector3.

Returns the center of the line segment.

set

function set( start: Vector3, end: Vector3 ): this;  

.ector3 - set the .start of the line.
.ector3 - set the .end of the line.

Sets the start and end values by copying the provided vectors.

Source

src/math/Line3.js