视锥由6个平面定义。
每个平面由一个
Cartesian4
对象表示,其中x、y和z分量
定义垂直于平面的单位向量,w分量是
从原点/摄影机位置平面。Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Example:
var 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
clone(result) → PerspectiveOffCenterFrustum
返回PerspectiveOffCenterFrustum实例的副本。
Name | Type | Description |
---|---|---|
result |
PerspectiveOffCenterFrustum | 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.
var cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
var intersect = cullingVolume.computeVisibility(boundingVolume);
比较提供的透视图OffCenterFrustum组件并返回
如果相等,则为
true
,否则为false
。Name | Type | Description |
---|---|---|
other |
PerspectiveOffCenterFrustum | optional 中心截锥的右侧透视图。 |
Returns:
如果相等,则为
true
,否则为false
。比较提供的透视图OffCenterFrustum组件并返回
true
如果它们通过绝对或相对公差测试,
false
否则。Name | Type | Default | Description |
---|---|---|---|
other |
PerspectiveOffCenterFrustum | 中心截锥的右侧透视图。 | |
relativeEpsilon |
Number | 用于相等性测试的相对ε公差。 | |
absoluteEpsilon |
Number |
relativeEpsilon
|
optional 用于相等性测试的绝对ε公差。 |
Returns:
true
如果这个和其他都在提供的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:
-
DeveloperError :drawingBufferWidth必须大于零。
-
DeveloperError :drawingBufferHeight必须大于零。
-
DeveloperError :pixelRatio必须大于零。
Examples:
// Example 1
// Get the width and height of a pixel.
var 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.
var position = camera.position;
var direction = camera.direction;
var toCenter = Cesium.Cartesian3.subtract(primitive.boundingVolume.center, position, new Cesium.Cartesian3()); // vector from camera to a primitive
var toCenterProj = Cesium.Cartesian3.multiplyByScalar(direction, Cesium.Cartesian3.dot(direction, toCenter), new Cesium.Cartesian3()); // project vector onto camera direction vector
var distance = Cesium.Cartesian3.magnitude(toCenterProj);
var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, scene.pixelRatio, new Cesium.Cartesian2());