PerspectiveFrustum

new Cesium.PerspectiveFrustum ( options )

视锥体由 6 个平面定义。每个平面由一个 Cartesian4 对象表示,其中 x、y 和 z 分量定义垂直于平面的单位矢量,w 分量是平面到原点/相机位置的距离。
Name Type Description
options Object 可选 具有以下属性的对象:
姓名 类型 默认 描述
fov 数字 可选 视场角 (FOV),以弧度为单位。
aspectRatio 数字 可选 截锥体宽度与其高度的纵横比。
near 数字 1.0 可选 近平面的距离。
far 数字 500000000.0 可选 远平面的距离。
xOffset 数字 0.0 可选 x 方向的偏移量。
yOffset 数字 0.0 可选 y 方向的偏移量。
Example:
const frustum = new Cesium.PerspectiveFrustum({
    fov : Cesium.Math.PI_OVER_THREE,
    aspectRatio : canvas.clientWidth / canvas.clientHeight
    near : 1.0,
    far : 1000.0
});
See:

Members

static Cesium.PerspectiveFrustum.packedLength : Number

用于将对象打包到数组中的元素数。
截锥体宽度与其高度的纵横比。
Default Value: undefined
远平面的距离。
Default Value: 500000000.0
视场角 (FOV),以弧度为单位。如果宽度大于高度,此角度将用作水平 FOV,否则将用作垂直 FOV。
Default Value: undefined

readonly fovy : Number

获取垂直视野的角度,以弧度为单位。
Default Value: undefined

readonly infiniteProjectionMatrix : Matrix4

从具有无限远平面的视锥体计算出的透视投影矩阵。
See:
近平面的距离。
Default Value: 1.0
获取从视锥计算的透视投影矩阵。
See:
在 x 方向偏移平截头体。
Default Value: 0.0
在 y 方向偏移平截头体。
Default Value: 0.0

Methods

static Cesium.PerspectiveFrustum.pack (value, array, startingIndex ) → Array.<Number>

将提供的实例存储到提供的数组中。
Name Type Default Description
value PerspectiveFrustum 要打包的值。
array Array.<Number> 要打包的数组。
startingIndex Number 0 可选 开始打包元素的数组索引。
Returns:
装入的数组

static Cesium.PerspectiveFrustum.unpack (array, startingIndex , result ) → PerspectiveFrustum

从打包数组中检索实例。
Name Type Default Description
array Array.<Number> 打包的数组。
startingIndex Number 0 可选 要解包的元素的起始索引。
result PerspectiveFrustum 可选 存储结果的对象。
Returns:
修改后的结果参数或新的 PerspectiveFrustum 实例(如果未提供)。
返回 PerspectiveFrustum 实例的副本。
Name Type Description
result PerspectiveFrustum 可选 存储结果的对象。
Returns:
修改后的结果参数或新的 PerspectiveFrustum 实例(如果未提供)。

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);

equals ( other ) → Boolean

比较提供的 PerspectiveFrustum 组件,如果它们相等则返回 true ,否则返回 false 。
Name Type Description
other PerspectiveFrustum 可选 右侧 PerspectiveFrustum。
Returns:
如果它们相等,则为 true ,否则为 false 。

equalsEpsilon (other, relativeEpsilon, absoluteEpsilon ) → Boolean

比较提供的 PerspectiveFrustum 组件,如果它们通过绝对或相对容差测试,则返回 true ,否则返回 false 。
Name Type Default Description
other PerspectiveFrustum 右侧 PerspectiveFrustum。
relativeEpsilon Number 用于相等性测试的相对 epsilon 容差。
absoluteEpsilon Number relativeEpsilon 可选 用于相等测试的绝对 epsilon 容差。
Returns:
true this 和 other 在提供的 epsilon 内,则为 true,否则为 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:
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());