///////////////////////////////////////////////////////////////////////////
|
// Copyright © 2019 zhongsong. All Rights Reserved.
|
// 模块描述:显示坐标
|
///////////////////////////////////////////////////////////////////////////
|
define([
|
'dojo/_base/declare',
|
'dojo/_base/lang',
|
'dojo/_base/array',
|
'dojo/_base/html',
|
'dojo/topic',
|
'jimu/BaseWidget',
|
'jimu/utils',
|
'jimu/css!libs/zTree_v3/css/zTreeStyle/zTreeStyle.css',
|
'libs/zTree_v3/js/jquery.ztree.all'
|
],
|
function (declare,
|
lang,
|
array,
|
html,
|
topic,
|
BaseWidget,
|
aspect,
|
string,
|
utils
|
) {
|
return declare([BaseWidget], {
|
baseClass: 'jimu-widget-modelDiagram',
|
name: 'modelDiagram',
|
layers: {},
|
startup: function () {
|
var that = this;
|
// 暴露在外的接口
|
// that.beginModelDiagram();
|
// that.beginCesium();
|
|
// 三个按钮事件
|
$('.jimu-widget-modelDiagram').find('.once').click(() => {
|
that.once();
|
})
|
$('.jimu-widget-modelDiagram').find('.always').click(() => {
|
that.always();
|
})
|
$('.jimu-widget-modelDiagram').find('.stopPlay').click(() => {
|
that.stopPlay();
|
})
|
|
$('.jimu-widget-modelDiagram').find('.always').unbind("mousedown").bind("mousedown", function (event) {
|
if (event.which == 3) {
|
// console.log('you');
|
if ($("#modelDiagramCHONGFU").is(":hidden")) { //判断是否隐藏
|
$('#modelDiagramCHONGFU').show();
|
$('#modelDYes').click(() => {
|
that.getInput();
|
var W = $('#modelDiagramW').val(),
|
H = $('#modelDiagramH').val(),
|
JW = $('#modelDiagramJW').val(),
|
JH = $('#modelDiagramJH').val(),
|
as = that.a - (0.00001 * ((+H + 1) / 2)) * JH,
|
bs = that.b - (0.00001 * ((+W + 1) / 2)) * JW;
|
for (var i = 1; i <= H; i++) {
|
var aa = as * 100000;
|
aa += i * JH;
|
aa = aa / 100000;
|
for (var n = 1; n <= W; n++) {
|
var bb = bs * 100000;
|
bb += n * JW;
|
bb = bb / 100000;
|
// console.log(aa,bb)
|
that.always(aa, bb);
|
}
|
}
|
})
|
$('#modelDNo').click(() => {
|
$('#modelDiagramCHONGFU').hide();
|
})
|
}
|
} else if (event.which == 1) {
|
// console.log('zuo');
|
}
|
});
|
|
$('.jimu-widget-modelDiagram').find('.closesmodelDiagram').click(() => {
|
$('.jimu-widget-modelDiagram').hide();
|
that.stopPlay();
|
})
|
//初演示
|
layui.use(['dropdown', 'util', 'layer', 'table'], function () {
|
var dropdown = layui.dropdown,
|
layer = layui.layer;
|
dropdown.render({
|
elem: '.models',
|
data: [{
|
title: '人偶',
|
value: './images/gltf/Cesium_Man.glb',
|
id: 100,
|
num: [3, 3, 1, 1]
|
}, {
|
title: '飞机',
|
value: './images/gltf/Cesium_Air.glb',
|
id: 101,
|
num: [3, 3, 30, 30]
|
}, {
|
title: '飞机2',
|
value: './images/gltf/CesiumDrone.glb',
|
id: 102,
|
num: [3, 3, 7, 7]
|
}, {
|
title: '装甲车',
|
value: './images/gltf/GroundVehicle.glb',
|
id: 103,
|
num: [3, 3, 4, 9]
|
}, {
|
title: '热气球',
|
value: './images/gltf/CesiumBalloon.glb',
|
id: 104,
|
num: [3, 3, 1, 1]
|
}, {
|
title: '牛奶车',
|
value: './images/gltf/CesiumMilkTruck.glb',
|
id: 105,
|
num: [3, 3, 1, 1]
|
}, {
|
title: '牛奶车gltf',
|
value: './images/gltf/CesiumMilkTruck.gltf',
|
id: 106,
|
num: [3, 3, 1, 1]
|
}, {
|
title: '人gltf',
|
value: './images/gltf/walk.gltf',
|
id: 107,
|
num: [3, 3, 1, 1]
|
}],
|
click: function (obj) {
|
layer.tips('选择了:' + obj.title, this.elem, {
|
tips: [1, '#5FB878']
|
});
|
that.urls = obj.value;
|
var dom = $('.models');
|
dom.empty();
|
var str = `${obj.title} <i class="layui-icon layui-icon-down layui-font-12"></i>`
|
dom.append(str);
|
that.setNum(obj.num)
|
}
|
});
|
});
|
|
|
},
|
urls: './images/gltf/Cesium_Man.glb',
|
setNum: function (num) {
|
$('#modelDiagramW').val(num[0])
|
$('#modelDiagramH').val(num[1])
|
$('#modelDiagramJW').val(num[2])
|
$('#modelDiagramJH').val(num[3])
|
},
|
beginCesium: function (a, b, g, once) {
|
var viewer = this.map,
|
that = this,
|
url = that.urls;
|
|
//静态
|
// var position = Cesium.Cartesian3.fromDegrees(116.058987, 28.973468, 1000);
|
var position = Cesium.Cartesian3.fromDegrees(a, b, g);
|
that.entityPeople = viewer.entities.add({ //viewer.trackedEntity跟随
|
name: url,
|
position: position,
|
model: {
|
uri: url,
|
scale: 110
|
},
|
});
|
|
|
|
if (once == 'once') {
|
// viewer.trackedEntity = that.entityPeople;
|
that.map.camera.flyTo({
|
destination: position,
|
duration: 3
|
});
|
}
|
|
|
},
|
entityPeople: '',
|
seeEntity: true,
|
openEntity: false,
|
time: '',
|
beginPlay: function () {
|
var postion = [116.058987, 28.973468, 1000],
|
a = 116.058987,
|
b = 28.973468,
|
g = 1000;
|
this.time = setInterval(() => {
|
|
if (this.openEntity) {
|
// this.map.entities.remove(this.entityPeople)//删除entity
|
// this.map.entities.remove(this.map.trackedEntity)//删除entity
|
this.map.entities.removeAll();
|
} else {
|
a += 0.01;
|
b += 0.01;
|
// g += 0.01;
|
this.beginCesium(a, b);
|
}
|
this.openEntity = !this.openEntity;
|
console.log(this.openEntity)
|
}, 1000);
|
},
|
stopPlay: function () {
|
this.map.entities.removeAll();
|
// clearInterval(this.time);
|
},
|
seemodo: function () {
|
var that = this;
|
if (that.seeEntity) {
|
this.map.trackedEntity = that.entityPeople; //目标视野跟踪
|
} else {
|
this.map.trackedEntity = '';
|
}
|
that.seeEntity = !that.seeEntity;
|
console.log(that.seeEntity)
|
// console.log('seedom')
|
// this.map.entities.remove(this.entityPeople)//删除entity
|
},
|
getInput: function () {
|
this.a = $('#modelDiagramjdu').val() == '' ? 116.058987 : +$('#modelDiagramjdu').val();
|
this.b = $('#modelDiagramwdu').val() == '' ? 28.973468 : +$('#modelDiagramwdu').val();
|
this.g = $('#modelDiagramgdu').val() == '' ? 1000 : +$('#modelDiagramgdu').val();
|
},
|
a: '',
|
b: '',
|
g: '',
|
//重复添加
|
always: function (aa = 'a', bb = 'b') {
|
this.getInput();
|
// console.log([a, b, g])
|
if (aa != 'a' && bb != 'b') {
|
this.beginCesium(aa, bb, this.g);
|
} else {
|
this.beginCesium(this.a, this.b, this.g);
|
}
|
},
|
//单次添加
|
once: function () {
|
this.stopPlay();
|
this.getInput();
|
// console.log([a, b, g])
|
this.beginCesium(this.a, this.b, this.g, 'once');
|
},
|
closeModo: function () {
|
if (this.openEntity) {
|
// this.map.entities.remove(this.entityPeople)//删除entity
|
// this.map.entities.remove(this.map.trackedEntity)//删除entity
|
this.map.entities.removeAll();
|
} else {
|
this.getInput
|
// console.log([a, b, g])
|
this.beginCesium(a, b, g);
|
}
|
this.openEntity = !this.openEntity;
|
console.log(this.openEntity)
|
// var that = this;
|
// if (that.seeEntity) {
|
// this.map.trackedEntity = that.entityPeople;//目标视野跟踪
|
// } else {
|
// this.map.trackedEntity = '';
|
// }
|
// viewer.entities.remove(that.entityPeople)//删除entity
|
|
// viewer.entities.removeById(id)//根据id删除entity
|
|
// viewer.entities.removeAll()//清空所有entity
|
|
// viewer.entities.getById(id)// 获取enetity
|
|
// viewer.entities.contains(entity)// 是否包含
|
// viewer.entities.removeById('')
|
},
|
beginModelDiagram: function () {
|
var that = this,
|
viewer = that.map,
|
scene = viewer.scene;
|
// scene.globe.show = false;
|
viewer.shouldAnimate = true;
|
var collect = new Cesium.InstanceLayer(scene._context),
|
url = "./images/gltf/walk.gltf",
|
gltf = viewer.entities.add({
|
name: "gltf",
|
position: new Cesium.Cartesian3.fromDegrees(115.783206 - 0.002034006, 28.810602 - 0.005072179, 800),
|
model: {
|
uri: url
|
}
|
});
|
viewer.zoomTo(gltf);
|
$("#modelDiagramSelOpt").change(function () {
|
var value = $(this).val();
|
if (value === "1") {
|
collect.removeInstance(url, [collect._instances._array[0]._array[0].id]);
|
viewer.entities._show = true;
|
} else {
|
viewer.entities._show = false;
|
collect.add(url, {
|
position: new Cesium.Cartesian3.fromDegrees(115.783206 - 0.002034006, 28.810602 - 0.005072179, 1000)
|
});
|
|
}
|
})
|
},
|
onClose: function () {
|
//面板关闭的时候触发 (when this panel is closed trigger)
|
},
|
|
onMinimize: function () {
|
this.resize();
|
},
|
|
onMaximize: function () {
|
this.resize();
|
},
|
|
resize: function () {
|
|
},
|
|
|
destroy: function () {
|
//销毁的时候触发
|
//todo
|
//do something before this func
|
this.inherited(arguments);
|
}
|
|
});
|
});
|