Skip to content

fix: avoid cumulative preview set-effect transforms#962

Open
A-kirami wants to merge 3 commits into
OpenWebGAL:devfrom
A-kirami:fix/preview-set-effect-baseline
Open

fix: avoid cumulative preview set-effect transforms#962
A-kirami wants to merge 3 commits into
OpenWebGAL:devfrom
A-kirami:fix/preview-set-effect-baseline

Conversation

@A-kirami
Copy link
Copy Markdown
Contributor

背景

此前 preview set-effect 会基于上一次写入后的 transform 继续合并。实时拖拽或局部调整时,未传入的字段会保留上一次 preview 值,导致位置、缩放、滤镜等效果在多次 set-effect 之间累积污染,也无法通过空 transform 恢复到本轮预览开始前的状态。

概要

  • 为 preview set-effect 命令按 target 捕获一份 baseline transform。
  • 每次收到 set-effect 时,都基于 baseline 和当前 payload 计算效果,不再基于上一次 preview 结果累积。
  • 在注册状态重置、场景同步、执行 snippet、运行临时场景内容时清空 baseline,避免跨场景污染。

行为变化

  • 未传入的 transform 字段会回到 baseline,而不是沿用上一次 set-effect 的结果。
  • transform: {} 会把目标恢复到当前 preview 会话捕获到的 baseline。

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a caching mechanism for effect transforms within the preview synchronization runtime. It modularizes transform merging logic into a new utility file, previewSetEffectTransform.ts, and updates previewSyncRuntime.ts to use a Map for storing baseline transforms. The cache is correctly cleared during scene resets and snippet executions to ensure state consistency. I have no feedback to provide as there were no review comments to assess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant