Skip to content

KBE3D / KBCore / Cesium / Camera

类: Camera

The camera is defined by a position, orientation, and view frustum. <br /><br /> The orientation forms an orthonormal basis with a view, up and right = view x up unit vectors. <br /><br /> The viewing frustum is defined by 6 planes. Each plane is represented by a Cartesian4 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.

示例

ts
// Create a camera looking down the negative z-axis, positioned at the origin,
// with a field of view of 60 degrees, and 1:1 aspect ratio.
const camera = new Cesium.Camera(scene);
camera.position = new Cesium.Cartesian3();
camera.direction = Cesium.Cartesian3.negate(Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());
camera.up = Cesium.Cartesian3.clone(Cesium.Cartesian3.UNIT_Y);
camera.frustum.fov = Cesium.Math.PI_OVER_THREE;
camera.frustum.near = 1.0;
camera.frustum.far = 2.0;

参数

The scene.

属性

DEFAULT_VIEW_RECTANGLE

static DEFAULT_VIEW_RECTANGLE: Rectangle

The default rectangle the camera will view on creation.


DEFAULT_VIEW_FACTOR

static DEFAULT_VIEW_FACTOR: number

A scalar to multiply to the camera position and add it back after setting the camera to view the rectangle. A value of zero means the camera will view the entire Camera#DEFAULT_VIEW_RECTANGLE, a value greater than zero will move it further away from the extent, and a value less than zero will move it close to the extent.


DEFAULT_OFFSET

static DEFAULT_OFFSET: HeadingPitchRange

The default heading/pitch/range that is used when the camera flies to a location that contains a bounding sphere.


position

position: Cartesian3

The position of the camera.


direction

direction: Cartesian3

The view direction of the camera.


up

up: Cartesian3

The up direction of the camera.


right: Cartesian3

The right direction of the camera.


frustum

frustum: PerspectiveFrustum | OrthographicFrustum | PerspectiveOffCenterFrustum

The region of space in view.


defaultMoveAmount

defaultMoveAmount: number

The default amount to move the camera when an argument is not provided to the move methods.


defaultLookAmount

defaultLookAmount: number

The default amount to rotate the camera when an argument is not provided to the look methods.


defaultRotateAmount

defaultRotateAmount: number

The default amount to rotate the camera when an argument is not provided to the rotate methods.


defaultZoomAmount

defaultZoomAmount: number

The default amount to move the camera when an argument is not provided to the zoom methods.


constrainedAxis

constrainedAxis: Cartesian3 | undefined

If set, the camera will not be able to rotate past this axis in either direction.


maximumZoomFactor

maximumZoomFactor: number

The factor multiplied by the the map size used to determine where to clamp the camera position when zooming out from the surface. The default is 1.5. Only valid for 2D and the map is rotatable.


percentageChanged

percentageChanged: number

The amount the camera has to change before the <code>changed</code> event is raised. The value is a percentage in the [0, 1] range.


transform

readonly transform: Matrix4

Gets the camera's reference frame. The inverse of this transformation is appended to the view matrix.


inverseTransform

readonly inverseTransform: Matrix4

Gets the inverse camera transform.


viewMatrix

readonly viewMatrix: Matrix4

Gets the view matrix.


inverseViewMatrix

readonly inverseViewMatrix: Matrix4

Gets the inverse view matrix.


positionCartographic

readonly positionCartographic: Cartographic

Gets the Cartographic position of the camera, with longitude and latitude expressed in radians and height in meters. In 2D and Columbus View, it is possible for the returned longitude and latitude to be outside the range of valid longitudes and latitudes when the camera is outside the map.


positionWC

readonly positionWC: Cartesian3

Gets the position of the camera in world coordinates.


directionWC

readonly directionWC: Cartesian3

Gets the view direction of the camera in world coordinates.


upWC

readonly upWC: Cartesian3

Gets the up direction of the camera in world coordinates.


rightWC

readonly rightWC: Cartesian3

Gets the right direction of the camera in world coordinates.


heading

readonly heading: number

Gets the camera heading in radians.


pitch

readonly pitch: number

Gets the camera pitch in radians.


roll

readonly roll: number

Gets the camera roll in radians.


moveStart

readonly moveStart: Event

