瀏覽代碼

3dModeling buildingCreate.js 沈瑞清 commit at 2021-02-25

沈瑞清 4 年之前
父節點
當前提交
05dd3a9712
共有 1 個文件被更改,包括 98 次插入0 次删除
  1. 98 0
      3dModeling/cxds/buildingCreate.js

+ 98 - 0
3dModeling/cxds/buildingCreate.js

@@ -70,3 +70,101 @@ var fileArr = [
  */
 THING.Utils.dynamicLoad(fileArr, function () {
     app.on('load', function (ev) {
+        skyBox = app.skyBox;  // 获取天空盒
+        app.level.change(ev.campus);  // 切换至园区层级
+        ev.campus.azimuth = '180';
+        mainPanle = new MainPanel(app);// 界面的类
+        //  setupNavpanel();
+        // creatFloorChoose();  //======================================本地数据测试===============================================
+        // 获取园区在CampusBuilder编辑时保存的地理位置
+        let tjsLnglat = app.root.defaultCampus.extraData;
+        if (tjsLnglat != undefined && tjsLnglat != null) {
+            tjsLnglat = tjsLnglat.coordinates;
+            if (tjsLnglat != undefined && tjsLnglat != null) {
+                tjsLnglat = tjsLnglat.split(",");
+            }
+        } else {
+            ev.campus.extraData = { coordinates: "116.4641,39.98606" }  // 园区绑定默认经纬度,地图才生效
+        }
+        createHtml();  // 创建html
+        restarRotate();  // 自动旋转
+
+        curCampus = ev.campus;
+        // 进入层级切换
+        app.level.change(ev.campus);
+    });
+});
+
+// 监听建筑层级的 LeaveLevel 事件
+app.on(THING.EventType.LeaveLevel, ".Building", function (ev) {
+    // 要进入的层级对象
+    var current = ev.current;
+    // 上一层级对象(退出的层级)
+    var preObject = ev.previous;
+    if (current.parent === preObject) {
+        removeMark();
+    }
+    else {
+        removeMark();
+    }
+})
+
+/**
+ * 说明:注册事件
+ */
+function registerEvent() {
+    var _this = this
+    // 楼层横向展开按钮的点击事件,楼层展开只在建筑有2层或2层以上的楼层才会生效
+    $('#horizontalExpansion').on('click', function () {
+        stopRotate();
+        checkBtnActives(['#mapBg', '#sceneSetting']);
+        let expandState = building.getAttribute('expandState');
+        if ($(this).hasClass('active')) {
+            // 楼层横向展开关闭
+            if (expandState == 'horizontal') {
+                $(this).removeClass('active');
+                horizontalExpand(building, 'close');
+            }
+        } else {
+            // 楼层横向展开前应判断楼层是否处于垂直展开状态,是,则应先关闭垂直展开,然后横向展开
+            if (expandState != 'moving') {
+                $(this).addClass('active');
+                $('#verticalExpansion').removeClass('active');
+                if (expandState == 'vertical') {
+                    verticalToHorizontal(building);
+                } else {
+                    horizontalExpand(building, 'horizontal');
+                }
+            }
+        }
+        restarRotate();
+    });
+    // 楼层垂直展开按钮的点击事件,楼层展开只在建筑有2层或2层以上的楼层才会生效
+    $('#verticalExpansion').on('click', function () {
+        stopRotate();
+        checkBtnActives(['#mapBg', '#sceneSetting']);
+        let expandState = building.getAttribute('expandState');
+        if ($(this).hasClass('active')) {
+            // 楼层垂直展开关闭
+            if (expandState == 'vertical') {
+                $(this).removeClass('active');
+                verticalExpand(building, 'close');
+            }
+        } else {
+            // 楼层垂直展开前应判断楼层是否处于横向展开状态,是,则应先关闭横向展开,然后垂直展开
+            if (expandState != 'moving') {
+                $(this).addClass('active');
+                $('#horizontalExpansion').removeClass('active');
+                if (expandState == 'horizontal') {
+                    horizontalToVertical(building);
+                } else {
+                    verticalExpand(building, 'vertical');
+                }
+            }
+        }
+        restarRotate();
+    });
+    // 设置按钮点击事件,按钮的tip与功能面板的互相切换
+    $('#sceneSetting').on('click', function () {
+        checkBtnActives(['#mapBg']);
+        if ($(this).hasClass('active')) {