瀏覽代碼

3dModeling pulic.js 朱俊杰 commit at 2021-01-04

朱俊杰 4 年之前
父節點
當前提交
dcba26d28f
共有 1 個文件被更改,包括 114 次插入0 次删除
  1. 114 0
      3dModeling/tjby21/pulic.js

+ 114 - 0
3dModeling/tjby21/pulic.js

@@ -90,3 +90,117 @@ function createMiniMap() {
         miniMapCtrl = app.addControl(new THING.MiniMapControl({
         miniMapCtrl = app.addControl(new THING.MiniMapControl({
             width: 200,
             width: 200,
             height: 200,
             height: 200,
+            position: THING.CornerType.LeftBottom,
+            opacity: 0.8,
+            scale: 1,
+            angle: 0,
+            mousewheel: true,
+            cameraViewImg: 'http://www.thingjs.com/static/images/minimap1.png',
+            cameraCenterImg: 'http://www.thingjs.com/static/images/minimap0.png'
+        }));
+        $('.minimap').css('border', '1px solid rgba(255, 255, 255, 0.8)');
+        $('.minimap').css('left', '3px');
+        $('.minimap').css('bottom', '3px');
+    } else {
+        destoryMiniMap();
+        createMiniMap();
+    }
+}
+/**
+ * 说明:关闭小地图
+ */
+function destoryMiniMap() {
+    if (miniMapCtrl != null) {
+        app.removeControl(miniMapCtrl);
+        miniMapCtrl = null;
+    }
+}
+/**
+ * 说明:全屏显示
+ */
+function fullScreen() {
+    let el = document.documentElement;
+    let rfs = el.requestFullScreen || el.webkitRequestFullScreen;
+    if (typeof rfs != "undefined" && rfs) {
+        rfs.call(el);
+    } else if (typeof window.ActiveXObject != "undefined") {
+        let wscript = new ActiveXObject("WScript.Shell");
+        if (wscript != null) {
+            wscript.SendKeys("{F11}");
+        }
+    }
+}
+/**
+ * 说明:退出全屏
+ */
+function exitFullScreen() {
+    let el = document;
+    let cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.exitFullScreen;
+    if (typeof cfs != "undefined" && cfs) {
+        cfs.call(el);
+    } else if (typeof window.ActiveXObject != "undefined") {
+        let wscript = new ActiveXObject("WScript.Shell");
+        if (wscript != null) {
+            wscript.SendKeys("{F11}");
+        }
+    }
+}
+/**
+ * 说明:摄像机飞行
+ */
+function cameraFly(position, target) {
+    // 摄像机飞行到某位置
+    app.camera.flyTo({
+        'position': position,
+        'target': target,
+        'time': 1000,
+        'complete': function () {
+        }
+    });
+}
+/**
+ * 说明:自动旋转
+ */
+function startRotate() {
+    app.camera.enableRotate = false;  // 关闭默认的旋转操作
+    app.camera.enablePan = false;  // 关闭默认的平移操作
+    app.camera.enableZoom = false;  // 关闭默认的缩放操作
+    // 绕摄像机当前目标点旋转
+    app.camera.rotateAround({
+        target: app.camera.target,  // 围绕摄像机当前目标点
+        // object: obj,  // 环绕的物体 (object 与 target 的设置互斥)
+        speed: 4,  // 环绕飞行的时间(3min)
+        yRotateAngle: 360,  // 环绕y轴飞行的旋转角度
+        loopType: THING.LoopType.Repeat  // 设置循环类型
+    });
+}
+/**
+ * 说明:停止自动旋转
+ */
+function stopRotate() {
+    app.camera.enableRotate = true;  // 开启默认的旋转操作
+    app.camera.enablePan = true;  // 开启默认的平移操作
+    app.camera.enableZoom = true;  // 开启默认的缩放操作
+    app.camera.stopRotateAround();
+    if (rotateTimer) {
+        clearTimeout(rotateTimer);
+        rotateTimer = null;
+    }
+}
+/**
+ * 说明:重新开始转动,未进行任何操作5s后开始自动旋转
+ */
+function restarRotate() {
+    if (fpsCtrl != null || !$('#sceneSetting .control-menu-pane li.autoRotate').hasClass('selected')) {
+        return;
+    }
+    if (rotateTimer == null) {
+        rotateTimer = setTimeout(function () {
+            //  startRotate();
+        }, restartTime);
+    } else {
+        clearTimeout(rotateTimer);
+        rotateTimer = null;
+        restarRotate();
+    }
+}