Files
workinf_Blender_Wasm/tools/web/teach/build-teach-catalog.mjs
mes123456 c47fa79102
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
feat(web): viewport transform parity — offscreen backend, per-island pivots, ortho sizing
- 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>
2026-11-28 07:48:17 +08:00

90 lines
3.4 KiB
JavaScript

/**
* Builds the teaching catalogues from the lesson files.
*
* Two sets share one schema and one coach:
* main → web/app/public/teach/catalog.json (ch01…ch32, the 31 manual
* chapters plus the practical case)
* pbr → web/app/public/teach/pbr/catalog.json (pbr-01…pbr-04, the standalone
* PBR course page)
*
* The catalogue must never disagree with the coach, so it is generated, never
* hand-maintained. Run after editing a lesson:
* `node tools/web/teach/build-teach-catalog.mjs`
*/
import fs from "node:fs";
import path from "node:path";
const REPO_ROOT = path.resolve(import.meta.dirname, "../../..");
const PUBLIC = path.join(REPO_ROOT, "web/app/public");
const PART_TITLES = {
"part-a": "A 入门与数据",
"part-b": "B 布局与建模",
"part-c": "C 曲线、UV、材质与纹理",
"part-d": "D 程序化、动画与模拟",
"part-e": "E 渲染、合成与交换",
"part-f": "F 脚本、设置与运维",
"part-g": "G 实战案例",
};
const SETS = [
{
name: "main",
lessonsDir: path.join(PUBLIC, "teach/lessons"),
outFile: path.join(PUBLIC, "teach/catalog.json"),
filePattern: /^ch\d{2}\.json$/,
lessonBase: "/teach/lessons/",
manualFor: (id) => `/manuals/index.html#${id}`,
},
{
name: "pbr",
lessonsDir: path.join(PUBLIC, "teach/pbr/lessons"),
outFile: path.join(PUBLIC, "teach/pbr/catalog.json"),
filePattern: /^pbr-\d{2}\.json$/,
lessonBase: "/teach/pbr/lessons/",
manualFor: () => "/tutorial/pbr/render-lesson.html",
},
];
function buildSet(set) {
const files = fs.readdirSync(set.lessonsDir).filter((name) => set.filePattern.test(name)).sort();
const chapters = files.map((name) => {
const lesson = JSON.parse(fs.readFileSync(path.join(set.lessonsDir, name), "utf8"));
const id = name.replace(/\.json$/, "");
if (lesson.id !== id) throw new Error(`${name}: 课时 id 是 ${lesson.id}`);
return {
id,
number: lesson.number,
part: lesson.part,
partTitle: PART_TITLES[lesson.part] ?? lesson.part,
title: lesson.title,
level: lesson.level,
workspace: lesson.workspace,
minutes: lesson.minutes,
summary: lesson.summary,
objectives: lesson.objectives.length,
steps: lesson.steps.length,
unit: lesson.unit ?? "章",
fixture: lesson.setup?.fixture ?? null,
/* Chapters that teach the native desktop canvas open the native entry; the
* coach mounts in both, and the controls they point at only exist there. */
entry: lesson.setup?.entry === "native" ? "native" : "web",
href: lesson.setup?.entry === "native" ? `/?teach=${id}` : `/?ui=web&teach=${id}`,
manual: lesson.setup?.manual ?? set.manualFor(id),
lesson: `${set.lessonBase}${name}`,
};
});
const parts = [...new Set(chapters.map((chapter) => chapter.part))].map((part) => ({
id: part,
title: PART_TITLES[part] ?? part,
chapters: chapters.filter((chapter) => chapter.part === part).map((chapter) => chapter.id),
}));
const catalog = { schemaVersion: 1, generatedAt: new Date().toISOString(), count: chapters.length, parts, chapters };
fs.writeFileSync(set.outFile, `${JSON.stringify(catalog, null, 2)}\n`);
return `${path.relative(REPO_ROOT, set.outFile)}: ${chapters.length} ${chapters[0]?.unit ?? "章"}, ${parts.length} parts`;
}
for (const set of SETS) console.log(`wrote ${buildSet(set)}`);