bill 5 달 전
부모
커밋
b828c8b147
4개의 변경된 파일52개의 추가작업 그리고 17개의 파일을 삭제
  1. 5 3
      src/sdk/association/animation.ts
  2. 16 10
      src/sdk/sdk.ts
  3. 30 3
      src/views/animation/index.vue
  4. 1 1
      src/views/animation/right/frame.vue

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

@@ -24,9 +24,9 @@ import Subtitle from "@/components/subtitle/index.vue";
 import { Size } from "@/components/drawing/dec";
 
 export let animationGroup: AnimationGroup;
-const getAMKey = (am: AnimationModel) => am.key || am.id;
+export const getAMKey = (am: AnimationModel) => am.key || am.id;
 
-const amMap: Record<
+export const amMap: Record<
   string,
   {
     am?: AnimationModel3D;
@@ -36,6 +36,7 @@ const amMap: Record<
     subtitles: Record<string, () => void>;
   }
 > = reactive({});
+
 export const addAM = (data: AnimationModel): Promise<AnimationModel3D> => {
   const key = getAMKey(data);
   const stopLoad = watch(
@@ -128,7 +129,8 @@ export const addFrame = (
   );
 
   const stopAttrib = mergeFuns(() =>
-    watchEffect(() => amMap[key].frames[data.id]?.changeTime(data.time))
+    watchEffect(() => amMap[key].frames[data.id]?.changeTime(data.time)),
+    watchEffect(() => amMap[key].frames[data.id]?.setMat(data.mat))
   );
 
   const stopWatch = watch(

+ 16 - 10
src/sdk/sdk.ts

@@ -380,7 +380,7 @@ export type AnimationModel3D = {
   // 销毁动画模型
   destory: () => void;
   // 更改动画模型可见性
-  visibility: (show: boolean) => void;
+  changeShow: (show: boolean) => void;
   // 更改动画可见范围  不传为全局可见
   changeVisibilityRange: (range?: number) => void;
   // 更改模型名称
@@ -411,18 +411,16 @@ export type AnimationModel3D = {
     rotation?: SceneLocalPos;
     originPosition?: SceneLocalPos;
   };
-  // 设置当前操控模式, translate rotate scale originTranslate
-  setCurrentMode: (mode?: string) => void;
-};
 
-export type AnimationModelFrame3D = {
-  // 销毁动画模型帧
-  destory: () => void;
-  // 修改帧播放时间 单位为秒
-  changeTime: (s: number) => void;
+  // 进入旋转
+  enterRotateMode: () => void
+  enterMoveMode: () => void
+  enterScaleMode: () => void
+  leaveTransform: () => void;
+
   // 动画帧姿态修改数据
   bus: Emitter<{
-    matChange: {
+    transformChanged: {
       position?: SceneLocalPos;
       scale?: number;
       rotation?: SceneLocalPos;
@@ -431,6 +429,14 @@ export type AnimationModelFrame3D = {
   }>;
 };
 
+export type AnimationModelFrame3D = {
+  // 销毁动画模型帧
+  destory: () => void;
+  // 修改帧播放时间 单位为秒
+  changeTime: (s: number) => void;
+  setMat: (mat: any) => void
+};
+
 export type AnimationModelAction3D = {
   // 销毁动画模型动作
   destory: () => void;

+ 30 - 3
src/views/animation/index.vue

@@ -45,12 +45,13 @@ import {
   initAnimationActions,
   initialAnimationModels,
 } from "@/store/animation";
-import { nextTick, reactive, ref, watch } from "vue";
+import { computed, nextTick, reactive, ref, watch, watchEffect } from "vue";
 import { Active } from "./type";
 import { getAddTLItemAttr } from "@/components/drawing-time-line/check";
 import { Message } from "bill/expose-common";
 import { uuid } from "@/components/drawing/hook";
 import { title } from "./type";
+import { amMap, getAMKey } from "@/sdk/association/animation";
 
 enterEdit(() => router.back());
 initialAnimationModels();
@@ -63,6 +64,32 @@ const currentTime = ref(0);
 const follow = ref(false);
 const frameAction = ref<string>();
 
+const amM = computed(() => focusAM.value && amMap[getAMKey(focusAM.value)]);
+
+watchEffect((onCleanup) => {
+  if (!amM.value || activeAttrib.value?.key !== "frames") return;
+  const frame = focusAM.value!.frames[activeAttrib.value.ndx];
+  const am3d = amM.value.am;
+  if (!am3d) return;
+
+  am3d.bus.on("transformChanged", (mat) => {
+    frame.mat = JSON.parse(JSON.stringify(mat));
+  });
+
+  switch (frameAction.value) {
+    case "translate":
+      am3d.enterMoveMode();
+      break;
+    case "rotate":
+      am3d.enterRotateMode();
+      break;
+    case "scale":
+      am3d.enterScaleMode();
+      break;
+  }
+  onCleanup(() => am3d.leaveTransform());
+});
+
 const updateFocus = (am?: AnimationModel) => {
   activeAttrib.value = undefined;
   focusAM.value = am;
@@ -113,8 +140,8 @@ const add = <T extends Active["key"]>(
 };
 
 const changeSelect = ({ select, unSelect }: Record<string, AnimationModel[]>) => {
-  console.log("select", select);
-  console.log("unSelect", unSelect);
+  select.forEach((item) => amMap[getAMKey(item)].am?.changeShow(true));
+  unSelect.forEach((item) => amMap[getAMKey(item)].am?.changeShow(false));
 };
 
 const deleteAm = (am: AnimationModel) => {

+ 1 - 1
src/views/animation/right/frame.vue

@@ -26,7 +26,7 @@ const actions = [
   { key: "translate", icon: "a-move" },
   { key: "rotate", icon: "a-rotate" },
   { key: "scale", icon: "a-zoom" },
-  { key: "originTranslate", icon: "a-anchor" },
+  // { key: "originTranslate", icon: "a-anchor" },
 ];
 
 defineProps<{ data: AnimationModelFrame; frameAction?: string }>();