Skip to content

feat(viewport): v1.0 B1 — render host 实时视口切引擎(看+转相机)#39

Merged
longyi-xw merged 13 commits into
mainfrom
feat/v1.0b-render-host
Jun 11, 2026
Merged

feat(viewport): v1.0 B1 — render host 实时视口切引擎(看+转相机)#39
longyi-xw merged 13 commits into
mainfrom
feat/v1.0b-render-host

Conversation

@longyi-xw

Copy link
Copy Markdown
Owner

What

  • IRenderHost 契约src/runtime/render-host.ts,B1 子集:mount / 渲染循环 / 相机 / resize / dispose)+ isEngineEditingCapable 能力门(B2/B3/B4 在一处放开能力)。
  • BabylonAdapter 构造可注入引擎(默认仍 NullEngine,conformance/headless 零改动)+ scene.useRightHandedSystem = true(对齐 three/glTF 右手坐标系,真渲染无 z 镜像)。
  • BabylonRenderHost:真 Engine + ArcRotateCamera(构图对齐 Three 编辑器相机 [4,3,4]/fov50°)+ 渲染循环;dispose 链 stop → camera → adapter.dispose()(engine 所有权在 adapter)。
  • BabylonViewport:镜像 ThreeViewport mount-effect 约定(dep 仅 project id);种场景/增量同步走新引擎中立纯函数 diffSceneNodessrc/ui/viewport/scene-diff.ts);单节点 sync 失败 warn-skip 不拉黑视口。
  • 顶层切换Viewport 包装组件 + 视口工具栏 EngineToggle pill(useUIStore.viewportEngine 会话态;切换强制退 play,防 play 残留卡死右栏)。
  • Babylon 模式 view-only 禁用面:play 按钮(tooltip)/ gizmo pill / Space / F focus / 资源拖拽统一经 isEngineEditingCapable 禁用;hierarchy 选中与面板编辑保持可用且实时同步。
  • ThreeViewport.tsx 一行未改(「并行+定接口」策略;B2/B3 按 A1 spec §8 边界清单收敛)。

Why

How to test

  • pnpm lint && pnpm typecheck && pnpm test(545 tests,含 conformance 双引擎 + 新增 scene-diff/render-host/BabylonViewport/Viewport/EngineToggle/禁用面用例)
  • pnpm tauri dev 视觉 smoke:
    • 视口左上 Three/Babylon pill,默认 Three,既有编辑(gizmo/拾取/拖放/play)无回归
    • 切 Babylon:同一场景、构图一致、无左右镜像(属性面板改 position.x=2,cube 应与 Three 同在画面右侧)
    • Babylon 模式拖拽轨道转相机、滚轮缩放、拉伸窗口 resize 不变形
    • Babylon 模式:gizmo pill/play 禁用(play hover 有 tooltip)、点视口不改选中、F/Space 无效、库卡片拖不出 ghost 也不落节点
    • Babylon 模式 hierarchy 选中 + 面板改 transform → 视口即时更新
    • Three 下进 play → 切 Babylon 自动退 edit;切回 Three 一切正常
    • 来回切 5+ 次 console 无报错

已跑 headless 视觉 smoke(vite dev 前端 + headless Chrome CDP 驱动,diff 为纯前端故 surface 等价):上述各项全过(滚轮缩放因 CDP quirk 未实测,orbit 已证);两个已记录的非阻塞观感 gap(Babylon 底色比 Three 暗——Three OutputPass sRGB 提亮、Babylon 直写 raw;Babylon 光强偏亮)已入 roadmap B4。

🤖 Generated with Claude Code

longyi-xw and others added 13 commits June 10, 2026 18:34
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…system

Enable BabylonRenderHost to inject a real Engine while preserving default
headless NullEngine behavior. Scene now uses right-handed coordinates to
match three.js / glTF conventions. All ownership and dispose semantics
preserved.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
….0 B1)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mounting ThreeViewport while a selection is already in the store (engine
switch back from Babylon, v1.0 B1) ran the initial syncSelection against
an empty adapter — seedScene had not resolved yet — so gizmo/outline
never appeared, and re-picking the same node is a store no-op that never
re-fires the subscription. Latent pre-B1: every previous mount path had a
null selection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@longyi-xw longyi-xw merged commit b876260 into main Jun 11, 2026
1 check passed
@longyi-xw longyi-xw deleted the feat/v1.0b-render-host branch June 11, 2026 13:54
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