Browse Source

fix: 新的绑定两边点的方式不用漫游点id而用pos

xzw 1 year ago
parent
commit
4d7f976f2b
2 changed files with 27 additions and 13 deletions
  1. 12 11
      src/components/header/index.vue
  2. 15 2
      src/utils/ConvertViews.js

+ 12 - 11
src/components/header/index.vue

@@ -61,6 +61,8 @@ import Login from './Login'
 import CopyLink from './CopyLink'
 import sync from '@/utils/sync'
 import { useI18n, getLocale } from '@/i18n'
+import math from "@/utils/math.js";
+
 const { t } = useI18n({ useScope: 'global' })
 const props = defineProps({
     project: Object,
@@ -102,22 +104,23 @@ const creatAvatar = head => {
 }
 const getCurPosInfo = () => {
     let app = sync.sourceInst
-    let id
+    let pos1
     if (app.sceneType == 'laser') {
-        id = app.viewer.images360.currentPano.id
+        pos1 = app.viewer.images360.position
     } else {
-        id = app.app.core.get('Player').currentPano.id
+        pos1 = app.app.core.get('Player').currentPano.position
     }
     let info = sync.targetInst.viewer.getCameraStatus()
-    let position = info.position
-    return { id, position }
+    let pos2 = info.position
+    return { pos1, pos2 }
+}
+const ifSame = (p1,p2)=>{
+    return p1 && p2 && (math.closeTo(p1.pos1, p2.pos1, 0.1) || math.closeTo(p1.pos2, p2.pos2, 0.1));
 }
 
 const onSetP1 = () => {
     let p1 = getCurPosInfo()
-    if (points.value.p2 && points.value.p2.id == p1.id) {
-        return (showTips.value = t('header.setPointfaidText'))
-    }
+    if(ifSame(p1, points.value.p2))  return (showTips.value = t('header.setPointfaidText'))
     if (points.value.p1) {
         showTips.value = t('header.pointUpdate')
     }
@@ -126,9 +129,7 @@ const onSetP1 = () => {
 }
 const onSetP2 = () => {
     let p2 = getCurPosInfo()
-    if (points.value.p1 && points.value.p1.id == p2.id) {
-        return (showTips.value = t('header.setPointfaidText'))
-    }
+    if(ifSame(points.value.p1, p2))  return (showTips.value = t('header.setPointfaidText'))
     if (points.value.p2) {
         showTips.value = t('header.pointUpdate')
     }

+ 15 - 2
src/utils/ConvertViews.js

@@ -695,10 +695,23 @@ export default class ConvertViews extends THREE.EventDispatcher{
     bimGetPanoData(sourceApp, targetApp, panoData){
         if(panoData){
             let sourcePano,targetPano 
-            let pano1 = [{position:new THREE.Vector3().copy(panoData.p1.position)},{position:new THREE.Vector3().copy(panoData.p2.position)}]
+            let pano1 = [//bim
+                {position:new THREE.Vector3().copy(panoData.p1.pos2 || panoData.p1.position)},
+                {position:new THREE.Vector3().copy(panoData.p2.pos2 || panoData.p2.position)}
+            ]
             
             let getPano2 = (app)=>{
-                return [app.fakeApp.panos.find(e=>e.id == panoData.p1.id), app.fakeApp.panos.find(e=>e.id == panoData.p2.id)] 
+                if(panoData.p1.id != void 0){//老数据用的id, 因为slam场景无漫游点所以改为用pos
+                    return [
+                        app.fakeApp.panos.find(e=>e.id == panoData.p1.id), 
+                        app.fakeApp.panos.find(e=>e.id == panoData.p2.id)
+                    ] 
+                }else{
+                    return [
+                        {position:new THREE.Vector3().copy(panoData.p1.pos1)},
+                        {position:new THREE.Vector3().copy(panoData.p2.pos1)}
+                    ]
+                }
             }
             
             if(targetApp.sceneType == 'bim'){