Ray

new Ray(origin?: Vector3, direction?: Vector3)
THREE: THREE.Ray

Infinite ray defined by an origin point and a direction vector. Used by Raycaster for intersection tests.

Differs from THREE.js

intersectBox3/intersectsBox3 instead of intersectBox/intersectsBox.

Properties

NameTypeDescription
origin

Vector3

Ray origin.

direction

Vector3

Ray direction (should be unit length). Default (0, 0, -1).

Methods

MethodDescription
set(origin: Vector3, direction: Vector3): this

Sets origin and direction.

at(t: number, target?: Vector3): Vector3

Returns the point at distance t along the ray.

intersectTriangle(a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean, target?: Vector3): Vector3|undefined

Tests intersection with a triangle. Returns the hit point or undefined.

intersectBox3(box: Box3, target?: Vector3): Vector3|undefined

Tests intersection with an axis-aligned box. Returns the entry point or undefined.

intersectSphere(sphere: Sphere, target?: Vector3): Vector3|undefined

Tests intersection with a sphere. Returns the nearest hit point or undefined.

intersectPlane(plane: Plane, target?: Vector3): Vector3|undefined

Tests intersection with a plane. Returns the hit point or undefined.

applyMatrix4(m: Matrix4): this

Transforms both origin and direction by a 4x4 matrix.

clone(): Ray

Returns a new Ray with the same origin and direction.