bill преди 2 години
родител
ревизия
50ad37abdf
променени са 4 файла, в които са добавени 13 реда и са изтрити 5 реда
  1. 10 3
      src/sdk/association.ts
  2. 1 0
      src/store/model.ts
  3. 1 1
      src/utils/store-help.ts
  4. 1 1
      src/views/merge/index.vue

+ 10 - 3
src/sdk/association.ts

@@ -53,7 +53,15 @@ const associationModels = (sdk: SDK) => {
       sceneModel.bus.on('transformChanged', transform => {
         setTimeout(() => {
           selfUpdate = true
-          Object.assign(item, transform)
+          const data = transform;
+          if (transform.rotation) {
+            data.rotation = {
+              x: transform.rotation.x,
+              y: transform.rotation.y,
+              z: transform.rotation.z
+            }
+          }
+          Object.assign(item, data)
           nextTick(() => selfUpdate = false)
         })
       })
@@ -77,10 +85,8 @@ const associationModels = (sdk: SDK) => {
         hideLoad()
       })
       sceneModel.bus.on('loadProgress', progress => item.progress = progress)
-      console.log("添加", item)
     }
     for (const item of deleted) {
-      console.log("取消", item)
       getSceneModel(item)?.destroy()
     }
   })
@@ -93,6 +99,7 @@ const associationModels = (sdk: SDK) => {
         if (loaded) {
           const modelShow = getModelShowVariable(item)
           watchEffect(() => {
+            selfUpdate || console.log('change bottom')
             item.bottom
             selfUpdate || getSceneModel(item)?.changeBottom(item.bottom)
           }, {flush: 'sync'})

+ 1 - 0
src/store/model.ts

@@ -64,6 +64,7 @@ export const backupModels = () => {
     rotation: {...model.rotation},
     position: {...model.position},
   }))
+  console.error(bcModels)
 }
 
 const serviceToLocal = (model: SModel): Model => ({

+ 1 - 1
src/utils/store-help.ts

@@ -205,7 +205,7 @@ export const recoverStoreItems = <T extends Array<{ id: any }>>(items: Ref<T>, g
   const backupItems = getBackupItems()
   items.value = backupItems.map(oldItem => {
     const model = items.value.find(item => item.id === oldItem.id)
-    console.log(model, oldItem)
+    console.log("===>", model, oldItem)
     return model ? Object.assign(model, oldItem) : oldItem
   }) as T
 }

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

@@ -83,7 +83,7 @@ const actionItems: ActionsProps['items'] = [
 
 const reset = async () => {
   if (custom.currentModel && await Dialog.confirm('确定恢复默认?此操作无法撤销')) {
-    Object.assign(custom.currentModel, defaultAttrs)
+    Object.assign(custom.currentModel, JSON.parse(JSON.stringify(defaultAttrs)))
     await nextTick()
     custom.currentModel && (custom.currentModel.bottom = 0)
   }