Gets the event that will be raised at when the camera starts to move.


moveEnd

readonly moveEnd: Event

Gets the event that will be raised when the camera has stopped moving.


changed

readonly changed: Event

Gets the event that will be raised when the camera has changed by <code>percentageChanged</code>.

方法

setView()

setView(options: { destination?: Cartesian3 | Rectangle; orientation?: DirectionUp | HeadingPitchRollValues; endTransform?: Matrix4; convert?: boolean; }): void

Sets the camera position, orientation and transform.

参数

options

Object with the following properties:

destination?

Cartesian3 | Rectangle

The final position of the camera in world coordinates or a rectangle that would be visible from a top-down view.

orientation?

DirectionUp | HeadingPitchRollValues

An object that contains either direction and up properties or heading, pitch and roll properties. By default, the direction will point towards the center of the frame in 3D and in the negative z direction in Columbus view. The up direction will point towards local north in 3D and in the positive y direction in Columbus view. Orientation is not used in 2D when in infinite scrolling mode.

endTransform?

Matrix4

Transform matrix representing the reference frame of the camera.

convert?

boolean

Whether to convert the destination from world coordinates to scene coordinates (only relevant when not using 3D). Defaults to <code>true</code>.

返回

void

示例

ts
// 1. Set position with a top-down view
viewer.camera.setView({
    destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0)
});

// 2 Set view with heading, pitch and roll
viewer.camera.setView({
    destination : cartesianPosition,
    orientation: {
        heading : Cesium.Math.toRadians(90.0), // east, default value is 0.0 (north)
        pitch : Cesium.Math.toRadians(-90),    // default value (looking down)
        roll : 0.0                             // default value
    }
});

// 3. Change heading, pitch and roll with the camera position remaining the same.
viewer.camera.setView({
    orientation: {
        heading : Cesium.Math.toRadians(90.0), // east, default value is 0.0 (north)
        pitch : Cesium.Math.toRadians(-90),    // default value (looking down)
        roll : 0.0                             // default value
    }
});

// 4. View rectangle with a top-down view
viewer.camera.setView({
    destination : Cesium.Rectangle.fromDegrees(west, south, east, north)
});

// 5. Set position with an orientation using unit vectors.
viewer.camera.setView({
    destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
    orientation : {
        direction : new Cesium.Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734),
        up : new Cesium.Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339)
    }
});

flyHome()

flyHome(duration?: number): void

Fly the camera to the home view. Use Camera#.DEFAULT_VIEW_RECTANGLE to set the default view for the 3D scene. The home view for 2D and columbus view shows the entire map.

参数

duration?

number

The duration of the flight in seconds. If omitted, Cesium attempts to calculate an ideal duration based on the distance to be traveled by the flight. See Camera#flyTo

返回

void


worldToCameraCoordinates()

worldToCameraCoordinates(cartesian: Cartesian4, result?: Cartesian4): Cartesian4

Transform a vector or point from world coordinates to the camera's reference frame.

参数

cartesian

Cartesian4

The vector or point to transform.

result?

Cartesian4

The object onto which to store the result.

返回

Cartesian4

The transformed vector or point.


worldToCameraCoordinatesPoint()

worldToCameraCoordinatesPoint(cartesian: Cartesian3, result?: Cartesian3): Cartesian3

Transform a point from world coordinates to the camera's reference frame.

参数

cartesian

Cartesian3

The point to transform.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The transformed point.


worldToCameraCoordinatesVector()

worldToCameraCoordinatesVector(cartesian: Cartesian3, result?: Cartesian3): Cartesian3

Transform a vector from world coordinates to the camera's reference frame.

参数

cartesian

Cartesian3

The vector to transform.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The transformed vector.


cameraToWorldCoordinates()

cameraToWorldCoordinates(cartesian: Cartesian4, result?: Cartesian4): Cartesian4

Transform a vector or point from the camera's reference frame to world coordinates.

参数

cartesian

Cartesian4

The vector or point to transform.

result?

Cartesian4

The object onto which to store the result.

返回

Cartesian4

The transformed vector or point.


cameraToWorldCoordinatesPoint()

cameraToWorldCoordinatesPoint(cartesian: Cartesian3, result?: Cartesian3): Cartesian3

