Namespace: FdCamera

FdCamera

漫游交互模块 用来管理相机操作相关的一些静态函数

Classes

capture2
FdCameraHeight
FdCameraHistory
FdManipulateCube2
FdMouseHandlerCenterIcon
FdPlaneViewCameraHelper
FdTrackManager
FdZoomByRectangle

Methods


<static> aerialView(scene [, duration] [, west] [, south] [, east] [, north])

鸟瞰中国

Parameters:
Name Type Argument Description
scene Freedo.Scene

场景对象

duration Number <optional>

飞行的时间(单位:秒)。如果省略,会根据飞行距离来计算一个理想的飞行时间

west Number <optional>

最西边的经度(单位:度,范围:[-180.0, 180.0]),默认80。

south Number <optional>

最南边的纬度(单位:度,范围:[-90.0, 90.0]),默认5。

east Number <optional>

最东边的经度(单位:度,范围:[-180.0, 180.0]),默认135。

north Number <optional>

最北边的纬度(单位:度,范围:[-90.0, 90.0]),默认55。

Example
var scene = viewer.scene;
Freedo.FdCamera.aerialView(scene);//可省略后面的5个参数
//Freedo.FdCamera.aerialView(scene, 2, 80, 5, 135, 55); //默认的中国范围

<static> capture(scene, captureResultFunc [, width] [, height])

截屏

Parameters:
Name Type Argument Description
scene Freedo.Scene

场景对象

captureResultFunc Callback

回调函数,捕获以后,通过回调函数获取相关图片,该回调函数有三个参数,参数为base64位字符串image图像及图像的长宽。

width Number <optional>

图像宽度,默认为128

height Number <optional>

图像高度,默认为128

Example
function saveCapturedScreenImage(imageData, width, height){}

var scene = viewer.scene;

Freedo.FdCamera.capture(scene, saveCapturedScreenImage, width, height);

<static> flyAround(position, scene [, options])

相机绕模型包围体顺时针飞行两周,缓慢停止

Parameters:
Name Type Argument Description
position Freedo.Cartesian3

旋转中心点

scene Freedo.Scene

场景对象

options Object <optional>

其他参数设置

Properties
Name Type Argument Description
duration Number <optional>

持续时间,单位秒,默认3s

rotateAngleRange Number <optional>

旋转角度,单位弧度,默认 Freedo.Math.PI * 4.0

easingFunction Freedo.EasingFunction <optional>

变化曲线,可以参照Freedo.EasingFunction进行设置,默认值为 Freedo.EasingFunction.QUADRACTIC_IN_OUT

delay Number <optional>

延迟时间,单位秒,默认0s

Returns:

返回值是一个函数,调用该函数可以取消环绕飞行。

Type
Freedo.Event~RemoveCallback
Example
var viewer = Freedo.FdApp.createDefaultViewer('freedoContainer');
Freedo.FdCamera.flyAround(Freedo.Cartesian3.fromDegrees(116, 31, 100), viewer.scene, {
    delay: 5
});

<static> flyToByCameraInfo(camera, cameraInfo, options)

飞入指定的相机方位,会有一个飞入的过程。

Parameters:
Name Type Description
camera Freedo.Camera

场景相机对象

cameraInfo Array.<Number>

存放相机信息的数组,该数组的组成与FdCamera.getCurrentCameraInfo相同。

options Object

包含一些选项,暂不开放

Example
var cameraInfo = [119.0, 39.0, 5000.0, 0.0, -90.0, 0.0];
Freedo.FdCamera.flyToByCameraInfo(viewer.scene.camera, cameraInfo) ;

<static> flyToByPosition(camera, positon, range)

飞入指定位置。

Parameters:
Name Type Description
camera Freedo.Camera

场景相机对象

positon Array.<Number>

位置数组[longitude, latitude, height]。

range Number

距离

Example
var positon = [119.0, 39.0, 5000.0];
Freedo.FdCamera.flyToByPosition(viewer.scene.camera, positon);

<static> flyToEast(scene, boundingSphere)

相机飞到模型包围球东边,朝向模型

Parameters:
Name Type Description
scene Freedo.Scene

场景对象

