相机由位置、方向和视锥定义。
方向与视图、上和右=视图x向上单位向量形成正交基准。
视锥由6个平面定义。
每个平面由一个
Cartesian4
对象表示,其中x、y和z分量
定义垂直于平面的单位向量,w分量是
从原点/摄影机位置平面。
Name |
Type |
Description |
scene |
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.
var 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
当摄影机飞到包含边界球体的位置时使用的默认方向/俯仰/范围。
static Cesium.Camera.DEFAULT_VIEW_FACTOR : Number
一个标量,用于倍增到摄影机位置,并在设置摄影机以查看矩形后将其添加回来。
零值大于61165意味着整个摄像机的值大于
将使其进一步远离范围,小于零的值将使其靠近范围。
创建时相机将查看的默认矩形。
获取当摄影机更改为percentageChanged
时将引发的事件。
如果已设置,摄影机将无法在任何方向旋转过该轴。
undefined
当参数不是时的默认旋转量
提供给look方法。
Math.PI / 60.0
参数不是时移动摄影机的默认值
提供给移动方法。
100000.0;
当参数不是时的默认旋转量
提供给rotate方法。
Math.PI / 3600.0
参数不是时移动摄影机的默认值
提供给缩放方法。
100000.0;
摄影机的视图方向。
获取摄影机在世界坐标系中的视图方向。
视野中的空间区域。
PerspectiveFrustum()
See:
获取以弧度表示的摄影机方向。
获取反转摄影机变换。
Matrix4.IDENTITY
获取反视图矩阵。
See:
因子乘以用于确定在何处钳制摄影机位置的贴图大小
从曲面缩小时。默认值为1.5。仅对2D有效,且贴图可旋转。
1.5
获取当摄影机停止移动时将引发的事件。
获取将在摄影机开始移动时引发的事件。
在事件61165被提升到6866之前,该事件已被提升到6866。该值是[0,1]范围内的百分比。
0.5
获取以弧度表示的摄影机间距。
摄像机的位置。
获取摄影机的
Cartographic
位置,以及经度和纬度
以米和弧度表示。在二维和哥伦布视图中,这是可能的
返回的经纬度超出有效经度范围
当摄像机在地图之外时的纬度。
获取摄影机在世界坐标系中的位置。
相机的正确方向。
获取相机在世界坐标系中的正确方向。
使摄影机以弧度旋转。
获取摄影机的参考帧。此变换的逆运算被附加到视图矩阵中。
Matrix4.IDENTITY
相机的向上方向。
获取摄影机在世界坐标系中的向上方向。
获取视图矩阵。
See:
Methods
将一个向量或点从相机的参考坐标系转换为世界坐标系。
Returns:
变换后的向量或点。
将一个点从相机的参考坐标系转换为世界坐标系。
Returns:
变换后的点。
将一个向量从相机的参考坐标系转换为世界坐标系。
Returns:
变换后的向量。
取消当前摄影机飞行并将摄影机保留在其当前位置。
如果没有飞行正在进行中,此函数不起任何作用。
完成当前相机飞行并立即将相机移动到其最终目的地。
如果没有飞行正在进行中,此函数不起任何作用。
计算椭球体上的近似可见矩形。
Name |
Type |
Default |
Description |
ellipsoid |
Ellipsoid
|
Ellipsoid.WGS84
|
optional
要知道可见区域的椭球体。 |
result |
Rectangle
|
|
optional
存储结果的矩形 |
Returns:
可见矩形或未定义(如果椭球体根本不可见)。
distanceToBoundingSphere(boundingSphere) → Number
返回从摄影机到边界球体前面的距离。
Returns:
到边界球体的距离。
将相机飞到主视图。使用Camera#.DEFAULT_VIEW_RECTANGLE
设置
三维场景的默认视图。二维和哥伦布视图的主视图显示
整个地图。
Name |
Type |
Description |
duration |
Number
|
optional
飞行的持续时间(秒)。如果省略,铯会根据飞行的距离来计算一个理想的持续时间。见Camera#flyTo |
将摄影机从当前位置飞到新位置。
Name |
Type |
Description |
options |
Object
|
具有以下属性的对象:
Name |
Type |
Description |
destination |
Cartesian3
|
Rectangle
|
相机在WGS84(世界)坐标系中的最终位置或从自顶向下视图中可以看到的矩形。 |
orientation |
Object
|
optional
包含方向和上方向属性或方向、俯仰和横滚属性的对象。默认情况下,方向将指向
在3D中朝向框架中心,在哥伦布视图中沿z负方向。向上方向在3D和正方向指向局部北
哥伦布视图中的y方向。在无限滚动模式下,2D中不使用方向。 |
duration |
Number
|
optional
飞行的持续时间(秒)。如果省略,铯将尝试根据飞行所要行驶的距离计算理想持续时间。 |
complete |
Camera.FlightCompleteCallback
|
optional
飞行完成后执行的功能。 |
cancel |
Camera.FlightCancelledCallback
|
optional
航班取消时执行的功能。 |
endTransform |
Matrix4
|
optional
变换矩阵表示飞行完成时相机将处于的参考帧。 |
maximumHeight |
Number
|
optional
飞行高峰时的最大高度。 |
pitchAdjustHeight |
Number
|
optional
如果摄影机的飞行高度高于该值,请在飞行过程中调整俯仰俯视,并将地球保持在视口中。 |
flyOverLongitude |
Number
|
optional
地球上总是有两个点。这个选项会迫使相机选择飞行方向以飞越该经度。 |
flyOverLongitudeWeight |
Number
|
optional
仅当飞行方式不超过短距离乘以飞行超长重量时,飞越飞越飞越指定的lon。 |
convert |
Boolean
|
optional
是否将目标从世界坐标转换为场景坐标(仅在不使用3D时相关)。默认为true 。 |
easingFunction |
EasingFunction.Callback
|
optional
控制如何在飞行持续时间内插值时间。 |
|
Throws:
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
}
});
flyToBoundingSphere(boundingSphere, options)
将摄影机飞到当前视图包含提供的边界球体的位置。
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.
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
|
要查看的边界球体,以世界坐标为单位。 |
options |
Object
|
optional
具有以下属性的对象:
Name |
Type |
Description |
duration |
Number
|
optional
飞行的持续时间(秒)。如果省略,铯将尝试根据飞行所要行驶的距离计算理想持续时间。 |
offset |
HeadingPitchRange
|
optional
在以目标为中心的局部东-北上参考坐标系中与目标的偏移。 |
complete |
Camera.FlightCompleteCallback
|
optional
飞行完成后执行的功能。 |
cancel |
Camera.FlightCancelledCallback
|
optional
航班取消时执行的功能。 |
endTransform |
Matrix4
|
optional
变换矩阵表示飞行完成时相机将处于的参考帧。 |
maximumHeight |
Number
|
optional
飞行高峰时的最大高度。 |
pitchAdjustHeight |
Number
|
optional
如果摄影机的飞行高度高于该值,请在飞行过程中调整俯仰俯视,并将地球保持在视口中。 |
flyOverLongitude |
Number
|
optional
地球上总是有两个点。这个选项会迫使相机选择飞行方向以飞越该经度。 |
flyOverLongitudeWeight |
Number
|
optional
仅当飞行方式不超过短距离乘以飞行超长重量时,飞越飞越飞越指定的lon。 |
easingFunction |
EasingFunction.Callback
|
optional
控制如何在飞行持续时间内插值时间。 |
|
获取摄影机位置的大小。在3D中,这是矢量幅值。二维和
哥伦布视图,这是到地图的距离。
Returns:
位置的大小。
从相机位置到windowPosition
处的像素创建光线
在世界坐标系中。
Name |
Type |
Description |
windowPosition |
Cartesian2
|
像素的x和y坐标。 |
result |
Ray
|
optional
要将结果存储到的对象。 |
Returns:
getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) → Number
返回以米为单位的像素大小。
Name |
Type |
Description |
boundingSphere |
BoundingSphere
|
世界坐标系中的边界球。 |
drawingBufferWidth |
Number
|
绘图缓冲区宽度。 |
drawingBufferHeight |
Number
|
绘图缓冲区高度。 |
Returns:
以米为单位的像素大小。
获取在椭球体或地图上查看矩形所需的相机位置
Returns:
查看矩形所需的相机位置
将相机的每个方向向量围绕axis
旋转angle
Name |
Type |
Description |
axis |
Cartesian3
|
旋转的轴。 |
angle |
Number
|
optional
要旋转的角度(以弧度为单位)。默认为defaultLookAmount 。 |
See:
使用目标和偏移设置摄影机位置和方向。必须交出目标
世界坐标。偏移量可以是笛卡尔坐标,也可以是以目标为中心的局部东-北上参考坐标系中的航向/俯仰/范围。
如果偏移量是笛卡尔坐标系,则它是相对于由变换矩阵定义的参考坐标系中心的偏移量。如果偏移量
是航向/俯仰/航程,则航向和俯仰角在变换矩阵定义的参考坐标系中定义。
航向是从y轴到x轴的角度。螺距是从xy平面旋转。正螺距
角度低于平面。负俯仰角高于平面。范围是到中心的距离。
在二维中,必须有一个自顶向下的视图。摄像机将放在目标上方俯视。高于
目标将是偏移量的大小。将确定与航向的偏移量。如果标题不能
根据偏移量确定,航向为北。
Throws:
Example:
// 1. Using a cartesian offset
var 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
var center = Cesium.Cartesian3.fromDegrees(-72.0, 40.0);
var heading = Cesium.Math.toRadians(50.0);
var pitch = Cesium.Math.toRadians(-20.0);
var range = 5000.0;
viewer.camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, range));
使用目标和变换矩阵设置摄影机位置和方向。偏移量可以是笛卡尔坐标或航向/俯仰/范围。
如果偏移量是笛卡尔坐标系,则它是相对于由变换矩阵定义的参考坐标系中心的偏移量。如果偏移量
是航向/俯仰/航程,则航向和俯仰角在变换矩阵定义的参考坐标系中定义。
航向是从y轴到x轴的角度。螺距是从xy平面旋转。正螺距
角度低于平面。负俯仰角高于平面。范围是到中心的距离。
在二维中,必须有一个自顶向下的视图。摄像机将被放置在参考坐标系中心的上方。高于
目标将是偏移量的大小。将确定与航向的偏移量。如果标题不能
根据偏移量确定,航向为北。
Throws:
Example:
// 1. Using a cartesian offset
var 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
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(-72.0, 40.0));
var heading = Cesium.Math.toRadians(50.0);
var pitch = Cesium.Math.toRadians(-20.0);
var range = 5000.0;
viewer.camera.lookAtTransform(transform, new Cesium.HeadingPitchRange(heading, pitch, range));
以弧度为单位,以反方向围绕其右向量旋转摄影机
如果不是在2D模式下。
Name |
Type |
Description |
amount |
Number
|
optional
要旋转的量(以弧度为单位)。默认为defaultLookAmount 。 |
See:
以弧度为单位,以反方向围绕其上方向向量旋转摄影机
如果不是在二维模式下。
Name |
Type |
Description |
amount |
Number
|
optional
要旋转的量(以弧度为单位)。默认为defaultLookAmount 。 |
See:
以弧度为单位,沿方向围绕其上方向向量旋转摄影机
如果不是在二维模式下。
Name |
Type |
Description |
amount |
Number
|
optional
要旋转的量(以弧度为单位)。默认为defaultLookAmount 。 |
See:
以弧度为单位,沿方向围绕其右向量旋转摄影机
如果不是在2D模式下。
Name |
Type |
Description |
amount |
Number
|
optional
要旋转的量(以弧度为单位)。默认为defaultLookAmount 。 |
See:
沿direction
将摄影机的位置平移amount
。
Name |
Type |
Description |
direction |
Cartesian3
|
移动的方向。 |
amount |
Number
|
optional
移动的量,以米为单位。默认为defaultMoveAmount 。 |
See:
将摄影机的位置沿相反方向平移amount
摄影机的视图向量。
在2D模式下,这将缩小摄影机而不是平移摄影机的位置。
Name |
Type |
Description |
amount |
Number
|
optional
移动的量,以米为单位。默认为defaultMoveAmount 。 |
See:
将摄影机的位置沿相反方向平移amount
摄像机的上方向向量。
Name |
Type |
Description |
amount |
Number
|
optional
移动的量,以米为单位。默认为defaultMoveAmount 。 |
See:
沿摄影机的视图向量将摄影机的位置平移amount
。
在2D模式下,这将放大摄影机而不是平移摄影机的位置。
Name |
Type |
Description |
amount |
Number
|
optional
移动的量,以米为单位。默认为defaultMoveAmount 。 |
See:
将摄影机的位置沿相反方向平移amount
相机的右向量。
Name |
Type |
Description |
amount |
Number
|
optional
移动的量,以米为单位。默认为defaultMoveAmount 。 |
See:
沿摄影机的右向量将摄影机的位置平移amount
。
Name |
Type |
Description |
amount |
Number
|
optional
移动的量,以米为单位。默认为defaultMoveAmount 。 |
See:
沿摄影机的上方向向量将摄影机的位置平移amount
。
Name |
Type |
Description |
amount |
Number
|
optional
移动的量,以米为单位。默认为defaultMoveAmount 。 |
See:
pickEllipsoid(windowPosition, ellipsoid, result) → Cartesian3|undefined
拾取椭球体或贴图。
Name |
Type |
Default |
Description |
windowPosition |
Cartesian2
|
|
像素的x和y坐标。 |
ellipsoid |
Ellipsoid
|
Ellipsoid.WGS84
|
optional
要拾取的椭球体。 |
result |
Cartesian3
|
|
optional
要将结果存储到的对象。 |
Returns:
如果选择了椭球体或贴图,
返回椭球体或世界地图表面上的点
协调。如果未拾取椭球体或贴图,则返回未定义。
Example:
var canvas = viewer.scene.canvas;
var center = new Cesium.Cartesian2(canvas.clientWidth / 2.0, canvas.clientHeight / 2.0);
var ellipsoid = viewer.scene.globe.ellipsoid;
var result = viewer.camera.pickEllipsoid(center, ellipsoid);
将相机围绕axis
旋转angle
。距离
相机的位置到相机参考坐标系中心的位置保持不变。
Name |
Type |
Description |
axis |
Cartesian3
|
在世界坐标系中给定的旋转轴。 |
angle |
Number
|
optional
要旋转的角度(以弧度为单位)。默认为defaultRotateAmount 。 |
See:
将摄影机围绕摄影机参考帧的中心向下旋转一个角度。
Name |
Type |
Description |
angle |
Number
|
optional
要旋转的角度(以弧度为单位)。默认为defaultRotateAmount 。 |
See:
围绕摄影机参考帧的中心向左旋转摄影机。
Name |
Type |
Description |
angle |
Number
|
optional
要旋转的角度(以弧度为单位)。默认为defaultRotateAmount 。 |
See:
围绕摄影机参考帧的中心向右旋转摄影机。
Name |
Type |
Description |
angle |
Number
|
optional
要旋转的角度(以弧度为单位)。默认为defaultRotateAmount 。 |
See:
围绕摄影机参考帧的中心向上旋转摄影机。
Name |
Type |
Description |
angle |
Number
|
optional
要旋转的角度(以弧度为单位)。默认为defaultRotateAmount 。 |
See:
设置摄影机位置、方向和变换。
Name |
Type |
Description |
options |
Object
|
具有以下属性的对象:
Name |
Type |
Description |
destination |
Cartesian3
|
Rectangle
|
optional
相机在WGS84(世界)坐标系中的最终位置或从自顶向下视图中可以看到的矩形。 |
orientation |
Object
|
optional
包含方向和上方向属性或方向、俯仰和横滚属性的对象。默认情况下,方向将指向
在3D中朝向框架中心,在哥伦布视图中沿z负方向。向上方向在3D和正方向指向局部北
哥伦布视图中的y方向。在无限滚动模式下,2D中不使用方向。 |
endTransform |
Matrix4
|
optional
表示摄像机参考帧的变换矩阵。 |
convert |
Boolean
|
optional
是否将目标从世界坐标转换为场景坐标(仅在不使用3D时相关)。默认为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中是不可操作的,它总是正交的。
将视锥/投影切换为透视。
这个函数在2D中是不可操作的,它必须始终是正交的。
以弧度为单位,围绕其方向向量逆时针旋转摄影机。
Name |
Type |
Description |
amount |
Number
|
optional
要旋转的量(以弧度为单位)。默认为defaultLookAmount 。 |
See:
以弧度为单位,围绕其方向向量顺时针旋转摄影机。
Name |
Type |
Description |
amount |
Number
|
optional
要旋转的量(以弧度为单位)。默认为defaultLookAmount 。 |
See:
viewBoundingSphere(boundingSphere, offset)
设置摄影机,使当前视图包含提供的边界球体。
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.
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.
Throws:
将向量或点从世界坐标变换到相机的参考帧。
Returns:
变换后的向量或点。
将点从世界坐标变换到相机的参考坐标系。
Returns:
变换后的点。
将向量从世界坐标变换到相机的参考帧。
Returns:
变换后的向量。
沿摄影机的视图向量缩放amount
。
Name |
Type |
Description |
amount |
Number
|
optional
移动量。默认为defaultZoomAmount 。 |
See:
沿的相反方向缩放amount
摄影机的视图向量。
Name |
Type |
Description |
amount |
Number
|
optional
移动量。默认为defaultZoomAmount 。 |
See:
Type Definitions
一种在航班取消时执行的函数。
飞行结束后执行的一种功能。