Bläddra i källkod

3dModeling buildingCreate.js 李欣儒 commit at 2021-02-21

李欣儒 4 år sedan
förälder
incheckning
ffa28ca187
1 ändrade filer med 143 tillägg och 0 borttagningar
  1. 143 0
      3dModeling/chly/buildingCreate.js

+ 143 - 0
3dModeling/chly/buildingCreate.js

@@ -439,3 +439,146 @@ function registerEvent() {
                 $('#fullScreen span').text('全屏');
                 fullScreenState = false;
             }
+        }
+    }
+}
+
+
+//====设备闪烁提示====
+function flash(objArray) {
+    objArray.forEach(function (obj) {
+        obj.on('update', function () {
+            obj.style.color = '#FFF000'
+            obj.style.opacity = 0.5 + 0.5 * Math.sin(2 * app.elapsedTime / 500);
+        }, '每帧改变透明度');
+    })
+}
+function queryDeviceStatus(evt) {
+    objArray = evt.data;
+    // objArray.forEach(function (deviceobj) {
+    //     obj = app.query("#" + deviceobj.ownerCode)[0];
+    //     obj.on('update', function () {
+    //         obj.style.color = '#FF0000'
+    //         obj.style.opacity = 0.5 + 0.5 * Math.sin(2 * app.elapsedTime / 500);
+    //     }, '每帧改变透明度');
+
+
+    // })
+    obj = app.query("#" + objArray)[0];
+    obj.on('update', function () {
+        obj.style.color = '#FF0000'
+        obj.style.opacity = 0.5 + 0.5 * Math.sin(2 * app.elapsedTime / 500);
+    }, '每帧改变透明度');
+}
+function reset(objArray) {
+    objArray.forEach(function (obj) {
+        obj.style.opacity = 1.0;
+        obj.style.color = null;
+        obj.off('update', null, '每帧改变透明度');
+    })
+}
+var timer = null;
+function getTabledata(d) {
+    var ygArray = [];
+    d.forEach(function (d) {
+        var deviceInfo = {
+            "设备编号": d.ownerCode,
+            "设备名称": d.ownerName,
+            "安装位置": d.unitinfo,
+        };
+        ygArray.push(deviceInfo)
+    })
+    // 表格数据//创建对象 book
+    var tableData = {
+
+        // 列标题
+        props: ['设备编号', '设备名称', '安装位置'],
+        // 列数据
+        items: ygArray
+    };
+    return tableData;
+}
+function createPerson(name, age, family) {
+    var o = new Object();
+    o.name = name;
+    o.age = age;
+    o.family = family;
+    o.say = function () {
+        alert(this.name);
+    }
+    return o;
+}
+function destroyPanel() {
+    var mydiv = document.getElementById('mydiv')
+    mydiv.remove();
+}
+//====================
+function updateData(obj) {
+
+    /** ******************* 以下为websoket数据对接 ********************/
+    // 对接自有websoket服务器
+    if (!webSocket) {
+        // 如果网站是 https 则对应 wss
+        // 如果网站是 http 则对应 ws 即可
+        webSocket = new WebSocket('ws://101.133.214.75:8080/Device_Manager/socket');
+        // 建立 websocket 连接成功触发事件
+        webSocket.onopen = function () {
+
+        };
+        // 接收服务端数据时触发事件
+        webSocket.onmessage = function (evt) {
+            queryDeviceStatus(evt);
+        };
+        webSocket.onclose = function (evt) {
+
+            webSocket = null;
+        }
+    }
+}
+
+//接收父级页面数据
+function userListener(data) {
+    
+    buildingStore = data.data;
+}
+
+// 监听用户页面传回的数据 并调用 ThingJS 页面方法
+window.addEventListener('message', function (e) {
+    var _this=this;
+    var array;
+    var data = e.data;
+    var funcName = data.funcName;
+    var param = data.param;
+    var company_code = e.data.param.company_code
+    // 调用 ThingJS 页面方法
+    window[funcName](param);
+    
+    //请求场景url的json文件
+    $.ajax({
+        type: "GET",
+        url:'/uploads/wechat/163607/file/杨浦16/park.json',
+        dataType: "json",
+        success: function (data) {
+            for(let i = 0; i < data.array.length; i++){
+                if(company_code === data.array[i].id){
+                    campusUrl = data.array[i]
+                    _this.changeScene(campusUrl);
+                    _this.createWidgets();
+                }
+            }
+        }
+    });
+});
+
+//父级页面数据处理
+function cleanObj(arr, key) {
+    var map = {},
+        dest = [];
+    for (var i = 0; i < arr.length; i++) {
+        var ai = arr[i];
+        if (!map[ai.min_level]) {
+            dest.push({
+                min_level: ai.min_level,
+                item: [ai]
+            });
+            map[ai.min_level] = ai;