Skip to main content

Ray

TypeNameInterface Description
Variablesdirection : Vector3f

Function: The direction vector of the ray.

Variablesorigin : Vector3f

Function: The starting vector of the ray.

Functionsconstructor()

Function: Creates a default ray with both origin and direction initialized to (0, 0, 0).

Functionsconstructor(min: Vector3f, max: Vector3f)

Function: Create a ray with a specified starting point and direction.

Functionsequals(other: Ray): boolean

Function: Checks whether the current ray is equal to another ray.

FunctionstoString(): string

Function: Returns the string representation of the current ray.

Functionsclone(): 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) {
}
}

DemoRayAPI.zip

Copyright © 2025 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalCookies