Class: PerspectiveFrustum

PerspectiveFrustum

new PerspectiveFrustum()

视锥由6个平面定义。每个平面由一个Cartesian4对象表示,其中x、y和z分量定义了与平面垂直的单位矢量,w分量是平面到原点/相机位置的距离。

Name Type Default Description
options.fov Number 可选

视场角(FOV)的角度,以弧度为单位。

options.aspectRatio Number 可选

视锥体宽度与高度的宽高比。

options.near Number 1.0 可选

近平面的距离。

options.far Number 500000000.0 可选

远平面的距离。

options.xOffset Number 0.0 可选

X方向的偏移量。

options.yOffset Number 0.0 可选

Y方向的偏移量。

See:
Example
var frustum = new SuperMap3D.PerspectiveFrustum({
    fov : SuperMap3D.Math.PI_OVER_THREE,
    aspectRatio : canvas.clientWidth / canvas.clientHeight
    near : 1.0,
    far : 1000.0
});

Members

aspectRatioNumber

视锥体的宽高比

Default Value:
undefined

farNumber

远平面的距离

Default Value:
500000000.0

fovNumber

视场角(FOV)的角度,以弧度为单位。如果宽度大于高度,此角度将用作水平视场角;否则将作为垂直视场角。

Default Value:
undefined

readonly fovyNumber

获取垂直视场的角度,以弧度为单位。

Default Value:
undefined

readonly infiniteProjectionMatrixMatrix4

在无限远平面上从视锥台计算的透视投影矩阵。

See:

nearNumber

近平面的距离

Default Value:
1.0

readonly projectionMatrixMatrix4

获取从视图截锥体计算的透视投影矩阵。

See:

xOffsetNumber

X方向的偏移量。

Default Value:
0.0

yOffsetNumber

Y方向的偏移量。

Default Value:
0.0

Methods

static pack(value, array, startingIndex){Array.<Number>}

将提供的实例存储到提供的数组中。

Name Type Default Description
value PerspectiveFrustum

要储存的实例

array Array.<Number>

用于储存实例的数组

startingIndex Number 0 可选

数组中开始打包元素的索引位置。

Returns:
Type Description
Array.<Number> 打包完成的数组

static unpack(array, startingIndex, result){PerspectiveFrustum}

从打包的数组中检索出一个实例。

Name Type Default Description
array Array.<Number>

打包的数组.

startingIndex Number 0 可选

要解包的元素的起始索引。

result PerspectiveFrustum 可选

用于存储结果的实例对象。

Returns:
Type Description
PerspectiveFrustum 修改后的结果参数,如果没有提供则返回一个新的透视投影视锥体实例。

clone(result){PerspectiveFrustum}

返回 PerspectiveFrustum 实例的副本。

Name Type Description
result PerspectiveFrustum 可选

存储结果的对象。

Returns:
Type Description
PerspectiveFrustum 修改后的结果参数,或一个新的 PerspectiveFrustum 实例(如果没有提供)。

computeCullingVolume(position, direction, up){CullingVolume}

为这个视锥体创建一个裁剪体。

Name Type Description
position Cartesian3

视点位置。

direction Cartesian3

视线方向。

up Cartesian3

向上的方向。

Returns:
Type Description
CullingVolume 在给定位置和方向上的裁剪体。
Example
// Check if a bounding volume intersects the frustum.
var cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
var intersect = cullingVolume.computeVisibility(boundingVolume);

equals(other){Boolean}

比较所提供的 PerspectiveFrustum 的分量,如果相等则返回 true,否则返回 false。

Name Type Description
other PerspectiveFrustum 可选

右侧的PerspectiveFrustum。

Returns:
Type Description
Boolean 如果相等则为 true,否则为 false。

equalsEpsilon(other, relativeEpsilon, absoluteEpsilon){Boolean}

比较提供的PerspectiveFrustum分量 若这些分量满足绝对公差或相对公差的检验标准, 则返回true,否则返回false

Name Type Default Description
other PerspectiveFrustum

要进行比较的透视投影视锥体。

relativeEpsilon Number

用于相等性测试的相对epsilon容差值。

absoluteEpsilon Number relativeEpsilon 可选

用于相等性测试的绝对epsilon容差值。

Returns:
Type Description
Boolean 如果此对象和其他对象在提供的epsilon范围内,则返回true,否则返回false

getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result){Cartesian2}

返回像素的宽度和高度,单位为米。

Name Type Description
drawingBufferWidth Number

绘制buffer的宽度。

drawingBufferHeight Number

绘制buffer的高度。

distance Number

到近平面的距离,以米为单位。

result Cartesian2

存储结果的对象。

Throws:
  • drawingBufferWidth 必须大于0。

    Type
    DeveloperError
  • drawingBufferHeight 必须大于0。

    Type
    DeveloperError
Returns:
Type Description
Cartesian2 修改后的结果参数或 Cartesian2 的新实例,其 x 和 y 属性中分别包含像素的宽度和高度。
Examples
// Example 1
// Get the width and height of a pixel.
var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new SuperMap3D.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 = SuperMap3D.Cartesian3.subtract(primitive.boundingVolume.center, position, new SuperMap3D.Cartesian3());      // vector from camera to a primitive
var toCenterProj = SuperMap3D.Cartesian3.multiplyByScalar(direction, SuperMap3D.Cartesian3.dot(direction, toCenter), new SuperMap3D.Cartesian3()); // project vector onto camera direction vector
var distance = SuperMap3D.Cartesian3.magnitude(toCenterProj);
var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new SuperMap3D.Cartesian2());