bill 1 年之前
父节点
当前提交
8092293b90
共有 2 个文件被更改,包括 22 次插入5 次删除
  1. 18 5
      src/sdk/association.ts
  2. 4 0
      src/utils/loading.ts

+ 18 - 5
src/sdk/association.ts

@@ -8,7 +8,8 @@ import {
   arrayChildEffectScope,
   togetherCallback,
   showLoad,
-  hideLoad
+  hideLoad,
+  round
 } from '@/utils'
 import SDKApp from './index.vue'
 import Components from 'bill/index'
@@ -56,12 +57,24 @@ const associationModels = (sdk: SDK) => {
           const data = transform;
           if (transform.rotation) {
             data.rotation = {
-              x: transform.rotation.x,
-              y: transform.rotation.y,
-              z: transform.rotation.z
+              x: round(transform.rotation.x, 3),
+              y: round(transform.rotation.y, 3),
+              z: round(transform.rotation.z, 3)
             }
           }
-          Object.assign(item, data)
+          if (transform.position) {
+            data.position = {
+              x: round(transform.position.x, 3),
+              y: round(transform.position.y, 3),
+              z: round(transform.position.z, 3)
+            }
+          }
+          if (transform.bottom) {
+            data.bottom = round(transform.bottom)
+          }
+          if (transform.scale) {
+            data.scale = round(transform.scale)
+          }
           nextTick(() => selfUpdate = false)
         })
       })

+ 4 - 0
src/utils/loading.ts

@@ -10,6 +10,10 @@ export const loadPack = <T, K extends (...args: any) => Promise<T>>(fn: K | Prom
     return ret
 }
 
+export const round = (num: number, index: number = 2) => {
+  const s = Math.pow(10, index)
+  return Math.round(num * s) / s
+}
 export const createLoadPack = <T, K extends (...args: any) => Promise<T>>(fn: K): K => 
   ((...args) => loadPack(() => fn(...args))) as K