English中文

PerspectiveFrustum

new Cesium.PerspectiveFrustum(options)

视锥体由 6 个平面定义。每个平面由一个表示 The viewing frustum is defined by 6 planes. Each plane is represented by a Cartesian4 对象,其中 x、y 和 z 分量定义垂直于平面的单位向量,w 分量是平面距原点/相机位置的距离。 object, where the x, y, and z components define the unit vector normal to the plane, and the w component is the distance of the plane from the origin/camera position.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: An object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
fov number 可选 optional 视场角 (FOV),以弧度为单位。 The angle of the field of view (FOV), in radians.
aspectRatio number 可选 optional 平截头体的宽度与其高度的纵横比。 The aspect ratio of the frustum's width to it's height.
near number 1.0 可选 optional 近平面的距离。 The distance of the near plane.
far number 500000000.0 可选 optional 远平面的距离。 The distance of the far plane.
xOffset number 0.0 可选 optional x 方向的偏移量。 The offset in the x direction.
yOffset number 0.0 可选 optional y 方向的偏移。 The offset in the y direction.
示例: 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

用于将对象打包到数组中的元素数量。 The number of elements used to pack the object into an array.

aspectRatio : number|undefined

平截头体的宽度与其高度的纵横比。 The aspect ratio of the frustum's width to it's height.
默认值: Default Value: undefined
远平面的距离。 The distance of the far plane.
默认值: Default Value: 500000000.0
视场角 (FOV),以弧度为单位。如果宽度大于高度,则该角度将用作水平 FOV,否则将用作垂直 FOV。 The angle of the field of view (FOV), in radians. This angle will be used as the horizontal FOV if the width is greater than the height, otherwise it will be the vertical FOV.
默认值: Default Value: undefined

readonly fovy : number|undefined

获取垂直视野的角度(以弧度为单位)。 Gets the angle of the vertical field of view, in radians.
默认值: Default Value: undefined

readonly infiniteProjectionMatrix : Matrix4

从具有无限远平面的视锥体计算的透视投影矩阵。 The perspective projection matrix computed from the view frustum with an infinite far plane.
另见: See:
近平面的距离。 The distance of the near plane.
默认值: Default Value: 1.0
获取根据视锥体计算的透视投影矩阵。如有必要,将重新计算投影矩阵。 Gets the perspective projection matrix computed from the view frustum. If necessary, the projection matrix will be recomputed.
另见: See:
在 x 方向上偏移平截头体。 Offsets the frustum in the x direction.
默认值: Default Value: 0.0
在 y 方向上偏移平截头体。 Offsets the frustum in the y direction.
默认值: Default Value: 0.0

方法 Methods

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

将提供的实例存储到提供的数组中。 Stores the provided instance into the provided array.
名称 Name 类型 Type 默认值 Default 说明 Description
value PerspectiveFrustum 包装的价值。 The value to pack.
array Array.<number> 要打包到的数组。 The array to pack into.
startingIndex number 0 可选 optional 开始打包元素的数组索引。 The index into the array at which to start packing the elements.
返回: Returns:
被打包成的数组 The array that was packed into

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

从打包数组中检索实例。 Retrieves an instance from a packed array.
名称 Name 类型 Type 默认值 Default 说明 Description
array Array.<number> 打包的数组。 The packed array.
startingIndex number 0 可选 optional 要解包的元素的起始索引。 The starting index of the element to be unpacked.
result PerspectiveFrustum 可选 optional 用于存储结果的对象。 The object into which to store the result.
返回: Returns:
修改后的结果参数或新的 PerspectiveFrustum 实例(如果未提供)。 The modified result parameter or a new PerspectiveFrustum instance if one was not provided.
返回 PerspectiveFrustum 实例的副本。 Returns a duplicate of a PerspectiveFrustum instance.
名称 Name 类型 Type 说明 Description
result PerspectiveFrustum 可选 optional 用于存储结果的对象。 The object onto which to store the result.
返回: Returns:
修改后的结果参数或新的 PerspectiveFrustum 实例(如果未提供)。 The modified result parameter or a new PerspectiveFrustum instance if one was not provided.

computeCullingVolume(position, direction, up)CullingVolume

为此视锥体创建剔除体积。 Creates a culling volume for this frustum.
名称 Name 类型 Type 说明 Description
position Cartesian3 眼睛的位置。 The eye position.
direction Cartesian3 视线方向。 The view direction.
up Cartesian3 向上的方向。 The up direction.
返回: Returns:
给定位置和方向的剔除体积。 A culling volume at the given position and orientation.
示例: Example:
// Check if a bounding volume intersects the frustum.
const cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
const intersect = cullingVolume.computeVisibility(boundingVolume);
比较提供的 PerspectiveFrustum 组件并返回 Compares the provided PerspectiveFrustum componentwise and returns true 如果它们相等, if they are equal, false otherwise.
名称 Name 类型 Type 说明 Description
other PerspectiveFrustum 可选 optional 右侧透视截头体。 The right hand side PerspectiveFrustum.
返回: Returns:
true 如果它们相等, if they are equal, false otherwise.

equalsEpsilon(other, relativeEpsilon, absoluteEpsilon)boolean

比较提供的 PerspectiveFrustum 组件并返回 Compares the provided PerspectiveFrustum componentwise and returns true 如果他们通过了绝对或相对耐受性测试, if they pass an absolute or relative tolerance test, false otherwise.
名称 Name 类型 Type 默认值 Default 说明 Description
other PerspectiveFrustum 右侧透视截头体。 The right hand side PerspectiveFrustum.
relativeEpsilon number 用于相等性测试的相对 epsilon 容差。 The relative epsilon tolerance to use for equality testing.
absoluteEpsilon number relativeEpsilon 可选 optional 用于相等性测试的绝对 epsilon 容差。 The absolute epsilon tolerance to use for equality testing.
返回: Returns:
true 如果这个和其他都在提供的 epsilon 范围内, if this and other are within the provided epsilon, false otherwise.

getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, pixelRatio, result)Cartesian2

返回像素的宽度和高度(以米为单位)。 Returns the pixel's width and height in meters.
名称 Name 类型 Type 说明 Description
drawingBufferWidth number 绘图缓冲区的宽度。 The width of the drawing buffer.
drawingBufferHeight number 绘图缓冲区的高度。 The height of the drawing buffer.
distance number 到近平面的距离(以米为单位)。 The distance to the near plane in meters.
pixelRatio number 从像素空间到坐标空间的缩放因子。 The scaling factor from pixel space to coordinate space.
result Cartesian2 用于存储结果的对象。 The object onto which to store the result.
返回: Returns:
修改后的结果参数或新实例 The modified result parameter or a new instance of Cartesian2 像素的宽度和高度分别位于 x 和 y 属性中。 with the pixel's width and height in the x and y properties, respectively.
抛出: Throws:
  • DeveloperError :drawingBufferWidth 必须大于零。 : drawingBufferWidth must be greater than zero.
  • DeveloperError :drawingBufferHeight 必须大于零。 : drawingBufferHeight must be greater than zero.
  • DeveloperError :pixelRatio 必须大于零。 : pixelRatio must be greater than zero.
示例: 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.