- Offscreen worker backend publishes the camera probe, so the G/R/S modal's pointer basis, transform gizmo and wireframe work on both renderers. - Edit-mode INDIVIDUAL_ORIGINS pivots every connected island on its own centre, committed as one grouped transaction (T(P)·R·S·T(-P) in object space). - Gizmo hits carry the pivot index; orthographic views size the axes from the visible world height instead of the 45° fov fallback. - View-menu navigation no longer switches workspace when a viewport is already on screen (the engine workspace transaction dropped the editor out of Edit). - Modal commits queue behind the shared command tail, so a trailing editEditorContext cannot consume the user's first Ctrl+Z. - Floating sidebar rotation field confirmed in degrees; headed cases for the offscreen path, per-island pivots and the sidebar unit, plus receipts/docs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
130 lines
9.0 KiB
Markdown
130 lines
9.0 KiB
Markdown
# 互动教学工具(TEACH-HUB,32 章 + PBR 四节)
|
||
|
||
面向使用者的 HTML 教学工具:在浏览器里打开 `/teach/` 选一章,进入真实的产品界面,被聚光灯高亮指引、被实时校验、可一键演示,也可以只看讲解。32 章 = 手册 31 章 + 1 个实战案例(给猴头赋材质);另有独立的 PBR 四节教程 `/teach/pbr/`,步骤与完成条件都是从线上功能测试套件里已经跑通的路径派生的。
|
||
|
||
## 1. 怎么用
|
||
|
||
| 入口 | 地址 | 用途 |
|
||
| --- | --- | --- |
|
||
| 教学目录页 | `/teach/` | 31 张章节卡、搜索、模式选择、继续上次学习、图文手册链接 |
|
||
| 应用内教学层 | `/?ui=web&teach=chNN&mode=guide\|demo\|explain[&step=chNN-sN]` | 在真实界面里逐步教学(PBR 课用 `teach=pbr-01`) |
|
||
| PBR 教程页 | `/teach/pbr/` | 四节 PBR 实战:工程与面板、资产库与赋材质、参数与贴图、渲染与保存 |
|
||
| 帮助菜单 | 帮助 → 教学向导(31 章) | 新窗口打开 `/teach/` |
|
||
|
||
CSP 是 `frame-ancestors 'none'`,教学页不能 iframe 套进应用,所以采用「页面跳转 + 应用内覆盖层」。
|
||
|
||
三种模式:
|
||
|
||
- **引导 + 校验**:聚光灯指向本步要点的控件,检查清单实时更新;检查全部通过后「下一步」才可用。
|
||
- **自动演示**:点「演示本步」执行该步动作并等检查通过;进入演示模式后会自动逐步走完整章,可随时暂停。
|
||
- **只做讲解**:不点控件,只显示文字、目标控件名、效果图与检查清单,适合投屏讲课。
|
||
|
||
进度按章保存在浏览器里(当前步、已完成步骤、模式、更新时间);目录页的进度环与「继续上次学习」都读同一份记录。刷新、关标签页后仍然可续。
|
||
|
||
教学面板默认停在右上;当本步的目标控件恰好落在面板下面(大纲树、属性标签页就在右列),面板会自动翻到左侧,避免挡住它正在指的那个控件。打开一章时还会自动切到该章声明的起始工作区(例如渲染几章需要 Rendering)。
|
||
|
||
涉及原生桌面画布的章节(ch26)声明 `setup.entry: "native"`,目录页会把入口写成 `/?teach=chNN`:教学层在 Web 与原生两个入口都会挂载。
|
||
|
||
## 2. 文件布局
|
||
|
||
```
|
||
web/app/public/teach/
|
||
index.html teach.css teach.js 静态目录页(外链资源,无内联脚本)
|
||
catalog.json 由课时数据生成,勿手改
|
||
lessons/ch01.json … ch31.json 课时数据,唯一事实来源
|
||
fixtures/*.blend 章节练习工程(basic-scene / nla-scene)
|
||
fixtures/monkey-head.glb 第 32 章的猴头模型(与 re/猴头.glb 同一文件)
|
||
pbr/index.html pbr/lessons/pbr-0N.json pbr/catalog.json PBR 四节教程
|
||
web/app/src/teach/ 应用内运行时
|
||
types.ts target.ts checks.ts lessons.ts progress.ts
|
||
TeachOverlay.tsx TeachSpotlight.tsx teach.css
|
||
tools/web/teach/build-teach-catalog.mjs 课时 → catalog.json
|
||
tools/web/teach/check-teach.mjs 静态校验
|
||
web/tests/deployed/09-teach.spec.ts 31 章在真实构建上的回放
|
||
web/tests/deployed/support/teach-checks.ts Playwright 侧的检查求值
|
||
```
|
||
|
||
## 3. 课时格式
|
||
|
||
一章一个 JSON。除排版字段外,全部内容都是可执行的声明:
|
||
|
||
```json
|
||
{
|
||
"schemaVersion": 1, "id": "ch08", "number": 8, "part": "part-b",
|
||
"title": "Outliner 选中对象并重命名", "level": "入门", "workspace": "Layout", "minutes": 5,
|
||
"summary": "…", "objectives": ["…"],
|
||
"setup": { "fixture": "/teach/fixtures/basic-scene.blend", "workspace": "Layout" },
|
||
"steps": [{
|
||
"id": "ch08-s1", "title": "在大纲树里选中立方体", "text": "…", "hint": "…",
|
||
"target": { "role": "treeitem", "name": "BasicCube" },
|
||
"referenceImage": "/manuals/images/ch08-outliner.jpg",
|
||
"checks": [{ "kind": "scene", "object": "BasicCube", "active": true }],
|
||
"demo": [{ "kind": "click", "target": { "role": "treeitem", "name": "BasicCube" } }]
|
||
}]
|
||
}
|
||
```
|
||
|
||
`setup.entry` 只取 `web`(默认)或 `native`;`native` 的章节目录页入口写成 `/?teach=chNN`,其余都是 `/?ui=web&teach=chNN`。`setup.workspace` 会在打开章节时自动切换。
|
||
|
||
**target**:`{ testid | css | role+name | name }`,可加 `nth`。解析顺序 testid → css → role+name → name;role 的可见名先精确匹配、再子串匹配——与 Playwright 的 `getByRole/getByTestId/locator` 一致,所以同一份声明浏览器内和回归里含义相同。
|
||
|
||
**checks**:
|
||
|
||
| kind | 含义 |
|
||
| --- | --- |
|
||
| `text` | 目标元素文本匹配 `matches`(正则)或等于 `equals` |
|
||
| `count` | 匹配元素数量 `equals` / `atLeast` |
|
||
| `exists` | 目标存在 |
|
||
| `attr` | 目标属性 `equals` / `matches` |
|
||
| `scene` | 场景事实:`object`(存在)、`active`(选中)、`mode`、`workspace`、`dirty`、`saved`、`objectCount`、`minObjects` |
|
||
| `value` | 表单值(`<select>`/`<input>` 的 `.value`),`equals` / 正则 `matches` |
|
||
| `event` | 产品侧结果:`saved` / `exported` / `render` |
|
||
|
||
`scene` 里同时写 `object` 和 `active: true` 表示「该对象被选中」(`active` 优先)。会往场景里加对象的章节用 `minObjects`,不要写死 `objectCount`。
|
||
|
||
**demo**:不写就按 target 点击(仅对 button / menuitem / treeitem 等可点角色);需要输入、菜单链或打开工程时写动作序列,复用教程动作词汇(`python` / `command` / `workspace` / `select` / `save` / `export` / `render` / `engineRender` / `openScene`),外加 `click` / `dblclick`(资产卡片双击分配)/ `fill` / `selectOption` / `importFile`(把随站点发布的 glb 喂给产品自己的文件入口)。
|
||
|
||
## 4. 怎么加一章
|
||
|
||
1. 从对应 `web/tests/deployed/*.spec.ts` 里取已经跑通的用户路径,写成 `lessons/chNN.json`(≥3 步,每步至少一个可机器判定的 check)。
|
||
2. 练习工程放到 `web/app/public/teach/fixtures/`,在 `setup.fixture` 里写站内路径。
|
||
3. `node tools/web/teach/build-teach-catalog.mjs` 重新生成目录。
|
||
4. `node tools/web/teach/check-teach.mjs`:章节齐全、结构合法、fixture 与配图存在、目录与课时一致;不通过会列出具体章与字段。
|
||
5. `DISPLAY=:1 node tools/web/run-deployed-functional-tests.mjs --local --grep "teach-chNN"`:把这一章在真实构建上走一遍,每步都要求检查通过。
|
||
|
||
## 5. 自动化回归
|
||
|
||
`web/tests/deployed/09-teach.spec.ts` 每条用例走一章:
|
||
|
||
- 用 `/?ui=web&teach=chNN&mode=guide&step=chNN-s1` 打开教学层(每例前清空进度键,避免续学跳步);
|
||
- 点「准备本章练习工程」应用该章 fixture;
|
||
- 逐步回放 `demo`(或点击可点 target),用**课时里的同一份 checks** 求值,最多等 45 s;
|
||
- 引导模式下「下一步」由检查结果解锁,最后一步点「完成本章」;
|
||
- 结束时断言 `blender-web:teach-progress:v1` 里本章步骤全部完成,并写出 `receipts/teach-chNN.json` 与截图。
|
||
|
||
用例标题是 `[teach-chNN]` 而不是 `[chNN]`:运行器把 `chNN` 计入功能覆盖章数,教学回放不得抬高那个数字。
|
||
|
||
```bash
|
||
node tools/web/teach/check-teach.mjs # 静态校验
|
||
DISPLAY=:1 node tools/web/run-deployed-functional-tests.mjs --local --grep "teach-ch" # 32 章本地回放
|
||
DISPLAY=:1 node tools/web/run-deployed-functional-tests.mjs --local --grep "teach-pbr" # PBR 四节回放
|
||
DISPLAY=:1 node tools/web/run-deployed-functional-tests.mjs --smoke # 线上冒烟
|
||
DISPLAY=:1 node tools/web/run-deployed-functional-tests.mjs --grep "teach-ch" # 线上回放
|
||
```
|
||
|
||
## 6. 进度存储
|
||
|
||
- localStorage 键 `blender-web:teach-progress:v1`:同步镜像,首屏即读。
|
||
- OPFS `tutorial/teach-progress.json`:持久副本,localStorage 被清理后仍可恢复。
|
||
- 形如 `{version:1, chapters:{chNN:{currentStepId, completedStepIds[], mode, updatedAt}}, updatedAt}`。
|
||
|
||
教学进度是界面状态,不涉及工程文件;工程、快照、渲染与导出仍然全部走 OPFS。
|
||
|
||
## 7. 已知限制
|
||
|
||
- 「事件」类检查(`saved` / `exported` / `render`)在应用内由引擎事件判定;Playwright 侧只有 `saved` 能直接从 `dirty-status` 读回,导出与渲染由用例自身断言下载/出图。
|
||
- 教学回放每章会重新载入一次应用(教学层按 URL 参数挂载),用的是同一浏览器上下文的缓存;一章约 30–40 s。
|
||
- 回放只实现了课时实际用到的演示动作(`click` / `fill` / `selectOption` / `openScene`);新动作必须在 `support/teach-checks.ts` 里补齐,否则该章直接失败而不是跳过。
|
||
- 聚光灯会暴露真实遮挡(例如快捷操作栏覆盖区域顶部)并提示「该控件被其他面板遮挡」,这是产品缺口信号,不是教学层的误报。
|
||
- 已知产品缺口:Rendering 工作区的大纲树不渲染对象行(同一工程在 Layout/Modeling 正常),所以 ch22 先在 Layout 选对象再切到 Rendering 看面板;该缺口记录在 [KNOWN_LIMITATIONS.md](KNOWN_LIMITATIONS.md)。
|