Transform a point from the camera's reference frame to world coordinates.

参数

cartesian

Cartesian3

The point to transform.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The transformed point.


cameraToWorldCoordinatesVector()

cameraToWorldCoordinatesVector(cartesian: Cartesian3, result?: Cartesian3): Cartesian3

Transform a vector from the camera's reference frame to world coordinates.

参数

cartesian

Cartesian3

The vector to transform.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The transformed vector.


move()

move(direction: Cartesian3, amount?: number): void

Translates the camera's position by <code>amount</code> along <code>direction</code>.

参数

direction

Cartesian3

The direction to move.

amount?

number

The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.

返回

void


moveForward()

moveForward(amount?: number): void

Translates the camera's position by <code>amount</code> along the camera's view vector. When in 2D mode, this will zoom in the camera instead of translating the camera's position.

参数

amount?

number

The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.

返回

void


moveBackward()

moveBackward(amount?: number): void

Translates the camera's position by <code>amount</code> along the opposite direction of the camera's view vector. When in 2D mode, this will zoom out the camera instead of translating the camera's position.

参数

amount?

number

The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.

返回

void


moveUp()

moveUp(amount?: number): void

Translates the camera's position by <code>amount</code> along the camera's up vector.

参数

amount?

number

The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.

返回

void


moveDown()

moveDown(amount?: number): void

Translates the camera's position by <code>amount</code> along the opposite direction of the camera's up vector.

参数

amount?

number

The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.

返回

void


moveRight()

moveRight(amount?: number): void

Translates the camera's position by <code>amount</code> along the camera's right vector.

参数

amount?

number

The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.

返回

void


moveLeft()

moveLeft(amount?: number): void

Translates the camera's position by <code>amount</code> along the opposite direction of the camera's right vector.

参数

amount?

number

The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.

返回

void


lookLeft()

lookLeft(amount?: number): void

Rotates the camera around its up vector by amount, in radians, in the opposite direction of its right vector if not in 2D mode.

参数

amount?

number

The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.

返回

void


lookRight()

lookRight(amount?: number): void

Rotates the camera around its up vector by amount, in radians, in the direction of its right vector if not in 2D mode.

参数

amount?

number

The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.

返回

void


lookUp()

lookUp(amount?: number): void

Rotates the camera around its right vector by amount, in radians, in the direction of its up vector if not in 2D mode.

参数

amount?

number

The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.

返回

void


lookDown()

lookDown(amount?: number): void

Rotates the camera around its right vector by amount, in radians, in the opposite direction of its up vector if not in 2D mode.

参数

amount?

number

The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.

返回

void


look()

look(axis: Cartesian3, angle?: number): void

Rotate each of the camera's orientation vectors around <code>axis</code> by <code>angle</code>

参数

axis

Cartesian3

The axis to rotate around.

angle?

number

The angle, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.

返回

void


twistLeft()

twistLeft(amount?: number): void

Rotate the camera counter-clockwise around its direction vector by amount, in radians.

参数

amount?

number

The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.

返回

void


twistRight()

twistRight(amount?: number): void

Rotate the camera clockwise around its direction vector by amount, in radians.

参数

amount?

number

The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.

返回

void


rotate()

rotate(axis: Cartesian3, angle?: number): void

Rotates the camera around <code>axis</code> by <code>angle</code>. The distance of the camera's position to the center of the camera's reference frame remains the same.

参数

axis

Cartesian3

The axis to rotate around given in world coordinates.

angle?

number

The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.

返回

void


rotateDown()

rotateDown(angle?: number): void

Rotates the camera around the center of the camera's reference frame by angle downwards.

参数

angle?

number

The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.

返回

void


rotateUp()

rotateUp(angle?: number): void

Rotates the camera around the center of the camera's reference frame by angle upwards.

参数

angle?

number

The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.

返回

void


rotateRight()

rotateRight(angle?: number): void

Rotates the camera around the center of the camera's reference frame by angle to the right.

参数

angle?

number

The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.

返回

void


rotateLeft()

rotateLeft(angle?: number): void

Rotates the camera around the center of the camera's reference frame by angle to the left.

参数

angle?

number

The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.

返回

void


zoomIn()

zoomIn(amount?: number): void

