AABB
Type | Name | Interface Description |
---|---|---|
Variables | maxX: number | • Function: The maximum X coordinate of the bounding box. |
Variables | maxY: number | • Function: The maximum Y coordinate of the bounding box. |
Variables | maxZ: number | • Function: The maximum Z coordinate of the bounding box. |
Variables | minX: number | • Function: The minimum X coordinate of the bounding box. |
Variables | minY: number | • Function: The minimum Y coordinate of the bounding box. |
Variables | minZ: number | • Function: The minimum Z coordinate of the bounding box. |
Example
console.log('minX', this.aabb.minX);
console.log('minY', this.aabb.minY);
console.log('minZ', this.aabb.minZ);
console.log('maxX', this.aabb.maxX);
console.log('maxY', this.aabb.maxY);
console.log('maxZ', this.aabb.maxZ);
Type | Name | Interface Description |
---|---|---|
Functions | constructor() | • Function: Creates a default bounding box instance with both the minimum and maximum values initialized to 0. |
Functions | constructor(min: Vector3f, max: Vector3f) | • Function: Create an instance of a bounding box with specified minimum and maximum values. |
Examples
constructor()
let aabb = new AABB();
constructor(min: Vector3f, max: Vector3f)
let min = new Vector3f(0, 0, 0);
let max = new Vector3f(10, 10, 10);
let aabb = new AABB(min, max);
Use Case
@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
private firstFrame = true;
private time = 0.0;
private aabb: APJS.AABB = new APJS.AABB(new APJS.Vector3f(-1,-1,-1), new APJS.Vector3f(1,1,1));
onStart() {
}
onUpdate(deltaTime: number) {
if (this.firstFrame) {
this.firstFrame = false;
console.log('minX', this.aabb.minX);
console.log('minY', this.aabb.minY);
console.log('minZ', this.aabb.minZ);
console.log('maxX', this.aabb.maxX);
console.log('maxY', this.aabb.maxY);
console.log('maxZ', this.aabb.maxZ);
}
}
}
Type | Name | Interface Description |
---|---|---|
Functions | equals(v: AABB): boolean | • Function: Checks whether the current bounding box is equal to another bounding box. |
Functions | toString(): string | • Function: Returns the string representation of the bounding box for easy debugging and logging. |
Functions | intersects(other: AABB): boolean | • Function: Check if the current bounding box intersects with another bounding box. |
Functions | clone(): AABB | • Function: Clone |
Examples
equals(v: AABB): boolean
let aabb1 = new AABB(new Vector3f(0, 0, 0), new Vector3f(10, 10, 10));
let aabb2 = new AABB(new Vector3f(0, 0, 0), new Vector3f(10, 10, 10));
let isEqual = aabb1.equals(aabb2); // true
toString(): string
let aabb = new AABB(new Vector3f(0, 0, 0), new Vector3f(10, 10, 10));
console.log(aabb.toString()); // "AABB(min: (0, 0, 0), max: (10, 10, 10))"
toString(): string
let aabb = new AABB(new Vector3f(0, 0, 0), new Vector3f(10, 10, 10));
console.log(aabb.toString()); // "AABB(min: (0, 0, 0), max: (10, 10, 10))"
intersects(other: AABB): boolean
let aabb1 = new AABB(new Vector3f(0, 0, 0), new Vector3f(10, 10, 10));
let aabb2 = new AABB(new Vector3f(5, 5, 5), new Vector3f(15, 15, 15));
let doesIntersect = aabb1.intersects(aabb2); // true
clone(): AABB
let aabb1 = new AABB(new Vector3f(0, 0, 0), new Vector3f(10, 10, 10));
let aabbCloned = aabb1.clone();
Use Case
@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
private firstFrame = true;
private time = 0.0;
onStart() {
}
onUpdate(deltaTime: number) {
if (this.firstFrame) {
this.firstFrame = false;
let aabb1 = new APJS.AABB(new APJS.Vector3f(0, 0, 0), new APJS.Vector3f(10, 10, 10));
let aabb2 = new APJS.AABB(new APJS.Vector3f(0, 0, 0), new APJS.Vector3f(10, 10, 10));
let isEqual = aabb1.equals(aabb2); // true
let isIntersect = aabb1.intersects(aabb2); // true
let aabbCloned = aabb1.clone();
console.log(isEqual, isIntersect, aabbCloned.toString());
}
}
}