소스 검색

3dModeling pulic.js 朱涛 commit at 2020-12-28

朱涛 4 년 전
부모
커밋
43cad9f34b
1개의 변경된 파일111개의 추가작업 그리고 0개의 파일을 삭제
  1. 111 0
      3dModeling/bgyyc30/pulic.js

+ 111 - 0
3dModeling/bgyyc30/pulic.js

@@ -0,0 +1,111 @@
+/**
+ * 说明:检测菜单项是否已打开
+ */
+function checkBtnActives(arr) {
+    for (let i = 0; i < arr.length; i++) {
+        let temp = arr[i];
+        if ($(temp).hasClass('active')) {
+            $(temp).removeClass('active');
+            $(temp).find('.control-menu').removeClass('actives');
+        }
+    }
+}
+/**
+ * 说明:判断是否全屏
+ */
+function checkFull() {
+    var isFull =
+        document.fullscreenElement ||
+        document.mozFullScreenElement ||
+        document.webkitFullscreenElement;
+    //to fix : false || undefined == undefined
+    if (isFull === undefined) isFull = false;
+    return isFull;
+}
+/**
+ * 说明:创建胶囊
+ */
+function createBox() {
+    if (box == null) {
+        box = app.create({
+            type: 'Thing',
+            url: 'https://model.3dmomoda.com/models/9CD08ED91F5C4E0ABB6B0833C86F2942/0/gltf/',
+            position: [0, 0, 0],
+            angle: 180,
+            scale: [1.7, 1.7, 1.7],
+            style: {
+                color: '#FF0000'
+            }
+        });
+    }
+}
+/**
+ * 说明:第一人称行走
+ */
+function enterFps(pos) {
+    if (fpsCtrl == null) {
+        app.pauseEvent(THING.EventType.Pick, '*', THING.EventTag.LevelPickOperation);
+        app.pauseEvent(THING.EventType.KeyUp, null, '空格键切换视角');
+        app.camera.position = pos;  // 起始位置为鼠标点击时的位置
+        // 添加第一人称行走控件
+        fpsCtrl = app.addControl(
+            new THING.WalkControl({  // 参数可以动态修改
+                walkSpeed: 0.02,  // 行走速度
+                turnSpeed: 0.25,  // 右键旋转速度
+                gravity: 26,  // 物体重量
+                eyeHeight: 1.6,  // 人高度
+                jumpSpeed: 10,  // 按空格键 跳跃的速度
+                enableKeyRotate: false,  // 默认不开启键盘控制旋转
+                useCollision: true,  // 默认不开启碰撞检测
+                useGravity: true,  // 默认开启重力
+                groundObjects: [app.scene],  // 把整个场景都添加,可把楼层或其他需要检测的添加进入碰撞体系里 | 默认值 园区地板,如果园区过大,可取消提升性能
+                collisionObjects: [app.scene]  // 把整个场景都添加,可把楼层或其他需要检测的添加进入碰撞体系里 | 默认值 园区地板,如果园区过大,可取消提升性能
+            })
+        );
+    }
+}
+/**
+ * 说明:退出第一人称行走
+ */
+function exitFps() {
+    app.removeControl(fpsCtrl);
+    fpsCtrl = null;
+    cameraFly(cameraInitPos[0], cameraInitPos[1]);
+    // 恢复默认双击事件
+    app.resumeEvent(THING.EventType.DBLClick, '*', THING.EventTag.LevelEnterOperation);
+    // 恢复默认点击事件
+    app.resumeEvent(THING.EventType.Click, '*', THING.EventTag.LevelBackOperation);
+    // 恢复默认拾取事件
+    app.resumeEvent(THING.EventType.Pick, '*', THING.EventTag.LevelPickOperation);
+    // 恢复默认键盘键抬起事件
+    app.resumeEvent(THING.EventType.KeyUp, null, '空格键切换视角');
+    $('#moveByFps').removeClass('active');
+}
+/**
+ * 说明:开启小地图
+ */
+function createMiniMap() {
+    if (miniMapCtrl == null) {
+        // 添加小地图控件
+        miniMapCtrl = app.addControl(new THING.MiniMapControl({
+            width: 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();
+    }
+}
+/**
+ * 说明:关闭小地图
+ */