feat: 优化位置和可见性批量设置逻辑,仅在提供坐标或角度时更新,提升渲染效率和可读性

This commit is contained in:
xudan 2025-09-15 18:10:04 +08:00
parent 5d56362848
commit ac3b380f31

View File

@ -148,19 +148,30 @@ const monitorScene = async () => {
} }
}); });
// //
const positionUpdates = updates.map(({ id, data }) => { const positionUpdates = updates
const { x, y, angle } = data; .map(({ id, data }) => {
if (isNil(x) || isNil(y)) { const { x, y, angle } = data;
return { id, visible: false }; // xy angle / false
} else { if (isNil(x) && isNil(y) && angle == null) {
const newX = x - 60; return undefined;
const newY = y - 60; }
// angle const payload: any = { id };
const rotate = angle == null ? undefined : -angle + 180; if (!isNil(x) && !isNil(y)) {
return { id, x: newX, y: newY, rotate, visible: true, locked: LockState.None }; const newX = x - 60;
} const newY = y - 60;
}); payload.x = newX;
payload.y = newY;
payload.visible = true;
payload.locked = LockState.None;
}
if (angle != null) {
// angle
payload.rotate = -angle + 180;
}
return payload;
})
.filter((v) => v);
// 使Meta2D // 使Meta2D
positionUpdates.forEach((update) => { positionUpdates.forEach((update) => {