PerspectiveFrustum

new Cesium.PerspectiveFrustum(options)

视锥体由 6 个平面定义。 每个平面都由一个 Cartesian4 对象表示,其中 x、y 和 z 分量 定义垂直于平面的单位向量,w 分量是 从原点/相机位置开始的平面。
Name Type Description
options object optional 对象,具有以下属性:
Name Type Default Description
fov number optional 视野角 (FOV),以弧度为单位。
aspectRatio number optional 视锥体的宽度与高度的纵横比。
near number 1.0 optional 近平面的距离。
far number 500000000.0 optional 远平面的距离。
xOffset number 0.0 optional x 方向的偏移量。
yOffset number 0.0 optional 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

用于将对象打包到数组中的元素数量。

aspectRatio : number|undefined

视锥体的宽度与高度的纵横比。
Default Value: undefined
远平面的距离。
Default Value: 500000000.0
视场角度 (FOV),以弧度为单位。 将使用这个角度 如果宽度大于高度,则作为水平 FOV,否则 这将是垂直 FOV。
Default Value: undefined

readonly fovy : number|undefined

获取垂直视野的角度,以弧度为单位。
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 optional 开始打包元素的数组的索引。
Returns:
被装入的数组

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

从打包数组中检索实例。
Name Type Default Description
array Array.<number> 打包数组。
startingIndex number 0 optional 要解压缩的元素的起始索引。
result PerspectiveFrustum optional 要在其中存储结果的对象。
Returns:
修改后的结果参数 或新的 PerspectiveFrustum 实例(如果未提供)。
返回 PerspectiveFrustum 实例的副本。
Name Type Description
result PerspectiveFrustum optional 要在其上存储结果的对象。
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);
对提供的 PerspectiveFrustum 组件进行比较,并返回 true,否则为false
Name Type Description
other PerspectiveFrustum optional 右边 PerspectiveFrustum.
Returns:
true,否则为false

equalsEpsilon(other, relativeEpsilon, absoluteEpsilon)boolean

对提供的 PerspectiveFrustum 组件进行比较,并返回 true 如果它们通过了绝对或相对耐受性测试, 否则 false
Name Type Default Description
other PerspectiveFrustum 右边 PerspectiveFrustum.
relativeEpsilon number 用于相等性检验的相对容差。
absoluteEpsilon number relativeEpsilon optional 用于相等性检验的绝对公差。
Returns:
true 如果 this 和其他都在提供的 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:
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());
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.