Explorar el Código

Merge branch 'dev' of http://192.168.0.115:3000/bill/fuse-code into dev

xzw hace 1 año
padre
commit
b977000827
Se han modificado 4 ficheros con 29 adiciones y 4 borrados
  1. 5 3
      src/sdk/sdk.ts
  2. 7 0
      src/utils/math.ts
  3. 8 1
      src/views/merge/index.vue
  4. 9 0
      src/views/tagging-position/index.vue

+ 5 - 3
src/sdk/sdk.ts

@@ -103,11 +103,13 @@ export type StartMeasure<T extends StoreMeasure['type']> = Measure<T> & {
 
 export interface SDK {
   layout: HTMLDivElement,
-  sceneBus: Emitter<{ 'cameraChange': void }>
+  sceneBus: Emitter<{ 'cameraChange':  SceneLocalPos }>
   setBackdrop: (drop: string) => void
   addModel: (props: AddModelProps) => SceneModel
+  showGrid: () => void
+  hideGrid: () => void
   calcPathInfo: (paths: CalcPathProps[0], info: CalcPathProps[1]) => Required<CalcPathProps[1]>
-  getPositionByScreen: (screenPos: ScreenLocalPos, modelId?: FuseModel['id']) => ScenePos | null
+  getPositionByScreen: (screenPos: ScreenLocalPos, modelId?: FuseModel['id']) => ScenePos & {worldPos: SceneLocalPos} | null
   getScreenByPosition: (localPos: SceneLocalPos, modelId?: FuseModel['id']) => ScreenPos | null
   screenshot: (width: number, height: number) => Promise<string>
   getPose: () => { position: SceneLocalPos, target: SceneLocalPos }
@@ -141,4 +143,4 @@ export const initialSDK = async (props: InialSDKProps) => {
   
 }
 
-export default sdk
+export default sdk!

+ 7 - 0
src/utils/math.ts

@@ -0,0 +1,7 @@
+
+export const distance = (p1: SceneLocalPos,p2: SceneLocalPos) =>
+  Math.sqrt(
+    Math.pow((p1.x - p2.x), 2) + 
+    Math.pow((p1.y - p2.y), 2)+ 
+    Math.pow((p1.z - p2.z), 2)
+    );

+ 8 - 1
src/views/merge/index.vue

@@ -68,7 +68,7 @@ import { RoutesName, router } from '@/router'
 import { RightPano } from '@/layout'
 import { autoSaveFuseModels, defaultFuseModelAttrs, isOld } from '@/store'
 import { togetherCallback } from '@/utils'
-import { getSceneModel, modelRange } from '@/sdk'
+import { sdk, getSceneModel, modelRange } from '@/sdk'
 import { useViewStack, useActive } from '@/hook'
 import { showLeftPanoStack, custom, modelsChangeStoreStack, showRightPanoStack } from '@/env'
 import { ref, nextTick, watchEffect, computed, watch } from 'vue'
@@ -130,6 +130,13 @@ useViewStack(() => togetherCallback([
   () => currentItem.value = null
 ]))
 useViewStack(autoSaveFuseModels)
+
+useViewStack(() => {
+  sdk.showGrid()
+  return () => {
+    sdk.hideGrid()
+  }
+})
 </script>
 
 <style lang="scss">

+ 9 - 0
src/views/tagging-position/index.vue

@@ -36,6 +36,7 @@ import {
 } from '@/store'
 
 import type { TaggingPosition } from '@/store'
+import { distance } from '@/utils/math'
 
 const tagging = computed(() => getTagging(router.currentRoute.value.params.id as string))
 const positions = computed(() => tagging.value && getTaggingPositions(tagging.value))
@@ -64,6 +65,9 @@ const deletePosition = (position: TaggingPosition) => {
   }
 }
 
+const cameraPos = ref<SceneLocalPos>()
+sdk.sceneBus.on('cameraChange', pos => cameraPos.value = pos)
+
 watchEffect((onCleanup) => {
   if (tagging.value) {
     const clickHandler = async (ev: MouseEvent) => {
@@ -82,6 +86,11 @@ watchEffect((onCleanup) => {
           taggingId: tagging.value!.id
         })
         taggingPositions.value.push(storePosition)
+        
+        
+        if (cameraPos.value && distance(cameraPos.value, position.worldPos) > 8) {
+          flyTaggingPosition(storePosition)
+        }
       }
     }
     sdk.layout.addEventListener('click', clickHandler, false)