bill 5 månader sedan
förälder
incheckning
ac5c3769bc

+ 1 - 0
src/components/subtitle/index.vue

@@ -1,5 +1,6 @@
 <template>
   <div
+    v-if="pixel"
     :style="{
       left: pixel.x + 'px',
       top: pixel.y + 'px',

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

@@ -22,6 +22,7 @@ import { diffArrayChange, mount } from "@/utils";
 import { Pos } from "@/utils/event";
 import Subtitle from "@/components/subtitle/index.vue";
 import { Size } from "@/components/drawing/dec";
+import router, { RoutesName } from "@/router";
 
 export let animationGroup: AnimationGroup;
 export const getAMKey = (am: AnimationModel) => am.key || am.id;
@@ -320,8 +321,10 @@ export const addSubtitle = (data: AnimationModelSubtitle) => {
 
   
   const stopAttrib = mergeFuns(
-    watch([currentTime, () => amMap[am.id].am, size], (_a, _b, onCleanup) => {
-      if (
+    watch([currentTime, () => amMap[am.id].am, size, play], (_a, _b, onCleanup) => {
+      if (!play.value && router.currentRoute.value.name !== RoutesName.animation) {
+        show.value = false
+      } else if (
         currentTime.value >= data.time &&
         currentTime.value <= (data.time + data.duration) 
       ) {
@@ -357,7 +360,19 @@ export const endTime = computed(() => {
     );
     return Math.max(...endPoints);
   })
-  return Math.max(...amsEndTime) + animationGroup.delayEndTime()
+  return Math.max(...amsEndTime) + (animationGroup.delayEndTime && animationGroup.delayEndTime() || 0)
+})
+
+export const play = ref(false);
+watch(play, (_a, _b, onCleanup) => {
+  play.value ? animationGroup?.play() : animationGroup?.pause();
+  onCleanup(
+    watchEffect(() => {
+      if (currentTime.value >= endTime.value) {
+        play.value = false;
+      }
+    })
+  );
 })
 
 export const currentTime = ref(0);

+ 3 - 3
src/sdk/association/guide.ts

@@ -6,7 +6,7 @@ import { fuseModels, isEdit, sysBus, fuseModelsLoaded } from "@/store";
 import type { FuseModel, FuseModels, Guide, GuidePath } from "@/store";
 import { analysisPoseInfo } from ".";
 import { fullView, isScenePlayRun, pauseScene, playScene } from "@/utils/full";
-import { animationGroup, currentTime } from "./animation";
+import { animationGroup, currentTime, play } from "./animation";
 
 // -----------------导览关联--------------------
 
@@ -99,7 +99,7 @@ export const playSceneGuide = (
         sceneGuide.bus.on("changePoint", (index) => {
           console.log(index)
           if (paths[index - 1].playAnimation) {
-            animationGroup && animationGroup.play()
+            play.value = true
           }
           changeIndexCallback && changeIndexCallback(index);
         });
@@ -118,7 +118,7 @@ export const playSceneGuide = (
       },
       pause: () => {
         sceneGuide.pause();
-        animationGroup && animationGroup.pause()
+        play.value = false
       },
       clear: () => {
         currentTime.value = 0

+ 1 - 28
src/views/animation/bottom.vue

@@ -101,7 +101,7 @@ import TimeLineFrame from "@/components/drawing-time-line/frame.vue";
 import TimeLineAction from "@/components/drawing-time-line/action.vue";
 import empty from "@/components/drawing-time-line/empty.vue";
 import { Active } from "./type";
-import { animationGroup, currentTime, endTime } from "@/sdk/association/animation";
+import { animationGroup, currentTime, endTime, play } from "@/sdk/association/animation";
 import { onlyId } from "@/components/drawing/hook";
 
 const props = defineProps<{
@@ -164,33 +164,6 @@ const count = computed(() =>
   Object.values(tlProps).reduce((t, c) => (props.am ? t + props.am[c.attr].length : 0), 0)
 );
 
-const play = ref(false);
-
-watch(play, (_a, _b, onCleanup) => {
-  play.value ? animationGroup.play() : animationGroup.pause();
-  onCleanup(
-    watchEffect(() => {
-      console.log(currentTime.value, endTime.value);
-      if (currentTime.value >= endTime.value) {
-        play.value = false;
-      }
-    })
-  );
-
-  // let isDes = false;
-  // let prevNow = Date.now();
-  // const animation = () => {
-  //   if (play.value && !isDes) {
-  //     const curNow = Date.now();
-  //     emit("update:currentTime", props.currentTime + (curNow - prevNow) * 0.001);
-  //     prevNow = curNow;
-  //     requestAnimationFrame(animation);
-  //   }
-  // };
-  // animation();
-  // onCleanup(() => (isDes = true));
-});
-
 const renderer = ref<any>();
 watch(
   () => props.am,