Browse Source

feat(draw): model save

gemercheung 1 year ago
parent
commit
d2754e5512
2 changed files with 31 additions and 2 deletions
  1. 25 2
      src/core/player/Player.js
  2. 6 0
      src/view/case/photos/index.vue

+ 25 - 2
src/core/player/Player.js

@@ -43,12 +43,18 @@ export default class Player {
     this.matLine = null;
     this.lineColor = 0xe44d54;
     // 1是画线,2是标方向
-    this.mode = 2;
+    this.mode = 0;
     this.init();
   }
 
   setMode(mode) {
     this.mode = mode;
+    if (mode === 1 || mode === 2) {
+      this.setEditMode();
+    }
+    if (mode === 0) {
+      this.setFreeMode();
+    }
   }
 
   removeMarker() {
@@ -57,6 +63,23 @@ export default class Player {
       this.marker = null;
     }
   }
+  setFreeMode() {
+    this.floorplanControls.enablePan = true;
+    this.floorplanControls.mouseButtons = {
+      LEFT: THREE.MOUSE.PAN,
+      MIDDLE: THREE.MOUSE.DOLLY,
+      RIGHT: THREE.MOUSE.PAN,
+    };
+  }
+
+  setEditMode() {
+    this.floorplanControls.enablePan = false;
+    this.floorplanControls.mouseButtons = {
+      LEFT: THREE.MOUSE.ROTATE,
+      MIDDLE: THREE.MOUSE.DOLLY,
+      RIGHT: THREE.MOUSE.PAN,
+    };
+  }
 
   init = () => {
     // //floorplanControls
@@ -85,7 +108,7 @@ export default class Player {
     //   MIDDLE: THREE.MOUSE.DOLLY,
     //   RIGHT: THREE.MOUSE.PAN
     // }
-
+    this.setFreeMode();
     this.floorplanControls.enableRotate = false;
     this.raycaster = new THREE.Raycaster();
     this.onBindEvent();

+ 6 - 0
src/view/case/photos/index.vue

@@ -25,6 +25,7 @@
         <el-button @click="handleMark">标注方向</el-button>
         <el-button @click="handleLine">标注连线</el-button>
         <el-button @click="handleSave">保存</el-button>
+        <el-button @click="handleFree">查看</el-button>
       </div>
       <swiper
         class="swiper"
@@ -162,6 +163,11 @@ const handleSave = () => {
   if (window.scene) {
   }
 };
+const handleFree = () => {
+  if (window.scene) {
+    window.scene.player.setMode(0);
+  }
+};
 onMounted(() => {
   renderCanvas();
 });