fix(editor-robot): 优化机器人状态覆盖层可见性逻辑,仅在有效位置数据时显示避免初始位置闪烁
This commit is contained in:
parent
d0b7b7180d
commit
db5b2275f7
@ -321,16 +321,20 @@ export class EditorRobotService {
|
|||||||
const pen = this.ctx.getPenById(id);
|
const pen = this.ctx.getPenById(id);
|
||||||
if (!pen) return;
|
if (!pen) return;
|
||||||
|
|
||||||
// [关键修复] 强制同步可见性,防止因底层库时序问题导致的状态不一致。
|
// [修复] 只有在机器人有有效位置数据时才设置为可见,避免在初始位置闪烁
|
||||||
// 在回放模式下,上游的 setValue 可能不会立即生效,导致此处的 pen.visible 仍为 false。
|
const hasValidPosition = (pen.x !== undefined && pen.y !== undefined &&
|
||||||
if (pen.visible === false) {
|
(pen.x !== 0 || pen.y !== 0)) ||
|
||||||
|
(newPosition?.x !== undefined && newPosition?.y !== undefined &&
|
||||||
|
(newPosition.x !== 0 || newPosition.y !== 0));
|
||||||
|
|
||||||
|
// 只有在机器人有有效位置且当前不可见时,才设置为可见
|
||||||
|
if (hasValidPosition && pen.visible === false) {
|
||||||
this.ctx.setValue({ id, visible: true }, { render: false, history: false, doEvent: false });
|
this.ctx.setValue({ id, visible: true }, { render: false, history: false, doEvent: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
const icon = this.getRobotStatusIcon(pen);
|
const icon = this.getRobotStatusIcon(pen);
|
||||||
// 鉴于上面已经强制设置了 visible,此处直接使用 true 或重新检查 pen.visible 均可。
|
// 机器人可见性取决于是否有有效位置数据
|
||||||
// 为确保逻辑的健壮性,我们直接使用 true。
|
const robotVisible = hasValidPosition;
|
||||||
const robotVisible = true;
|
|
||||||
|
|
||||||
const baseW = (pen as any).iconWidth ?? 42;
|
const baseW = (pen as any).iconWidth ?? 42;
|
||||||
const baseH = (pen as any).iconHeight ?? 76;
|
const baseH = (pen as any).iconHeight ?? 76;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user