three.js OBB

2023-02-16 17:51 更新

表示 3D 空間中的定向邊界框 (OBB)。

示例

webgl_math_obb

構(gòu)造函數(shù)

OBB( center : Vector3, halfSize : Vector3, rotation : Matrix3 )

center — OBB 的中心。 (可選的)

halfSize — OBB 沿每個(gè)軸的正半寬范圍。 (可選的)

rotation — OBB 的旋轉(zhuǎn)。 (可選的)

創(chuàng)建一個(gè)新的 OBB。

屬性

.center : Vector3

OBB 的中心。默認(rèn)為 ( 0, 0, 0 )。

.halfSize : Vector3

OBB 沿每個(gè)軸的正半寬范圍。默認(rèn)為 ( 0, 0, 0 )。

.rotation : Matrix3

OBB 的旋轉(zhuǎn)。默認(rèn)為單位矩陣。

方法

.applyMatrix4 ( matrix : Matrix4 ) : this

matrix — 一個(gè) 4x4 變換矩陣。

將給定的轉(zhuǎn)換矩陣應(yīng)用于此 OBB。此方法可用于使用 3D 對象的世界矩陣轉(zhuǎn)換邊界體積,以便使兩個(gè)實(shí)體保持同步。

.clampPoint ( point : Vector3, clampedPoint : Vector3 ) : Vector3

point — 應(yīng)夾在該 OBB 范圍內(nèi)的點(diǎn)。

clampedPoint — 結(jié)果將被復(fù)制到這個(gè)向量中。

將給定點(diǎn)限制在該 OBB 的范圍內(nèi)。

.clone () : OBB

為此實(shí)例創(chuàng)建一個(gè)克隆的 OBB。

.containsPoint ( point : Vector3 ) : Boolean

point — 要測試的點(diǎn)。

給定點(diǎn)是否位于此 OBB 內(nèi)。

.copy ( obb : OBB ) : this

obb — 要復(fù)制的 OBB。

將給定 OBB 的屬性復(fù)制到此 OBB。

.equals ( obb : OBB ) : Boolean

obb — 要測試的 OBB。

給定的 OBB 是否等于此 OBB。

.fromBox3 ( box3 : Box3 ) : this

box3 — AABB。

根據(jù)給定的 AABB 定義一個(gè) OBB。

.getSize ( size : Vector3 ) : Vector3

size — 結(jié)果將被復(fù)制到這個(gè)向量中。

將此 OBB 的大小返回到給定向量中。

.intersectsBox3 ( box3 : Box3 ) : Boolean

box3 — AABB 進(jìn)行測試。

給定的 AABB 是否與該 OBB 相交。

.intersectsSphere ( sphere : Sphere ) : Boolean

sphere — 要測試的邊界球體。

給定的邊界球體是否與該 OBB 相交。

.intersectsOBB ( obb : OBB, epsilon : Number ) : Boolean

obb — 要測試的 OBB。

epsilon — 用于抵消算術(shù)錯(cuò)誤的可選數(shù)值。默認(rèn)值為 Number.EPSILON。

給定的 OBB 是否與該 OBB 相交。

.intersectsRay ( ray : Ray ) : Boolean

ray — 要測試的射線。

給定的射線是否與該 OBB 相交。

.intersectRay ( ray : Ray, intersectionPoint : Vector3 ) : Vector3

ray — 要測試的射線。

intersectionPoint — 結(jié)果將被復(fù)制到這個(gè)向量中。

執(zhí)行 Ray/OBB 相交測試并將交點(diǎn)存儲到給定的 3D 矢量。如果未檢測到交集,則返回 null。

.set ( center : Vector3, halfSize : Vector3, rotation : Matrix3 ) : this

center — OBB 的中心。

halfSize — OBB 沿每個(gè)軸的正半寬范圍。

rotation — OBB 的旋轉(zhuǎn)。

定義給定值的 OBB。

源碼

examples/jsm/math/OBB.js


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號