Files
workinf_Blender_Wasm/web/app/src/teach/lessons.ts
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

40 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { TeachLesson } from "./types";
/**
* Lesson loader. One JSON per chapter under `/teach/lessons/`, so a chapter is
* fetched only when the learner opens it, and the static catalogue and the
* deployed suite read exactly the same files.
*/
const cache = new Map<string, Promise<TeachLesson>>();
/** `chNN` = 手册章(32 章向导),`pbr-NN` = 独立的 PBR 四节课。 */
export function chapterIdFromParam(value: string | undefined | null): string | null {
if (!value) return null;
const match = /^(ch\d{2}|pbr-\d{2})$/.exec(value.trim());
return match ? match[1] : null;
}
export function lessonUrl(id: string): string {
return id.startsWith("pbr-") ? `/teach/pbr/lessons/${id}.json` : `/teach/lessons/${id}.json`;
}
export function loadLesson(id: string): Promise<TeachLesson> {
const cached = cache.get(id);
if (cached) return cached;
const pending = fetch(lessonUrl(id), { credentials: "same-origin" })
.then(async (response) => {
if (!response.ok) throw new Error(`课时 ${id} 加载失败(HTTP ${response.status})`);
const lesson = await response.json() as TeachLesson;
if (lesson.schemaVersion !== 1 || lesson.id !== id || !Array.isArray(lesson.steps) || lesson.steps.length === 0) {
throw new Error(`课时 ${id} 格式不正确`);
}
return lesson;
})
.catch((error) => { cache.delete(id); throw error; });
cache.set(id, pending);
return pending;
}
export function clearLessonCache(): void { cache.clear(); }