bill 4 月之前
父节点
当前提交
f939559c15

+ 2 - 1
src/api/map-tile.ts

@@ -11,8 +11,9 @@ type ServiceMapTile = {
 export type MapTile = {
   id: number;
   name: string,
-  mapUrls: string[];
+  mapUrls: {tempUrl: string, maximumLevel: number}[];
   coord: string;
+  maximumLevel: number
 };
 
 export const fetchMapTiles = async () => {

+ 36 - 18
src/sdk/association/animation.ts

@@ -5,7 +5,7 @@ import {
   AnimationModelPath,
   AnimationModelSubtitle,
 } from "@/api";
-import {
+import sdk, {
   AnimationGroup,
   AnimationModel3D,
   AnimationModelAction3D,
@@ -66,6 +66,7 @@ export const addAM = (data: AnimationModel): Promise<AnimationModel3D> => {
         const am = animationGroup.addAnimationModel(data);
         am.bus.on("loadDone", () => {
           amMap[key].am = am;
+          console.log('0.0', am)
         });
       }
     },
@@ -312,27 +313,31 @@ export const addSubtitle = (data: AnimationModelSubtitle) => {
     ([map, exists]) => {
       if (!map?.am) return;
       if (exists && !map.subtitles[data.id]) {
-        const mountEl = document.querySelector("#app")!
-        const layer = document.createElement('div')
-        layer.className = 'subtitle'
+        const mountEl = document.querySelector("#app")!;
+        const layer = document.createElement("div");
+        layer.className = "subtitle";
         const cleanups = [
           watchEffect(() => {
-            layer.innerHTML = data.content
-            size.value = { width: layer.offsetWidth, height: layer.offsetHeight }
+            layer.innerHTML = data.content;
+            size.value = {
+              width: layer.offsetWidth,
+              height: layer.offsetHeight,
+            };
           }),
-          watchEffect(() => layer.style.background = data.background),
+          watchEffect(() => (layer.style.background = data.background)),
           watchEffect(() => {
-            layer.style.visibility = pixel.value && show.value ? 'visible' : 'hidden'
+            layer.style.visibility =
+              pixel.value && show.value ? "visible" : "hidden";
           }),
           watchEffect(() => {
             if (pixel.value) {
-              layer.style.transform = `translate(${pixel.value.x}px, ${pixel.value.y}px)`;
+              layer.style.transform = `translate(${pixel.value.x}px, calc(${pixel.value.y}px - 50%))`;
             }
           }),
-          () => mountEl.removeChild(layer)
-        ]
-        mountEl.appendChild(layer)
-        map.subtitles[data.id] = mergeFuns(cleanups)
+          () => mountEl.removeChild(layer),
+        ];
+        mountEl.appendChild(layer);
+        map.subtitles[data.id] = mergeFuns(cleanups);
       } else if (!exists && map.subtitles[data.id]) {
         map.subtitles[data.id]();
         delete map.subtitles[data.id];
@@ -341,21 +346,19 @@ export const addSubtitle = (data: AnimationModelSubtitle) => {
 
     { immediate: true }
   );
-  let isRun = false
+  let isRun = false;
   const update = () => {
     // if (isRun) return;
     // isRun = true
     // setTimeout(() => {
-      pixel.value = amMap[am.id]?.am?.getCurrentSubtitlePixel(
-        size.value
-      );
+    pixel.value = amMap[am.id]?.am?.getCurrentSubtitlePixel(size.value);
     //   isRun = false
     // }, 16);
   };
 
   const stopAttrib = mergeFuns(
     watch(
-      [currentTime, () => amMap[am.id]?.am, size, play],
+      [currentTime, () => amMap[am.id]?.am, size, play, () => amMap[key]?.am],
       (_a, _b, onCleanup) => {
         if (
           !play.value &&
@@ -368,6 +371,19 @@ export const addSubtitle = (data: AnimationModelSubtitle) => {
         ) {
           update();
           show.value = true;
+
+          onCleanup(
+            watch(
+              play,
+              (play, _a, onCleanup) => {
+                if (!play && _sdk) {
+                  _sdk.sceneBus.on("cameraChange", update);
+                  onCleanup(() => _sdk.sceneBus.off("cameraChange", update));
+                }
+              },
+              { immediate: true }
+            )
+          );
         } else {
           show.value = false;
         }
@@ -399,6 +415,7 @@ export const endTime = computed(() => {
     ].map((item) => item.time + (item.duration || 0));
     return Math.max(...endPoints);
   });
+  console.log('amsEndTime', amsEndTime, ams.value)
   return (
     Math.max(...amsEndTime) +
     ((animationGroup.delayEndTime && animationGroup.delayEndTime()) || 0)
@@ -410,6 +427,7 @@ watch(play, (_a, _b, onCleanup) => {
   play.value ? animationGroup?.play() : animationGroup?.pause();
   onCleanup(
     watchEffect(() => {
+      console.error('endTime.value', endTime.value)
       if (currentTime.value >= endTime.value) {
         play.value = false;
       }

+ 0 - 1
src/sdk/association/guide.ts

@@ -98,7 +98,6 @@ export const playSceneGuide = (
         );
         sceneGuide.bus.on("changePoint", (index) => {
           if (paths[index - 1].playAnimation) {
-            console.error(currentTime.value)
             play.value = true
           }
           changeIndexCallback && changeIndexCallback(index);

+ 9 - 8
src/sdk/association/setting.ts

@@ -2,6 +2,7 @@ import { setting, sysTiles } from "@/store";
 import { nextTick, watchEffect } from "vue";
 import { SDK, SettingResourceType } from "../sdk";
 import { setPose } from ".";
+import { MapTile } from "@/api/map-tile";
 
 export const associationSetting = (sdk: SDK, mountEl: HTMLDivElement) => {
   watchEffect(() => {
@@ -23,11 +24,11 @@ export const associationSetting = (sdk: SDK, mountEl: HTMLDivElement) => {
   });
 
   watchEffect(() => {
-    let mapUrls: string[] | undefined
+    let tile: MapTile | undefined
     if (setting.value?.mapId) {
-      mapUrls = sysTiles.value.find(item => item.id === setting.value?.mapId)?.mapUrls
+      tile = sysTiles.value.find(item => item.id === setting.value?.mapId)
     }
-    if (!mapUrls && setting.value?.back) {
+    if (!tile && setting.value?.back) {
       const back = setting.value!.back;
       sdk.setBackdrop(
         back,
@@ -35,14 +36,14 @@ export const associationSetting = (sdk: SDK, mountEl: HTMLDivElement) => {
         {}
       );
       return;
-    } else if (!mapUrls) {
-      mapUrls = sysTiles.value[0].mapUrls
+    } else if (!tile) {
+      tile = sysTiles.value[0]
     }
 
 
-    if (mapUrls) {
-      console.log('切换瓦片图', mapUrls)
-      sdk.changeMapTile && sdk.changeMapTile(mapUrls)
+    if (tile) {
+      console.log('切换瓦片图', tile.mapUrls)
+      sdk.changeMapTile && sdk.changeMapTile(tile.mapUrls)
     }
   });
 };

+ 1 - 1
src/sdk/sdk.ts

@@ -166,7 +166,7 @@ export interface SDK {
     modeChange: { mode: "pano" | "fuse"; active: SceneModel };
   }>;
 
-  changeMapTile: (tempUrls: string[]) => void,
+  changeMapTile: (args: {tempUrl: string, maximumLevel: number}[]) => void,
   exitWatchMonitor: () => void
   setBackdrop: (
     drop: string,

+ 1 - 0
src/views/animation/index.vue

@@ -86,6 +86,7 @@ const amM = computed(() => focusAM.value && amMap[getAMKey(focusAM.value)]);
 
 onUnmounted(() => (currentTime.value = 0));
 
+
 const asyncOper = (item: AnimationModel, oper: (obj: AnimationModel3D) => void) => {
   let onCleanup = () => {};
   if (amMap[getAMKey(item)]?.am) {