bill 4 bulan lalu
induk
melakukan
396fd3a9e9

TEMPAT SAMPAH
public/animation/kid.glb


+ 2 - 9
src/api/animation.ts

@@ -22,13 +22,6 @@ type ServiceAnimationModel = {
   paths: string
 }
 
-export interface AnimationAction {
-  id: string;
-  title: string;
-  url: string;
-  action: string;
-}
-
 export type AnimationModelAction = {
   amplitude: number;
   speed: number;
@@ -104,8 +97,8 @@ export const fetchAnimationModels = async () => {
   return [
     {
       id: "1",
-      title: "dog",
-      url: "/animation/dog.glb",
+      title: "kid",
+      url: "/animation/kid.glb",
       showTitle: true,
       fontSize: 12,
       globalVisibility: true,

+ 2 - 0
src/sdk/sdk.ts

@@ -382,6 +382,8 @@ export type AnimationGroup = {
 };
 
 export type AnimationModel3D = {
+  getSupportActions: () => string[]
+
   // 销毁动画模型
   destroy: () => void;
   changeShow: (focus: boolean) => void

+ 0 - 6
src/store/animation.ts

@@ -17,7 +17,6 @@ import {
 } from "@/utils";
 
 import type {
-  AnimationAction,
   AnimationModel,
   AnimationModels,
 } from "@/api";
@@ -30,11 +29,6 @@ export type {
 export type { AnimationModel, AnimationModels };
 
 export const ams = ref<AnimationModels>([]);
-export const amActions = ref<AnimationAction[]>([]);
-
-export const initAnimationActions = async () => {
-  amActions.value = await fetchAnimationActions();
-};
 
 export const createAnimationModel = (
   am: Partial<AnimationModel> = {}

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

@@ -43,7 +43,6 @@ import {
   ams,
   AnimationModel,
   autoSaveAnimationModel,
-  initAnimationActions,
   initialAnimationModels,
 } from "@/store/animation";
 import { computed, nextTick, reactive, ref, watch, watchEffect } from "vue";
@@ -58,7 +57,6 @@ import { bottomBarHeightStack, showBottomBarStack } from "@/env";
 
 enterEdit(() => router.back());
 initialAnimationModels();
-initAnimationActions();
 // useViewStack(autoSaveAnimationModel);
 useViewStack(() => showBottomBarStack.push(ref(true)));
 

+ 50 - 4
src/views/animation/right/am.vue

@@ -65,7 +65,11 @@
         <ui-group-option class="item">
           <span class="label">字幕</span>
           <span class="oper">
-            <ui-icon @click="$emit('addSubtitle', {background: '#000'})" type="add_a" ctrl />
+            <ui-icon
+              @click="$emit('addSubtitle', { background: '#000' })"
+              type="add_a"
+              ctrl
+            />
           </span>
         </ui-group-option>
       </ui-group>
@@ -79,7 +83,14 @@
             <ui-icon
               type="add_a"
               ctrl
-              @click="$emit('addAction', { amplitude: 1, speed: 1, key: action.action, name: action.title })"
+              @click="
+                $emit('addAction', {
+                  amplitude: 1,
+                  speed: 1,
+                  key: action.action,
+                  name: action.title,
+                })
+              "
             />
           </span>
         </ui-group-option>
@@ -123,18 +134,53 @@ import { Switch, Slider, TabPane, Tabs } from "ant-design-vue";
 import { AnimationModel } from "@/api";
 import SignItem from "@/views/tagging-position/sign-item.vue";
 import { computed, ref } from "vue";
-import { amActions } from "@/store/animation";
 import { paths } from "@/store/path";
 import Message from "bill/components/message/message.vue";
 import { Modal } from "ant-design-vue";
+import { amMap } from "@/sdk/association/animation";
 
-defineProps<{ am: AnimationModel }>();
+const props = defineProps<{ am: AnimationModel }>();
 const emit = defineEmits<{
   (e: "addFrame" | "addPath" | "addSubtitle" | "addAction", preset?: any): void;
   (e: "applyGlobal", d: keyof AnimationModel): void;
 }>();
 const activeKey = ref("setting");
 
+const actionsMap: Record<string, string> = {
+  sit_to_stand: "坐:站起",
+  fist_pump: "坐下",
+  end_bicycle_sit_up: "躺:起来",
+  hit_on_legs: "向后倒下",
+  crawling: "爬",
+  medium_hit_to_head: "挨打",
+  illegal_knee: "左膝盖",
+  death_from_back_headshot: "向前倒地",
+  dying: "向前倒地死掉",
+  standard_walk: "标准走",
+  start_walking: "起步走",
+  left_turn_wbriefcase: "向左转",
+  running: "标准跑",
+  drunk_walk: "醉汉走",
+  mma_kick: "右前踢",
+  standing_jump: "标准向上跳",
+  sitting: "标准坐",
+  peone_forward: "匍匐前行",
+  wall_crash: "松手摔倒",
+  head_hit: "头被击中",
+};
+const keys = Object.keys(actionsMap);
+const amActions = computed(() => {
+  const actions = amMap[props.am.id].am?.getSupportActions() || [];
+  return actions.map((action) => {
+    let key = action.toLowerCase().replaceAll(/( |-)/gi, "_");
+    !keys.find((k) => key.includes(k)) && console.log(key);
+    key = keys.find((k) => key.includes(k)) || key;
+
+    console.log(action, key);
+    return { action, title: actionsMap[key] || action };
+  });
+});
+
 const options = computed(() =>
   paths.value.map((item) => ({ label: item.name, value: item.id }))
 );