three.js Frustum

2023-02-16 17:46 更新

Frustums 用于确定相机视野内的东西。 它有助于加速渲染过程——位于摄像机视锥体外的物体可以安全地排除在渲染之外。

该类主要用于渲染器内部计算 camera 或 shadowCamera的视锥体。

构造器(Constructor)

Frustum(p0 : Plane, p1 : Plane, p2 : Plane, p3 : Plane, p4 : Plane, p5 : Plane)

p0 - (可选参数) Plane.
p1 - (可选参数) Plane.
p2 - (可选参数) Plane.
p3 - (可选参数) Plane.
p4 - (可选参数) Plane.
p5 - (可选参数) Plane.

使用6个面来构建一个视锥体。

属性(Properties)

.planes : Array

包含6个平面 planes 的数组。

方法(Methods)

.clone () : Frustum

返回一个与当前对象有相同参数的视锥体。

.containsPoint ( point : Vector3 ) : Boolean

point - Vector3 被检测的点。

检测该点 point 是否在视锥体内。

.copy ( frustum : Frustum ) : this

frustum - 用于拷贝的视锥体。

将传入 frustum 的属性拷贝到当前对象。

.intersectsBox ( box : Box3 ) : Boolean

box - Box3 用于检测是否要交的包围盒。

返回 true 如果该 box 与视锥体相交。

.intersectsObject ( object : Object3D ) : Boolean

检测 object 的包围球 bounding sphere 是否与视锥体相交。

注意:该对象必须有一个 BufferGeometry ,因为这样才能计算出包围球。

.intersectsSphere ( sphere : Sphere ) : Boolean

sphere - Sphere 用于检查是否相交。

返回true 如果球sphere与视锥体相交。

.intersectsSprite ( sprite : Sprite ) : Boolean

检查精灵sprite是否与截锥体相交。

.set ( p0 : Plane, p1 : Plane, p2 : Plane, p3 : Plane, p4 : Plane, p5 : Plane ) : this

从传入的平面设置当前视锥体。没有隐式的顺序。

请注意,此方法仅复制给定对象的值。

.setFromProjectionMatrix ( matrix : Matrix4 ) : this

matrix - 投影矩阵 Matrix4 会被用来设置该视椎体的 planes

根据投影矩阵 matrix 来设置当前视椎体的六个面。

源码

src/math/Frustum.js


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号