new PerspectiveFrustum()
The cone of sight is defined by six planes. Each plane is represented by a Cartesian object, where the x, y, and z components define the unit vector perpendicular to the plane, and the w component is the distance from the plane to the origin/camera position.
| Name | Type | Default | Description |
|---|---|---|---|
options.fov |
Number |
optional
The angle of field of view (FOV), measured in radians. |
|
options.aspectRatio |
Number |
optional
The aspect ratio of cone width to height. |
|
options.near |
Number | 1.0 |
optional
Distance near the plane. |
options.far |
Number | 500000000.0 |
optional
Distance from the far plane. |
options.xOffset |
Number | 0.0 |
optional
The offset in the X direction. |
options.yOffset |
Number | 0.0 |
optional
The offset in the Y direction. |
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
-
The aspect ratio of the visual cone
- Default Value: undefined
farNumber
Distance from the far plane
- Default Value: 500000000.0
fovNumber
The angle of field of view (FOV), measured in radians. If the width is greater than the height, this angle will be used as the horizontal field of view angle; Otherwise, it will be considered as a vertical field of view angle.
- Default Value: undefined
readonly fovyNumber
Obtain the angle of the vertical field of view in radians.
- Default Value: undefined
readonly infiniteProjectionMatrixMatrix4
The perspective projection matrix calculated from the frustum on an infinite plane.
nearNumber
Distance near the plane
- Default Value: 1.0
readonly projectionMatrixMatrix4
Obtain the perspective projection matrix calculated from the frustum of the view.
xOffsetNumber
The offset in the X direction.
- Default Value: 0.0
yOffsetNumber
The offset in the Y direction.
- Default Value: 0.0
Methods
-
static pack(value, array, startingIndex){Array.<Number>}
-
Store the provided instance in the provided array.
Name Type Default Description valuePerspectiveFrustum Instances to be stored
arrayArray.<Number> Array for storing instances
startingIndexNumber 0 optional The index position of the starting packaged element in the array.
Returns:
Type Description Array.<Number> Packaged array -
static unpack(array, startingIndex, result){PerspectiveFrustum}
-
Retrieve an instance from the packaged array.
Name Type Default Description arrayArray.<Number> Packaged array
startingIndexNumber 0 optional The starting index of the element to be unpacked.
resultPerspectiveFrustum optional An instance object used to store results.
Returns:
Type Description PerspectiveFrustum If the modified result parameters are not provided, return a new perspective projection cone instance. -
clone(result){PerspectiveFrustum}
-
Return a copy of the PerspectiveFrustum instance.
Name Type Description resultPerspectiveFrustum optional The object that stores the results.
Returns:
Type Description PerspectiveFrustum The modified result parameters, or a new PerspectiveFrustum instance (if not provided). -
computeCullingVolume(position, direction, up){CullingVolume}
-
Create a cropped body for this viewing cone.
Name Type Description positionCartesian3 Viewpoint position.
directionCartesian3 Direction of gaze.
upCartesian3 Upward direction.
Returns:
Type Description CullingVolume A cropped object in a given position and direction. Example
// Check if a bounding volume intersects the frustum. var cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp); var intersect = cullingVolume.computeVisibility(boundingVolume); -
equals(other){Boolean}
-
Compare the components of the provided PerspectiveFrustum, return true if they are equal, otherwise return false.
Name Type Description otherPerspectiveFrustum optional The Perspective Frustum on the right.
Returns:
Type Description Boolean If they are equal, it is true; otherwise, it is false. -
equalsEpsilon(other, relativeEpsilon, absoluteEpsilon){Boolean}
-
If the provided PerspectiveFrustum components meet the inspection criteria for absolute or relative tolerances, return true; otherwise, return false.
Name Type Default Description otherPerspectiveFrustum A perspective projection cone for comparison.
relativeEpsilonNumber The relative epsilon tolerance value used for equality testing.
absoluteEpsilonNumber relativeEpsilon optional The absolute epsilon tolerance value used for equality testing.
Returns:
Type Description Boolean If this object and other objects are within the provided epsilon range, return true; otherwise, return false. -
getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result){Cartesian2}
-
Returns the width and height of pixels in meters.
Name Type Description drawingBufferWidthNumber Draw the width of the buffer.
drawingBufferHeightNumber Draw the height of the buffer.
distanceNumber The distance to the near plane, measured in meters.
resultCartesian2 The object that stores the results.
Throws:
-
-
DrawingBufferWidth must be greater than 0.
- Type
- DeveloperError
-
-
-
DrawingBufferHeight must be greater than 0.
- Type
- DeveloperError
-
Returns:
Type Description Cartesian2 The modified result parameter or a new instance of Cartesian2 contains the width and height of the pixel in its x and y attributes, respectively. 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()); -