视锥体由 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:
|
示例: 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
定义底部剪切平面。 Defines the bottom clipping plane.
-
默认值: Default Value:
undefined
远平面的距离。 The distance of the far plane.
-
默认值: Default Value:
500000000.0
readonly infiniteProjectionMatrix : Matrix4
获取根据具有无限远平面的视锥计算的透视投影矩阵。 Gets the perspective projection matrix computed from the view frustum with an infinite far plane.
定义左剪裁平面。 Defines the left clipping plane.
-
默认值: Default Value:
undefined
近平面的距离。 The distance of the near plane.
-
默认值: Default Value:
1.0
readonly projectionMatrix : Matrix4
获取根据视锥体计算的透视投影矩阵。如果任何视锥体参数发生更改,将重新计算投影矩阵。 Gets the perspective projection matrix computed from the view frustum. The projection matrix will be recomputed if any frustum parameters have changed.
定义右剪切平面。 Defines the right clipping plane.
-
默认值: Default Value:
undefined
定义顶部剪切平面。 Defines the top clipping plane.
-
默认值: Default Value:
undefined
方法 Methods
返回 PerspectiveOffCenterFrustum 实例的副本。 Returns a duplicate of a PerspectiveOffCenterFrustum instance.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
result |
PerspectiveOffCenterFrustum | 可选 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);
比较提供的 PerspectiveOffCenterFrustum 组件并返回 Compares the provided PerspectiveOffCenterFrustum componentwise and returns
true 如果它们相等, if they are equal, false otherwise.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
other |
PerspectiveOffCenterFrustum | 可选 optional 右侧 PerspectiveOffCenterFrustum。 The right hand side PerspectiveOffCenterFrustum. |
返回: Returns:
true 如果它们相等, if they are equal, false otherwise.
比较提供的 PerspectiveOffCenterFrustum 组件并返回 Compares the provided PerspectiveOffCenterFrustum componentwise and returns
true 如果他们通过了绝对或相对耐受性测试, if they pass an absolute or relative tolerance test,
false otherwise.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
other |
PerspectiveOffCenterFrustum | 右侧 PerspectiveOffCenterFrustum。 The right hand side PerspectiveOffCenterFrustum. | |
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());
