Browse Source

Merge branch 'v1.2.0-ga' of http://192.168.0.115:3000/bill/fuse-code into v1.2.0-ga

xzw 4 months ago
parent
commit
68c5a49d59

+ 1 - 0
src/api/animation.ts

@@ -76,6 +76,7 @@ export interface AnimationModel {
   paths: AnimationModelPath[];
   mat?: {
     position?: SceneLocalPos;
+    quaAtPath?: any
     scale?: number;
     rotation?: SceneLocalPos & {w: number};
     quaternion?: SceneLocalPos & {w: number};

+ 2 - 2
src/hook/ids.ts

@@ -37,8 +37,8 @@ export const useSelects = <T extends { id: any }>(items: Ref<T[]>, test = false)
         items.map((item) => item.id),
         oldItems.map((item) => item.id)
       );
-      test && console.error('added', added)
-      test && console.error('deleted', deleted)
+      // test && console.error('added', added)
+      // test && console.error('deleted', deleted)
       
       added.forEach((id) => updateSelectId(id, true));
       deleted.forEach((id) => updateSelectId(id, false));

+ 2 - 2
src/hook/use-fly.ts

@@ -67,13 +67,13 @@ export const flyTaggingPosition = (position: TaggingPosition) => {
     } as any, sdk, false);
   } else {
     sdk.comeTo({
-      position: getTaggingPosNode(position)!.getImageCenter(),
+      focusPos: getTaggingPosNode(position)!.getImageCenter(),
       modelId: position.modelId,
       dur: 300,
       // distance: 3,
       maxDis: 15,
       isFlyToTag: true,
-    });
+    } as any);
   }
 };
 

+ 1 - 1
src/layout/edit/scene-select.vue

@@ -220,7 +220,7 @@ watch(visible, (visible, oldvisible) => {
 const selectModel = async () => {
   const list = await selectMaterials({
     uploadFormat: ["zip"],
-    format: ["obj", "ply", "las", "laz", "b3dm", "shp", "osgb"],
+    format: ["obj", "ply", "las", "laz", "b3dm", "shp", "osgb", "glb"],
     maxSize: 2 * 1024 * 1024 * 1024,
   });
   if (!list?.length) return;

+ 8 - 16
src/sdk/association/animation.ts

@@ -74,7 +74,7 @@ export const addAM = (data: AnimationModel): Promise<AnimationModel3D> => {
           paths: {},
           subtitles: {},
         };
-        const am = animationGroup.addAnimationModel(data);
+        const am = animationGroup.addAnimationModel({...data, quaAtPath: data.mat?.quaAtPath});
         am.bus.on("loadDone", () => {
           amMap[key].am = am;
           console.log("0.0", am);
@@ -550,14 +550,12 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
         const am3d = amMap[getAMKey(am)];
         if (!am3d || !am3d.am) continue;
 
-        am3d.am.setDefaultPose(am.mat || am3d.am.getModelPose())
-        // const frame = am3d.am!.addFrame({
-        //   id: uuid(),
-        //   mat: am.mat || am3d.am.getModelPose(),
-        //   name: "global-frame",
-        //   time: 0,
-        // });
-        // am3d.globalFrame = frame;
+        const getMat = () => {
+          return (am.mat && 'position' in am.mat) ? am.mat : am3d.am!.getModelPose()
+        }
+
+        am3d.am.setDefaultPose && am3d.am.setDefaultPose(getMat())
+
         const mat = am.mat || am3d.am.getModelPose();
         am3d.am.changePosition(mat.position!);
         am3d.am.changeRotation(mat.rotation!);
@@ -565,18 +563,12 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
 
         cleanupMap[getAMKey(am)] = mergeFuns(
           watchEffect(() => {
-            // am.mat && frame.setMat(am.mat);
             if (am.mat && am3d.am) {
-              am3d.am.setDefaultPose(am.mat)
-              // console.log(am.mat)
-              // am3d.am.changePosition(mat.position!)
-              // am3d.am.changeRotation(mat.rotation!)
-              // am3d.am.changeScale(mat.scale!)
+              am3d.am.setDefaultPose && am3d.am.setDefaultPose(getMat())
             }
             console.log("set-default-pose", am.mat);
           }),
           () => {
-            // frame.destroy();
             am3d.am?.addFrame;
             am3d.globalFrame = undefined;
             delete cleanupMap[getAMKey(am)];

+ 1 - 1
src/sdk/sdk.ts

@@ -375,7 +375,7 @@ export type AnimationGroup = {
   // 暂停
   pause: () => void;
   // 添加动画模型
-  addAnimationModel: (data: AnimationModel) => AnimationModel3D;
+  addAnimationModel: (data: any) => AnimationModel3D;
   delayEndTime: () => number;
 
   // 设置当前时间, 单位为秒

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

@@ -147,11 +147,24 @@ watchEffect((onCleanup) => {
 
   const updateMat = (data: any) => {
     if (!data.byControl) return;
-    if (activeAttrib.value?.key === "frames") {
+    const mat = JSON.parse(JSON.stringify(am3d.getModelPose()));
+    if (data.quaAtPath) {
+      focusAM.value!.mat = !focusAM.value!.mat
+        ? { quaAtPath: data.quaAtPath }
+        : {
+            ...focusAM.value!.mat,
+            quaAtPath: data.quaAtPath,
+          };
+    } else if (activeAttrib.value?.key === "frames") {
       const frame = focusAM.value!.frames[activeAttrib.value.ndx];
-      frame.mat = JSON.parse(JSON.stringify(am3d.getModelPose()));
+      frame.mat = mat;
     } else {
-      focusAM.value!.mat = JSON.parse(JSON.stringify(am3d.getModelPose()));
+      focusAM.value!.mat = !focusAM.value!.mat
+        ? mat
+        : {
+            quaAtPath: focusAM.value!.mat.quaAtPath,
+            ...mat,
+          };
     }
   };
 

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

@@ -82,7 +82,7 @@ const updateSelectAm = (item: AnimationModel, select: boolean) => {
 // if (import.meta.env.DEV) {
 activeKey.value = "animation";
 const stop = watchEffect(() => {
-  if (ams.value.length > 0 && amMap[getAMKey(ams.value[0])].am) {
+  if (ams.value.length > 0 && amMap[getAMKey(ams.value[0])]?.am) {
     setTimeout(() => {
       emit("update:focus", ams.value[0]);
       stop();