Class BoundingBox
חבילה: @aspose/3d (v24.12.0)
BoundingBox מייצג תיבת גבול מיושרת לציר (AABB) במרחב תלת‑ממדי. הוא מאחסן minimum פינה ו maximum פינה כעצמים פשוטים עם x, y, z שדות. אובייקט שנבנה זה עתה BoundingBox() בלי ארגומנטים נמצא במצב “null” — minimum מחזיר +Infinity ו maximum מחזיר -Infinity — ומתרחב כראוי כאשר נקודות מתווספות דרך merge(). BoundingBox מיוצא מה @aspose/3d/utilities תת‑נתיב.
export class BoundingBoximport { BoundingBox } from '@aspose/3d/utilities';ColladaSaveOptions
חשב תיבת גבול עבור קבוצת נקודות.
import { BoundingBox, Vector3 } from '@aspose/3d/utilities';
const points = [
new Vector3(-1, 0, -1),
new Vector3(1, 2, 1),
new Vector3(0, -0.5, 0),
];
const bbox = new BoundingBox();
for (const p of points) {
bbox.merge(p);
}
console.log(`Min: (${bbox.minimum.x}, ${bbox.minimum.y}, ${bbox.minimum.z})`);
// Min: (-1, -0.5, -1)
console.log(`Max: (${bbox.maximum.x}, ${bbox.maximum.y}, ${bbox.maximum.z})`);
// Max: (1, 2, 1)
const c = bbox.center;
console.log(`Center: (${c.x}, ${c.y.toFixed(3)}, ${c.z})`);
// Center: (0, 0.750, 0)
ColladaSaveOptions
| ColladaSaveOptions | ColladaSaveOptions |
|---|---|
new BoundingBox() | יוצר תיבת גבול null. מתרחב כאשר merge() נקרא. |
new BoundingBox(minimum, maximum) | יוצר קופסה משניים {x, y, z} אובייקטים של פינה. |
new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ) | יוצר קופסה משישה רכיבים סקלריים. |
מאפיינים סטטיים
| ColladaSaveOptions | ColladaSaveOptions | ColladaSaveOptions |
|---|---|---|
BoundingBox.null | BoundingBox | תיבת גבול null (ללא ממדים, לא מאותחלת). |
BoundingBox.infinite | BoundingBox | תיבה המתפרסת על כל טווח המספרים מ -Infinity עד +Infinity. |
ColladaSaveOptions
שמות חשובים: BoundingBox משתמש ב minimum ו maximum — לא min ו max.
| ColladaSaveOptions | ColladaSaveOptions | ColladaSaveOptions |
|---|---|---|
minimum | {x: number, y: number, z: number} (קריאה בלבד) | הקצה עם ערכי x, y, z הקטנים ביותר. מחזיר +Infinity בכל ציר כאשר התיבה ריקה. |
maximum | {x: number, y: number, z: number} (קריאה בלבד) | הקצה עם ערכי x, y, z הגדולים ביותר. מחזיר -Infinity בכל ציר כאשר התיבה ריקה. |
center | {x: number, y: number, z: number} (קריאה בלבד) | המרכז הגאומטרי, מחושב כ (minimum + maximum) / 2. מחזיר (0, 0, 0) כאשר ריק. |
size | {x: number, y: number, z: number} (קריאה בלבד) | ממדי הקופסה: maximum - minimum לכל ציר. |
extent | BoundingBoxExtent (קריאה בלבד) | חצי-קיצוצים לאורך כל ציר. כל שדה הוא Math.abs(size / 2). |
ColladaSaveOptions
merge(point)
מרחיב את תיבת הגבול כדי לכלול נקודה. מקבל {x, y, z} אובייקט, a Vector3, מערך של 3 מספרים, או שלושה נפרדים (x, y, z) ארגומנטים.
merge(point: Vector3 | {x: number, y: number, z: number}): void
merge(x: number, y: number, z: number): voidColladaSaveOptions
import { BoundingBox, Vector3 } from '@aspose/3d/utilities';
const bb = new BoundingBox();
bb.merge(new Vector3(2, 3, 4));
bb.merge(-1, 0, 0);
console.log(`Min X: ${bb.minimum.x}`); // Min X: -1
console.log(`Max Y: ${bb.maximum.y}`); // Max Y: 3
contains(arg)
ColladaSaveOptions true אם הנקודה או תיבת הגבול הנתונה נמצאות במלואן בתוך תיבה זו. מקבל {x, y, z} אובייקט נקודה, a Vector3, או אחר BoundingBox.
contains(arg: Vector3 | {x: number, y: number, z: number} | BoundingBox): booleanColladaSaveOptions
import { BoundingBox, Vector3 } from '@aspose/3d/utilities';
const bb = new BoundingBox(-1, -1, -1, 1, 1, 1);
console.log(bb.contains(new Vector3(0, 0, 0))); // true
console.log(bb.contains(new Vector3(2, 0, 0))); // false
overlapsWith(box)
ColladaSaveOptions true אם תיבת הגבול הזו חופפת עם תיבה אחרת BoundingBox (קצוות שנוגעים נחשבים כחופפים).
overlapsWith(box: BoundingBox): booleanscale()
מחזיר את ערך הקואורדינטה המוחלטת המקסימלי בכל הפינות, המייצג את הסקלה הדומיננטית של תיבת הגבול. מחזיר 0 כאשר התיבה היא null.
scale(): numberBoundingBoxExtent
BoundingBoxExtent הוא מחלקה נלווית שמוחזרת על ידי BoundingBox.extent. היא מאחסנת חצי-קיצוצים לאורך כל ציר.
| ColladaSaveOptions | ColladaSaveOptions | ColladaSaveOptions |
|---|---|---|
extentX | number | חצי-רוחב לאורך X. |
extentY | number | חצי-גובה לאורך Y. |
extentZ | number | חצי-עומק לאורך Z. |