Zooms <code>amount</code> along the camera's view vector.

参数

amount?

number

The amount to move. Defaults to <code>defaultZoomAmount</code>.

返回

void


zoomOut()

zoomOut(amount?: number): void

Zooms <code>amount</code> along the opposite direction of the camera's view vector.

参数

amount?

number

The amount to move. Defaults to <code>defaultZoomAmount</code>.

返回

void


getMagnitude()

getMagnitude(): number

Gets the magnitude of the camera position. In 3D, this is the vector magnitude. In 2D and Columbus view, this is the distance to the map.

返回

number

The magnitude of the position.


lookAt()

lookAt(target: Cartesian3, offset: Cartesian3 | HeadingPitchRange): void

Sets the camera position and orientation using a target and offset. The target must be given in world coordinates. The offset can be either a cartesian or heading/pitch/range in the local east-north-up reference frame centered at the target. If the offset is a cartesian, then it is an offset from the center of the reference frame defined by the transformation matrix. If the offset is heading/pitch/range, then the heading and the pitch angles are defined in the reference frame defined by the transformation matrix. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are below the plane. Negative pitch angles are above the plane. The range is the distance from the center.

In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the target will be the magnitude of the offset. The heading will be determined from the offset. If the heading cannot be determined from the offset, the heading will be north.

参数

target

Cartesian3

The target position in world coordinates.

offset

The offset from the target in the local east-north-up reference frame centered at the target.

Cartesian3 | HeadingPitchRange

返回

void

示例

ts
// 1. Using a cartesian offset
const center = Cesium.Cartesian3.fromDegrees(-98.0, 40.0);
viewer.camera.lookAt(center, new Cesium.Cartesian3(0.0, -4790000.0, 3930000.0));

// 2. Using a HeadingPitchRange offset
const center = Cesium.Cartesian3.fromDegrees(-72.0, 40.0);
const heading = Cesium.Math.toRadians(50.0);
const pitch = Cesium.Math.toRadians(-20.0);
const range = 5000.0;
viewer.camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, range));

lookAtTransform()

lookAtTransform(transform: Matrix4, offset?: Cartesian3 | HeadingPitchRange): void

Sets the camera position and orientation using a target and transformation matrix. The offset can be either a cartesian or heading/pitch/range. If the offset is a cartesian, then it is an offset from the center of the reference frame defined by the transformation matrix. If the offset is heading/pitch/range, then the heading and the pitch angles are defined in the reference frame defined by the transformation matrix. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are below the plane. Negative pitch angles are above the plane. The range is the distance from the center.

In 2D, there must be a top down view. The camera will be placed above the center of the reference frame. The height above the target will be the magnitude of the offset. The heading will be determined from the offset. If the heading cannot be determined from the offset, the heading will be north.

参数

transform

Matrix4

The transformation matrix defining the reference frame.

offset?

The offset from the target in a reference frame centered at the target.

Cartesian3 | HeadingPitchRange

返回

void

示例

ts
// 1. Using a cartesian offset
const transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(-98.0, 40.0));
viewer.camera.lookAtTransform(transform, new Cesium.Cartesian3(0.0, -4790000.0, 3930000.0));

// 2. Using a HeadingPitchRange offset
const transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(-72.0, 40.0));
const heading = Cesium.Math.toRadians(50.0);
const pitch = Cesium.Math.toRadians(-20.0);
const range = 5000.0;
viewer.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, range));

getRectangleCameraCoordinates()

getRectangleCameraCoordinates(rectangle: Rectangle, result?: Cartesian3): Cartesian3

Get the camera position needed to view a rectangle on an ellipsoid or map

参数

rectangle

Rectangle

The rectangle to view.

result?

Cartesian3

The camera position needed to view the rectangle

返回

Cartesian3

The camera position needed to view the rectangle


pickEllipsoid()

pickEllipsoid(windowPosition: Cartesian2, ellipsoid?: Ellipsoid, result?: Cartesian3): Cartesian3 | undefined

Pick an ellipsoid or map.

参数

windowPosition

Cartesian2

The x and y coordinates of a pixel.

ellipsoid?

Ellipsoid

The ellipsoid to pick.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3 | undefined

