相机由位置、方向和视锥体定义。
The camera is defined by a position, orientation, and view frustum.
方向与视图形成正交基,向上和向右 = 视图 x 向上单位向量。
The orientation forms an orthonormal basis with a view, up and right = view x up unit vectors.
视锥体由 6 个平面定义。每个平面由一个表示
The viewing frustum is defined by 6 planes. Each plane is represented by a Cartesian4 对象,其中 x、y 和 z 分量定义垂直于平面的单位向量,w 分量是平面距原点/相机位置的距离。
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.
| 名称 Name |
类型 Type |
说明 Description |
scene |
Scene
|
现场。 The scene. |
示例: Example:
// 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;
演示: Demo:
成员 Members
当相机飞到包含边界球的位置时使用的默认航向/俯仰/范围。 The default heading/pitch/range that is used when the camera flies to a location that contains a bounding sphere.
一个标量,用于乘以相机位置,并在设置相机查看矩形后将其加回来。值为零意味着相机将查看整个 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.
相机在创建时将查看的默认矩形。 The default rectangle the camera will view on creation.
获取当相机改变时将引发的事件 Gets the event that will be raised when the camera has changed by percentageChanged.
如果设置,相机将无法沿任一方向旋转超过该轴。 If set, the camera will not be able to rotate past this axis in either direction.
undefined
未向 Look 方法提供参数时旋转相机的默认量。 The default amount to rotate the camera when an argument is not provided to the look methods.
Math.PI / 60.0
未向移动方法提供参数时移动相机的默认量。 The default amount to move the camera when an argument is not provided to the move methods.
100000.0;
未向旋转方法提供参数时旋转相机的默认量。 The default amount to rotate the camera when an argument is not provided to the rotate methods.
Math.PI / 3600.0
未向缩放方法提供参数时移动相机的默认量。 The default amount to move the camera when an argument is not provided to the zoom methods.
100000.0;
相机的视角方向。 The view direction of the camera.
获取世界坐标中相机的视图方向。 Gets the view direction of the camera in world coordinates.
视野中的空间区域。 The region of space in view.
PerspectiveFrustum()
另见: See:
获取以弧度表示的相机航向。 Gets the camera heading in radians.
获取逆相机变换。 Gets the inverse camera transform.
Matrix4.IDENTITY
获取逆视图矩阵。 Gets the inverse view matrix.
另见: See:
该系数乘以地图大小,用于确定从表面缩小时限制相机位置的位置。默认值为 1.5。仅对 2D 有效且地图可旋转。 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.
1.5
获取当相机停止移动时将引发的事件。 Gets the event that will be raised when the camera has stopped moving.
获取当相机开始移动时将引发的事件。 Gets the event that will be raised at when the camera starts to move.
相机在之前必须改变的量 The amount the camera has to change before the changed 事件被引发。该值是 [0, 1] 范围内的百分比。 event is raised. The value is a percentage in the [0, 1] range.
0.5
获取以弧度为单位的相机俯仰角。 Gets the camera pitch in radians.
相机的位置。 The position of the camera.
得到
Gets the Cartographic 相机的位置,经度和纬度以弧度表示,高度以米表示。在 2D 和哥伦布视图中,当相机位于地图之外时,返回的经度和纬度可能会超出有效经度和纬度范围。
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.
获取相机在世界坐标中的位置。 Gets the position of the camera in world coordinates.
相机的正确方向。 The right direction of the camera.
获取世界坐标中相机的正确方向。 Gets the right direction of the camera in world coordinates.
获取以弧度表示的相机胶卷。 Gets the camera roll in radians.
获取相机的参考系。该变换的逆变换被附加到视图矩阵中。 Gets the camera's reference frame. The inverse of this transformation is appended to the view matrix.
Matrix4.IDENTITY
相机的向上方向。 The up direction of the camera.
获取世界坐标中相机的向上方向。 Gets the up direction of the camera in world coordinates.
获取视图矩阵。 Gets the view matrix.
另见: See:
方法 Methods
将矢量或点从相机的参考系变换到世界坐标。 Transform a vector or point from the camera's reference frame to world coordinates.
| 名称 Name |
类型 Type |
说明 Description |
cartesian |
Cartesian4
|
要变换的向量或点。 The vector or point to transform. |
result |
Cartesian4
|
可选 optional
用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
变换后的向量或点。 The transformed vector or point.
将点从相机的参考系变换到世界坐标。 Transform a point from the camera's reference frame to world coordinates.
| 名称 Name |
类型 Type |
说明 Description |
cartesian |
Cartesian3
|
转变的点。 The point to transform. |
result |
Cartesian3
|
可选 optional
用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
变换后的点。 The transformed point.
将矢量从相机的参考系转换为世界坐标。 Transform a vector from the camera's reference frame to world coordinates.
| 名称 Name |
类型 Type |
说明 Description |
cartesian |
Cartesian3
|
要变换的向量。 The vector to transform. |
result |
Cartesian3
|
可选 optional
用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
变换后的向量。 The transformed vector.
取消当前相机飞行并将相机保留在当前位置。如果没有正在进行的航班,则此功能不执行任何操作。 Cancels the current camera flight and leaves the camera at its current location. If no flight is in progress, this function does nothing.
完成当前的相机飞行并将相机立即移动到最终目的地。如果没有正在进行的航班,则此功能不执行任何操作。 Completes the current camera flight and moves the camera immediately to its final destination. If no flight is in progress, this function does nothing.
计算椭球体上的近似可见矩形。 Computes the approximate visible rectangle on the ellipsoid.
| 名称 Name |
类型 Type |
默认值 Default |
说明 Description |
ellipsoid |
Ellipsoid
|
Ellipsoid.default
|
可选 optional
您想要了解可见区域的椭球体。 The ellipsoid that you want to know the visible region. |
result |
Rectangle
|
|
可选 optional
用于存储结果的矩形 The rectangle in which to store the result |
返回: Returns:
可见矩形或未定义(如果椭球体根本不可见)。 The visible rectangle or undefined if the ellipsoid isn't visible at all.
返回从相机到边界球体前面的距离。 Return the distance from the camera to the front of the bounding sphere.
| 名称 Name |
类型 Type |
说明 Description |
boundingSphere |
BoundingSphere
|
世界坐标中的边界球。 The bounding sphere in world coordinates. |
返回: Returns:
到边界球的距离。 The distance to the bounding sphere.
将相机飞至主视图。使用 Fly the camera to the home view. Use Camera#.DEFAULT_VIEW_RECTANGLE 设置 3D 场景的默认视图。 2D 和哥伦布视图的主视图显示整个地图。 to set the default view for the 3D scene. The home view for 2D and columbus view shows the entire map.
| 名称 Name |
类型 Type |
说明 Description |
duration |
number
|
可选 optional
飞行的持续时间(以秒为单位)。如果省略,Cesium 会尝试根据航班飞行的距离计算理想的持续时间。参见 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 |
将相机从当前位置飞行到新位置。 Flies the camera from its current position to a new position.
| 名称 Name |
类型 Type |
说明 Description |
options |
object
|
具有以下属性的对象: Object with the following properties:
| 名称 Name |
类型 Type |
说明 Description |
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 |
object
|
可选 optional
包含方向和向上属性或航向、俯仰和滚动属性的对象。默认情况下,该方向将指向 3D 框架的中心以及哥伦布视图中的负 z 方向。向上方向将在 3D 中指向当地北方,在哥伦布视图中指向正 y 方向。在无限滚动模式下,2D 中不使用方向。 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
|
可选 optional
飞行的持续时间(以秒为单位)。如果省略,Cesium 会尝试根据航班飞行的距离计算理想的持续时间。 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 |
Camera.FlightCompleteCallback
|
可选 optional
飞行完成时执行的函数。 The function to execute when the flight is complete. |
cancel |
Camera.FlightCancelledCallback
|
可选 optional
航班取消时执行的函数。 The function to execute if the flight is cancelled. |
endTransform |
Matrix4
|
可选 optional
表示飞行完成时相机所处参考系的变换矩阵。 Transform matrix representing the reference frame the camera will be in when the flight is completed. |
maximumHeight |
number
|
可选 optional
飞行高峰时的最大高度。 The maximum height at the peak of the flight. |
pitchAdjustHeight |
number
|
可选 optional
如果相机飞行高度高于该值,请在飞行过程中调整俯仰角度以向下看,并将地球保持在视口中。 If camera flyes higher than that value, adjust pitch duiring the flight to look down, and keep Earth in viewport. |
flyOverLongitude |
number
|
可选 optional
地球上的两点之间总是有两种方式。此选项强制相机选择飞行方向以飞过该经度。 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
|
可选 optional
仅当该路径不长于短路径时间flyOverLongitudeWeight时,才飞越通过flyOverLongitude指定的lon。 Fly over the lon specifyed via flyOverLongitude only if that way is not longer than short way times flyOverLongitudeWeight. |
convert |
boolean
|
可选 optional
是否将目的地从世界坐标转换为场景坐标(仅在不使用 3D 时相关)。默认为 Whether to convert the destination from world coordinates to scene coordinates (only relevant when not using 3D). Defaults to true. |
easingFunction |
EasingFunction.Callback
|
可选 optional
控制如何在飞行期间内插时间。 Controls how the time is interpolated over the duration of the flight. |
|
抛出: Throws:
-
DeveloperError
:如果给出了方向或向上,则两者都是必需的。
: If either direction or up is given, then both are required.
示例: Example:
// 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
}
});
将相机飞行到当前视图包含所提供的边界球的位置。
Flies the camera to a location where the current view contains the provided bounding sphere.
偏移量是以边界球体中心为中心的局部东西向参考系中的航向/俯仰/范围。航向角和俯仰角在当地的东西向参考系中定义。航向是与 y 轴的角度并朝 x 轴增加。俯仰角是相对于 xy 平面的旋转。正俯仰角位于平面下方。负俯仰角位于平面上方。范围是距中心的距离。如果范围为零,则将计算一个范围,使得整个边界球体可见。 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.
在 2D 和哥伦布视图中,必须有自顶向下的视图。相机将放置在目标上方,俯视。目标上方的高度将是范围。航向将与当地北部对齐。 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.
| 名称 Name |
类型 Type |
说明 Description |
boundingSphere |
BoundingSphere
|
在世界坐标中要查看的边界球体。 The bounding sphere to view, in world coordinates. |
options |
object
|
可选 optional
具有以下属性的对象: Object with the following properties:
| 名称 Name |
类型 Type |
说明 Description |
duration |
number
|
可选 optional
飞行的持续时间(以秒为单位)。如果省略,Cesium 会尝试根据航班飞行的距离计算理想的持续时间。 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
|
可选 optional
以目标为中心的局部东西向参考系中距目标的偏移量。 The offset from the target in the local east-north-up reference frame centered at the target. |
complete |
Camera.FlightCompleteCallback
|
可选 optional
飞行完成时执行的函数。 The function to execute when the flight is complete. |
cancel |
Camera.FlightCancelledCallback
|
可选 optional
航班取消时执行的函数。 The function to execute if the flight is cancelled. |
endTransform |
Matrix4
|
可选 optional
表示飞行完成时相机所处参考系的变换矩阵。 Transform matrix representing the reference frame the camera will be in when the flight is completed. |
maximumHeight |
number
|
可选 optional
飞行高峰时的最大高度。 The maximum height at the peak of the flight. |
pitchAdjustHeight |
number
|
可选 optional
如果相机飞行高度高于该值,请在飞行过程中调整俯仰角度以向下看,并将地球保持在视口中。 If camera flyes higher than that value, adjust pitch duiring the flight to look down, and keep Earth in viewport. |
flyOverLongitude |
number
|
可选 optional
地球上的两点之间总是有两种方式。此选项强制相机选择飞行方向以飞过该经度。 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
|
可选 optional
仅当该路径不长于短路径时间flyOverLongitudeWeight时,才飞越通过flyOverLongitude指定的lon。 Fly over the lon specifyed via flyOverLongitude only if that way is not longer than short way times flyOverLongitudeWeight. |
easingFunction |
EasingFunction.Callback
|
可选 optional
控制如何在飞行期间内插时间。 Controls how the time is interpolated over the duration of the flight. |
|
获取相机位置的大小。在 3D 中,这是矢量幅度。在 2D 和哥伦布视图中,这是到地图的距离。 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.
返回: Returns:
位置的大小。 The magnitude of the position.
创建一条从相机位置穿过像素的光线 Create a ray from the camera position through the pixel at windowPosition
在世界坐标中。 in world coordinates.
| 名称 Name |
类型 Type |
说明 Description |
windowPosition |
Cartesian2
|
像素的 x 和 y 坐标。 The x and y coordinates of a pixel. |
result |
Ray
|
可选 optional
用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
返回
Returns the Cartesian3 射线的位置和方向,如果无法确定拾取射线,则未定义。
position and direction of the ray, or undefined if the pick ray cannot be determined.
getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) → number
返回像素大小(以米为单位)。 Return the pixel size in meters.
| 名称 Name |
类型 Type |
说明 Description |
boundingSphere |
BoundingSphere
|
世界坐标中的边界球。 The bounding sphere in world coordinates. |
drawingBufferWidth |
number
|
绘图缓冲区宽度。 The drawing buffer width. |
drawingBufferHeight |
number
|
绘图缓冲区的高度。 The drawing buffer height. |
返回: Returns:
像素大小(以米为单位)。 The pixel size in meters.
获取在椭球体或地图上查看矩形所需的相机位置 Get the camera position needed to view a rectangle on an ellipsoid or map
| 名称 Name |
类型 Type |
说明 Description |
rectangle |
Rectangle
|
要查看的矩形。 The rectangle to view. |
result |
Cartesian3
|
可选 optional
查看矩形所需的相机位置 The camera position needed to view the rectangle |
返回: Returns:
查看矩形所需的相机位置 The camera position needed to view the rectangle
旋转每个相机的方向向量 Rotate each of the camera's orientation vectors around axis by angle
| 名称 Name |
类型 Type |
说明 Description |
axis |
Cartesian3
|
围绕其旋转的轴。 The axis to rotate around. |
angle |
number
|
可选 optional
要旋转的角度(以弧度为单位)。默认为 The angle, in radians, to rotate by. Defaults to defaultLookAmount. |
另见: See:
使用目标和偏移设置相机位置和方向。目标必须以世界坐标给出。偏移量可以是笛卡尔坐标,也可以是以目标为中心的局部东西向参考系中的航向/俯仰/范围。如果偏移量是笛卡尔坐标系,则它是距变换矩阵定义的参考系中心的偏移量。如果偏移是航向/俯仰/范围,则航向和俯仰角在变换矩阵定义的参考系中定义。航向是与 y 轴的角度并朝 x 轴增加。俯仰角是相对于 xy 平面的旋转。正俯仰角位于平面下方。负俯仰角位于平面上方。范围是距中心的距离。在 2D 中,必须有一个自顶向下的视图。相机将放置在目标上方,俯视。目标之上的高度将是偏移的大小。航向将根据偏移量确定。如果无法根据偏移确定航向,则航向将为北。 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.
| 名称 Name |
类型 Type |
说明 Description |
target |
Cartesian3
|
世界坐标中的目标位置。 The target position in world coordinates. |
offset |
Cartesian3
|
HeadingPitchRange
|
以目标为中心的局部东西向参考系中距目标的偏移量。 The offset from the target in the local east-north-up reference frame centered at the target. |
抛出: Throws:
示例: Example:
// 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));
使用目标和变换矩阵设置相机位置和方向。偏移量可以是笛卡尔坐标或航向/俯仰/范围。如果偏移量是笛卡尔坐标系,则它是距变换矩阵定义的参考系中心的偏移量。如果偏移是航向/俯仰/范围,则航向和俯仰角在变换矩阵定义的参考系中定义。航向是与 y 轴的角度并朝 x 轴增加。俯仰角是相对于 xy 平面的旋转。正俯仰角位于平面下方。负俯仰角位于平面上方。范围是距中心的距离。在 2D 中,必须有一个自顶向下的视图。相机将放置在参考系中心上方。目标之上的高度将是偏移的大小。航向将根据偏移量确定。如果无法根据偏移确定航向,则航向将为北。 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.
| 名称 Name |
类型 Type |
说明 Description |
transform |
Matrix4
|
定义参考系的变换矩阵。 The transformation matrix defining the reference frame. |
offset |
Cartesian3
|
HeadingPitchRange
|
可选 optional
以目标为中心的参考系中距目标的偏移。 The offset from the target in a reference frame centered at the target. |
抛出: Throws:
-
DeveloperError
:变形时不支持lookAtTransform。
: lookAtTransform is not supported while morphing.
示例: Example:
// 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));
如果不是在 2D 模式下,则将相机绕其右向量旋转一定量(以弧度为单位),并沿其上向量的相反方向旋转。 Rotates the camera around its right vector by amount, in radians, in the opposite direction of its up vector if not in 2D mode.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
要旋转的量(以弧度为单位)。默认为 The amount, in radians, to rotate by. Defaults to defaultLookAmount. |
另见: See:
如果不在 2D 模式下,则将相机绕其向上向量旋转一定量(以弧度为单位),并沿其右向量的相反方向旋转。 Rotates the camera around its up vector by amount, in radians, in the opposite direction of its right vector if not in 2D mode.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
要旋转的量(以弧度为单位)。默认为 The amount, in radians, to rotate by. Defaults to defaultLookAmount. |
另见: See:
如果不是在 2D 模式下,则将相机绕其向上向量旋转一定量(以弧度为单位),并沿其右侧向量的方向旋转。 Rotates the camera around its up vector by amount, in radians, in the direction of its right vector if not in 2D mode.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
要旋转的量(以弧度为单位)。默认为 The amount, in radians, to rotate by. Defaults to defaultLookAmount. |
另见: See:
如果不是在 2D 模式下,则将相机沿其向上向量的方向绕其右向量旋转一定量(以弧度为单位)。 Rotates the camera around its right vector by amount, in radians, in the direction of its up vector if not in 2D mode.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
要旋转的量(以弧度为单位)。默认为 The amount, in radians, to rotate by. Defaults to defaultLookAmount. |
另见: See:
Translates the camera's position by amount along direction.
| 名称 Name |
类型 Type |
说明 Description |
direction |
Cartesian3
|
移动的方向。 The direction to move. |
amount |
number
|
可选 optional
移动量(以米为单位)。默认为 The amount, in meters, to move. Defaults to defaultMoveAmount. |
另见: See:
Translates the camera's position by amount 沿着相机视图矢量的相反方向。在 2D 模式下,这将缩小相机而不是平移相机的位置。 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.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
移动量(以米为单位)。默认为 The amount, in meters, to move. Defaults to defaultMoveAmount. |
另见: See:
Translates the camera's position by amount 沿着相机向上矢量的相反方向。 along the opposite direction of the camera's up vector.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
移动量(以米为单位)。默认为 The amount, in meters, to move. Defaults to defaultMoveAmount. |
另见: See:
Translates the camera's position by amount 沿着相机的视图向量。在 2D 模式下,这将放大相机而不是平移相机的位置。 along the camera's view vector. When in 2D mode, this will zoom in the camera instead of translating the camera's position.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
移动量(以米为单位)。默认为 The amount, in meters, to move. Defaults to defaultMoveAmount. |
另见: See:
Translates the camera's position by amount 沿着相机右向量的相反方向。 along the opposite direction of the camera's right vector.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
移动量(以米为单位)。默认为 The amount, in meters, to move. Defaults to defaultMoveAmount. |
另见: See:
Translates the camera's position by amount 沿着相机的右矢量。 along the camera's right vector.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
移动量(以米为单位)。默认为 The amount, in meters, to move. Defaults to defaultMoveAmount. |
另见: See:
Translates the camera's position by amount 沿着相机的向上向量。 along the camera's up vector.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
移动量(以米为单位)。默认为 The amount, in meters, to move. Defaults to defaultMoveAmount. |
另见: See:
选择一个椭球体或地图。 Pick an ellipsoid or map.
| 名称 Name |
类型 Type |
默认值 Default |
说明 Description |
windowPosition |
Cartesian2
|
|
像素的 x 和 y 坐标。 The x and y coordinates of a pixel. |
ellipsoid |
Ellipsoid
|
Ellipsoid.default
|
可选 optional
要选取的椭球体。 The ellipsoid to pick. |
result |
Cartesian3
|
|
可选 optional
用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
如果选取了椭球体或地图,则返回世界坐标中椭球体或地图表面上的点。如果未选择椭球体或地图,则返回未定义。 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.
示例: Example:
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);
旋转相机 Rotates the camera around axis by angle。相机位置到相机参考系中心的距离保持不变。 . The distance of the camera's position to the center of the camera's reference frame remains the same.
| 名称 Name |
类型 Type |
说明 Description |
axis |
Cartesian3
|
围绕世界坐标中给定的旋转轴。 The axis to rotate around given in world coordinates. |
angle |
number
|
可选 optional
要旋转的角度(以弧度为单位)。默认为 The angle, in radians, to rotate by. Defaults to defaultRotateAmount. |
另见: See:
将相机围绕相机参考系的中心向下旋转一定角度。 Rotates the camera around the center of the camera's reference frame by angle downwards.
| 名称 Name |
类型 Type |
说明 Description |
angle |
number
|
可选 optional
要旋转的角度(以弧度为单位)。默认为 The angle, in radians, to rotate by. Defaults to defaultRotateAmount. |
另见: See:
将相机围绕相机参考系的中心向左旋转一定角度。 Rotates the camera around the center of the camera's reference frame by angle to the left.
| 名称 Name |
类型 Type |
说明 Description |
angle |
number
|
可选 optional
要旋转的角度(以弧度为单位)。默认为 The angle, in radians, to rotate by. Defaults to defaultRotateAmount. |
另见: See:
将相机围绕相机参考系的中心向右旋转一定角度。 Rotates the camera around the center of the camera's reference frame by angle to the right.
| 名称 Name |
类型 Type |
说明 Description |
angle |
number
|
可选 optional
要旋转的角度(以弧度为单位)。默认为 The angle, in radians, to rotate by. Defaults to defaultRotateAmount. |
另见: See:
将相机围绕相机参考系的中心向上旋转一定角度。 Rotates the camera around the center of the camera's reference frame by angle upwards.
| 名称 Name |
类型 Type |
说明 Description |
angle |
number
|
可选 optional
要旋转的角度(以弧度为单位)。默认为 The angle, in radians, to rotate by. Defaults to defaultRotateAmount. |
另见: See:
设置相机位置、方向和变换。 Sets the camera position, orientation and transform.
| 名称 Name |
类型 Type |
说明 Description |
options |
object
|
具有以下属性的对象: Object with the following properties:
| 名称 Name |
类型 Type |
说明 Description |
destination |
Cartesian3
|
Rectangle
|
可选 optional
相机在世界坐标中的最终位置或从自上而下视图中可见的矩形。 The final position of the camera in world coordinates or a rectangle that would be visible from a top-down view. |
orientation |
HeadingPitchRollValues
|
DirectionUp
|
可选 optional
包含方向和向上属性或航向、俯仰和滚动属性的对象。默认情况下,该方向将指向 3D 框架的中心以及哥伦布视图中的负 z 方向。向上方向将在 3D 中指向当地北方,在哥伦布视图中指向正 y 方向。在无限滚动模式下,2D 中不使用方向。 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
|
可选 optional
表示相机参考系的变换矩阵。 Transform matrix representing the reference frame of the camera. |
convert |
boolean
|
可选 optional
是否将目的地从世界坐标转换为场景坐标(仅在不使用 3D 时相关)。默认为 Whether to convert the destination from world coordinates to scene coordinates (only relevant when not using 3D). Defaults to true. |
|
示例: Example:
// 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)
}
});
将平截头体/投影切换为正交。此函数在 2D 中是无操作的,并且始终是正交的。 Switches the frustum/projection to orthographic. This function is a no-op in 2D which will always be orthographic.
将视锥体/投影切换为透视。此函数在 2D 中是无操作的,必须始终是正交的。 Switches the frustum/projection to perspective. This function is a no-op in 2D which must always be orthographic.
将相机绕其方向矢量逆时针旋转一定量(以弧度为单位)。 Rotate the camera counter-clockwise around its direction vector by amount, in radians.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
要旋转的量(以弧度为单位)。默认为 The amount, in radians, to rotate by. Defaults to defaultLookAmount. |
另见: See:
将相机绕其方向矢量顺时针旋转一定量(以弧度为单位)。 Rotate the camera clockwise around its direction vector by amount, in radians.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
要旋转的量(以弧度为单位)。默认为 The amount, in radians, to rotate by. Defaults to defaultLookAmount. |
另见: See:
设置相机,使当前视图包含提供的边界球体。
Sets the camera so that the current view contains the provided bounding sphere.
偏移量是以边界球体中心为中心的局部东西向参考系中的航向/俯仰/范围。航向角和俯仰角在当地的东西向参考系中定义。航向是与 y 轴的角度并朝 x 轴增加。俯仰角是相对于 xy 平面的旋转。正俯仰角位于平面下方。负俯仰角位于平面上方。范围是距中心的距离。如果范围为零,则将计算一个范围,使得整个边界球体可见。 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.
在 2D 中,必须有一个自顶向下的视图。相机将放置在目标上方,俯视。目标上方的高度将是范围。航向将根据偏移量确定。如果无法根据偏移确定航向,则航向将为北。 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.
| 名称 Name |
类型 Type |
说明 Description |
boundingSphere |
BoundingSphere
|
在世界坐标中要查看的边界球体。 The bounding sphere to view, in world coordinates. |
offset |
HeadingPitchRange
|
可选 optional
以目标为中心的局部东西向参考系中距目标的偏移量。 The offset from the target in the local east-north-up reference frame centered at the target. |
抛出: Throws:
-
DeveloperError
:变形时不支持 viewBoundingSphere。
: viewBoundingSphere is not supported while morphing.
将矢量或点从世界坐标变换到相机的参考系。 Transform a vector or point from world coordinates to the camera's reference frame.
| 名称 Name |
类型 Type |
说明 Description |
cartesian |
Cartesian4
|
要变换的向量或点。 The vector or point to transform. |
result |
Cartesian4
|
可选 optional
用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
变换后的向量或点。 The transformed vector or point.
将点从世界坐标变换到相机的参考系。 Transform a point from world coordinates to the camera's reference frame.
| 名称 Name |
类型 Type |
说明 Description |
cartesian |
Cartesian3
|
转变的点。 The point to transform. |
result |
Cartesian3
|
可选 optional
用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
变换后的点。 The transformed point.
将矢量从世界坐标变换到相机的参考系。 Transform a vector from world coordinates to the camera's reference frame.
| 名称 Name |
类型 Type |
说明 Description |
cartesian |
Cartesian3
|
要变换的向量。 The vector to transform. |
result |
Cartesian3
|
可选 optional
用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
变换后的向量。 The transformed vector.
Zooms amount 沿着相机的视图向量。 along the camera's view vector.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
移动量。默认为 The amount to move. Defaults to defaultZoomAmount. |
另见: See:
Zooms amount 沿着相机视图矢量的相反方向。 along the opposite direction of the camera's view vector.
| 名称 Name |
类型 Type |
说明 Description |
amount |
number
|
可选 optional
移动量。默认为 The amount to move. Defaults to defaultZoomAmount. |
另见: See:
类型定义 Type Definitions
航班取消时将执行的函数。 A function that will execute when a flight is cancelled.
飞行完成时将执行的函数。 A function that will execute when a flight completes.