Ray
Type | Name | Interface Description |
---|---|---|
Variables | direction : Vector3f | • Function: The direction vector of the ray. |
Variables | origin : Vector3f | • Function: The starting vector of the ray. |
Functions | constructor() | • Function: Creates a default ray with both origin and direction initialized to (0, 0, 0). |
Functions | constructor(min: Vector3f, max: Vector3f) | • Function: Create a ray with a specified starting point and direction. |
Functions | equals(other: Ray): boolean | • Function: Checks whether the current ray is equal to another ray. |
Functions | toString(): string | • Function: Returns the string representation of the current ray. |
Functions | clone(): Ray | • Function: Clone |
Examples
direction : Vector3f
const dir = ray.direction;
origin : Vector3f
const origin = ray.origin;
constructor()
let ray = new Ray();
constructor(min: Vector3f, max: Vector3f)
let origin = new Vector3f(0, 0, 0);
let direction = new Vector3f(1, 0, 0);
let ray = new Ray(origin, direction);
equals(other: Ray): boolean
let origin = new Vector3f(0, 0, 0);
let direction = new Vector3f(1, 0, 0);
let ray1 = new Ray(origin, direction);
let ray2 = new Ray(origin, direction);
console.log(ray1.equals(ray2)); // true
toString(): string
let origin = new Vector3f(0, 0, 0);
let direction = new Vector3f(1, 0, 0);
let ray = new Ray(origin, direction);
console.log(ray.toString()); // "Ray(origin: (0, 0, 0), direction: (1, 0, 0))"
clone(): Ray
const newRay = ray.clone();
Use Case
@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
let ray = new APJS.Ray();
ray.origin = new APJS.Vector3f(0,0,0);
ray.direction = new APJS.Vector3f(0,0,1);
console.log(ray.toString());
let ray2 = new APJS.Ray(ray.origin, ray.direction);
console.log(ray2.equals(ray));
console.log(ray2.clone());
}
onUpdate(deltaTime: number) {
}
}