/////////////////////////////////////////////////////////////////////////// // 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, 15, 17] }, { title: '牛奶车', value: './images/gltf/CesiumMilkTruck.glb', id: 105, num: [3, 3, 3, 5] }, { title: '牛奶车gltf', value: './images/gltf/CesiumMilkTruck.gltf', id: 106, num: [3, 3, 3, 5] }, { 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} ` dom.append(str); a = obj.num[2]; b = obj.num[3]; that.getInput(); var neWnum = [obj.num[0], obj.num[1], obj.num[2] * that.scale, obj.num[3] * that.scale] that.setNum(neWnum); } }); }); var a = 1; var b = 1; $("#modelDiagrambeishu").on("input", function () { // $('#modelDiagramW').val(); var it = $(this).val(); $('#modelDiagramJW').val(a * it); // $('#modelDiagramH').val(); $('#modelDiagramJH').val(b * it); console.log(a, b, it) }); }, 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, scale) { var viewer = this.map, that = this, url = that.urls; //静态 // var position = Cesium.Cartesian3.fromDegrees(116.058987, 28.973468, 1000); // console.log(a, b, g, scale) var position = Cesium.Cartesian3.fromDegrees(a, b, g); that.entityPeople = viewer.entities.add({ //viewer.trackedEntity跟随 name: url, position: position, model: { uri: url, scale: scale }, }); if (once == 'once') { // viewer.trackedEntity = that.entityPeople; var gg = g + scale * 6; that.map.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(a, b, gg), duration: 3 }); } }, 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(); this.scale = $('#modelDiagrambeishu').val() == '' ? 1000 : +$('#modelDiagrambeishu').val(); }, a: '', b: '', g: '', scale: '', //重复添加 always: function (aa = 'a', bb = 'b') { this.getInput(); // console.log([a, b, g]) if (aa != 'a' && bb != 'b') { this.beginCesium(aa, bb, this.g, '', this.scale); } else { this.beginCesium(this.a, this.b, this.g, '', this.scale); } }, //单次添加 once: function () { this.stopPlay(); this.getInput(); // console.log([a, b, g]) this.beginCesium(this.a, this.b, this.g, 'once', this.scale); }, 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); } }); });