If the ellipsoid or map was picked, returns the point on the surface of the ellipsoid or map in world coordinates. If the ellipsoid or map was not picked, returns undefined.

示例

ts
const canvas = viewer.scene.canvas;
const center = new Cesium.Cartesian2(canvas.clientWidth / 2.0, canvas.clientHeight / 2.0);
const ellipsoid = viewer.scene.ellipsoid;
const result = viewer.camera.pickEllipsoid(center, ellipsoid);

getPickRay()

getPickRay(windowPosition: Cartesian2, result?: Ray): Ray | undefined

Create a ray from the camera position through the pixel at <code>windowPosition</code> in world coordinates.

参数

windowPosition

Cartesian2

The x and y coordinates of a pixel.

result?

Ray

The object onto which to store the result.

返回

Ray | undefined

Returns the Cartesian3 position and direction of the ray, or undefined if the pick ray cannot be determined.


distanceToBoundingSphere()

distanceToBoundingSphere(boundingSphere: BoundingSphere): number

Return the distance from the camera to the front of the bounding sphere.

参数

boundingSphere

BoundingSphere

The bounding sphere in world coordinates.

返回

number

The distance to the bounding sphere.


getPixelSize()

getPixelSize(boundingSphere: BoundingSphere, drawingBufferWidth: number, drawingBufferHeight: number): number

Return the pixel size in meters.

参数

boundingSphere

BoundingSphere

The bounding sphere in world coordinates.

drawingBufferWidth

number

The drawing buffer width.

drawingBufferHeight

number

The drawing buffer height.

返回

number

The pixel size in meters.


cancelFlight()

cancelFlight(): void

Cancels the current camera flight and leaves the camera at its current location. If no flight is in progress, this function does nothing.

返回

void


completeFlight()

completeFlight(): void

Completes the current camera flight and moves the camera immediately to its final destination. If no flight is in progress, this function does nothing.

返回

void


flyTo()

flyTo(options: { destination: Cartesian3 | Rectangle; orientation?: any; duration?: number; complete?: FlightCompleteCallback; cancel?: FlightCancelledCallback; endTransform?: Matrix4; maximumHeight?: number; pitchAdjustHeight?: number; flyOverLongitude?: number; flyOverLongitudeWeight?: number; convert?: boolean; easingFunction?: Callback; }): void

Flies the camera from its current position to a new position.

参数

options

Object with the following properties:

destination

Cartesian3 | Rectangle

The final position of the camera in world coordinates or a rectangle that would be visible from a top-down view.

orientation?

any

An object that contains either direction and up properties or heading, pitch and roll properties. By default, the direction will point towards the center of the frame in 3D and in the negative z direction in Columbus view. The up direction will point towards local north in 3D and in the positive y direction in Columbus view. Orientation is not used in 2D when in infinite scrolling mode.

duration?

number

The duration of the flight in seconds. If omitted, Cesium attempts to calculate an ideal duration based on the distance to be traveled by the flight.

complete?

FlightCompleteCallback

The function to execute when the flight is complete.

cancel?

FlightCancelledCallback

The function to execute if the flight is cancelled.

endTransform?

Matrix4

Transform matrix representing the reference frame the camera will be in when the flight is completed.

maximumHeight?

number

The maximum height at the peak of the flight.

pitchAdjustHeight?

number

If camera flyes higher than that value, adjust pitch duiring the flight to look down, and keep Earth in viewport.

flyOverLongitude?

number

There are always two ways between 2 points on globe. This option force camera to choose fight direction to fly over that longitude.

flyOverLongitudeWeight?

number

Fly over the lon specifyed via flyOverLongitude only if that way is not longer than short way times flyOverLongitudeWeight.

convert?

boolean

Whether to convert the destination from world coordinates to scene coordinates (only relevant when not using 3D). Defaults to <code>true</code>.

easingFunction?

Callback

Controls how the time is interpolated over the duration of the flight.

返回

void

示例

ts
// 1. Fly to a position with a top-down view
viewer.camera.flyTo({
    destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0)
});

// 2. Fly to a Rectangle with a top-down view
viewer.camera.flyTo({
    destination : Cesium.Rectangle.fromDegrees(west, south, east, north)
});

