codecamp

three.js OBB

表示 3D 空间中的定向边界框 (OBB)。

示例

webgl_math_obb

构造函数

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

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

halfSize — OBB 沿每个轴的正半宽范围。 (可选的)

rotation — OBB 的旋转。 (可选的)

创建一个新的 OBB。

属性

.center : Vector3

OBB 的中心。默认为 ( 0, 0, 0 )。

.halfSize : Vector3

OBB 沿每个轴的正半宽范围。默认为 ( 0, 0, 0 )。

.rotation : Matrix3

OBB 的旋转。默认为单位矩阵。

方法

.applyMatrix4 ( matrix : Matrix4 ) : this

matrix — 一个 4x4 变换矩阵。

将给定的转换矩阵应用于此 OBB。此方法可用于使用 3D 对象的世界矩阵转换边界体积,以便使两个实体保持同步。

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

point — 应夹在该 OBB 范围内的点。

clampedPoint — 结果将被复制到这个向量中。

将给定点限制在该 OBB 的范围内。

.clone () : OBB

为此实例创建一个克隆的 OBB。

.containsPoint ( point : Vector3 ) : Boolean

point — 要测试的点。

给定点是否位于此 OBB 内。

.copy ( obb : OBB ) : this

obb — 要复制的 OBB。

将给定 OBB 的属性复制到此 OBB。

.equals ( obb : OBB ) : Boolean

obb — 要测试的 OBB。

给定的 OBB 是否等于此 OBB。

.fromBox3 ( box3 : Box3 ) : this

box3 — AABB。

根据给定的 AABB 定义一个 OBB。

.getSize ( size : Vector3 ) : Vector3

size — 结果将被复制到这个向量中。

将此 OBB 的大小返回到给定向量中。

.intersectsBox3 ( box3 : Box3 ) : Boolean

box3 — AABB 进行测试。

给定的 AABB 是否与该 OBB 相交。

.intersectsSphere ( sphere : Sphere ) : Boolean

sphere — 要测试的边界球体。

给定的边界球体是否与该 OBB 相交。

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

obb — 要测试的 OBB。

epsilon — 用于抵消算术错误的可选数值。默认值为 Number.EPSILON。

给定的 OBB 是否与该 OBB 相交。

.intersectsRay ( ray : Ray ) : Boolean

ray — 要测试的射线。

给定的射线是否与该 OBB 相交。

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

ray — 要测试的射线。

intersectionPoint — 结果将被复制到这个向量中。

执行 Ray/OBB 相交测试并将交点存储到给定的 3D 矢量。如果未检测到交集,则返回 null。

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

center — OBB 的中心。

halfSize — OBB 沿每个轴的正半宽范围。

rotation — OBB 的旋转。

定义给定值的 OBB。

源码

examples/jsm/math/OBB.js


three.js MeshSurfaceSampler
three.js Face
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

参考

核心 / BufferAttributes

渲染器 / WebXR

开发者参考

WebGL渲染器

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }