分享
查看: 2115|回复: 0

[分享] ThingJS智慧粮仓源码分享

[复制链接]

ThingJS智慧粮仓源码分享

发表于 2020-5-13 12:00:16 来自 分享 阅读模式 倒序浏览
zzv_icon2115 zzr_icon0 查看全部

如何使用thingjs制作智慧粮仓可视化项目?物联网可视化项目如何制作?制作好的物联网场景该怎么去开发?

在制作项目的时候,能不能做是一个问题,怎么去做又是一个问题,交付项目的时候能否让用户满意?能否在规定时间保质保量的交付项目,而三维可视化项目的制作,相比于普通项目来说更让人头大,它要有场景模型,还得有一定的交互功能,比如摄像机视角移动或者是跟随某个物体移动,同时还得采集数据,还得使用数据采集器(传感器),收集到数据并上传到数据库中,然后3D开发人员还得获取到这个数据,并且将有需要的数据处理成可以看见的图表或者是云图等等,总体来说,一个完整需求的三维可视化开发难度还是比较大的,这里,分享一个智慧粮仓的可视化解决方案。

本次要分享的ThingJS公开的可视化解决方案是“智慧粮仓”。

如何制作这个解决方案的呢?

第一步:搭建场景;

第二步:开发场景;

第三步:数据对接;

第四步:发布项目;


场景的搭建,通过3Dmax搭建相关特殊模型,通过3dmax上传插件上传到ThingJS的campusbuilder中,通过thingjs的campusbuilder园区搭建工具制作粮仓场景;


开发场景,第一点就是控制摄像机的视角,thingjs的视角也是camera摄像机来控制的,要开发项目,首先就是学会使用camera,然后才是各种功能,智慧粮仓中有着通栏,里面含有编号、温湿度、云图、能耗、视频、人车定位这几个功能,这些功能均在thingjs在线开发左侧的官方示例。


本次分享的智慧粮仓可视化解决方案中的数据都是写死的数据,可自行使用JavaScript语法,通过thingjs官方示例中的数据对接方式,获取数据并且放入到对于图表中。以下是四种数据对接中的ajax对接方式。

/**
* 说明:
* 通过CORS解决跨域问题
* 并将数据挂接到物体(car01)身上,与panel面板进行数据绑定
* 当温度>25℃时 car01变红
* 教程:ThingJS教程——>数据对接——>Ajax对接
* 难度:★★☆☆☆
*/
var app = new THING.App({
    url: 'https://www.thingjs.com/static/models/storehouse'
});

// 定时器
var timer;

app.on('load', function () {
    var car = app.query('car01')[0];

    // 物体身上创建monitorData对象 用于存储动态监控数据
    car.monitorData = {
        '温度': ''
    };

    updateData(car);
    createPanel(car);
})

/** ******************* 以下为ajax数据对接 ********************/
// 服务器程序端 通过设置 Access-Control-Allow-Origin 解决跨域问题
// 更多关于 CORS "跨域资源共享"(Cross-origin resource sharing)的技术细节 请自行搜索
// 请求传入参数为 { "id": id }
// 服务器返回的数据格式为 {"state":"success","data":{"id":"4967","temper":"15℃","humi":"59%","power":"20kWh"}}

function updateData(obj) {
    // 如果网站是 https 接口则对应 https 请求
    // 如果网站是 http 接口则对应 http 请求即可
    $.ajax({
        type: "get",
        url: "https://3dmmd.cn/getMonitorDataById",
        data: { "id": obj.id },
        dataType: "json", // 返回的数据类型 json
        success: function (d) {
            console.log(d);
            var temper = d.data.temper;

            // 设置物体身上的监控数据
            obj.setAttribute("monitorData/温度", temper);

            changeColor(obj);

            // 每隔3s 请求一次数据
            timer = setTimeout(function () {
                updateData(obj)
            }, 3000);
        }
    });
}

// 停止请求数据
function stopUpdate() {
    clearTimeout(timer);
}

function createPanel(obj) {
    // 界面组件
    var panel = new THING.widget.Panel({
        titleText: 'car01温度',
        hasTitle: true
    });

    var monitorControl = panel.addBoolean({ 'isOpen': true }, "isOpen").caption("监控开关");
    // 将物体的monitor对象中的数据 与 panel 进行绑定
    panel.add(obj.monitorData, '温度').name('温度');

    monitorControl.on('change', function (ev) {
        if (ev) {
            updateData(obj);
        }
        else {
            stopUpdate();
        }
    })
}

// 如果温度>25 改变颜色
function changeColor(obj) {
    var temper = obj.getAttribute("monitorData/温度");
    var value = temper.substr(0, temper.indexOf("℃"));
    if (value > 25) {
        obj.style.color = 'rgb(255,0,0)';
    }
    else {
        obj.style.color = null;
    }
}



开发场景需要通过thingjs的app对象引入我们搭建的园区场景:

//-----------------------------------------------------------------------------
// 应用入口
var toolBarState = true;
var startFps = false;
var fpsControl = null;

var app = new THING.App({
   container: "div3d",
   skyBox: 'BlueSky',
   url: "models/silohouse",
   ak: "app_test_key",
   sucess: function () {
       app.camera.position = [98.5, 176.3, 218.5];
       app.camera.target = [19.7, -47.8, -22.5];
   }
});


