视锥体由 6 个平面定义。
每个平面由一个
Cartesian4 对象表示,其中 x、y 和 z 分量
定义了法向量的单位向量,而 w 分量是平面离原点/相机位置的距离。
| Name | Type | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
具有以下属性的对象:
|
Example:
const frustum = new Cesium.PerspectiveOffCenterFrustum({
left : -1.0,
right : 1.0,
top : 1.0,
bottom : -1.0,
near : 1.0,
far : 100.0
});
See:
Members
定义底部裁剪平面。
-
Default Value:
undefined
远平面的距离。
-
Default Value:
500000000.0
readonly infiniteProjectionMatrix : Matrix4
获取从视锥体计算出的透视投影矩阵,具有无限远平面。
定义左侧裁剪平面。
-
Default Value:
undefined
近平面的距离。
-
Default Value:
1.0
readonly projectionMatrix : Matrix4
获取从视锥体计算出的透视投影矩阵。
如果任何视锥体参数发生变化,投影矩阵将被重新计算。
定义右侧裁剪平面。
-
Default Value:
undefined
定义顶部裁剪平面。
-
Default Value:
undefined
Methods
返回一个 PerspectiveOffCenterFrustum 实例的副本。
| Name | Type | Description |
|---|---|---|
result |
PerspectiveOffCenterFrustum | optional 存储结果的对象. |
Returns:
修改后的结果参数或如果未提供,则返回一个新的 PerspectiveOffCenterFrustum 实例。
computeCullingVolume(position, direction, up) → CullingVolume
为此视锥体创建一个剔除体。
| Name | Type | Description |
|---|---|---|
position |
Cartesian3 | 眼睛的位置。 |
direction |
Cartesian3 | 视线方向。 |
up |
Cartesian3 | 上方向。 |
Returns:
在给定位置和方向的剔除体。
Example:
// Check if a bounding volume intersects the frustum.
const cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
const intersect = cullingVolume.computeVisibility(boundingVolume);
按组件比较提供的 PerspectiveOffCenterFrustum,并返回
如果相等则为
true,否则为 false。
| Name | Type | Description |
|---|---|---|
other |
PerspectiveOffCenterFrustum | optional 右侧的 PerspectiveOffCenterFrustum。 |
Returns:
如果相等则为
true,否则为 false。
按组件比较提供的 PerspectiveOffCenterFrustum,并返回
如果通过绝对或相对公差测试,则为
true,否则为 false。
| Name | Type | Default | Description |
|---|---|---|---|
other |
PerspectiveOffCenterFrustum | 右侧的 PerspectiveOffCenterFrustum。 | |
relativeEpsilon |
number | 用于相等性测试的相对 epsilon 容差。 | |
absoluteEpsilon |
number |
relativeEpsilon
|
optional 用于平等测试的绝对 epsilon 容差。 |
Returns:
true 如果 this 和 other 在提供的 epsilon 内,false 否则。
getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, pixelRatio, result) → Cartesian2
返回像素在米中的宽度和高度。
| Name | Type | Description |
|---|---|---|
drawingBufferWidth |
number | 绘图缓冲区的宽度。 |
drawingBufferHeight |
number | 绘图缓冲区的高度。 |
distance |
number | 到近平面的距离(以米为单位)。 |
pixelRatio |
number | 从像素空间到坐标空间的缩放因子。 |
result |
Cartesian2 | 存储结果的对象。 |
Returns:
修改后的结果参数或一个新的
Cartesian2 实例,其 x 和 y 属性分别为像素的宽度和高度。
Throws:
-
DeveloperError : drawingBufferWidth 必须大于零。
-
DeveloperError : drawingBufferHeight 必须大于零。
-
DeveloperError : pixelRatio 必须大于零。
Examples:
// Example 1
// Get the width and height of a pixel.
const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, scene.pixelRatio, new Cesium.Cartesian2());
// Example 2
// Get the width and height of a pixel if the near plane was set to 'distance'.
// For example, get the size of a pixel of an image on a billboard.
const position = camera.position;
const direction = camera.direction;
const toCenter = Cesium.Cartesian3.subtract(primitive.boundingVolume.center, position, new Cesium.Cartesian3()); // vector from camera to a primitive
const toCenterProj = Cesium.Cartesian3.multiplyByScalar(direction, Cesium.Cartesian3.dot(direction, toCenter), new Cesium.Cartesian3()); // project vector onto camera direction vector
const distance = Cesium.Cartesian3.magnitude(toCenterProj);
const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, scene.pixelRatio, new Cesium.Cartesian2());