// 3. Fly to a position with an orientation using unit vectors.
viewer.camera.flyTo({
    destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
    orientation : {
        direction : new Cesium.Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734),
        up : new Cesium.Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339)
    }
});

// 4. Fly to a position with an orientation using heading, pitch and roll.
viewer.camera.flyTo({
    destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
    orientation : {
        heading : Cesium.Math.toRadians(175.0),
        pitch : Cesium.Math.toRadians(-35.0),
        roll : 0.0
    }
});

viewBoundingSphere()

viewBoundingSphere(boundingSphere: BoundingSphere, offset?: HeadingPitchRange): void

Sets the camera so that the current view contains the provided bounding sphere.

<p>The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere. The heading and the pitch angles are defined in the local east-north-up reference frame. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are below the plane. Negative pitch angles are above the plane. The range is the distance from the center. If the range is zero, a range will be computed such that the whole bounding sphere is visible.</p>

<p>In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the target will be the range. The heading will be determined from the offset. If the heading cannot be determined from the offset, the heading will be north.</p>

参数

boundingSphere

BoundingSphere

The bounding sphere to view, in world coordinates.

offset?

HeadingPitchRange

The offset from the target in the local east-north-up reference frame centered at the target.

返回

void


flyToBoundingSphere()

flyToBoundingSphere(boundingSphere: BoundingSphere, options?: { duration?: number; offset?: HeadingPitchRange; complete?: FlightCompleteCallback; cancel?: FlightCancelledCallback; endTransform?: Matrix4; maximumHeight?: number; pitchAdjustHeight?: number; flyOverLongitude?: number; flyOverLongitudeWeight?: number; easingFunction?: Callback; }): void

Flies the camera to a location where the current view contains the provided bounding sphere.

<p> The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere. The heading and the pitch angles are defined in the local east-north-up reference frame. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are below the plane. Negative pitch angles are above the plane. The range is the distance from the center. If the range is zero, a range will be computed such that the whole bounding sphere is visible.</p>

<p>In 2D and Columbus View, there must be a top down view. The camera will be placed above the target looking down. The height above the target will be the range. The heading will be aligned to local north.</p>

参数

boundingSphere

BoundingSphere

The bounding sphere to view, in world coordinates.

options?

Object with the following properties:

duration?

number

The duration of the flight in seconds. If omitted, Cesium attempts to calculate an ideal duration based on the distance to be traveled by the flight.

offset?

HeadingPitchRange

The offset from the target in the local east-north-up reference frame centered at the target.

complete?

FlightCompleteCallback

The function to execute when the flight is complete.

cancel?

FlightCancelledCallback

The function to execute if the flight is cancelled.

endTransform?

Matrix4

Transform matrix representing the reference frame the camera will be in when the flight is completed.

maximumHeight?

number

The maximum height at the peak of the flight.

pitchAdjustHeight?

number

If camera flyes higher than that value, adjust pitch duiring the flight to look down, and keep Earth in viewport.

flyOverLongitude?

number

There are always two ways between 2 points on globe. This option force camera to choose fight direction to fly over that longitude.

flyOverLongitudeWeight?

number

Fly over the lon specifyed via flyOverLongitude only if that way is not longer than short way times flyOverLongitudeWeight.

easingFunction?

Callback

Controls how the time is interpolated over the duration of the flight.

返回

void


computeViewRectangle()

computeViewRectangle(ellipsoid?: Ellipsoid, result?: Rectangle): Rectangle | undefined

Computes the approximate visible rectangle on the ellipsoid.

参数

ellipsoid?

Ellipsoid

The ellipsoid that you want to know the visible region.

result?

Rectangle

The rectangle in which to store the result

返回

Rectangle | undefined

The visible rectangle or undefined if the ellipsoid isn't visible at all.


switchToPerspectiveFrustum()

switchToPerspectiveFrustum(): void

Switches the frustum/projection to perspective.

This function is a no-op in 2D which must always be orthographic.

返回

void


switchToOrthographicFrustum()

switchToOrthographicFrustum(): void

Switches the frustum/projection to orthographic.

This function is a no-op in 2D which will always be orthographic.

返回

void

构造函数

构造函数

new Camera(scene: Scene): Camera

参数

scene

Scene

返回

Camera

KBE3D @3.0.0 Copyright © 2024-present KBE3D