视锥体由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
Returns a duplicate of a PerspectiveOffCenterFrustum instance.
| Name | Type | Description |
|---|---|---|
result |
PerspectiveOffCenterFrustum | optional The object onto which to store the result. |
Returns:
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);
Compares the provided PerspectiveOffCenterFrustum componentwise and returns
true if they are equal, false otherwise.
| Name | Type | Description |
|---|---|---|
other |
PerspectiveOffCenterFrustum | optional The right hand side PerspectiveOffCenterFrustum. |
Returns:
true if they are equal, false otherwise.
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 | The right hand side PerspectiveOffCenterFrustum. | |
relativeEpsilon |
number | The relative epsilon tolerance to use for equality testing. | |
absoluteEpsilon |
number |
relativeEpsilon
|
optional The absolute epsilon tolerance to use for equality testing. |
Returns:
true 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 with the pixel's width and height in the x and y properties, respectively.
Throws:
-
DeveloperError : drawingBufferWidth must be greater than zero.
-
DeveloperError : drawingBufferHeight must be greater than zero.
-
DeveloperError : 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());