boundingSphere Freedo.BoundingSphere

模型包围体

Example
var boundingSphere = tileset.boundingSphere;
Freedo.FdCamera.flyToEast(viewer.scene, boundingSphere);

<static> flyToNorth(scene, boundingSphere)

相机飞到模型包围球北边,朝向模型

Parameters:
Name Type Description
scene Freedo.Scene

场景对象

boundingSphere Freedo.BoundingSphere

模型包围体

Example
var boundingSphere = tileset.boundingSphere;
Freedo.FdCamera.flyToNorth(viewer.scene, boundingSphere);

<static> flyToSouth(scene, boundingSphere)

相机飞到模型包围球南边,朝向模型

Parameters:
Name Type Description
scene Freedo.Scene

场景对象

boundingSphere Freedo.BoundingSphere

模型包围体

Example
var boundingSphere = tileset.boundingSphere;
Freedo.FdCamera.flyToSouth(viewer.scene, boundingSphere);

<static> flyToTop(scene, boundingSphere)

相机飞到模型包围球上边,俯视模型

Parameters:
Name Type Description
scene Freedo.Scene

场景对象

boundingSphere Freedo.BoundingSphere

模型包围体

Example
var boundingSphere = tileset.boundingSphere;
Freedo.FdCamera.flyToTop(viewer.scene, boundingSphere);

<static> flyToWest(scene, boundingSphere)

相机飞到模型包围球西边,朝向模型

Parameters:
Name Type Description
scene Freedo.Scene

场景对象

boundingSphere Freedo.BoundingSphere

模型包围体

Example
var boundingSphere = tileset.boundingSphere;
Freedo.FdCamera.flyToWest(viewer.scene, boundingSphere);

<static> getCurrentCameraInfo(camera)

获取相机位置和姿态信息

Parameters:
Name Type Description
camera Freedo.Camera

场景相机对象

Returns:

返回一个数组,分别记录了相机的经纬度坐标位置和姿态(角度值),即[longitude, latitude, height, heading, pitch, roll]

Type
Array.<Number>
Example
var cameraInfo = getCurrentCameraInfo(camera);

<static> goToByCameraInfo(camera, cameraInfo)

直接跳入指定的相机方位,不会有飞行的过程。

Parameters:
Name Type Description
camera Freedo.Camera

场景相机对象

cameraInfo Array.<Number>

存放相机信息的数组,该数组的组成与FdCamera.getCurrentCameraInfo相同。

Example
var cameraInfo = [119.0, 39.0, 5000.0, 0.0, -90.0, 0.0];
Freedo.FdCamera.goToByCameraInfo(viewer.scene.camera, cameraInfo) ;

<static> goToByPosition(camera, positon, range)

跳入指定位置。

Parameters:
Name Type Description
camera Freedo.Camera

场景相机对象

positon Array.<Number>

位置数组[longitude, latitude, height]。

range Number

距离

Example
var positon = [119.0, 39.0, 5000.0];
Freedo.FdCamera.goToByPosition(viewer.scene.camera, positon);

<static> gotoModel(viewer, model)

跳转到GLTF模型

Parameters:
Name Type Description
viewer Object

Viewer对象

model Object

GLTF模型

Example
Freedo.FdCamera.gotoModel(viewer, tileset);

<static> lookLeft(camera, angle)

以当前相机世界坐标为中心点向左旋转相机

Parameters:
Name Type Description
camera Freedo.Camera

场景相机对象

angle Number

相机旋转角度,单位为度

Example
var angle = 30;
Freedo.FdCamera.lookLeft(viewer.scene.camera, angle);

<static> lookRight(camera, angle)

以当前相机世界坐标为中心点向右旋转相机

Parameters:
Name Type Description
camera Freedo.Camera

场景相机对象

angle Number

相机旋转角度,单位为度

Example
var angle = 30;
Freedo.FdCamera.lookRight(viewer.scene.camera, angle);

<static> setZoomFactor(viewer, factor)

设置鼠标滚轮滚动速度

Parameters:
Name Type Description
viewer Freedo.Viewer

视口对象

factor Number

缩放因子,默认值为5,值越小滚动一次变化的距离越小