Explorar el Código

对接distance

bill hace 3 años
padre
commit
653a9bfc63

+ 2 - 2
src/components/tagging/list.vue

@@ -12,13 +12,13 @@
 
 <script lang="ts" setup>
 import Sign from './sign.vue'
-import { Tagging, models, getModelShowVariable } from '@/store';
+import { Tagging, models, getModelShowVariable, getModel } from '@/store';
 import { custom } from '@/env'
 
 defineProps<{ tagging: Tagging }>()
 
 const isShowSign = (modelId: string) => {
-  const model = models.value.find(model => model.id === modelId)
+  const model = getModel(modelId)
   return model?.loaded && getModelShowVariable(model).value
 }
 

+ 15 - 10
src/components/tagging/sign.vue

@@ -39,14 +39,14 @@
 </template>
 
 <script lang="ts" setup>
-import { computed, ref, watchEffect } from 'vue'
+import { computed, ref, watchEffect, watch } from 'vue'
 import UIBubble from 'bill/components/bubble/index.vue'
 import Images from '@/views/tagging/images.vue'
 import Preview, { MediaType } from '../static-preview/index.vue'
-import { Tagging, getTaggingStyle } from '@/store';
+import { Tagging, getTaggingStyle, getModel } from '@/store';
 import { getFileUrl } from '@/utils'
 import { sdk } from '@/sdk'
-import { custom, showTaggingPositionsStack } from '@/env'
+import { custom } from '@/env'
 
 export type SignProps = { tagging: Tagging, scenePos: Tagging['positions'][number], show?: boolean }
 
@@ -65,23 +65,27 @@ const updatePosStyle = () => {
   }
 }
 watchEffect(updatePosStyle)
+sdk.sceneBus.on('cameraChange', updatePosStyle)
+const model = getModel(props.scenePos.modelId)
+model && watch(model, updatePosStyle, { deep: true })
+
+
 const showContent = computed(() => {
   return !~pullIndex.value 
-    && (
-      isHover.value || show.value 
-      || custom.showTaggingPositions.has(props.scenePos)
-    )
+    && (isHover.value || custom.showTaggingPositions.has(props.scenePos))
 })
-sdk.sceneBus.on('cameraChange', updatePosStyle)
 
 const taggingStyle = getTaggingStyle(props.tagging.styleId)
 
 const pullIndex = ref(-1)
 const isHover = ref(false)
-const show = ref(false)
 
 const iconClickHandler = () => {
-  show.value = !show.value
+  if (custom.showTaggingPositions.has(props.scenePos)) {
+    custom.showTaggingPositions.delete(props.scenePos)
+  } else {
+    custom.showTaggingPositions.add(props.scenePos)
+  }
 }
 
 </script>
@@ -90,6 +94,7 @@ const iconClickHandler = () => {
 .hot-item {
   pointer-events: all;
   position: absolute;
+  transform: translate(-50%, -50%);
   cursor: pointer;
 
   > img {

+ 8 - 1
src/sdk/sdk.ts

@@ -46,6 +46,13 @@ export type ScreenPos = {
   modelId: Model['id'] 
 }
 
+export interface CameraComeToProps { 
+  position: SceneLocalPos; 
+  target?: SceneLocalPos; 
+  dur?: number, 
+  modelId?: Model['id'], 
+  distance?: 1 | 2 | 3 
+}
 export interface SDK {
   layout: HTMLDivElement,
   sceneBus: Emitter<{ 'cameraChange': void }>
@@ -54,7 +61,7 @@ export interface SDK {
   getScreenByPosition: (localPos: SceneLocalPos, modelId?: Model['id']) => ScreenPos | null
   screenshot: (width: number, height: number) => Promise<string>
   getPose: () => { position: SceneLocalPos, target: SceneLocalPos }
-  comeTo: (pos: { position: SceneLocalPos; target?: SceneLocalPos; dur?: number, modelId?: Model['id'] }) => void
+  comeTo: (pos: CameraComeToProps) => void
   enterSceneGuide: (data: SceneGuidePath[]) => SceneGuide
 }
   

+ 1 - 0
src/store/model.ts

@@ -23,6 +23,7 @@ export type Models = Model[]
 
 export const models = ref<Models>([])
 
+export const getModel = (modelId: Model['id']) => models.value.find(model => model.id === modelId)
 export const getModelShowVariable = (model: Model) => 
   computed({
     get: () => custom.showModelsChangeStore 

+ 12 - 2
src/views/tagging/index.vue

@@ -60,7 +60,9 @@ import {
   autoSaveTaggings, 
   createTagging,
   enterEdit, 
-Model
+  Model,
+  getModel,
+getModelShowVariable
 } from '@/store'
 import { 
   custom, 
@@ -100,11 +102,19 @@ const flyTaggingPositions = (tagging: Tagging) => {
       return;
     }
     const position = tagging.positions[i]
+    const model = getModel(position.modelId)
+    if (!model || !getModelShowVariable(model).value) {
+      flyIndex(i + 1)
+      return;
+    }
+
+    
     const pop = showTaggingPositionsStack.push(ref(new WeakSet([position])))
     sdk.comeTo({ 
       position: position.localPos, 
       modelId: position.modelId,
-      dur: 300
+      dur: 300,
+      distance: 3
     })
     
     console.log('改变了', custom.showTaggingPositions.has(position))