import { BoundingBox } from "./BoundingBox" ; import { BoundingSphere } from "./BoundingSphere" ; import { CollisionUtil } from "./CollisionUtil" ; import { Plane } from "./Plane" ; import { Vector3 } from "./Vector3" ; /**
 * Represents a ray with an origin and a direction in 3D space.
 */ export class Ray { /** The origin of the ray. */ readonly origin : Vector3 = new Vector3 ( ) ; /** The normalized direction of the ray. */ readonly direction : Vector3 = new Vector3 ( ) ; param origin param direction constructor ( origin = null , direction = null ) { origin && origin . cloneTo ( this . origin ) ; direction && direction . cloneTo ( this . direction ) ; } param plane returns intersectPlane ( plane ) { return CollisionUtil . intersectsRayAndPlane ( this , plane ) ; } param sphere returns intersectSphere ( sphere ) { return CollisionUtil . intersectsRayAndSphere ( this , sphere ) ; } param box returns intersectBox ( box ) { return CollisionUtil . intersectsRayAndBox ( this , box ) ; } param distance param out returns getPoint ( distance , out ) { Vector3 . scale ( this . direction , distance , out ) ; return out . add ( this . origin ) ; } }