|
@@ -44,11 +44,9 @@ import type {
|
|
|
|
|
|
let isUnSet = false
|
|
let isUnSet = false
|
|
const unSet = ((fn: () => void) => {
|
|
const unSet = ((fn: () => void) => {
|
|
- nextTick(() => {
|
|
|
|
- isUnSet = true
|
|
|
|
- fn()
|
|
|
|
- nextTick(() => isUnSet = false)
|
|
|
|
- })
|
|
|
|
|
|
+ isUnSet = true
|
|
|
|
+ fn()
|
|
|
|
+ nextTick(() => isUnSet = false)
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -83,31 +81,37 @@ const associationModels = (sdk: SDK) => {
|
|
})
|
|
})
|
|
sceneModelMap.set(itemRaw, sceneModel)
|
|
sceneModelMap.set(itemRaw, sceneModel)
|
|
|
|
|
|
|
|
+ let changeId: NodeJS.Timeout
|
|
sceneModel.bus.on('transformChanged', transform => {
|
|
sceneModel.bus.on('transformChanged', transform => {
|
|
- transform = { ...transform }
|
|
|
|
- if (transform.rotation) {
|
|
|
|
- transform.rotation = {
|
|
|
|
- x: round(transform.rotation.x, 5),
|
|
|
|
- y: round(transform.rotation.y, 5),
|
|
|
|
- z: round(transform.rotation.z, 5),
|
|
|
|
|
|
+ clearTimeout(changeId)
|
|
|
|
+
|
|
|
|
+ changeId = setTimeout(() => {
|
|
|
|
+ transform = { ...transform }
|
|
|
|
+ if (transform.rotation) {
|
|
|
|
+ transform.rotation = {
|
|
|
|
+ x: round(transform.rotation.x, 5),
|
|
|
|
+ y: round(transform.rotation.y, 5),
|
|
|
|
+ z: round(transform.rotation.z, 5),
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (transform.position) {
|
|
|
|
- transform.position = {
|
|
|
|
- x: round(transform.position.x, 5),
|
|
|
|
- y: round(transform.position.y, 5),
|
|
|
|
- z: round(transform.position.z, 5),
|
|
|
|
|
|
+ if (transform.position) {
|
|
|
|
+ transform.position = {
|
|
|
|
+ x: round(transform.position.x, 5),
|
|
|
|
+ y: round(transform.position.y, 5),
|
|
|
|
+ z: round(transform.position.z, 5),
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- const updateKeys = Object.keys(transform)
|
|
|
|
- const update: any = {}
|
|
|
|
- for (const key of updateKeys) {
|
|
|
|
- update[key] = (item as any)[key]
|
|
|
|
- }
|
|
|
|
- if (deepIsRevise(update, transform)) {
|
|
|
|
- unSet(() => Object.assign(item, transform))
|
|
|
|
- }
|
|
|
|
|
|
+ const updateKeys = Object.keys(transform)
|
|
|
|
+ const update: any = {}
|
|
|
|
+ for (const key of updateKeys) {
|
|
|
|
+ update[key] = (item as any)[key]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (deepIsRevise(update, transform)) {
|
|
|
|
+ unSet(() => Object.assign(item, transform))
|
|
|
|
+ }
|
|
|
|
+ }, 16)
|
|
})
|
|
})
|
|
|
|
|
|
sceneModel.bus.on('changeSelect', select => {
|
|
sceneModel.bus.on('changeSelect', select => {
|
|
@@ -158,12 +162,22 @@ const associationModels = (sdk: SDK) => {
|
|
)
|
|
)
|
|
watch(
|
|
watch(
|
|
() => item.position,
|
|
() => item.position,
|
|
- () => isUnSet || getSceneModel(item)?.changePosition(item.position),
|
|
|
|
|
|
+ () => {
|
|
|
|
+ if (!isUnSet) {
|
|
|
|
+ console.log('set position', item.position)
|
|
|
|
+ getSceneModel(item)?.changePosition(item.position)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
{ immediate: true }
|
|
{ immediate: true }
|
|
)
|
|
)
|
|
watch(
|
|
watch(
|
|
() => item.rotation,
|
|
() => item.rotation,
|
|
- () => isUnSet || getSceneModel(item)?.changeRotation(item.rotation),
|
|
|
|
|
|
+ () => {
|
|
|
|
+ if (!isUnSet) {
|
|
|
|
+ console.log('set rotation', item.rotation)
|
|
|
|
+ getSceneModel(item)?.changeRotation(item.rotation)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
{ immediate: true }
|
|
{ immediate: true }
|
|
)
|
|
)
|
|
watch(
|
|
watch(
|