其余的就是添加页面元素以及通过URL的方式将模型加载到在线开发中,制作出对应的tab表格,完整的智慧粮仓代码如下:

  1. document.title = 'Demo-粮仓管理';
  2. /**
  3. * 仓库封装类
  4. */
  5. function SiloHouse(obj) {
  6. this.name = obj.name;
  7. this.obj = obj;
  8. obj.siloHouse = this;
  9. this.height = obj.size[1];
  10. this.roof = obj.query('/gaizi')[0];
  11. this.roof.initPos = this.roof.position; // 保存盖子的初始位置
  12. this.temper = this.humi = this.power = this.store = "";
  13. this.info = null;
  14. this.heatMap = null;
  15. this.panel = null;
  16. this.ui = null;
  17. this.setupEvents();
  18. this.simulateData();
  19. }
  20. // 几个粮仓的静态变量
  21. SiloHouse.current = null; // 正在选中的粮仓
  22. SiloHouse.currentOpen = null; // 正在打开的粮仓
  23. SiloHouse.summeryPanel = null; // 注意统计信息只有一个面板,是静态变量
  24. // 选择
  25. SiloHouse.prototype.select = function () {
  26. this.obj.style.outlineColor = 0x0000FF;
  27. this.showSummery(true);
  28. }
  29. SiloHouse.prototype.unselect = function () {
  30. this.obj.style.outlineColor = null;
  31. this.showSummery(false);
  32. }
  33. // 屋顶
  34. SiloHouse.prototype.openRoof = function () {
  35. this.roof.initPos = this.roof.position; // 保存盖子的初始位置
  36. var pos = this.obj.upPosition(80);
  37. this.roof.moveTo({ 'position': pos, 'time': 300 });
  38. }
  39. SiloHouse.prototype.resetRoof = function () {
  40. var pos = this.roof.initPos;
  41. this.roof.moveTo({ 'position': pos, 'time': 300 });
  42. this.destroyHeatmap(); // 关闭房顶要确认云图删除
  43. }
  44. // 事件
  45. SiloHouse.prototype.setupEvents = function (obj) {
  46. var that = this;
  47. var obj = this.obj;
  48. // 单击
  49. obj.on('singleclick', function () {
  50. if (SiloHouse.current)
  51. SiloHouse.current.unselect();
  52. SiloHouse.current = that;
  53. SiloHouse.current.select();
  54. });
  55. // 双击
  56. obj.on('dblclick', function () {
  57. if (SiloHouse.currentOpen == that)
  58. return;
  59. // 取消选中的
  60. if (SiloHouse.current) {
  61. SiloHouse.current.unselect();
  62. SiloHouse.current = null;
  63. }
  64. // 取消上一次打开的
  65. if (SiloHouse.currentOpen)
  66. SiloHouse.currentOpen.resetRoof();
  67. SiloHouse.currentOpen = that;
  68. // 打开屋顶
  69. that.openRoof();
  70. // 摄像机跳转
  71. var obj = SiloHouse.currentOpen.obj;
  72. app.camera.flyTo({//飞到
  73. offset: [0, 70, -30],
  74. target: obj,
  75. time: 1000, // 耗时毫秒
  76. complete: function () {
  77. if (toolBar.data.cloud == true)
  78. SiloHouse.currentOpen.createHeatmap();
  79. }
  80. });
  81. });
  82. }
  83. // 模拟数据
  84. SiloHouse.prototype.simulateData = function (obj) {
  85. var that = this;
  86. this.info = {
  87. "基本信息": {
  88. "品种": Math.ceil(Math.random() * 2) == 1 ? "小麦" : "玉米",
  89. "库存数量": Math.ceil(Math.random() * 9000) + "",
  90. "报关员": Math.ceil(Math.random() * 2) == 1 ? "张三" : "李四",
  91. "入库时间": Math.ceil(Math.random() * 2) == 1 ? "11:24" : "19:02",
  92. "用电量": Math.ceil(Math.random() * 100) + "",
  93. "单仓核算": "无"
  94. },
  95. "粮情信息": {
  96. "仓房温度": Math.ceil(Math.random() * 27 + 25) + "",
  97. "粮食温度": Math.ceil(Math.random() * 25 + 20) + "",
  98. },
  99. "报警信息": {
  100. "火灾": "无",
  101. "虫害": "无"
  102. }
  103. };
  104. // 模拟间隔刷新的数据
  105. var simuTime = Math.ceil(1000 + Math.random() * 1000);
  106. setInterval(function () {
  107. that.temper = Math.ceil(20 + Math.random() * 10) + "℃"; // 温度
  108. that.humi = Math.ceil(30 + Math.random() * 10) + "%"; // 湿度
  109. that.power = Math.ceil(Math.random() * 20) + "kWh"; // 能耗
  110. }, simuTime);
  111. }
  112. // 头顶界面
  113. SiloHouse.prototype.createUI = function (width) {
  114. width = width || 120;
  115. // 创建widget (动态绑定数据用)
  116. var panel = new THING.widget.Panel({
  117. template: 'default',
  118. cornerType: 's2c5',
  119. width: width.toString() + "px",
  120. isClose: false,
  121. opacity: 0.8,
  122. media: true
  123. });
  124. this.panel = panel;
  125. // 创建obj ui (跟随物体用)
  126. var ui = app.create({
  127. type: 'UI',
  128. parent: this.obj,
  129. el: panel.domElement,
  130. offset: [0, this.height, 0],
  131. pivot: [0.3, 0]
  132. });
  133. this.ui = ui;
  134. return panel;
  135. }
  136. SiloHouse.prototype.showUI = function (uiName, boolValue) {
  137. if (this.panel || this.ui)
  138. this.hideUI();
  139. if (boolValue) {
  140. if (uiName == 'number') {
  141. this.createUI().add(this.obj, 'name').name('编号');
  142. } else if (uiName == 'temper') {
  143. this.createUI().add(this, uiName).name('温度');
  144. } else if (uiName == 'humi') {
  145. this.createUI().add(this, uiName).name('湿度');
  146. } else if (uiName == 'power') {
  147. this.createUI(150).add(this, uiName).name('能耗');
  148. }
  149. }
  150. }
  151. SiloHouse.prototype.hideUI = function () {
  152. if (this.panel) {
  153. this.panel.destroy();
  154. this.panel = null;
  155. }
  156. if (this.ui) {
  157. this.ui.destroy();
  158. this.ui = null;
  159. }
  160. }
  161. // 云图相关
  162. SiloHouse.prototype.createHeatmap = function () {
  163. this.heatMap = app.create({
  164. type: "Heatmap",
  165. width: this.obj.size[0],
  166. height: this.obj.size[2],
  167. minValue: 15,
  168. maxValue: 45,
  169. radius: 1.2
  170. });
  171. this.heatMap.randomData();
  172. this.heatMap.position = this.obj.position;
  173. this.heatMap.moveY(this.height + 1);
  174. this.heatMap.rotateX(90);
  175. }
  176. SiloHouse.prototype.destroyHeatmap = function () {
  177. if (!this.heatMap)
  178. return;
  179. this.heatMap.destroy();
  180. this.heatMap = null;
  181. }
  182. // 统计信息 (处理全局唯一一个面板)
  183. SiloHouse.prototype.showSummery = function (boolValue) {
  184. if (SiloHouse.summeryPanel) {
  185. SiloHouse.summeryPanel.destroy();
  186. SiloHouse.summeryPanel = null;
  187. }
  188. if (boolValue) {
  189. SiloHouse.summeryPanel = new THING.widget.Panel({
  190. template: 'default',
  191. name: this.name,
  192. isClose: true,
  193. isDrag: true,
  194. isRetract: true,
  195. hasTitle: true,
  196. width: "325px",
  197. media: true
  198. });
  199. SiloHouse.summeryPanel.setZIndex(999999);//设置ui排序
  200. SiloHouse.summeryPanel.addTab(this.info);
  201. SiloHouse.summeryPanel.setPosition({ left: 300, top: 50 });
  202. }
  203. }
  204. // ----------------------------------------------------------------------------
  205. // 摄像头封装类
  206. function VideoCamera(obj) {
  207. this.obj = obj;
  208. this.videoFrame = null;
  209. var that = this;
  210. this.marker = app.create({
  211. type: "Marker",
  212. offset: [0, 3.5, 0],
  213. size: 23,
  214. url: "https://www.thingjs.com/static/images/sliohouse/videocamera3.png",
  215. parent: obj
  216. });
  217. this.marker.visible = false;
  218. this.marker.on('click', function () {
  219. that.showVideoFrame();
  220. });
  221. }
  222. VideoCamera.prototype.showUI = function (boolValue) {
  223. this.marker.visible = boolValue;
  224. }
  225. VideoCamera.prototype.showVideoFrame = function () {
  226. if (this.videoFrame) {
  227. this.videoFrame.destroy();
  228. this.videoFrame = null;
  229. }
  230. this.videoFrame = new THING.widget.Panel({
  231. template: 'default',
  232. name: this.obj.name,
  233. isClose: true,
  234. isDrag: true,
  235. hasTitle: true,
  236. width: "450px",
  237. media: true
  238. });
  239. var ui2data = { iframe: true };
  240. var videoUrlList = ["https://gctxyc.liveplay.myqcloud.com/gc/ljgcdyhxgjt_1/index.m3u8?contentid=2820180516001", "http://gcdnc.v.dwion.com/gc/ljgcwglytylxs_1/index.m3u8?contentid=2820180516001", "https://gctxyc.liveplay.myqcloud.com/gc/hswlf_1/index.m3u8?contentid=2820180516001"];//大研花巷观景,万古楼遥望玉龙雪山,黄山卧云峰
  241. this.videoFrame.addIframe(ui2data, 'iframe').name(" ").iframeUrl('https://www.thingjs.com/demos/player/player.html?url=' + videoUrlList[parseInt((videoUrlList.length) * Math.random())]).setHeight('321px');
  242. this.videoFrame.setPosition({ left: app.domElement.offsetWidth - this.videoFrame.domElement.offsetWidth - 100, top: 100 });// ui位置默认在 右上角
  243. this.videoFrame.setZIndex(999999);
  244. var that = this;
  245. this.videoFrame.on('close', function () {
  246. if (that.videoFrame) {
  247. that.videoFrame.destroy();
  248. that.videoFrame = null;
  249. }
  250. });
  251. }
  252. // ----------------------------------------------------------------------------
  253. // 卡车封装类
  254. function Truck(obj) {
  255. this.obj = obj;
  256. this.info = { "车牌": "京A12345", "公司": "北京优锘科技有限公司", "状态": "出库", "仓房": "1号", "状态": "过磅" };
  257. }
  258. Truck.prototype.createUI = function (width) {
  259. // 创建widget (动态绑定数据用)
  260. var panel = new THING.widget.Panel({
  261. cornerType: 'polyline',
  262. width: "350px",
  263. isClose: false,
  264. opacity: 0.8,
  265. media: true
  266. });
  267. for (var key in this.info)
  268. panel.add(this.info, key);
  269. this.panel = panel;
  270. // 创建obj ui (跟随物体用)
  271. var ui = app.create({
  272. type: 'UI',
  273. parent: this.obj,
  274. el: panel.domElement,
  275. offset: [0, this.height, 0],
  276. pivot: [0, 1.45]
  277. });
  278. this.ui = ui;
  279. return panel;
  280. }
  281. Truck.prototype.showUI = function (boolValue) {
  282. if (this.ui || this.panel)
  283. this.hideUI();
  284. if (boolValue)
  285. this.createUI();
  286. }
  287. Truck.prototype.hideUI = function (width) {
  288. this.panel.destroy();
  289. this.panel = null;
  290. this.ui.destroy();
  291. this.ui = null;
  292. }
  293. //-----------------------------------------------------------------------------
  294. // 应用入口
  295. var toolBarState = true;
  296. var startFps = false;
  297. var fpsControl = null;
  298. var app = new THING.App({
  299. container: "div3d",
  300. skyBox: 'BlueSky',
  301. url: "models/silohouse",
  302. ak: "app_test_key",
  303. sucess: function () {
  304. app.camera.position = [98.5, 176.3, 218.5];
  305. app.camera.target = [19.7, -47.8, -22.5];
  306. }
  307. });
  308. // 加载完成
  309. app.on('load', function () {
  310. init();
  311. init_gui();
  312. });
  313. var siloHouseList = [];
  314. var videoCameraList = [];
  315. var truckList = [];
  316. function init() {
  317. // 摄像机
  318. app.camera.flyTo({
  319. time: 1500,
  320. position: [-182.16900300883736, 53.24677728392183, 72.21965470775368],
  321. target: [-68.1412926741533, -18.16319203074775, -23.30416731768694]
  322. });
  323. // 设置效果
  324. app.setPostEffect({
  325. enable: true,
  326. antialias: {
  327. enable: true,
  328. type: 'FXAA',
  329. },
  330. colorAdjustment: {
  331. enable: true,
  332. brightness: 0,
  333. contrast: 1.15,
  334. exposure: 0,
  335. gamma: 1,
  336. saturation: 1.3
  337. },
  338. screenSpaceAmbientOcclusion: {
  339. enable: false
  340. }
  341. });
  342. app.setLighting({
  343. ambientLight: {
  344. intensity: 0.4,
  345. color: '#FFFFFF',
  346. },
  347. mainLight: {
  348. shadow: true,
  349. intensity: 0.6,
  350. color: '#FFFFFF',
  351. alpha: 45,
  352. beta: 0,
  353. },
  354. secondaryLight: {
  355. shadow: false,
  356. intensity: 0,
  357. color: '#FFFFFF',
  358. alpha: 0,
  359. beta: 0,
  360. }
  361. });
  362. // 粮仓
  363. app.query("[物体类型=粮仓]").forEach(function (obj) {
  364. var siloHouse = new SiloHouse(obj);
  365. siloHouseList.push(siloHouse);
  366. });
  367. // 摄像头
  368. app.query("[物体类型=摄像头]").forEach(function (obj) {
  369. videoCameraList.push(new VideoCamera(obj));
  370. });
  371. // 卡车
  372. create_truck();
  373. app.query("[物体类型=卡车]").forEach(function (obj) {
  374. truckList.push(new Truck(obj));
  375. });
  376. // ----------------------------------------------------------------------------------
  377. // 单击 如果没拾取到,则取消上次选择的粮仓
  378. app.on('singleclick', function (event) {
  379. if (event.object == null || event.object.attr('物体类型') != '粮仓') {
  380. if (SiloHouse.current) {
  381. SiloHouse.current.unselect();
  382. SiloHouse.current = null;
  383. }
  384. }
  385. });
  386. // 双击 如果没pick到,则取消上次打开的粮仓
  387. app.on('dblclick', function (event) {
  388. if (event.object == null || event.object.attr('物体类型') != '粮仓') {
  389. if (SiloHouse.currentOpen) {
  390. SiloHouse.currentOpen.resetRoof();
  391. SiloHouse.currentOpen = null;
  392. }
  393. }
  394. });
  395. // 右键 则取消上次打开的粮仓
  396. var mouseDownPos = null;
  397. app.on('mousedown', function (event) {
  398. if (event.button == 2)
  399. mouseDownPos = [event.x, event.y];
  400. });
  401. app.on('click', function (event) {
  402. if (event.button == 2 && Math.getDistance(mouseDownPos, [event.x, event.y]) < 4) { // 小于4像素执行click事件
  403. if (SiloHouse.currentOpen) {
  404. SiloHouse.currentOpen.resetRoof();
  405. SiloHouse.currentOpen = null;
  406. }
  407. }
  408. });
  409. // 屏蔽鼠标右键系统菜单
  410. document.body.oncontextmenu = function (evt) {
  411. evt = evt || event;
  412. evt.returnValue = false;
  413. return false;
  414. };
  415. // 第一人称
  416. fpsControl = new THING.WalkControl({
  417. enableKeyRotate: true, walkSpeed: 0.02,turnSpeed: 0.25, gravity: 29.8, eyeHeight: 1.6,jumpSpeed: 10
  418. });
  419. }
  420. // ----------------------------------------------------------------------------------
  421. // 定位相关,演示只创建一个卡车
  422. var positionList = [];// 人车定位相关
  423. var truckInfo = { "车牌": "京A12345", "公司": "北京优锘科技有限公司", "状态": "出库", "仓房": "1号", "状态": "过磅" };
  424. var wayPointList = ["L109", "L110", "L104", "L103", "L102", "L108", "L109", "L118", "L119", "L112", "L111", "L117", "L118"];
  425. function create_truck() {
  426. // 生成path,从场景中物体取得位置
  427. var path = [];
  428. for (var i = 0; i < wayPointList.length; i++) {
  429. var pObj = app.query(wayPointList[i])[0];
  430. if (!pObj)
  431. continue;
  432. path.push(pObj.position);
  433. }
  434. // 创建卡车并行走路径
  435. truck = app.create({
  436. type: 'Thing',
  437. name: "truck",
  438. url: "https://www.thingjs.com/static/models/truck"
  439. });
  440. truck.movePath({
  441. 'orientToPath': true,
  442. 'orientToPathDegree': 180,
  443. 'path': path,
  444. 'speed': 20,
  445. 'delayTime': 500,
  446. 'lerp': false,
  447. 'loop': true
  448. });
  449. truck.attr('物体类型', '卡车');
  450. }
  451. // ----------------------------------------------------------------------------
  452. // 界面相关
  453. var toolBar = null;
  454. function init_gui() {//ui 初始化
  455. var baseURL = "https://www.thingjs.com/static/images/sliohouse/";
  456. toolBar = new THING.widget.Banner({ template: 'default' ,column: 'left'});
  457. toolBar.data = { number: false, temper: false, humi: false, power: false, store: false, video: false, cloud: false, location: false };
  458. var img0 = toolBar.addImageBoolean(toolBar.data, 'number').caption('仓库编号').imgUrl(baseURL + 'warehouse_code.png');
  459. var img1 = toolBar.addImageBoolean(toolBar.data, 'temper').caption('温度检测').imgUrl(baseURL + 'temperature.png');
  460. var img2 = toolBar.addImageBoolean(toolBar.data, 'humi').caption('湿度检测').imgUrl(baseURL + 'humidity.png');
  461. var img3 = toolBar.addImageBoolean(toolBar.data, 'power').caption('能耗统计').imgUrl(baseURL + 'statistics.png');
  462. var img4 = toolBar.addImageBoolean(toolBar.data, 'store').caption('粮食储量').imgUrl(baseURL + 'cereals_reserves.png');
  463. var img5 = toolBar.addImageBoolean(toolBar.data, 'video').caption('视频监控').imgUrl(baseURL + 'video.png');
  464. var img6 = toolBar.addImageBoolean(toolBar.data, 'cloud').caption('温度云图').imgUrl(baseURL + 'cloud.png');
  465. var img7 = toolBar.addImageBoolean(toolBar.data, 'location').caption('人车定位').imgUrl(baseURL + 'orientation.png');
  466. img0.on('change', function (boolValue) { onChangeImageButton('number', boolValue); });
  467. img1.on('change', function (boolValue) { onChangeImageButton('temper', boolValue); });
  468. img2.on('change', function (boolValue) { onChangeImageButton('humi', boolValue); });
  469. img3.on('change', function (boolValue) { onChangeImageButton('power', boolValue); });
  470. img4.on('change', function (boolValue) { onChangeImageButton('store', boolValue); });
  471. img5.on('change', function (boolValue) { onChangeImageButton('video', boolValue); });
  472. img6.on('change', function (boolValue) { onChangeImageButton('cloud', boolValue); });
  473. img7.on('change', function (boolValue) { onChangeImageButton('location', boolValue); });
  474. }
  475. // 处理工具条按钮
  476. function onChangeImageButton(key, boolValue) {
  477. // 更新界面绑定对象,其中排除 云图 和 人车定位
  478. if (boolValue) {
  479. for (var elem in toolBar.data) {
  480. if (elem == "cloud" || elem == "location" || elem == key)
  481. continue;
  482. toolBar.data[elem] = false;
  483. }
  484. }
  485. // 分类别处理
  486. if (key == "cloud") { // 云图
  487. if (!boolValue) {
  488. if (SiloHouse.currentOpen)
  489. SiloHouse.currentOpen.destroyHeatmap();
  490. } else {
  491. if (SiloHouse.currentOpen && app.camera.flying == false)
  492. SiloHouse.currentOpen.createHeatmap();
  493. }
  494. } else if (key == "location") { // 人车定位
  495. truckList.forEach(function (tr) {
  496. tr.showUI(boolValue);
  497. });
  498. } else if (key == "video") { // 视频监控
  499. videoCameraList.forEach(function (vc) {
  500. vc.showUI(boolValue);
  501. });
  502. } else if (key == "store") { // 储量
  503. siloHouseList.forEach(function (siloHouse) {
  504. siloHouse.hideUI();
  505. siloHouse.obj.visible = !boolValue;
  506. });
  507. } else { // 其他粮仓UI显示
  508. siloHouseList.forEach(function (siloHouse) {
  509. siloHouse.showUI(key, boolValue);
  510. });
  511. }
  512. }
  513. function changeFPS(start) {
  514. if (start) {
  515. app.addControl(fpsControl);
  516. } else {
  517. app.removeControl(fpsControl);
  518. }
  519. }
复制代码

avatar
游客~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

130700ppkpl8x3t7tt1b1t