You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
4.5 KiB
139 lines
4.5 KiB
/**
|
|
* 全局变量_Tool工具
|
|
*/
|
|
var gisToolsRoam_entity;
|
|
|
|
//点击设备:图标/模型,三维模型触发的点击事件
|
|
var PutInVideo_RightHandler3D = new _Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
PutInVideo_RightHandler3D.setInputAction(function(movement) {
|
|
var pick = viewer.scene.pick(movement.position);
|
|
//获取模型坐标位置
|
|
var position = viewer.scene.pickPosition(movement.position);
|
|
//将笛卡尔坐标转化为经纬度坐标
|
|
var cartographic = _Cesium.Cartographic.fromCartesian(position);
|
|
var longitude = _Cesium.Math.toDegrees(cartographic.longitude);
|
|
var latitude = _Cesium.Math.toDegrees(cartographic.latitude);
|
|
var height = cartographic.height;
|
|
if (height < 0) {
|
|
height = 0;
|
|
}
|
|
if(pick && pick.id){
|
|
if(pick.id._name == "camera"){
|
|
DrawVideoPlace(longitude,latitude,height);
|
|
}
|
|
}else{
|
|
console.log("当前选中的是模型");
|
|
}
|
|
}, _Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
|
|
//点击设备:图标/模型,三维模型触发的点击事件
|
|
var GetPoint = function (){
|
|
var handler3D = new _Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
handler3D.setInputAction(function(movement) {
|
|
var pick = viewer.scene.pick(movement.position);
|
|
//获取模型坐标位置
|
|
var position = viewer.scene.pickPosition(movement.position);
|
|
//将笛卡尔坐标转化为经纬度坐标
|
|
var cartographic = _Cesium.Cartographic.fromCartesian(position);
|
|
var longitude = _Cesium.Math.toDegrees(cartographic.longitude);
|
|
var latitude = _Cesium.Math.toDegrees(cartographic.latitude);
|
|
var height = cartographic.height;
|
|
if (height < 0) {
|
|
height = 0;
|
|
}
|
|
console.log(longitude+","+latitude+","+height);
|
|
}, _Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
}
|
|
|
|
//获取当前相机位置
|
|
var GetCameraPoint = function (){
|
|
var camera = viewer.camera;
|
|
console.log(camera);
|
|
|
|
var cartographic=viewer.scene.globe.ellipsoid.cartesianToCartographic(camera.position);
|
|
var lng=_Cesium.Math.toDegrees(cartographic.longitude);
|
|
var lat=_Cesium.Math.toDegrees(cartographic.latitude);
|
|
var alt=cartographic.height;
|
|
console.log(lng+","+lat+","+alt);//输出x,y,z(经纬度)
|
|
|
|
var heading = _Cesium.Math.toDegrees(camera.heading);
|
|
var pitch = _Cesium.Math.toDegrees(camera.pitch);
|
|
var roll = _Cesium.Math.toDegrees(camera.roll);
|
|
console.log(heading+","+pitch+","+roll);//输出方向(度数)
|
|
|
|
var rectangle = viewer.camera.computeViewRectangle();
|
|
var west =rectangle.west / Math.PI * 180;
|
|
var north = rectangle.north / Math.PI * 180;
|
|
var east = rectangle.east / Math.PI * 180;
|
|
var south = rectangle.south / Math.PI * 180;
|
|
console.log(west+","+north+","+east+","+south);//输出相机所看到的区域坐标(经纬度)
|
|
}
|
|
|
|
/**
|
|
* flyTo:飞行定位公用方法
|
|
* x:经度(WGS84)
|
|
* y:纬度(WGS84)
|
|
* z:高程(WGS84)
|
|
* h:水平旋转偏航角(°)
|
|
* p:垂直旋转俯仰角(°)
|
|
* r:左右旋转翻滚角(°)
|
|
* d:飞行时间(mm)
|
|
*/
|
|
var flyTo = function (x,y,z,h,p,r,d){
|
|
viewer.camera.flyTo({
|
|
destination: _Cesium.Cartesian3.fromDegrees(x,y,z),
|
|
orientation: {
|
|
heading: _Cesium.Math.toRadians(h),
|
|
pitch: _Cesium.Math.toRadians(p),
|
|
roll: r
|
|
},
|
|
duration: d//动画持续时间
|
|
});
|
|
}
|
|
|
|
/**
|
|
* setView:瞬间定位公用方法(没有飞行动画效果)
|
|
* x:经度(WGS84)
|
|
* y:纬度(WGS84)
|
|
* z:高程(WGS84)
|
|
* h:水平旋转偏航角(°)
|
|
* p:垂直旋转俯仰角(°)
|
|
* r:左右旋转翻滚角(°)
|
|
*/
|
|
var setView = function (x,y,z,h,p,r){
|
|
viewer.camera.setView({
|
|
destination: _Cesium.Cartesian3.fromDegrees(x,y,z),
|
|
orientation: {
|
|
heading: _Cesium.Math.toRadians(h),
|
|
pitch: _Cesium.Math.toRadians(p),
|
|
roll: r
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function GetRoamStart(){
|
|
gisToolsRoam_entity = viewer.entities.add({
|
|
availability : new _Cesium.TimeIntervalCollection([new _Cesium.TimeInterval({
|
|
start : roam_start,
|
|
stop : roam_stop
|
|
})]),
|
|
position : roam_position,
|
|
orientation : new _Cesium.VelocityOrientationProperty(roam_position),
|
|
model : {
|
|
uri : ctx+'/js/gis/data/XFC.gltf',
|
|
distanceDisplayCondition : 0
|
|
}
|
|
});
|
|
viewer.trackedEntity = gisToolsRoam_entity;
|
|
|
|
viewer.clock.startTime = roam_start.clone();
|
|
viewer.clock.stopTime = roam_stop.clone();
|
|
viewer.clock.currentTime = roam_start.clone();
|
|
viewer.clock.clockRange = _Cesium.ClockRange.LOOP_STOP; //Loop at the end
|
|
viewer.clock.multiplier = 1;
|
|
}
|
|
function GetRoamStop(){
|
|
viewer.entities.remove(gisToolsRoam_entity);
|
|
}
|
|
|
|
|