bill 4 months ago
parent
commit
e0b1ac0ed4

+ 7 - 7
src/sdk/association/animation.ts

@@ -354,14 +354,14 @@ export const addSubtitle = (data: AnimationModelSubtitle) => {
     // if (isRun) return;
     // if (isRun) return;
     // isRun = true
     // isRun = true
     // setTimeout(() => {
     // setTimeout(() => {
-    pixel.value = amMap[am.id]?.am?.getCurrentSubtitlePixel(size.value);
+    pixel.value = amMap[getAMKey(am)]?.am?.getCurrentSubtitlePixel(size.value);
     //   isRun = false
     //   isRun = false
     // }, 16);
     // }, 16);
   };
   };
 
 
   const stopAttrib = mergeFuns(
   const stopAttrib = mergeFuns(
     watch(
     watch(
-      [currentTime, () => amMap[am.id]?.am, size, play, () => amMap[key]?.am],
+      [currentTime, () => amMap[getAMKey(am)]?.am, size, play, () => amMap[key]?.am],
       (_a, _b, onCleanup) => {
       (_a, _b, onCleanup) => {
         if (
         if (
           !play.value &&
           !play.value &&
@@ -502,14 +502,14 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
   watch(
   watch(
     () => {
     () => {
       const gAms = ams.value.filter(
       const gAms = ams.value.filter(
-        (am) => !am.frames.length && amMap[am.id]?.am
+        (am) => !am.frames.length && amMap[getAMKey(am)]?.am
       );
       );
       return gAms;
       return gAms;
     },
     },
     (am3ds, oldAm3ds = []) => {
     (am3ds, oldAm3ds = []) => {
       const { added, deleted } = diffArrayChange(am3ds, oldAm3ds);
       const { added, deleted } = diffArrayChange(am3ds, oldAm3ds);
       for (const am of added) {
       for (const am of added) {
-        const am3d = amMap[am.id];
+        const am3d = amMap[getAMKey(am)];
         if (!am3d || !am3d.am) continue;
         if (!am3d || !am3d.am) continue;
         const frame = am3d.am!.addFrame({
         const frame = am3d.am!.addFrame({
           id: uuid(),
           id: uuid(),
@@ -518,7 +518,7 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
           time: 0,
           time: 0,
         });
         });
         am3d.globalFrame = frame;
         am3d.globalFrame = frame;
-        cleanupMap[am.id] = mergeFuns(
+        cleanupMap[getAMKey(am)] = mergeFuns(
           watchEffect(() => {
           watchEffect(() => {
             am.mat && frame.setMat(am.mat);
             am.mat && frame.setMat(am.mat);
             console.log("set-global-frame", am.mat);
             console.log("set-global-frame", am.mat);
@@ -526,12 +526,12 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
           () => {
           () => {
             frame.destroy();
             frame.destroy();
             am3d.globalFrame = undefined;
             am3d.globalFrame = undefined;
-            delete cleanupMap[am.id];
+            delete cleanupMap[getAMKey(am)];
           }
           }
         );
         );
       }
       }
       for (const am of deleted) {
       for (const am of deleted) {
-        cleanupMap[am.id] && cleanupMap[am.id]();
+        cleanupMap[getAMKey(am)] && cleanupMap[getAMKey(am)]();
       }
       }
     },
     },
     { flush: "post", immediate: true }
     { flush: "post", immediate: true }

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

@@ -279,7 +279,7 @@ onUnmounted(
             label: "移动到这里",
             label: "移动到这里",
             icon: "move",
             icon: "move",
             handler() {
             handler() {
-              amMap[focusAM.value!.id]?.am?.moveModelTo(pixel, pos?.worldPos);
+              amMap[getAMKey(focusAM.value!)]?.am?.moveModelTo(pixel, pos?.worldPos);
             },
             },
           },
           },
         ]);
         ]);

+ 2 - 3
src/views/animation/left.vue

@@ -50,7 +50,7 @@ import { TabPane, Tabs } from "ant-design-vue";
 import { ams, AnimationModel, createAnimationModel } from "@/store/animation";
 import { ams, AnimationModel, createAnimationModel } from "@/store/animation";
 import { useSelects } from "@/hook/ids";
 import { useSelects } from "@/hook/ids";
 import { fetchMaterialGroups } from "@/api/material";
 import { fetchMaterialGroups } from "@/api/material";
-import { amMap } from "@/sdk/association/animation";
+import { amMap, getAMKey } from "@/sdk/association/animation";
 
 
 useViewStack(() =>
 useViewStack(() =>
   togetherCallback([
   togetherCallback([
@@ -82,9 +82,8 @@ const updateSelectAm = (item: AnimationModel, select: boolean) => {
 // if (import.meta.env.DEV) {
 // if (import.meta.env.DEV) {
 activeKey.value = "animation";
 activeKey.value = "animation";
 const stop = watchEffect(() => {
 const stop = watchEffect(() => {
-  if (amMap[ams.value[0]?.id].am) {
+  if (amMap[getAMKey(ams.value[0])].am) {
     setTimeout(() => {
     setTimeout(() => {
-      console.error(ams.value[0]);
       emit("update:focus", ams.value[0]);
       emit("update:focus", ams.value[0]);
       stop();
       stop();
     }, 1000);
     }, 1000);

+ 3 - 3
src/views/animation/right/action.vue

@@ -53,7 +53,7 @@
 import { Slider, TabPane, Tabs } from "ant-design-vue";
 import { Slider, TabPane, Tabs } from "ant-design-vue";
 import { AnimationModel, AnimationModelAction } from "@/api";
 import { AnimationModel, AnimationModelAction } from "@/api";
 import SignItem from "@/views/tagging-position/sign-item.vue";
 import SignItem from "@/views/tagging-position/sign-item.vue";
-import { amMap } from "@/sdk/association/animation";
+import { amMap, getAMKey } from "@/sdk/association/animation";
 import { computed, ref, watch, watchEffect } from "vue";
 import { computed, ref, watch, watchEffect } from "vue";
 import { round } from "@/utils";
 import { round } from "@/utils";
 
 
@@ -61,7 +61,7 @@ const props = defineProps<{ data: AnimationModelAction; am: AnimationModel }>();
 defineEmits<{ (e: "updateDuration", dur: number): void }>();
 defineEmits<{ (e: "updateDuration", dur: number): void }>();
 
 
 const dur = computed(() => {
 const dur = computed(() => {
-  const actions = amMap[props.am.id]?.am?.getSupportActions() || [];
+  const actions = amMap[getAMKey(props.am)]?.am?.getSupportActions() || [];
   const action = actions.find((item) => item.name === props.data.key);
   const action = actions.find((item) => item.name === props.data.key);
   if (action?.duration) {
   if (action?.duration) {
     return action?.duration / props.data.speed;
     return action?.duration / props.data.speed;
@@ -69,7 +69,7 @@ const dur = computed(() => {
 });
 });
 
 
 watch(
 watch(
-  () => amMap[props.am.id]?.actions[props.data.id],
+  () => amMap[getAMKey(props.am)]?.actions[props.data.id],
   (action, _, onCleanup) => {
   (action, _, onCleanup) => {
     console.log(action);
     console.log(action);
     if (action) {
     if (action) {

+ 3 - 3
src/views/animation/right/am.vue

@@ -139,7 +139,7 @@ import { round } from "@/utils";
 import { paths } from "@/store/path";
 import { paths } from "@/store/path";
 import Message from "bill/components/message/message.vue";
 import Message from "bill/components/message/message.vue";
 import { Modal } from "ant-design-vue";
 import { Modal } from "ant-design-vue";
-import { amMap } from "@/sdk/association/animation";
+import { amMap, getAMKey } from "@/sdk/association/animation";
 
 
 const props = defineProps<{ am: AnimationModel }>();
 const props = defineProps<{ am: AnimationModel }>();
 const emit = defineEmits<{
 const emit = defineEmits<{
@@ -172,7 +172,7 @@ const actionsMap: Record<string, string> = {
 };
 };
 const keys = Object.keys(actionsMap);
 const keys = Object.keys(actionsMap);
 const amActions = computed(() => {
 const amActions = computed(() => {
-  const actions = amMap[props.am.id]?.am?.getSupportActions() || [];
+  const actions = amMap[getAMKey(props.am)]?.am?.getSupportActions() || [];
   return actions.map(({ name: action, duration }) => {
   return actions.map(({ name: action, duration }) => {
     let key = action.toLowerCase().replaceAll(/( |-)/gi, "_");
     let key = action.toLowerCase().replaceAll(/( |-)/gi, "_");
     !keys.find((k) => key.includes(k)) && console.log(key);
     !keys.find((k) => key.includes(k)) && console.log(key);
@@ -199,7 +199,7 @@ const selectPathHandler = () => {
 };
 };
 
 
 const getActionDur = (key: string) => {
 const getActionDur = (key: string) => {
-  const actions = amMap[props.am.id]?.am?.getSupportActions() || [];
+  const actions = amMap[getAMKey(props.am)]?.am?.getSupportActions() || [];
   const action = actions.find((item) => item.name === key);
   const action = actions.find((item) => item.name === key);
   if (action?.duration) {
   if (action?.duration) {
     return round(action?.duration);
     return round(action?.duration);