chore(web): checkpoint export fixes, operator routing and three-domain evidence
- Web engine CMake: apply WITH_WEB_USD_PYTHON to blender_web_engine_core, embed /usd resources, link pxr Python bindings after the core archive and whole-archive the monolithic OpenUSD archive. Fixes the wm.usd_export abort and restores Alembic/USD embedded export. - ?ui=web menus: fix inverted localOnly gating and route queueLocalDesktopOperator and nativeAdd through the desktop operator channel with a VIEW_3D context; non-mesh edit-mode selection uses the native VIEW3D_SELECT bridge. - Refresh WebEngine wasm/js artifacts, manual/course pages and the complete course video asset. - Record focused Chromium probes for Add/F3/parameters/modifier/UV/curve/deform, scene operations, OPFS save/reopen and worker restart. Evidence is NOT_CLAIMED. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
74
tools/web/course/check-complete-course.mjs
Normal file
74
tools/web/course/check-complete-course.mjs
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Validate the generated 24-module complete beginner course and its media.
|
||||
* Usage: node tools/web/course/check-complete-course.mjs
|
||||
*/
|
||||
import { execFileSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
||||
const DIR = path.join(REPO, "web/app/public/tutorial/complete");
|
||||
const INDEX = path.join(DIR, "index.html");
|
||||
const SOURCE = path.join(REPO, "tools/web/course/complete-course.json");
|
||||
const errors = [];
|
||||
|
||||
const course = fs.existsSync(SOURCE) ? JSON.parse(fs.readFileSync(SOURCE, "utf8")) : { modules: [], videos: [] };
|
||||
const expectedModules = course.modules.length;
|
||||
const html = fs.existsSync(INDEX) ? fs.readFileSync(INDEX, "utf8") : "";
|
||||
if (!html) errors.push("missing index.html");
|
||||
const modules = [...html.matchAll(/class="course-module"/g)].length;
|
||||
if (modules !== expectedModules) errors.push(`expected ${expectedModules} modules, found ${modules}`);
|
||||
if (expectedModules < 20) errors.push(`complete course has only ${expectedModules} modules`);
|
||||
if (!html.includes("OPFS")) errors.push("course does not mention OPFS");
|
||||
if (/<script\b/i.test(html)) errors.push("course page has inline script");
|
||||
if (/<style\b/i.test(html)) errors.push("course page has inline style");
|
||||
if (/https?:\/\//i.test(html)) errors.push("course page references a remote URL");
|
||||
if (!/<video\b/i.test(html)) errors.push("course page has no video");
|
||||
|
||||
const checkAsset = (src) => {
|
||||
if (!src || /^https?:/i.test(src)) return;
|
||||
const file = src.startsWith("/") ? path.join(REPO, "web/app/public", src.slice(1)) : path.join(DIR, src);
|
||||
if (!fs.existsSync(file)) errors.push(`missing asset ${src}`);
|
||||
};
|
||||
for (const match of html.matchAll(/<img[^>]+src="([^"]+)"/g)) checkAsset(match[1]);
|
||||
for (const match of html.matchAll(/<video[^>]+src="([^"]+)"/g)) checkAsset(match[1]);
|
||||
for (const match of html.matchAll(/<track[^>]+src="([^"]+)"/g)) checkAsset(match[1]);
|
||||
|
||||
const media = [];
|
||||
for (const match of html.matchAll(/<video[^>]+src="([^"]+)"/g)) {
|
||||
const file = match[1].startsWith("/") ? path.join(REPO, "web/app/public", match[1].slice(1)) : path.join(DIR, match[1]);
|
||||
if (!fs.existsSync(file)) continue;
|
||||
const probe = JSON.parse(execFileSync("/usr/bin/ffprobe", ["-v", "error", "-show_entries",
|
||||
"format=duration,size:stream=codec_type,codec_name,width,height", "-of", "json", file], { encoding: "utf8" }));
|
||||
const video = probe.streams.find((stream) => stream.codec_type === "video") ?? {};
|
||||
const audio = probe.streams.find((stream) => stream.codec_type === "audio") ?? {};
|
||||
media.push({ src: match[1], duration: Number(probe.format?.duration ?? 0), bytes: Number(probe.format?.size ?? 0), width: video.width, height: video.height, videoCodec: video.codec_name, audioCodec: audio.codec_name });
|
||||
if (video.codec_name !== "h264" || audio.codec_name !== "aac") errors.push(`${match[1]} is not H.264/AAC`);
|
||||
if (video.width !== 1280 || video.height !== 720) errors.push(`${match[1]} is not 1280x720`);
|
||||
if (Number(probe.format?.duration ?? 0) < 1200 || Number(probe.format?.duration ?? 0) > 90 * 60) errors.push(`${match[1]} duration outside 20-90 minutes`);
|
||||
}
|
||||
|
||||
for (const module of course.modules) {
|
||||
if (!html.includes(`id="${module.id}"`)) errors.push(`module ${module.id} missing from HTML`);
|
||||
const article = html.split(`id="${module.id}"`)[1]?.split("</article>")[0] ?? "";
|
||||
const images = [...article.matchAll(/<img\b/g)].length;
|
||||
if (images < module.steps.length) errors.push(`module ${module.id} has ${images} images for ${module.steps.length} steps`);
|
||||
if (!article.includes("course-objectives")) errors.push(`module ${module.id} has no objectives`);
|
||||
if (module.checks?.length && !article.includes("完成检查") && !article.includes("checks")) { /* checks rendered as part of steps in this template */ }
|
||||
}
|
||||
|
||||
const vtt = course.videos?.[0]?.vtt;
|
||||
if (vtt) {
|
||||
const file = vtt.startsWith("/") ? path.join(REPO, "web/app/public", vtt.slice(1)) : path.join(DIR, vtt);
|
||||
if (!fs.existsSync(file)) errors.push(`missing narration VTT ${vtt}`);
|
||||
else {
|
||||
const cues = (fs.readFileSync(file, "utf8").match(/-->/g) ?? []).length;
|
||||
if (cues < expectedModules) errors.push(`VTT has ${cues} cues for ${expectedModules} modules`);
|
||||
}
|
||||
}
|
||||
|
||||
const result = { schemaVersion: 1, status: errors.length === 0 ? "PASS" : "FAIL", modules, videos: media.length, totalMediaBytes: media.reduce((total, item) => total + (item.bytes ?? 0), 0), media, errors };
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
if (errors.length > 0) process.exitCode = 1;
|
||||
428
tools/web/course/complete-course.json
Normal file
428
tools/web/course/complete-course.json
Normal file
@@ -0,0 +1,428 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"title": "Web Blender 完整初学者课程",
|
||||
"subtitle": "用 RE 5000PBR 资产与猴头 GLB,从第一次打开到完整工作流",
|
||||
"version": "1.0.0",
|
||||
"audience": "第一次使用 Web Blender 的初学者;只需会使用浏览器和鼠标",
|
||||
"firstLoadNote": "首次打开需要加载较大的 WebAssembly 引擎,可能需要 30–193 秒。底栏出现 Engine: SceneIR 后再开始操作。",
|
||||
"rules": [
|
||||
"所有保存、重开和恢复都使用浏览器 OPFS;不会自动下载文件。",
|
||||
"需要本地 .blend 时,使用顶栏“下载 .blend”或“文件 → 下载 .blend 到本地”手动触发。",
|
||||
"本课程使用 Chromium;其他浏览器不在本轮验证范围。",
|
||||
"每一步都先看“你会看到什么”,再做下一步;状态栏和底栏是判断成功的主要依据。"
|
||||
],
|
||||
"videos": [
|
||||
{
|
||||
"id": "complete",
|
||||
"title": "完整操作视频(带中文配音)",
|
||||
"src": "/tutorial/complete/video/complete-course-720p.mp4",
|
||||
"poster": "/tutorial/complete/video/poster.jpg",
|
||||
"vtt": "/tutorial/complete/video/complete-course.zh-Hans.vtt",
|
||||
"note": "建议第一遍连续观看,第二遍按章节跟做。"
|
||||
}
|
||||
],
|
||||
"modules": [
|
||||
{
|
||||
"id": "M01",
|
||||
"title": "工程、导入猴头与 OPFS 保存",
|
||||
"level": "入门",
|
||||
"minutes": 12,
|
||||
"summary": "新建工程,导入 re/猴头.glb,保存到浏览器 OPFS,关闭后从最近项目重开,并手动下载一份本地备份。",
|
||||
"objectives": ["认识顶栏、状态栏和底栏", "从本地导入 GLB", "区分 OPFS 保存与手动下载"],
|
||||
"steps": [
|
||||
{ "text": "打开 /?ui=web,等待底栏显示 Engine: SceneIR。新建常规工程会得到立方体、相机和灯光三个对象。", "image": "steps/M01-startup.jpg" },
|
||||
{ "text": "点击“文件 → 打开”,选择 /home/mes123456/workinf_Blender_Wasm/re/猴头.glb。导入是追加,不会替换当前场景;对象数增加 1,活动对象是 Suzanne。", "image": "steps/M01-import-monkey.jpg" },
|
||||
{ "text": "点击顶栏“保存项目”。底栏保存状态变为 SUCCEEDED,工程写入 OPFS;这一步不会下载文件。", "image": "steps/M01-opfs-save.jpg" },
|
||||
{ "text": "关闭项目,再从“文件 → 最近打开”选择刚保存的工程。对象数和活动对象应与保存前一致。", "image": "steps/M01-reopen.jpg" },
|
||||
{ "text": "需要本地备份时,点击顶栏“下载 .blend”。这是唯一会生成本地文件的动作,由你手动触发。", "image": "steps/M01-download.jpg" }
|
||||
],
|
||||
"tips": ["状态栏 SceneIR 后面的对象数是判断导入/重开是否成功的可靠信号。", "猴头本身没有材质,导入后是灰色,这是正常的基线。"],
|
||||
"warnings": ["清除浏览器站点数据会删除 OPFS 工程;重要工程请手动下载备份。"],
|
||||
"checks": ["底栏 Engine 显示 SceneIR", "导入后对象数增加 1", "保存状态 SUCCEEDED", "重开后对象数一致"]
|
||||
},
|
||||
{
|
||||
"id": "M02",
|
||||
"title": "界面、工作区与视口",
|
||||
"level": "入门",
|
||||
"minutes": 10,
|
||||
"summary": "认识 11 个工作区,切换 Layout/Modeling/Rendering 等,使用区域 ⋮ 菜单分割与合并,并掌握轨道、缩放和框显。",
|
||||
"objectives": ["切换工作区", "分割与合并区域", "在 3D 视口导航"],
|
||||
"steps": [
|
||||
{ "text": "顶部工作区标签依次是 Layout、Modeling、Sculpting、UV Editing、Texture Paint、Shading、Animation、Rendering、Compositing、Geometry Nodes、Scripting。点击任意标签切换。", "image": "steps/M02-workspaces.jpg" },
|
||||
{ "text": "把鼠标放到某个区域,点击区域右上角或头部的 ⋮ 菜单,选择“垂直分割(左右)”。再点一次可合并或交换区域。", "image": "steps/M02-area-menu.jpg" },
|
||||
{ "text": "在 3D 视口按住中键拖动旋转,滚轮缩放,Shift+中键平移;数字小键盘 0 进入相机视图,Home 框显全部。", "image": "steps/M02-viewport.jpg" },
|
||||
{ "text": "按 F3 打开操作搜索,输入“移动”或“保存”,可以看到并执行命令。F3 是找不到按钮时的首选入口。", "image": "steps/M02-f3.jpg" }
|
||||
],
|
||||
"tips": ["工作区只是布局,不会改变工程数据。", "F3 搜索结果会标注执行位置(本地/服务器)。"],
|
||||
"warnings": ["灰色或标 unavailable 的命令表示当前上下文不可用,不是 bug。"],
|
||||
"checks": ["11 个工作区都能切换", "区域可以分割并恢复", "F3 能搜到命令并执行"]
|
||||
},
|
||||
{
|
||||
"id": "M03",
|
||||
"title": "Outliner、对象与层级",
|
||||
"level": "入门",
|
||||
"minutes": 10,
|
||||
"summary": "在 Outliner 选择、重命名、切换可见性、拖放父子关系,并建立集合。",
|
||||
"objectives": ["选择和重命名对象", "切换可见性", "建立父子与集合"],
|
||||
"steps": [
|
||||
{ "text": "在 Outliner 单击对象名选择;Shift 单击可多选。选中猴头后,3D 视口会出现橙色轮廓。", "image": "steps/M03-select.jpg" },
|
||||
{ "text": "按 F2 或双击名称重命名;改名会写入 Main,保存后重开仍保留。", "image": "steps/M03-rename.jpg" },
|
||||
{ "text": "点击对象右侧的眼睛图标切换可见性;隐藏只影响显示,不删除数据。", "image": "steps/M03-visibility.jpg" },
|
||||
{ "text": "把一个对象拖到另一个对象上建立父子关系;拖到集合上则移动集合链接。", "image": "steps/M03-parent.jpg" }
|
||||
],
|
||||
"tips": ["Outliner 的选择会同步到 3D 视口和 Properties。", "Join 会合并网格数据,Parent 只改变层级。"],
|
||||
"warnings": ["删除对象可用撤销恢复;删除数据块前请先保存。"],
|
||||
"checks": ["选择与视口一致", "重命名保存后保留", "父子/集合关系正确"]
|
||||
},
|
||||
{
|
||||
"id": "M04",
|
||||
"title": "Properties、变换、相机与灯光",
|
||||
"level": "入门",
|
||||
"minutes": 12,
|
||||
"summary": "在 Properties 编辑位置/旋转/缩放,应用变换与设置原点,编辑相机、灯光、世界和场景渲染属性。",
|
||||
"objectives": ["编辑变换并撤销", "应用变换/原点", "编辑相机与灯光"],
|
||||
"steps": [
|
||||
{ "text": "Properties 顶部有对象、修改器、材质三个标签。对象标签里直接输入位置/旋转/缩放数值。", "image": "steps/M04-transform.jpg" },
|
||||
{ "text": "在“物体 → 应用 → 全部变换”把变换烘焙进网格;设置原点可把轴心移到几何体中心。", "image": "steps/M04-apply.jpg" },
|
||||
{ "text": "选择相机,编辑焦距、裁剪和相机视图;数字小键盘 0 进入/退出相机视图。", "image": "steps/M04-camera.jpg" },
|
||||
{ "text": "选择灯光,调整类型、能量、阴影;World 区可调环境光。", "image": "steps/M04-light.jpg" }
|
||||
],
|
||||
"tips": ["变换输入框支持直接键入数值和撤销。", "应用变换后数值归零,但网格形状不变。"],
|
||||
"warnings": ["链接对象/材质的属性是只读的;需要先 Make Local。"],
|
||||
"checks": ["变换改变视口", "应用后网格保持形状", "相机视图与灯光生效"]
|
||||
},
|
||||
{
|
||||
"id": "M05",
|
||||
"title": "建模与网格编辑",
|
||||
"level": "进阶",
|
||||
"minutes": 18,
|
||||
"summary": "创建基础体,进入编辑模式,使用顶点/边/面/边框选,执行挤出、倒角、环切、内插与法线修正。",
|
||||
"objectives": ["进入编辑模式", "框选与环选", "常用网格算子"],
|
||||
"steps": [
|
||||
{ "text": "在 Modeling 工作区或“添加”菜单创建立方体/平面/球体;也可按 F3 搜索 primitive 命令。", "image": "steps/M05-primitive.jpg" },
|
||||
{ "text": "点击模式按钮切到 Edit Mode;选择顶点/边/面模式。B 键或视口框选工具可框选元素。", "image": "steps/M05-edit-mode.jpg" },
|
||||
{ "text": "按 E 挤出、Ctrl+B 倒角、Ctrl+R 环切、I 内插;这些操作在 ?ui=web 下通过真实 Blender 算子执行。", "image": "steps/M05-tools.jpg" },
|
||||
{ "text": "使用“法线 → 重新计算”和“按距离合并”修正拓扑;每步都可用撤销恢复。", "image": "steps/M05-normals.jpg" }
|
||||
],
|
||||
"tips": ["菜单和 F3 都可以调用同一批算子。", "高面数操作注意浏览器内存与响应时间。"],
|
||||
"warnings": ["破坏性操作后先保存或确认可撤销。"],
|
||||
"checks": ["编辑模式可切换选择域", "框选/环选生效", "算子后网格更新"]
|
||||
},
|
||||
{
|
||||
"id": "M06",
|
||||
"title": "修改器栈",
|
||||
"level": "进阶",
|
||||
"minutes": 12,
|
||||
"summary": "添加 Subdivision、Mirror、Boolean、Decimate、Array 等修改器,调整顺序和参数,并应用。",
|
||||
"objectives": ["添加与排序修改器", "调参数并观察视口", "应用修改器"],
|
||||
"steps": [
|
||||
{ "text": "在 Properties 的修改器标签点击添加,选择 Subdivision Surface,级别从 1 调到 2。", "image": "steps/M06-add.jpg" },
|
||||
{ "text": "添加 Mirror,设置轴与裁切;再添加 Boolean,选择另一个对象作为操作数。", "image": "steps/M06-stack.jpg" },
|
||||
{ "text": "拖动修改器顺序会改变结果;眼睛图标控制视口/渲染可见性。", "image": "steps/M06-order.jpg" },
|
||||
{ "text": "点击 Apply 把修改器烘焙进网格;Apply 前先复制对象以便对比。", "image": "steps/M06-apply.jpg" }
|
||||
],
|
||||
"tips": ["Boolean 需要封闭网格;Mirror 依赖原点。", "修改器参数与顺序都保存到 OPFS。"],
|
||||
"warnings": ["应用后不能再用参数回退,只能撤销或重做。"],
|
||||
"checks": ["修改器按顺序求值", "参数改变视口", "Apply 后网格变化"]
|
||||
},
|
||||
{
|
||||
"id": "M07",
|
||||
"title": "雕刻",
|
||||
"level": "进阶",
|
||||
"minutes": 14,
|
||||
"summary": "在 Sculpting 工作区用 Draw/Inflate/Grab/Smooth 笔刷拖拽雕刻,设置遮罩/面组并执行 Voxel Remesh。",
|
||||
"objectives": ["选择笔刷并拖拽", "遮罩与面组", "Voxel Remesh"],
|
||||
"steps": [
|
||||
{ "text": "选中猴头,切到 Sculpting 工作区;在属性面板选择 Draw 笔刷,设置半径和强度。", "image": "steps/M07-brush.jpg" },
|
||||
{ "text": "在视口按住左键拖拽,松开后一次原生 sculptStroke 会提交;撤销可恢复。", "image": "steps/M07-stroke.jpg" },
|
||||
{ "text": "调整 Mask 和 Active Face Set;遮罩区域不会被笔刷改变。", "image": "steps/M07-mask.jpg" },
|
||||
{ "text": "设置 Remesh 体素大小并点击 Voxel Remesh,重新拓扑后再继续雕刻。", "image": "steps/M07-remesh.jpg" }
|
||||
],
|
||||
"tips": ["每次拖拽是一次采样笔触;复杂形状分多次画。", "高细分网格会显著变慢。"],
|
||||
"warnings": ["Remesh 会重建拓扑;先保存或确认可撤销。"],
|
||||
"checks": ["笔刷改变网格", "撤销恢复", "Remesh 后仍可雕刻"]
|
||||
},
|
||||
{
|
||||
"id": "M08",
|
||||
"title": "UV 编辑",
|
||||
"level": "进阶",
|
||||
"minutes": 14,
|
||||
"summary": "进入编辑模式,在 UV 工作区全选、展开、打包与缝合,为 PBR 贴图准备坐标。",
|
||||
"objectives": ["进入 UV 工作区", "展开与打包", "检查 UV 岛"],
|
||||
"steps": [
|
||||
{ "text": "选中猴头,切到 UV Editing;桌面语义要求网格处于 Edit Mode,先进入编辑模式。", "image": "steps/M08-workspace.jpg" },
|
||||
{ "text": "在 UV 画布点击“全选 UV”,等待选择提交;再点击“展开所选 UV”。", "image": "steps/M08-unwrap.jpg" },
|
||||
{ "text": "使用“打包 UV 岛”和“平均岛缩放”整理布局;标记缝合线可改善展开结果。", "image": "steps/M08-pack.jpg" },
|
||||
{ "text": "回到 Layout 保存;重开后 UV 数据和贴图坐标保持一致。", "image": "steps/M08-save.jpg" }
|
||||
],
|
||||
"tips": ["展开前标记缝合线通常能得到更整齐的 UV 岛。", "UV 选择与 3D 视口选择是两套状态。"],
|
||||
"warnings": ["链接网格数据需要先 Make Local 才能写入。"],
|
||||
"checks": ["UV 选择提交成功", "展开/打包改变布局", "保存重开 UV 不变"]
|
||||
},
|
||||
{
|
||||
"id": "M09",
|
||||
"title": "纹理绘制",
|
||||
"level": "进阶",
|
||||
"minutes": 14,
|
||||
"summary": "在 Texture Paint 工作区对 packed 图像绘制、撤销/重做,并把库链接图像设为本地。",
|
||||
"objectives": ["选择纹理图像", "画笔绘制与撤销", "Make Local"],
|
||||
"steps": [
|
||||
{ "text": "切到 Texture Paint,选择要绘制的 packed 图像;没有图像时先从材质或外部贴图导入。", "image": "steps/M09-workspace.jpg" },
|
||||
{ "text": "设置颜色、半径和强度,在画布拖拽绘制;松开后提交为一个绘制事务。", "image": "steps/M09-stroke.jpg" },
|
||||
{ "text": "使用撤销/重做对比结果;保存 OPFS 后重开,笔画仍在。", "image": "steps/M09-undo.jpg" },
|
||||
{ "text": "库链接图像先点击“设为本地”(原生 Make Local),再绘制;3D 投影绘制需要原生会话。", "image": "steps/M09-make-local.jpg" }
|
||||
],
|
||||
"tips": ["图像越大,PNG 编码越慢;课程使用 1024×1024。", "2D 绘制是本地能力;UDIM/投影属于原生会话路径。"],
|
||||
"warnings": ["清除站点数据会丢失 OPFS 中的贴图;重要贴图手动下载备份。"],
|
||||
"checks": ["画布像素变化", "撤销恢复", "重开后笔画仍在"]
|
||||
},
|
||||
{
|
||||
"id": "M10",
|
||||
"title": "曲线、文本、字体与 Grease Pencil",
|
||||
"level": "进阶",
|
||||
"minutes": 14,
|
||||
"summary": "创建曲线/曲面/文本/融球/Grease Pencil,编辑控制点与字体,并绘制 GP 笔画。",
|
||||
"objectives": ["创建非网格对象", "编辑曲线/文本", "绘制 GP"],
|
||||
"steps": [
|
||||
{ "text": "“添加”菜单包含 Bezier/NURBS 曲线、曲面、文本、骨架、融球、体积、晶格、点云、毛发、Grease Pencil 与力场。", "image": "steps/M10-add.jpg" },
|
||||
{ "text": "进入编辑模式编辑曲线控制点;文本属性可编辑正文、布局与字体链接。", "image": "steps/M10-text.jpg" },
|
||||
{ "text": "导入本地 TTF/OTF/PFB 字体会打包进 Main,保存 OPFS 后重开仍可用。", "image": "steps/M10-font.jpg" },
|
||||
{ "text": "在 GP 编辑器中添加图层/帧并绘制笔画;可调整材质与插值。", "image": "steps/M10-grease-pencil.jpg" }
|
||||
],
|
||||
"tips": ["非网格数据的高级编辑受能力矩阵限制,部分操作走原生/F3。", "字体文件会进入工程资源,注意体积。"],
|
||||
"warnings": ["库链接字体的部分编辑只读。"],
|
||||
"checks": ["非网格对象出现在 Outliner", "曲线/文本可编辑", "GP 笔画可保存"]
|
||||
},
|
||||
{
|
||||
"id": "M11",
|
||||
"title": "Shading 与 RE 5000PBR 资产库",
|
||||
"level": "核心",
|
||||
"minutes": 20,
|
||||
"summary": "从 RE 5000PBR 派生库加载 6 种材质,分配给猴头,检查材质编译与贴图,并体验 HQ 2048。",
|
||||
"objectives": ["认识资产库", "分配 6 种材质", "理解标准/HQ 与 packed 贴图"],
|
||||
"steps": [
|
||||
{ "text": "切到 Shading 工作区;左下角 PBR 资产库有 pbr-essentials 与 RE 两个来源。选择 RE 5000PBR,只显示 6 张材质卡片。", "image": "steps/M11-library.jpg" },
|
||||
{ "text": "单击卡片只选中,双击才会分配。分配前确认顶部模式是 Object Mode;编辑模式下 Blender 会拒绝追加资产。依次双击防滑颗粒、砖墙、随机瓷砖、光亮瓷砖、规则砖墙、做旧砖墙。", "image": "steps/M11-assign.jpg" },
|
||||
{ "text": "每次分配后等待材质槽更新且材质球显示 COMPILED;贴图状态应为 ready。", "image": "steps/M11-compiled.jpg" },
|
||||
{ "text": "点击“加载高清贴图 (2048)”按需启用 HQ 库;HQ 更清晰但占用更多显存和加载时间。", "image": "steps/M11-hq.jpg" }
|
||||
],
|
||||
"tips": ["资产来源下拉框决定当前显示的库。", "RE 资产由 /home/mes123456/workinf_Blender_Wasm/re/5000PBR精简版 派生,贴图已 packed。"],
|
||||
"warnings": ["HQ 是懒加载,首次启用会明显变慢;低显存设备先用标准库。"],
|
||||
"checks": ["6 张卡片可见", "材质槽更新", "COMPILED 与贴图 ready", "HQ 可加载"]
|
||||
},
|
||||
{
|
||||
"id": "M12",
|
||||
"title": "PBR 渲染与诊断",
|
||||
"level": "核心",
|
||||
"minutes": 20,
|
||||
"summary": "在 Rendering 工作区渲染猴头,调整分辨率/相机/视角/曝光/位移,查看诊断视图并下载 PNG。",
|
||||
"objectives": ["完成一次 PBR 渲染", "使用诊断视图", "理解位移与 GPU"],
|
||||
"steps": [
|
||||
{ "text": "切到 Rendering;PBR 面板可选择分辨率 256–2048、相机与视角预设 SCENE_CAMERA/COMPARISON。", "image": "steps/M12-panel.jpg" },
|
||||
{ "text": "点击“渲染 PBR”,等待结果图出现;材质、贴图和灯光共同决定画面。", "image": "steps/M12-render.jpg" },
|
||||
{ "text": "切换诊断视图 BASE_COLOR/NORMAL/ROUGHNESS,检查贴图与法线;曝光可选 0/+1/+2 EV。", "image": "steps/M12-diagnostics.jpg" },
|
||||
{ "text": "调整位移强度观察几何细节;点击“下载 PNG”手动保存渲染结果。", "image": "steps/M12-download.jpg" }
|
||||
],
|
||||
"tips": ["渲染使用 WebGL2/three.js 的 PBR 路径,不是桌面 EEVEE/Cycles。", "RTX 4060 硬件 lane 比 SwiftShader 快;首次纹理加载需要时间。"],
|
||||
"warnings": ["交互视口不细分位移,位移主要影响静态渲染。", "深色材质在 PBR 下看起来偏暗,可提高曝光。"],
|
||||
"checks": ["结果图出现", "诊断视图切换", "PNG 手动下载", "多次渲染 SHA 不同"]
|
||||
},
|
||||
{
|
||||
"id": "M13",
|
||||
"title": "动画、Graph/NLA/驱动器与播放",
|
||||
"level": "核心",
|
||||
"minutes": 20,
|
||||
"summary": "插关键帧、播放动画、编辑 F-Curve/Graph、提交 NLA、设置驱动器表达式,并用对象作相机。",
|
||||
"objectives": ["关键帧与播放", "Graph/NLA", "驱动器与相机"],
|
||||
"steps": [
|
||||
{ "text": "在 Animation 工作区选中猴头,移动时间线到不同帧,点击 Loc/Rot/Scale 插入关键帧。", "image": "steps/M13-keyframes.jpg" },
|
||||
{ "text": "点击播放,时间线按 Blender 持久 depsgraph 逐帧求值;暂停后拖到中间帧检查插值。", "image": "steps/M13-playback.jpg" },
|
||||
{ "text": "在 Graph Editor 调整关键帧/插值;在 NLA 表单提交 strip;驱动器表达式可写入并查看变量/目标。", "image": "steps/M13-graph-nla.jpg" },
|
||||
{ "text": "在 Scene Bindings 点击“用当前对象作相机”,视口切换到该对象视角;可用 Numpad0/锁定持久化。", "image": "steps/M13-camera.jpg" }
|
||||
],
|
||||
"tips": ["自动关键帧可在 Preferences → 动画中开启。", "播放依赖原生 depsgraph,不是 JS 逐帧模拟。"],
|
||||
"warnings": ["Graph 是简化编辑器;复杂驱动/曲线以原生会话为准。"],
|
||||
"checks": ["关键帧出现在时间线", "播放推进帧", "NLA/驱动器提交", "对象相机生效"]
|
||||
},
|
||||
{
|
||||
"id": "M14",
|
||||
"title": "EEVEE/Cycles 后端渲染",
|
||||
"level": "核心",
|
||||
"minutes": 14,
|
||||
"summary": "通过 server/native 后端使用桌面 Blender 的 EEVEE/Cycles 渲染,并把产物取回 Web 工程。",
|
||||
"objectives": ["理解后端渲染", "提交渲染任务", "取回产物"],
|
||||
"steps": [
|
||||
{ "text": "确认后端已启动:部署服务器 + BLENDER_BIN 指向本机 Blender;打开渲染面板的桌面 EEVEE 区域。", "image": "steps/M14-backend.jpg" },
|
||||
{ "text": "选择引擎与帧范围,提交渲染;任务完成后产物出现在文件列表。", "image": "steps/M14-render.jpg" },
|
||||
{ "text": "下载或应用结果;后端结果 .blend 可按 revision 回写 Main。", "image": "steps/M14-result.jpg" }
|
||||
],
|
||||
"tips": ["后端并发上限 2,单任务 512 MiB;大场景请分批。", "后端渲染与本地 PBR 是两条不同路径。"],
|
||||
"warnings": ["后端需要 bwrap/prlimit/xvfb-run 与 Blender 二进制;缺失时返回 503,不是本地 bug。"],
|
||||
"checks": ["后端健康", "渲染任务完成", "产物可取回"]
|
||||
},
|
||||
{
|
||||
"id": "M15",
|
||||
"title": "Compositor 合成",
|
||||
"level": "核心",
|
||||
"minutes": 16,
|
||||
"summary": "在 Compositor 画布添加/连线/提交节点,使用 WASM 合成求值,并体验服务端合成渲染。",
|
||||
"objectives": ["节点图编辑", "WASM 求值", "服务端合成"],
|
||||
"steps": [
|
||||
{ "text": "切到 Compositing,画布已有输出节点;从“添加节点类型”选择 Constant Color/Exposure 等并添加。", "image": "steps/M15-nodes.jpg" },
|
||||
{ "text": "从节点右侧输出拖到下一个节点输入,再连到 Composite;点击“提交图”写入 Main。", "image": "steps/M15-links.jpg" },
|
||||
{ "text": "点击“WASM 合成求值”,在浏览器内用 Blender CPU 合成器求值并显示结果。", "image": "steps/M15-wasm-eval.jpg" },
|
||||
{ "text": "在 Render Pipeline 点击“服务端合成渲染”,由 server Blender 执行完整合成。", "image": "steps/M15-server.jpg" }
|
||||
],
|
||||
"tips": ["节点目录是 allowlist;未知节点会被拒绝。", "合成结果可保存重开,节点位置/连线保留。"],
|
||||
"warnings": ["服务端合成需要后端;失败时记录为后端 BLOCKED。"],
|
||||
"checks": ["节点/连线/提交", "WASM 求值出图", "服务端合成出图"]
|
||||
},
|
||||
{
|
||||
"id": "M16",
|
||||
"title": "Geometry Nodes",
|
||||
"level": "核心",
|
||||
"minutes": 16,
|
||||
"summary": "在 Geometry Nodes 工作区添加节点、连线并提交,生成程序化几何。",
|
||||
"objectives": ["理解 GN 图", "添加/连线/提交", "查看结果"],
|
||||
"steps": [
|
||||
{ "text": "切到 Geometry Nodes,画布已有 Group Input/Output;从节点目录选择 Transform/Set Position 等添加。", "image": "steps/M16-nodes.jpg" },
|
||||
{ "text": "连接 Geometry 线,修改节点参数,点击“提交图”;网格随图更新。", "image": "steps/M16-commit.jpg" },
|
||||
{ "text": "尝试 Mesh Cube/Instance on Points 等 40 类目录中的节点;Simulation Zone 仍为明确边界。", "image": "steps/M16-result.jpg" }
|
||||
],
|
||||
"tips": ["原生 writer 接受已注册节点;UI 只提供 allowlist。", "保存重开会保留节点、连线与位置。"],
|
||||
"warnings": ["Simulation Zone/Repeat/Foreach 未开放。"],
|
||||
"checks": ["节点/连线提交", "几何更新", "保存重开保留"]
|
||||
},
|
||||
{
|
||||
"id": "M17",
|
||||
"title": "Spreadsheet 求值属性",
|
||||
"level": "进阶",
|
||||
"minutes": 12,
|
||||
"summary": "在 Spreadsheet 查看对象/顶点/边/面/UV/属性,并读取 GN 修改器求值后的属性域。",
|
||||
"objectives": ["切换数据源", "过滤/分页/CSV", "读取求值属性"],
|
||||
"steps": [
|
||||
{ "text": "在 Geometry Nodes 工作区的 Spreadsheet 选择数据源 Objects/Vertices/Edges/Faces/UV/Attributes。", "image": "steps/M17-sources.jpg" },
|
||||
{ "text": "在 Attributes 点击“读取求值后属性”,查看名称/域/类型/数量与前 8 个值。", "image": "steps/M17-evaluated.jpg" },
|
||||
{ "text": "使用过滤行、分页与“导出 CSV”;CSV 通过手动下载保存。", "image": "steps/M17-csv.jpg" }
|
||||
],
|
||||
"tips": ["求值属性读取的是 GN 修改器求值后的网格,不是原始缓冲。", "大表用分页避免整表截断。"],
|
||||
"warnings": ["Spreadsheet 是只读检查器。"],
|
||||
"checks": ["数据源切换", "求值属性出现", "CSV 下载"]
|
||||
},
|
||||
{
|
||||
"id": "M18",
|
||||
"title": "Scripting 与 Python 控制台",
|
||||
"level": "进阶",
|
||||
"minutes": 12,
|
||||
"summary": "在 Scripting 工作区使用内嵌 CPython 控制台执行脚本、读取 Main、停止/重置会话并下载记录。",
|
||||
"objectives": ["执行 Python", "读取对象", "重置/下载记录"],
|
||||
"steps": [
|
||||
{ "text": "切到 Scripting,Python Console 使用浏览器内嵌 CPython,不依赖原生会话。", "image": "steps/M18-console.jpg" },
|
||||
{ "text": "输入 import bpy; print([o.name for o in bpy.data.objects]) 并点击“执行 Python”。", "image": "steps/M18-execute.jpg" },
|
||||
{ "text": "使用停止/重置会话处理长脚本;下载控制台记录以便排查。", "image": "steps/M18-reset.jpg" }
|
||||
],
|
||||
"tips": ["脚本可修改 Main;执行前保存并保留撤销点。", "Text Editor 也可运行文本数据块。"],
|
||||
"warnings": ["任意网络/插件安装 Python 不在能力范围。"],
|
||||
"checks": ["脚本输出", "对象读取", "会话重置"]
|
||||
},
|
||||
{
|
||||
"id": "M19",
|
||||
"title": "导入:GLB、glTF 文件夹、OBJ/STL/PLY、图像/VFont",
|
||||
"level": "核心",
|
||||
"minutes": 16,
|
||||
"summary": "导入猴头 GLB、带外部 .bin/贴图的 glTF 文件夹、OBJ/STL/PLY,以及图像与字体。",
|
||||
"objectives": ["GLB 导入", "glTF 文件夹", "其他格式"],
|
||||
"steps": [
|
||||
{ "text": "“文件 → 打开”选择 .glb 会追加导入;本课程的猴头就是这种方式。", "image": "steps/M19-glb.jpg" },
|
||||
{ "text": "F3 搜索“Import glTF 文件夹”,选择包含 .gltf/.bin/贴图的目录;相对路径会被保留。", "image": "steps/M19-gltf-folder.jpg" },
|
||||
{ "text": "OBJ 使用“导入 OBJ”面板,可同时选择 .mtl 与贴图;STL/PLY 通过同一文件输入。", "image": "steps/M19-obj.jpg" },
|
||||
{ "text": "图像和字体从材质/文本属性导入,资源进入 OPFS 工程。" , "image": "steps/M19-image-font.jpg" }
|
||||
],
|
||||
"tips": ["glTF 文件夹导入使用目录选择,不是单文件。", "导入是追加,不会替换当前场景。"],
|
||||
"warnings": ["外部资源缺失时,模型可能没有贴图。"],
|
||||
"checks": ["GLB 追加", "glTF 文件夹导入", "OBJ/STL/PLY 导入"]
|
||||
},
|
||||
{
|
||||
"id": "M20",
|
||||
"title": "导出:GLB/OBJ 与 USD/Alembic/FBX",
|
||||
"level": "核心",
|
||||
"minutes": 14,
|
||||
"summary": "浏览器内导出 GLB/OBJ,并通过 server/native 后端导出 USD/Alembic/FBX。",
|
||||
"objectives": ["本地导出", "后端导出", "校验产物"],
|
||||
"steps": [
|
||||
{ "text": "“文件 → 导出 → Web GLB”在浏览器内直接生成并手动下载;“glTF Binary (.glb)”条目会打开原生导出面板。", "image": "steps/M20-glb.jpg" },
|
||||
{ "text": "OBJ 导出可选本地或原生路径;本地导出会生成 .obj。", "image": "steps/M20-obj.jpg" },
|
||||
{ "text": "USD/Alembic/FBX 通过导出面板提交给 server Blender,完成后下载产物包。", "image": "steps/M20-native.jpg" }
|
||||
],
|
||||
"tips": ["本地导出不依赖后端,适合日常交换。", "USD/FBX 需要后端;失败时检查服务与 Blender 二进制。"],
|
||||
"warnings": ["导出不会自动覆盖本地文件,下载由浏览器决定位置。"],
|
||||
"checks": ["GLB/OBJ 产物", "USD/FBX 产物", "文件可被重新导入"]
|
||||
},
|
||||
{
|
||||
"id": "M21",
|
||||
"title": "物理与模拟",
|
||||
"level": "进阶",
|
||||
"minutes": 14,
|
||||
"summary": "编辑刚体/布料/流体/粒子参数,播放模拟并执行 Simulate Range 推进 depsgraph。",
|
||||
"objectives": ["物理参数", "播放", "Simulate Range"],
|
||||
"steps": [
|
||||
{ "text": "在 Properties → Physics 选择 Rigid Body/Cloth/Fluid/Particle,编辑质量、摩擦、碰撞、缓存。", "image": "steps/M21-settings.jpg" },
|
||||
{ "text": "点击播放,Blender 持久 depsgraph 逐帧推进求解与缓存。", "image": "steps/M21-playback.jpg" },
|
||||
{ "text": "在 Simulate Range 输入起止帧并点击 Simulate,完成后检查对象位置/缓存状态。", "image": "steps/M21-range.jpg" }
|
||||
],
|
||||
"tips": ["重负载求解建议使用 server/native bake。", "缓存写入 OPFS/原生缓存,保存 .blend 不一定包含外部缓存文件。"],
|
||||
"warnings": ["流体/粒子在单线程 WASM 下可能很慢。"],
|
||||
"checks": ["参数写入 Main", "播放推进", "Simulate Range 完成"]
|
||||
},
|
||||
{
|
||||
"id": "M22",
|
||||
"title": "Sequencer 与本地媒体",
|
||||
"level": "进阶",
|
||||
"minutes": 14,
|
||||
"summary": "导入本地媒体到 OPFS/VFS,添加 Strip,编辑时间/通道/转场,并恢复媒体或提交服务端导出。",
|
||||
"objectives": ["媒体选择", "Strip 编辑", "恢复/导出"],
|
||||
"steps": [
|
||||
{ "text": "在 Properties 的 Sequencer 区域选择 Strip 类型(Movie/Sound/Image),用“媒体文件”选择本地文件。", "image": "steps/M22-media.jpg" },
|
||||
{ "text": "点击 Add Strip;媒体写入 OPFS 并暂存到当前会话 VFS。", "image": "steps/M22-strip.jpg" },
|
||||
{ "text": "编辑起止帧、通道、静音,使用 Move/Trim/Split 与转场/调色。", "image": "steps/M22-edit.jpg" },
|
||||
{ "text": "重开工程后点击“恢复媒体”从 OPFS 重新暂存;最终导出走 server Blender。", "image": "steps/M22-export.jpg" }
|
||||
],
|
||||
"tips": ["媒体不会自动下载;需要本地文件时手动导出。", "恢复媒体只重挂当前工程的所有媒体资产。"],
|
||||
"warnings": ["浏览器不提供本地媒体选择器之外的路径访问。"],
|
||||
"checks": ["媒体导入", "Strip 编辑", "恢复媒体", "服务端导出"]
|
||||
},
|
||||
{
|
||||
"id": "M23",
|
||||
"title": "相机锁定、追踪与遮罩",
|
||||
"level": "进阶",
|
||||
"minutes": 12,
|
||||
"summary": "使用对象作相机、相机视图与锁定持久化,并在 Tracking/Mask 面板编辑 Marker 与遮罩点。",
|
||||
"objectives": ["相机视图/锁定", "对象作相机", "追踪/遮罩"],
|
||||
"steps": [
|
||||
{ "text": "数字小键盘 0 进入/退出相机视图;在相机视图导航会移动相机并可撤销。", "image": "steps/M23-camera.jpg" },
|
||||
{ "text": "在 Scene Bindings 点击“用当前对象作相机”,再点“恢复场景相机”切回。", "image": "steps/M23-object-camera.jpg" },
|
||||
{ "text": "在 Tracking/Mask 面板选择 clip/track 或 mask/layer/spline,编辑 Marker 位置或遮罩点的坐标/羽化。", "image": "steps/M23-tracking.jpg" }
|
||||
],
|
||||
"tips": ["相机锁按视口保存,刷新后保留。", "追踪/遮罩编辑通过内嵌 bpy 写入 Main。"],
|
||||
"warnings": ["Camera solve 需要已验证的求解实现;面板只显示已有状态。"],
|
||||
"checks": ["相机视图/锁定", "对象作相机", "Marker/遮罩点更新"]
|
||||
},
|
||||
{
|
||||
"id": "M24",
|
||||
"title": "偏好设置、键位、主题与 Add-ons",
|
||||
"level": "入门",
|
||||
"minutes": 12,
|
||||
"summary": "在 Preferences 调整界面/视口/动画/导航,录制键位,切换主题预设,并启停内嵌 Add-ons。",
|
||||
"objectives": ["打开偏好设置", "编辑键位/主题", "Add-ons"],
|
||||
"steps": [
|
||||
{ "text": "“编辑 → 偏好设置”打开窗口;左侧有界面、视口、动画、输入与导航、键位、保存与加载、文件、主题、系统。", "image": "steps/M24-preferences.jpg" },
|
||||
{ "text": "在键位页点击“录制”后按下组合键;冲突会提示。保存偏好写入 OPFS。", "image": "steps/M24-keymap.jpg" },
|
||||
{ "text": "主题页选择 DARK/LIGHT/HIGH_CONTRAST,界面立即应用。", "image": "steps/M24-theme.jpg" },
|
||||
{ "text": "系统页可查看 Blender 版本并启停内嵌 Add-ons;外部扩展安装不支持。", "image": "steps/M24-addons.jpg" }
|
||||
],
|
||||
"tips": ["偏好保存到 OPFS,刷新后保留。", "浏览器保留的快捷键可能与桌面键位冲突。"],
|
||||
"warnings": ["完整桌面主题颜色表与全部键位仍以原生会话为准。"],
|
||||
"checks": ["偏好保存", "键位录制", "主题切换", "Add-on 启停"]
|
||||
}
|
||||
]
|
||||
}
|
||||
136
tools/web/course/complete-video-chapters.json
Normal file
136
tools/web/course/complete-video-chapters.json
Normal file
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"voice": "zh-CN-XiaoxiaoNeural",
|
||||
"chapters": [
|
||||
{
|
||||
"id": "intro",
|
||||
"title": "开场:这套课程会带你做什么",
|
||||
"narration": "这一套课程面向第一次使用 Web Blender 的同学,目标是让你在浏览器里独立完成一次真实的小项目。我们使用的素材不是示范用的替代品,而是本机的两个真实文件:一个只有网格、没有材质的猴头 GLB,以及从 RE 五千 PBR 精简版资产目录派生出来的六种材质。课程会从新建工程开始,先导入猴头,再从资产库分配材质,然后依次走完建模、修改器、雕刻、UV、纹理绘制、曲线与文字、材质节点、PBR 渲染、原生后端渲染、合成、几何节点、数据表、Python 脚本、导入导出、物理模拟、序列编辑器、相机与追踪、偏好设置。每个模块都会告诉你点哪里、应该看到什么、以及为什么这样做。所有保存、重开和恢复都使用浏览器 OPFS,只有你主动点击下载时才会生成本地文件。建议第一遍连续观看,第二遍打开产品按模块跟做,遇到不一致时先看底栏状态和对象数。"
|
||||
},
|
||||
{
|
||||
"id": "M01",
|
||||
"title": "工程、导入猴头与 OPFS 保存",
|
||||
"narration": "先打开产品入口,地址里的 ui 等于 web。第一次加载需要把较大的 WebAssembly 引擎下载到浏览器,可能需要几十秒到几分钟,耐心等待底栏出现 Engine 和场景状态。新建常规工程后,场景里有立方体、相机和灯光三个对象。点击文件菜单里的打开,选择 re 目录里的猴头点 GLB。注意导入是追加,不会替换当前场景;导入完成后对象数增加一,活动对象变成 Suzanne。此时猴头没有材质,所以是灰色的,这是正常的基线。接下来点击顶栏的保存项目。这个动作只写入浏览器 OPFS,不会弹出下载框。底栏的保存状态变成 SUCCEEDED,表示工程已经落盘。为了验证保存,关闭项目,再从最近的工程里选择刚保存的 studio 点 blend,等待场景恢复;对象数应该和保存前一致,活动对象仍然是 Suzanne。如果你需要一份本地备份,最后再点击下载点 blend,这是唯一会生成本地文件的动作。记住区分保存和下载:保存用于继续工作,下载用于备份或交付。"
|
||||
},
|
||||
{
|
||||
"id": "M02",
|
||||
"title": "界面、工作区与视口",
|
||||
"narration": "顶部一排是工作区标签,依次是 Layout、Modeling、Sculpting、UV Editing、Texture Paint、Shading、Animation、Rendering、Compositing、Geometry Nodes 和 Scripting。工作区只是布局,不会改变工程数据。点击标签即可切换,右侧的工作区列表菜单也提供同样的入口。区域右上角和头部有三点菜单,可以把当前区域垂直或水平分割、合并、交换,也可以复制、最大化或关闭。分割后每个区域都有独立的编辑器类型下拉框,例如把 Outliner 切换成 Spreadsheet 或 Python Console。三维视口的导航要熟练:按住鼠标中键拖动旋转,滚轮缩放,Shift 加中键平移;数字小键盘零进入相机视图,再按一次退出;Home 框显全部对象。找不到按钮时按 F3 打开操作搜索,输入移动、保存或某个算子名,结果会标注执行位置。灰色的命令表示当前上下文不可用,不是程序坏了。"
|
||||
},
|
||||
{
|
||||
"id": "M03",
|
||||
"title": "Outliner、对象与层级",
|
||||
"narration": "Outliner 是场景的层级表。单击对象名选择,按住 Shift 再单击可以多选;选中的对象在三维视口里会出现橙色轮廓。按 F2 或者双击名称进入重命名,输入后按 Enter 确认。改名会写入 Main 数据,保存 OPFS 后重新打开仍然保留。对象右侧的眼睛图标控制可见性,隐藏只影响显示,不会删除数据,再次点击就恢复。把对象拖到另一个对象上会建立父子关系,拖到集合上则改变集合链接。物体菜单里的 Parent 和 Join 要区分:Parent 只改变层级,子对象仍保留自己的网格;Join 会把多个网格合并成一个数据块,活动对象决定合并后的名称和数据。集合用于组织场景,新建集合后可以把对象拖进去。所有层级和集合变化都会进入撤销历史,操作错了先撤销再继续。"
|
||||
},
|
||||
{
|
||||
"id": "M04",
|
||||
"title": "Properties、变换、相机与灯光",
|
||||
"narration": "Properties 是右侧的属性面板,顶部有对象、修改器、材质三个标签。对象标签里可以看到并直接输入位置、旋转和缩放,输入后立即提交并进入撤销历史。物体菜单的应用子菜单可以把位置、旋转、缩放烘焙进网格;应用后数值归零,但网格形状不变。设置原点可以把轴心移到几何体中心、游标或世界原点,后续旋转和缩放会围绕新轴心进行。选择相机后,相机属性可以调整焦距、裁剪起点和终点;数字小键盘零进入相机视图,在相机视图里导航会移动相机本身。选择灯光后,可以调整类型、能量、阴影和衰减;World 区域调整环境光和背景。链接对象或链接材质的属性是只读的,需要先设为本地才能编辑。场景和渲染属性在下方,包含分辨率、帧范围、色彩管理和输出格式。"
|
||||
},
|
||||
{
|
||||
"id": "M05",
|
||||
"title": "建模与网格编辑",
|
||||
"narration": "在 Modeling 工作区或添加菜单里创建立方体、平面、UV 球、圆柱、圆锥和圆环,也可以按 F3 搜索基础体命令。选中网格后点击模式按钮切到编辑模式,再选择顶点、边或面选择域。视口工具里的框选按钮可以拖出一个矩形选择元素;B 键是桌面版的框选,也可以沿循环边、边环或相似元素扩展选择。常用操作要形成手感:E 挤出,Ctrl B 倒角,Ctrl R 环切,I 内插,G 移动,S 缩放,R 旋转。这些操作在 Web 版里通过真实 Blender 原生算子执行,不是前端模拟。拓扑有问题时,用重新计算法线、按距离合并、删除松散元素和溶解来修正。每一步都可以撤销,破坏性操作前先保存或确认撤销可用。菜单和 F3 调用的是同一批算子,找不到按钮时优先用 F3。"
|
||||
},
|
||||
{
|
||||
"id": "M06",
|
||||
"title": "修改器栈",
|
||||
"narration": "修改器是不破坏原始网格的编辑方式。在 Properties 的修改器标签点击添加,先加细分曲面,把视口级别从一调到二,紫色线框会显示细分后的形状。再加镜像,选择轴并打开裁切,让对象关于原点对称。布尔修改器需要选择另一个对象作为操作数,并选择并集、差集或交集;布尔要求网格尽量封闭,否则结果会破面。阵列修改器通过数量和偏移复制对象。修改器从上到下求值,拖动顺序会改变结果。每个修改器右侧的眼睛控制视口显示,相机图标控制渲染显示。确认效果后点击应用,把修改器烘焙进网格;应用后不能再靠参数回退,只能撤销或重做。修改器栈会随工程保存到 OPFS。"
|
||||
},
|
||||
{
|
||||
"id": "M07",
|
||||
"title": "雕刻",
|
||||
"narration": "选中猴头,切到 Sculpting 工作区。属性面板里有笔刷、半径、强度、压力、对称和镜像设置。先选择 Draw 笔刷,把半径调到适合头部的尺寸,强度不要一开始就拉满。在视口按住左键拖拽,指针移动会被采样成一条笔触,松开后提交为一次原生 sculptStroke。画错了直接撤销。Inflate 让表面鼓起,Grab 抓住一片区域移动,Smooth 平滑过渡。遮罩可以保护已有形状,活动面组用于局部操作。需要重新拓扑时设置 Remesh 的体素大小,再点击 Voxel Remesh;体素越小细节越多,但内存和计算也越高。复杂形状分多次画,每次画完检查视口和撤销,避免一次改太多。"
|
||||
},
|
||||
{
|
||||
"id": "M08",
|
||||
"title": "UV 编辑",
|
||||
"narration": "选中猴头,切到 UV Editing。桌面 Blender 的 UV 编辑器要求网格处于编辑模式,所以先点击模式按钮进入 Edit Mode。左侧是三维视口,右侧是 UV 画布。在 UV 画布点击全选 UV,等待状态提示选择已提交;再点击展开所选 UV,橙色点会变成展开后的 UV 岛。展开前标记缝合线通常能得到更整齐的结果,可以用边菜单或 F3 标记缝合线。展开后使用打包 UV 岛整理布局,平均岛缩放让各个面的纹理密度接近。UV 选择与三维视口选择是两套状态,切换时注意当前焦点。完成后回到 Layout 保存 OPFS,重新打开工程,UV 数据和贴图坐标应保持一致。链接网格数据需要先设为本地才能写入。"
|
||||
},
|
||||
{
|
||||
"id": "M09",
|
||||
"title": "纹理绘制",
|
||||
"narration": "切到 Texture Paint 工作区。先选择要绘制的 packed 图像;如果没有图像,可以从材质的外部贴图入口导入,资源会进入 OPFS 工程。设置画笔颜色、半径和强度,在二维画布上拖拽绘制。松开后一次绘制提交为一个事务,可以用撤销和重做对比结果。保存 OPFS 后重新打开,笔画仍然存在。库链接的图像要先点击设为本地,这一步调用原生的 Make Local,之后再绘制才能写入。课程使用一千零二十四分辨率的图像,图像越大,PNG 编码和加载越慢。需要 UDIM 多块贴图或三维投影绘制时,通过原生会话完成;二维 packed 绘制是浏览器内的本地能力。"
|
||||
},
|
||||
{
|
||||
"id": "M10",
|
||||
"title": "曲线、文本、字体与 Grease Pencil",
|
||||
"narration": "添加菜单里有 Bezier 和 NURBS 曲线、曲面、文本、骨架、融球、体积、晶格、点云、毛发、Grease Pencil 和力场。创建曲线或文本后进入编辑模式,可以编辑控制点、手柄和样条类型;曲线属性里可以设置挤出、倒角、锥化和分辨率。文本属性可以编辑正文、对齐、行距和字体链接。导入本地 TTF、OTF 或 PFB 字体会把文件打包进 Main,保存 OPFS 后重新打开仍然可用,字体文件也会计入工程资源体积。Grease Pencil 在属性面板里管理图层、帧和笔画,可以绘制、选择、移动和插值;材质和插值属于进阶操作。非网格数据的高级编辑受能力矩阵限制,部分操作需要原生会话或 F3。"
|
||||
},
|
||||
{
|
||||
"id": "M11",
|
||||
"title": "Shading 与 RE 5000PBR 资产库",
|
||||
"narration": "切到 Shading 工作区。左下角是 PBR 资产库,默认有基础资产和 RE 两个来源;用资产来源下拉框选择 RE 五千 PBR,列表只保留六张材质卡片。卡片显示缩略图和材质名。单击卡片只会选中,不会分配;双击才会把材质分配给当前对象。依次双击防滑颗粒、砖墙、随机瓷砖、光亮瓷砖、规则砖墙和做旧砖墙,每次等待材质槽更新,并确认材质球显示 COMPILED、贴图状态为 ready。如果缩略图还没加载完,稍等或点击刷新。需要更高清时可以点击加载高清贴图,启用两千零四十八的 HQ 库;HQ 是按需加载的,首次启用会明显变慢,也会占用更多显存。RE 资产来自本机的五千 PBR 精简版目录,贴图已经打包,不依赖网络。"
|
||||
},
|
||||
{
|
||||
"id": "M12",
|
||||
"title": "PBR 渲染与诊断",
|
||||
"narration": "切到 Rendering 工作区,右侧是 PBR 渲染面板。先选择分辨率,课程用一千零二十四或两千零四十八;再选择相机和视角预设,SCENE_CAMERA 使用场景相机,COMPARISON 提供对比视角。点击渲染 PBR,等待结果图出现,状态会显示纹理准备情况和渲染进度。如果画面偏暗,可以用教学曝光加一或加二 EV。诊断视图可以切换基础色、法线和粗糙度,用来检查贴图是否正确绑定、法线方向是否合理。位移强度控制几何细节的夸张程度,交互视口不会细分,位移主要在静态渲染里体现。满意后点击下载 PNG,这是手动触发的本地保存。需要记住,这条路径是浏览器内的 WebGL2 PBR 渲染,不是桌面 EEVEE 或 Cycles。"
|
||||
},
|
||||
{
|
||||
"id": "M13",
|
||||
"title": "动画、Graph、NLA 与播放",
|
||||
"narration": "在 Animation 工作区选中猴头。时间线可以跳到首帧、末帧、上一帧或下一帧,也可以直接输入帧号。移动到目标帧后,点击位置、旋转、缩放按钮插入关键帧;Dope Sheet 会显示关键点。点击播放,时间线由 Blender 持久依赖图逐帧求值,状态栏会显示原生播放状态;再次点击暂停,然后拖到中间帧检查插值。Graph 编辑器可以调整关键帧、手柄和插值方式;NLA 表单可以添加轨道和 Strip,并提交到 Main;驱动器可以写入表达式,变量和目标在下方只读展示。自动关键帧可以在偏好设置里开启,开启后移动对象会自动插入关键帧。场景绑定里点击用当前对象作相机,可以把视口切换到对象视角;数字小键盘零和相机锁定用于持久化。"
|
||||
},
|
||||
{
|
||||
"id": "M14",
|
||||
"title": "EEVEE 与 Cycles 后端渲染",
|
||||
"narration": "浏览器内的 PBR 渲染和桌面的 EEVEE、Cycles 是两条不同路径。需要原生引擎时,使用部署服务器提供的原生工作流。先确认服务已启动,Blender 二进制路径指向本机编译好的版本;服务器会通过 bwrap、prlimit 和 xvfb 运行有界任务。在 Rendering 工作区展开桌面 EEVEE 渲染区域,选择引擎和帧范围,提交任务。任务完成后产物会出现在文件列表,可以下载或把结果工程回写 Main。后端并发上限是两个任务,单任务源码上限五百一十二兆,渲染帧数也有上限;大场景请分批。后端缺失工具时会返回五百零三,这不是前端缺陷,先检查部署环境。"
|
||||
},
|
||||
{
|
||||
"id": "M15",
|
||||
"title": "Compositor 合成",
|
||||
"narration": "切到 Compositing 工作区。画布上已经有合成输出节点,可以从添加节点类型里选择常量颜色、曝光、模糊、混合、变换、图像和渲染层等节点,点击添加。节点添加后,从右侧输出圆点拖到下一个节点的输入圆点,再连到合成输出;连线会写入节点图。修改节点参数后点击提交图,整个图会写入 Main 并保存到 OPFS。点击 WASM 合成求值,浏览器会调用 Blender 的 CPU 合成器执行当前节点树,并把结果画在画布上;这是真实原生求值,不是前端滤镜。需要完整渲染管线时,在 Render Pipeline 区域点击服务端合成渲染,由服务器 Blender 执行。合成节点目录是受控 allowlist,未知节点会被拒绝。"
|
||||
},
|
||||
{
|
||||
"id": "M16",
|
||||
"title": "Geometry Nodes",
|
||||
"narration": "切到 Geometry Nodes 工作区。画布上已有组输入和组输出节点。从添加节点类型下拉框选择变换、设置位置、连接几何、实例化或基础网格等节点,点击添加;节点会出现在画布上。把几何输出连到下一个节点的几何输入,修改参数,再点击提交图。提交后原生几何节点修改器会重建网格,视口随图更新。当前目录提供四十类节点,覆盖基础网格、实例化、分布、实例变换、曲线和挤出等常用能力;仿真区域、重复和遍历仍是明确边界。保存 OPFS 后重新打开,节点、连线、位置和参数都会保留。复杂节点图先在副本上试验,避免破坏主对象。"
|
||||
},
|
||||
{
|
||||
"id": "M17",
|
||||
"title": "Spreadsheet 求值属性",
|
||||
"narration": "在 Geometry Nodes 工作区的右下角是 Spreadsheet。顶部数据源可以选择对象、顶点、边、面、UV 或属性。对象表显示名称、类型、可见性和变换;顶点、边、面表显示索引和坐标;属性页最关键。点击读取求值后属性,Spreadsheet 会通过 Blender 求值依赖图读取几何节点修改器作用后的网格属性,显示名称、域、数据类型、数量和前八个值。这样你能看到最终几何上的属性,而不是原始缓冲。使用过滤行搜索,使用分页和每页行数查看大表,避免一次渲染几十万行。需要离线分析时点击导出 CSV,由浏览器手动下载。Spreadsheet 是只读检查器,不会修改工程。"
|
||||
},
|
||||
{
|
||||
"id": "M18",
|
||||
"title": "Scripting 与 Python 控制台",
|
||||
"narration": "切到 Scripting 工作区。Python 控制台使用浏览器内嵌的 CPython,不依赖原生会话。在输入框里写 import bpy,然后打印所有对象名,点击执行 Python。输出会显示在控制台,命令也会记录到 Info 区域。脚本可以读取和修改 Main,因此执行前先保存 OPFS,并确认撤销历史可用。长脚本运行时可以点击停止;会话异常时可以重置 Python 会话;控制台记录可以下载,便于排查错误。Text Editor 可以保存和运行文本数据块,适合反复执行的脚本。任意网络访问、安装第三方包和加载外部插件不在能力范围;需要完整 Python 环境时使用原生会话。"
|
||||
},
|
||||
{
|
||||
"id": "M19",
|
||||
"title": "导入:GLB、glTF 文件夹与其他格式",
|
||||
"narration": "文件菜单的打开可以导入 blend 和多种模型格式。导入 GLB 会追加到当前场景,本课程的猴头就是这样进入工程的;导入后检查对象数和活动对象。带外部资源的 glTF 需要按 F3 搜索导入 glTF 文件夹,然后选择包含 gltf、bin 和贴图的整个目录;相对路径会被保留,贴图才能正确找到。OBJ 使用导入 OBJ 面板,可以同时选择 obj、mtl 和贴图文件;STL 和 PLY 通过同一个文件输入导入。图像和字体从材质或文本属性导入,资源会进入 OPFS 工程,保存后重新打开仍然可用。导入失败时先看状态栏的错误码,常见原因是文件不完整或格式不受支持。"
|
||||
},
|
||||
{
|
||||
"id": "M20",
|
||||
"title": "导出:GLB、OBJ 与 USD、Alembic、FBX",
|
||||
"narration": "文件菜单的导出子菜单提供多种格式。需要浏览器本地导出时选择 Web GLB,完成后由浏览器下载;这是最常用的交换格式。glTF Binary 条目会打开原生导出面板。OBJ 可以选择本地导出或原生导出;本地导出不依赖后端,适合快速交换。USD、Alembic 和 FBX 需要完整的 Blender IO 模块,因此通过导出面板提交给服务器 Blender,任务完成后下载产物包。导出前确认活动对象和选择范围,避免把不需要的对象一起导出。导出不会自动覆盖本地文件,下载位置由浏览器决定。需要验证时,把导出的文件重新导入一个新工程,检查对象数、材质和贴图是否保留。"
|
||||
},
|
||||
{
|
||||
"id": "M21",
|
||||
"title": "物理与模拟",
|
||||
"narration": "在 Properties 的物理区域选择刚体、布料、流体、软体或粒子系统。刚体可以设置质量、摩擦、弹性、碰撞形状和运动学;布料可以设置质量、空气阻尼、各种刚度和压力;流体可以设置域类型、分辨率、粘度和缓存范围;粒子可以设置数量和缓存。参数写入 Main 后,点击播放,Blender 持久依赖图会逐帧推进求解和缓存。也可以在 Simulate Range 输入起止帧,点击 Simulate,让模拟一次推进到目标帧,完成后检查对象位置和缓存状态。重负载求解建议使用服务器或原生烘焙,浏览器内单线程 WASM 对流体和大量粒子会比较慢。缓存文件可能不在 blend 内,保存前确认缓存策略。"
|
||||
},
|
||||
{
|
||||
"id": "M22",
|
||||
"title": "Sequencer 与本地媒体",
|
||||
"narration": "序列编辑器在 Properties 的时间线区域。先选择 Strip 类型,Movie 用于视频,Sound 用于音频,Image 用于图片;用媒体文件按钮选择本地文件。点击 Add Strip 后,媒体会写入 OPFS,并暂存到当前会话的虚拟文件系统,Strip 出现在时间线上。可以编辑起止帧、通道、静音和锁定,使用移动、裁剪、分割调整时间,使用转场和调色设置效果。重开工程后,媒体文件仍保存在 OPFS,但当前会话的虚拟文件系统是空的,需要点击恢复媒体,把所有媒体资产重新暂存。最终视频导出通过服务器 Blender 完成,因为浏览器内不编译原生 FFmpeg 编码器。媒体不会自动下载,需要本地文件时手动导出。"
|
||||
},
|
||||
{
|
||||
"id": "M23",
|
||||
"title": "相机锁定、追踪与遮罩",
|
||||
"narration": "数字小键盘零进入或退出相机视图;在相机视图里导航会移动相机,并可以用撤销恢复。相机锁定按视口保存,刷新后仍然保留。场景绑定区域可以把当前对象设为相机,这对用网格或空物体做镜头运动很有用;点击恢复场景相机可以切回。追踪和遮罩面板位于 Properties:选择片段和轨道后,可以添加、更新或删除标记点,设置帧和位置;选择遮罩、图层和样条后,可以编辑遮罩点的坐标、手柄类型和羽化,或者切换样条是否闭合。这些编辑通过内嵌 bpy 写入真实的 MovieClip 和 Mask 数据。相机求解需要已验证的求解实现,面板只显示已有的求解状态。"
|
||||
},
|
||||
{
|
||||
"id": "M24",
|
||||
"title": "偏好设置、键位、主题与 Add-ons",
|
||||
"narration": "点击编辑菜单里的偏好设置打开设置窗口。左侧分类有界面、视口、动画、输入与导航、键位、保存与加载、文件、主题和系统。界面页控制状态栏、快捷工具栏、区域切换器和启动工作区;视口页控制 gizmo 大小和默认着色;动画页控制自动关键帧、插值方式和手柄类型。键位页点击录制后按下组合键,冲突会给出提示;恢复默认可以回到 Blender 预设。主题页可以切换深色、浅色和高对比度,界面立即应用。系统页显示内嵌 Blender 版本,并可以启停内嵌 Add-ons;外部扩展安装和网络 Python 不在能力范围。点击保存偏好写入 OPFS,刷新后仍然生效。"
|
||||
},
|
||||
{
|
||||
"id": "outro",
|
||||
"title": "收尾:把完整流程连起来",
|
||||
"narration": "到这里,你已经用同一套猴头 GLB 和 RE 五千 PBR 资产走完了三十一项能力:从工程与 OPFS,到界面布局、对象层级、属性与变换、建模、修改器、雕刻、UV、纹理绘制、曲线文字、材质与资产库、PBR 渲染、原生后端渲染、合成、几何节点、数据表、Python 脚本、导入导出、物理、序列、相机、追踪和设置。建议回到课程页,按模块跟做;每一步都检查底栏 Engine 状态、对象数、保存状态和材质编译状态。遇到与课程不一致的地方,记录操作路径、截图和错误码,再回到对应章节定位。需要本地备份时手动下载 blend;需要原生引擎或插件能力时使用服务器或原生会话。完成整套练习后,你已经可以在浏览器里独立完成一个带材质、动画和渲染的真实小项目。"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -731,13 +731,13 @@
|
||||
"image": "steps/M15-console.jpg"
|
||||
},
|
||||
{
|
||||
"text": "已知限制:多区域 split/join、完整 Driver 编辑器、完整节点/画笔目录、生产级 UDIM/4K 纹理绘制尚未完成。",
|
||||
"text": "能力边界:完整桌面主题颜色表、全部键位、完整 Driver 变量编辑器与任意节点目录以原生会话为准;2D packed 纹理绘制与 UDIM/投影路径见支持矩阵。",
|
||||
"image": "steps/M15-scripting.jpg"
|
||||
}
|
||||
],
|
||||
"tips": [
|
||||
"支持矩阵与最新进度见 docs/status/WEB_BLENDER_FULL_COURSE_20261113.md。",
|
||||
"课程不宣称完整 Blender parity。"
|
||||
"课程按能力矩阵标注本地/后端执行位置。"
|
||||
],
|
||||
"warnings": [
|
||||
"脚本可修改 Main;执行前先保存到 OPFS 并保留撤销点。"
|
||||
|
||||
171
tools/web/course/generate-complete-course.mjs
Normal file
171
tools/web/course/generate-complete-course.mjs
Normal file
@@ -0,0 +1,171 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Generate the static 15-module Web Blender course from complete-course.json.
|
||||
*
|
||||
* Usage:
|
||||
* node tools/web/course/generate-full-course.mjs
|
||||
*
|
||||
* Outputs:
|
||||
* web/app/public/tutorial/complete/index.html
|
||||
* web/app/public/tutorial/complete/course.css
|
||||
* web/app/public/tutorial/complete/course.json
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const REPO = path.resolve(HERE, "../../..");
|
||||
const DATA = path.join(HERE, "complete-course.json");
|
||||
const PUBLIC = path.join(REPO, "web/app/public");
|
||||
const OUT = path.join(PUBLIC, "tutorial/complete");
|
||||
fs.mkdirSync(OUT, { recursive: true });
|
||||
|
||||
const escapeHtml = (value) => String(value)
|
||||
.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">")
|
||||
.replaceAll('"', """).replaceAll("'", "'");
|
||||
|
||||
const course = JSON.parse(fs.readFileSync(DATA, "utf8"));
|
||||
const missing = [];
|
||||
const exists = (relative) => {
|
||||
const file = relative.startsWith("/")
|
||||
? path.join(PUBLIC, relative.slice(1))
|
||||
: path.join(OUT, relative);
|
||||
if (!fs.existsSync(file)) missing.push(relative);
|
||||
return fs.existsSync(file);
|
||||
};
|
||||
|
||||
const nav = course.modules.map((module) => `<a href="#${escapeHtml(module.id)}"><span>${escapeHtml(module.id)}</span>${escapeHtml(module.title)}</a>`).join("\n ");
|
||||
|
||||
const videos = (course.videos ?? []).map((video) => {
|
||||
exists(video.src);
|
||||
const poster = video.poster && exists(video.poster) ? ` poster="${escapeHtml(video.poster)}"` : "";
|
||||
const track = video.vtt && exists(video.vtt) ? `<track kind="subtitles" srclang="zh-Hans" label="中文" src="${escapeHtml(video.vtt)}" default />` : "";
|
||||
return `<section class="course-video" id="video-${escapeHtml(video.id)}">
|
||||
<h2>${escapeHtml(video.title)}</h2>
|
||||
<video controls preload="metadata" src="${escapeHtml(video.src)}"${poster} width="1280" height="720">${track}</video>
|
||||
<p>${escapeHtml(video.note)}</p>
|
||||
</section>`;
|
||||
}).join("\n ");
|
||||
|
||||
const modules = course.modules.map((module) => {
|
||||
const steps = module.steps.map((step, index) => {
|
||||
const image = step.image && exists(step.image) ? `<figure><img src="${escapeHtml(step.image)}" alt="${escapeHtml(module.title)} 第 ${index + 1} 步截图" loading="lazy" width="1600" height="900" /><figcaption>${escapeHtml(module.id)} · 步骤 ${index + 1}</figcaption></figure>` : "";
|
||||
return `<li><p>${escapeHtml(step.text)}</p>${image}</li>`;
|
||||
}).join("\n ");
|
||||
const objectives = module.objectives.map((item) => `<li>${escapeHtml(item)}</li>`).join("");
|
||||
const moduleVideo = module.video ? (() => {
|
||||
const src = module.video.src; const poster = module.video.poster; const vtt = module.video.vtt;
|
||||
exists(src);
|
||||
const posterAttr = poster && exists(poster) ? ` poster="${escapeHtml(poster)}"` : "";
|
||||
const track = vtt && exists(vtt) ? `<track kind="subtitles" srclang="zh-Hans" label="中文" src="${escapeHtml(vtt)}" default />` : "";
|
||||
return `<section class="course-module-video" data-module-video="${escapeHtml(module.id)}"><h3>本模块操作录像</h3><video controls preload="metadata" src="${escapeHtml(src)}"${posterAttr} width="1280" height="720">${track}</video><p>${escapeHtml(module.video.note ?? "")}</p></section>`;
|
||||
})() : "";
|
||||
const tips = (module.tips ?? []).map((item) => `<li>${escapeHtml(item)}</li>`).join("");
|
||||
const warnings = (module.warnings ?? []).map((item) => `<li>${escapeHtml(item)}</li>`).join("");
|
||||
return `<article class="course-module" id="${escapeHtml(module.id)}">
|
||||
<header>
|
||||
<p class="course-module-id">${escapeHtml(module.id)} · ${escapeHtml(module.level)} · 约 ${module.minutes} 分钟</p>
|
||||
<h2>${escapeHtml(module.title)}</h2>
|
||||
<p class="course-summary">${escapeHtml(module.summary)}</p>
|
||||
</header>
|
||||
<div class="course-objectives"><h3>本模块目标</h3><ul>${objectives}</ul></div>
|
||||
${moduleVideo}
|
||||
<ol class="course-steps">
|
||||
${steps}
|
||||
</ol>
|
||||
${tips ? `<div class="course-callout course-tips"><h3>提示</h3><ul>${tips}</ul></div>` : ""}
|
||||
${warnings ? `<div class="course-callout course-warnings"><h3>注意</h3><ul>${warnings}</ul></div>` : ""}
|
||||
</article>`;
|
||||
}).join("\n ");
|
||||
|
||||
const rules = course.rules.map((rule) => `<li>${escapeHtml(rule)}</li>`).join("");
|
||||
|
||||
const html = `<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>${escapeHtml(course.title)}</title>
|
||||
<link rel="stylesheet" href="./course.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header class="course-hero">
|
||||
<p class="course-kicker">Web Blender · ${escapeHtml(course.version)}</p>
|
||||
<h1>${escapeHtml(course.title)}</h1>
|
||||
<p class="course-subtitle">${escapeHtml(course.subtitle)}</p>
|
||||
<p class="course-audience">${escapeHtml(course.audience)}</p>
|
||||
<p class="course-first-load">${escapeHtml(course.firstLoadNote)}</p>
|
||||
</header>
|
||||
<div class="course-layout">
|
||||
<nav class="course-nav" aria-label="课程目录">
|
||||
<strong>24 个模块</strong>
|
||||
${nav}
|
||||
</nav>
|
||||
<main class="course-main">
|
||||
<section class="course-rules">
|
||||
<h2>开始之前</h2>
|
||||
<ul>${rules}</ul>
|
||||
</section>
|
||||
${videos}
|
||||
${modules}
|
||||
<footer class="course-footer">
|
||||
<p>课程截图来自本机有头 Chromium + RTX 4060 的实际操作。功能边界与最新进度见 docs/status/COMPLETE_TUTORIAL_20261113.md。</p>
|
||||
<p><a href="/">返回 Web Blender</a></p>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
const css = `:root{color-scheme:dark;--bg:#181818;--panel:#232323;--panel-2:#2b2b2b;--line:#3c3c3c;--text:#e6e6e6;--muted:#a9a9a9;--accent:#6aa1d8;--accent-2:#d8a45a}
|
||||
*{box-sizing:border-box}
|
||||
body{margin:0;background:var(--bg);color:var(--text);font:16px/1.7 "Noto Sans SC",system-ui,-apple-system,"Segoe UI",sans-serif}
|
||||
a{color:var(--accent)}
|
||||
.course-hero{padding:52px clamp(20px,5vw,72px) 34px;background:linear-gradient(135deg,#1d2833,#242424 60%,#2a2318);border-bottom:1px solid var(--line)}
|
||||
.course-kicker{margin:0 0 10px;color:var(--accent-2);font-size:13px;letter-spacing:.12em;text-transform:uppercase}
|
||||
.course-hero h1{margin:0 0 12px;font-size:clamp(30px,4vw,52px);line-height:1.15}
|
||||
.course-subtitle{margin:0 0 10px;max-width:900px;color:#c8d8e6;font-size:clamp(16px,2vw,21px)}
|
||||
.course-audience{margin:0 0 16px;color:var(--muted)}
|
||||
.course-first-load{margin:0;max-width:900px;padding:10px 14px;border-left:3px solid var(--accent-2);background:#2b2620;color:#e8d4b6}
|
||||
.course-layout{display:grid;grid-template-columns:260px minmax(0,1fr);gap:0;align-items:start}
|
||||
.course-nav{position:sticky;top:0;max-height:100vh;overflow:auto;padding:18px 14px;border-right:1px solid var(--line);background:#1d1d1d}
|
||||
.course-nav strong{display:block;margin:0 0 10px;color:var(--muted);font-size:12px;letter-spacing:.08em}
|
||||
.course-nav a{display:flex;gap:9px;padding:7px 8px;border-radius:5px;color:#d4d4d4;text-decoration:none;font-size:13px;line-height:1.35}
|
||||
.course-nav a:hover{background:#2c2c2c}
|
||||
.course-nav a span{flex:none;color:var(--accent-2);font-family:monospace}
|
||||
.course-main{min-width:0;padding:26px clamp(18px,4vw,56px) 60px}
|
||||
.course-rules,.course-video,.course-module{max-width:1180px;margin:0 auto 34px;padding:22px clamp(16px,2.5vw,30px);background:var(--panel);border:1px solid var(--line);border-radius:8px}
|
||||
.course-rules h2,.course-video h2,.course-module h2{margin-top:0;line-height:1.25}
|
||||
.course-video video,.course-module-video video{width:100%;height:auto;background:#000;border-radius:6px}
|
||||
.course-module-video{margin:16px 0 20px;padding:14px 16px;background:#262626;border:1px solid #3d4a3f;border-radius:6px}
|
||||
.course-module-video h3{margin:0 0 8px;font-size:15px;color:#cfe0ef}
|
||||
.course-module-video p{margin:8px 0 0;color:#aaa;font-size:13px}
|
||||
.course-video p{margin:10px 0 0;color:var(--muted)}
|
||||
.course-module-id{margin:0 0 4px;color:var(--accent-2);font-size:12px;letter-spacing:.08em;text-transform:uppercase}
|
||||
.course-summary{margin:0;color:#cfcfcf}
|
||||
.course-objectives{margin:18px 0}
|
||||
.course-objectives h3,.course-callout h3{margin:0 0 6px;font-size:15px;color:#cfe0ef}
|
||||
.course-objectives ul{margin:0;padding-left:22px}
|
||||
.course-steps{margin:20px 0 0;padding:0;list-style:none;counter-reset:step}
|
||||
.course-steps>li{counter-increment:step;position:relative;margin:0 0 22px;padding:0 0 0 40px}
|
||||
.course-steps>li::before{content:counter(step);position:absolute;left:0;top:0;display:grid;place-items:center;width:27px;height:27px;border-radius:50%;background:#36506a;color:#e8f2fb;font-size:13px;font-weight:700}
|
||||
.course-steps p{margin:2px 0 10px}
|
||||
.course-steps figure{margin:0}
|
||||
.course-steps img{display:block;width:100%;height:auto;border:1px solid var(--line);border-radius:6px;background:#111}
|
||||
.course-steps figcaption{margin-top:5px;color:#8f9aa4;font-size:12px}
|
||||
.course-callout{margin-top:18px;padding:12px 16px;border-radius:6px;background:var(--panel-2);border-left:3px solid #57708a}
|
||||
.course-callout ul{margin:0;padding-left:20px}
|
||||
.course-warnings{border-left-color:#c98e5a;background:#2d2720}
|
||||
.course-footer{max-width:1180px;margin:0 auto;padding-top:18px;border-top:1px solid var(--line);color:var(--muted);font-size:13px}
|
||||
@media(max-width:900px){.course-layout{grid-template-columns:1fr}.course-nav{position:static;max-height:none;border-right:0;border-bottom:1px solid var(--line);display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr))}.course-nav strong{grid-column:1/-1}.course-main{padding-top:18px}}
|
||||
`;
|
||||
|
||||
fs.mkdirSync(OUT, { recursive: true });
|
||||
fs.writeFileSync(path.join(OUT, "index.html"), html, "utf8");
|
||||
fs.writeFileSync(path.join(OUT, "course.css"), css, "utf8");
|
||||
fs.writeFileSync(path.join(OUT, "course.json"), JSON.stringify(course, null, 2) + "\n", "utf8");
|
||||
|
||||
console.log(JSON.stringify({ status: missing.length === 0 ? "PASS" : "MISSING_ASSETS", modules: course.modules.length, videos: course.videos.length, missing, output: OUT }, null, 2));
|
||||
if (missing.length > 0) process.exitCode = 1;
|
||||
179
tools/web/course/lib/lesson-recorder.mjs
Normal file
179
tools/web/course/lib/lesson-recorder.mjs
Normal file
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* Shared helpers for the complete Web Blender course capture/recording.
|
||||
* Reuses the conventions proven by tools/web/course/capture-full-course.mjs and
|
||||
* tools/web/record-re-pbr-lesson-video.mjs, but keeps one implementation.
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import crypto from "node:crypto";
|
||||
import { createRequire } from "node:module";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../..");
|
||||
export const WEB = path.join(REPO, "web");
|
||||
const requireFromWeb = createRequire(path.join(WEB, "package.json"));
|
||||
export const { chromium } = requireFromWeb("playwright");
|
||||
|
||||
export const ASSETS = {
|
||||
studio: path.join(REPO, "web/app/public/tutorial/pbr/studio.blend"),
|
||||
monkey: path.join(REPO, "re/猴头.glb"),
|
||||
monkeyFixture: path.join(REPO, "tests/files/web/pbr-render-lesson/monkey-head.glb"),
|
||||
texture: path.join(REPO, "web/app/public/tutorial/texture-paint/re-texture-base.png"),
|
||||
standardLibrary: "library:re-pbr-v1",
|
||||
highQualityLibrary: "library:re-pbr-hq-v1",
|
||||
};
|
||||
|
||||
export const HARDWARE_ARGS = [
|
||||
"--no-sandbox", "--use-gl=angle", "--use-angle=gl", "--ignore-gpu-blocklist",
|
||||
"--enable-gpu-rasterization", "--enable-zero-copy", "--enable-unsafe-webgpu",
|
||||
];
|
||||
export const SWIFTSHADER_ARGS = [
|
||||
"--no-sandbox", "--use-gl=swiftshader", "--enable-unsafe-swiftshader",
|
||||
"--enable-unsafe-webgpu", "--use-angle=swiftshader",
|
||||
];
|
||||
|
||||
export function parseArgs(argv = process.argv.slice(2)) {
|
||||
const value = (name, fallback) => {
|
||||
const index = argv.indexOf(`--${name}`);
|
||||
return index >= 0 && argv[index + 1] ? argv[index + 1] : fallback;
|
||||
};
|
||||
const has = (name) => argv.includes(`--${name}`);
|
||||
return {
|
||||
port: Number.parseInt(value("port", "5184"), 10) || 5184,
|
||||
baseUrl: value("base-url", ""),
|
||||
gpu: value("gpu", process.env.GPU_MODE ?? "hardware"),
|
||||
lane: value("lane", "local"),
|
||||
out: path.resolve(value("out", path.join(REPO, "tests/golden/COMPLETE-TUTORIAL-001"))),
|
||||
modules: value("module", ""),
|
||||
all: has("all"),
|
||||
resume: has("resume"),
|
||||
};
|
||||
}
|
||||
|
||||
export async function waitForServer(url, timeoutMs = 120_000) {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
while (Date.now() < deadline) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
if (response.status < 500) return;
|
||||
}
|
||||
catch { /* retry */ }
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
throw new Error(`server did not start: ${url}`);
|
||||
}
|
||||
|
||||
export async function launchBrowser(gpuMode, options = {}) {
|
||||
const args = gpuMode === "hardware" ? HARDWARE_ARGS : SWIFTSHADER_ARGS;
|
||||
return chromium.launch({
|
||||
headless: gpuMode !== "hardware" ? true : false,
|
||||
executablePath: process.env.CHROME_PATH || "/usr/bin/google-chrome",
|
||||
args,
|
||||
...(options.recordVideo ? { recordVideo: { dir: options.recordVideo, size: { width: 1600, height: 900 } } } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function newPage(browser, { baseUrl, viewport = { width: 1600, height: 900 } } = {}) {
|
||||
const context = await browser.newContext({ viewport, deviceScaleFactor: 1, acceptDownloads: true });
|
||||
const page = await context.newPage();
|
||||
const consoleErrors = [];
|
||||
page.on("pageerror", (error) => consoleErrors.push(String(error)));
|
||||
page.on("console", (message) => { if (message.type() === "error") consoleErrors.push(message.text()); });
|
||||
if (baseUrl) await openApp(page, baseUrl);
|
||||
return { context, page, consoleErrors };
|
||||
}
|
||||
|
||||
export async function openApp(page, baseUrl) {
|
||||
const url = baseUrl.includes("?") ? baseUrl : `${baseUrl}/?ui=web`;
|
||||
await page.goto(url, { waitUntil: "domcontentloaded" });
|
||||
await page.locator("main.blender-app").waitFor({ timeout: 180_000 });
|
||||
await page.waitForFunction(() => globalThis.crossOriginIsolated === true, { timeout: 30_000 }).catch(() => {});
|
||||
}
|
||||
|
||||
export async function openFile(page, filePath) {
|
||||
await page.locator('[data-testid="blend-file-input"]').setInputFiles(filePath);
|
||||
}
|
||||
|
||||
export async function waitScene(page, { objects, active, timeout = 180_000 } = {}) {
|
||||
// The engine status is not always "SceneIR": imports report "GLB imported rN",
|
||||
// and reopen reports a SceneIR revision. Wait for a real scene instead.
|
||||
await page.waitForFunction(() => {
|
||||
const main = document.querySelector("main.blender-app");
|
||||
const status = document.querySelector('[data-testid="engine-status"]')?.textContent ?? "";
|
||||
return Boolean(main?.getAttribute("data-project-id")) && !/open a \.blend|Engine: ready/i.test(status);
|
||||
}, null, { timeout });
|
||||
if (objects !== undefined) {
|
||||
await page.waitForFunction((expected) => {
|
||||
const text = document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "";
|
||||
return new RegExp(`Objects\\s+${expected}\\b`).test(text);
|
||||
}, String(objects), { timeout });
|
||||
}
|
||||
if (active) {
|
||||
await page.waitForFunction((name) => {
|
||||
const text = document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "";
|
||||
return text.includes(`Active ${name}`);
|
||||
}, active, { timeout });
|
||||
}
|
||||
}
|
||||
|
||||
export async function switchWorkspace(page, name) {
|
||||
const tab = page.locator("nav.workspace-tabs").getByRole("button", { name, exact: true });
|
||||
await tab.click();
|
||||
await page.waitForTimeout(250);
|
||||
}
|
||||
|
||||
export const domClick = (locator) => locator.evaluate((element) => element.click());
|
||||
|
||||
export async function moveClick(page, locator) {
|
||||
await locator.scrollIntoViewIfNeeded().catch(() => {});
|
||||
const box = await locator.boundingBox().catch(() => null);
|
||||
if (box) await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
||||
await locator.click({ force: true });
|
||||
}
|
||||
|
||||
export async function shot(page, directory, name) {
|
||||
fs.mkdirSync(directory, { recursive: true });
|
||||
const file = path.join(directory, `${name}.jpg`);
|
||||
await page.screenshot({ path: file, type: "jpeg", quality: 82, fullPage: true });
|
||||
return { path: file, sha256: sha256File(file), bytes: fs.statSync(file).size };
|
||||
}
|
||||
|
||||
export function sha256File(file) {
|
||||
return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
||||
}
|
||||
|
||||
export function installOverlay(page) {
|
||||
// The app's CSP forbids inline <style>; reuse the external overlay stylesheet.
|
||||
return page.evaluate(() => {
|
||||
if (!document.querySelector('link[data-lesson-video-overlay]')) {
|
||||
const link = document.createElement("link");
|
||||
link.rel = "stylesheet";
|
||||
link.href = "/tutorial/pbr/lesson/video-overlay.css";
|
||||
link.dataset.lessonVideoOverlay = "";
|
||||
document.head.append(link);
|
||||
}
|
||||
if (document.getElementById("__lesson_video_overlay")) return;
|
||||
const root = document.createElement("div");
|
||||
root.id = "__lesson_video_overlay";
|
||||
const cursor = document.createElement("div");
|
||||
cursor.id = "__lesson_video_cursor";
|
||||
const caption = document.createElement("div");
|
||||
caption.id = "__lesson_video_caption";
|
||||
root.append(cursor, caption);
|
||||
document.body.append(root);
|
||||
window.__lessonSetCaption = (text) => { caption.textContent = text || ""; };
|
||||
window.addEventListener("mousemove", (event) => {
|
||||
cursor.getAnimations().forEach((animation) => animation.cancel());
|
||||
cursor.animate([{ transform: `translate(${event.clientX}px, ${event.clientY}px)` }], { duration: 90, fill: "forwards", easing: "linear" });
|
||||
}, { passive: true });
|
||||
window.addEventListener("mousedown", (event) => {
|
||||
const ripple = document.createElement("div");
|
||||
ripple.className = "__lesson_video_ripple";
|
||||
root.append(ripple);
|
||||
ripple.animate([
|
||||
{ transform: `translate(${event.clientX}px, ${event.clientY}px) scale(1)`, opacity: 0.95 },
|
||||
{ transform: `translate(${event.clientX}px, ${event.clientY}px) scale(4.2)`, opacity: 0 },
|
||||
], { duration: 520, easing: "ease-out" }).finished.then(() => ripple.remove());
|
||||
}, { passive: true });
|
||||
});
|
||||
}
|
||||
163
tools/web/course/record-complete-video.mjs
Normal file
163
tools/web/course/record-complete-video.mjs
Normal file
@@ -0,0 +1,163 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Record the one complete narrated Web Blender course video.
|
||||
*
|
||||
* Prepare narration first:
|
||||
* python3 -I /home/mes123456/workinf_Blender_Wasm/tools/web/generate-re-pbr-narration.py \
|
||||
* --mode prepare --chapters /home/mes123456/workinf_Blender_Wasm/tools/web/course/complete-video-chapters.json \
|
||||
* --out /home/mes123456/workinf_Blender_Wasm/tests/golden/COMPLETE-TUTORIAL-001/video
|
||||
*
|
||||
* Then:
|
||||
* DISPLAY=:1 CHROME_PATH=/usr/bin/google-chrome \
|
||||
* node tools/web/course/record-complete-video.mjs --port 5184 --gpu hardware
|
||||
*
|
||||
* Outputs: tests/golden/COMPLETE-TUTORIAL-001/video/{screencast.webm,timeline.json,record-report.json}
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import {
|
||||
REPO, ASSETS, parseArgs, waitForServer, launchBrowser, newPage,
|
||||
openFile, waitScene, switchWorkspace, domClick, installOverlay, sha256File,
|
||||
} from "./lib/lesson-recorder.mjs";
|
||||
|
||||
const args = parseArgs();
|
||||
const BASE = args.baseUrl || `http://127.0.0.1:${args.port}`;
|
||||
const OUT = path.join(args.out, "video");
|
||||
const CHAPTERS = path.join(REPO, "tools/web/course/complete-video-chapters.json");
|
||||
const FINAL = path.join(REPO, "web/app/public/tutorial/complete/video/complete-course-720p.mp4");
|
||||
fs.mkdirSync(OUT, { recursive: true });
|
||||
fs.mkdirSync(path.dirname(FINAL), { recursive: true });
|
||||
|
||||
const chapters = JSON.parse(fs.readFileSync(CHAPTERS, "utf8")).chapters;
|
||||
const narrationPath = path.join(OUT, "narration.json");
|
||||
if (!fs.existsSync(narrationPath)) {
|
||||
console.error(`missing ${narrationPath}; run --mode prepare first`);
|
||||
process.exit(1);
|
||||
}
|
||||
const narration = JSON.parse(fs.readFileSync(narrationPath, "utf8"));
|
||||
const durationOf = (id) => narration.chapters.find((chapter) => chapter.id === id)?.durationMs ?? 6000;
|
||||
const only = args.modules ? new Set(args.modules.split(",").map((item) => item.trim()).filter(Boolean)) : null;
|
||||
// Timeline origin matches the videos directory's recording start.
|
||||
const t0 = Date.now();
|
||||
|
||||
await waitForServer(`${BASE}/?ui=web`);
|
||||
const browser = await launchBrowser(args.gpu);
|
||||
const context = await browser.newContext({ viewport: { width: 1600, height: 900 }, recordVideo: { dir: OUT, size: { width: 1600, height: 900 } } });
|
||||
const page = await context.newPage();
|
||||
await page.goto(`${BASE}/?ui=web`, { waitUntil: "domcontentloaded" });
|
||||
await page.locator("main.blender-app").waitFor({ timeout: 180_000 });
|
||||
await installOverlay(page);
|
||||
page.setDefaultTimeout(8_000);
|
||||
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
const timeline = [];
|
||||
const report = { schemaVersion: 1, task: "COMPLETE-TUTORIAL-001", voice: narration.voice, startedAt: new Date().toISOString(), chapters: [] };
|
||||
|
||||
const workspace = async (name) => {
|
||||
await domClick(page.locator(".workspace-tabs button", { hasText: name }).first());
|
||||
await sleep(500);
|
||||
};
|
||||
const caption = async (text) => { await page.evaluate((value) => window.__lessonSetCaption?.(value), text).catch(() => {}); };
|
||||
const ensureObjectMode = async () => {
|
||||
const chip = page.locator(".mode-chip button").first();
|
||||
if (!(await chip.count())) return;
|
||||
await domClick(chip);
|
||||
const objectMode = page.getByRole("menuitemcheckbox", { name: /物体模式|Object Mode/ }).first();
|
||||
if (await objectMode.count()) await objectMode.click().catch(() => {});
|
||||
await sleep(1200);
|
||||
};
|
||||
|
||||
const baseline = async () => {
|
||||
const stats = await page.getByTestId("scene-stats").innerText().catch(() => "");
|
||||
if (/Objects 7/.test(stats)) return;
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 180_000 });
|
||||
await openFile(page, ASSETS.monkey);
|
||||
await waitScene(page, { objects: 7, active: "Suzanne", timeout: 180_000 });
|
||||
};
|
||||
|
||||
const actions = {
|
||||
intro: async () => { await workspace("Layout"); },
|
||||
M01: async () => { await baseline(); await domClick(page.locator('button[aria-label="保存项目"]')); await page.waitForFunction(() => document.querySelector("main.blender-app")?.getAttribute("data-user-action-save-status") === "SUCCEEDED", null, { timeout: 180_000 }); },
|
||||
M02: async () => { for (const name of ["Layout", "Modeling", "Shading", "Rendering", "Layout"]) await workspace(name); },
|
||||
M03: async () => { await workspace("Layout"); const row = page.locator(".outliner-row").first(); if (await row.count()) await domClick(row); },
|
||||
M04: async () => { await workspace("Layout"); await page.getByTestId("object-transform-readout").scrollIntoViewIfNeeded().catch(() => {}); },
|
||||
M05: async () => { await workspace("Modeling"); const chip = page.locator(".mode-chip button").first(); if (await chip.count()) { await domClick(chip); await sleep(800); } },
|
||||
M06: async () => { await workspace("Layout"); await domClick(page.locator('.property-tabs [role="tab"]').nth(1)).catch(() => {}); },
|
||||
M07: async () => { await workspace("Sculpting"); await page.getByTestId("sculpt-editor").scrollIntoViewIfNeeded().catch(() => {}); },
|
||||
M08: async () => { await workspace("UV Editing"); await page.locator(".wasm-uv-editor").waitFor({ timeout: 60_000 }).catch(() => {}); },
|
||||
M09: async () => { await workspace("Texture Paint"); await page.getByTestId("texture-paint-canvas").waitFor({ timeout: 60_000 }).catch(() => {}); },
|
||||
M10: async () => { await workspace("Layout"); await domClick(page.getByRole("button", { name: "添加", exact: true }).first()).catch(() => {}); },
|
||||
M11: async () => {
|
||||
await ensureObjectMode();
|
||||
await workspace("Shading");
|
||||
await page.locator(".pbr-asset-library").waitFor({ timeout: 60_000 });
|
||||
await page.locator('select[aria-label="资产来源"]').selectOption("library:re-pbr-v1");
|
||||
await page.waitForFunction(() => document.querySelectorAll('[data-library="library:re-pbr-v1"]').length === 6, null, { timeout: 60_000 });
|
||||
const material = page.locator('[data-library="library:re-pbr-v1"]', { hasText: "black_tiles_wall" }).first();
|
||||
if (await material.count()) {
|
||||
const assigned = () => page.waitForFunction(() => {
|
||||
const slot = document.querySelector('select[aria-label^="材质槽"]');
|
||||
return slot instanceof HTMLSelectElement && slot.value.includes("black_tiles_wall");
|
||||
}, null, { timeout: 90_000 });
|
||||
await material.evaluate((element) => element.dispatchEvent(new MouseEvent("dblclick", { bubbles: true })));
|
||||
try { await assigned(); }
|
||||
catch { await sleep(2000); await material.evaluate((element) => element.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }))); await assigned().catch(() => {}); }
|
||||
}
|
||||
},
|
||||
M12: async () => { await workspace("Rendering"); const render = page.getByRole("button", { name: /渲染 PBR/ }).first(); if (await render.count()) { await domClick(render); await sleep(9000); } },
|
||||
M13: async () => { await workspace("Animation"); const key = page.getByRole("button", { name: "插入位置关键帧", exact: true }).first(); if (await key.count()) { await domClick(key); await sleep(700); } },
|
||||
M14: async () => { await workspace("Rendering"); const panel = page.locator(".native-render-fallback").first(); if (await panel.count()) await panel.evaluate((element) => { element.open = true; }); },
|
||||
M15: async () => { await workspace("Compositing"); const canvas = page.getByTestId("compositor-canvas"); await canvas.waitFor({ timeout: 60_000 }); await canvas.getByLabel("添加节点类型").selectOption("CONSTANT_COLOR"); await domClick(canvas.getByRole("button", { name: "添加节点", exact: true })); },
|
||||
M16: async () => { await workspace("Geometry Nodes"); const canvas = page.getByTestId("geometry-node-canvas"); await canvas.waitFor({ timeout: 60_000 }); const add = canvas.getByRole("button", { name: "添加节点", exact: true }); if (await add.count()) await domClick(add); },
|
||||
M17: async () => { await workspace("Geometry Nodes"); const sheet = page.getByTestId("spreadsheet-view"); await sheet.waitFor({ timeout: 60_000 }); await sheet.getByLabel("数据源").selectOption("attributes"); },
|
||||
M18: async () => { await workspace("Scripting"); const input = page.getByLabel("Python 输入").first(); if (await input.count()) await input.fill("import bpy; print([o.name for o in bpy.data.objects])"); const run = page.getByRole("button", { name: "执行 Python" }).first(); if (await run.count()) await domClick(run); await sleep(2000); },
|
||||
M19: async () => { await workspace("Layout"); await domClick(page.getByRole("button", { name: "文件", exact: true })); },
|
||||
M20: async () => { await page.keyboard.press("Escape"); await domClick(page.getByRole("button", { name: "文件", exact: true })); await page.getByRole("menuitem", { name: /导出|Export/ }).first().click().catch(() => {}); },
|
||||
M21: async () => { await workspace("Layout"); await page.locator('[data-testid="physics-workbench"]').first().scrollIntoViewIfNeeded().catch(() => {}); },
|
||||
M22: async () => { await workspace("Layout"); await page.locator('section[aria-label="Sequencer Strip Editing"]').first().scrollIntoViewIfNeeded().catch(() => {}); },
|
||||
M23: async () => { await workspace("Layout"); await page.getByTestId("tracking-mask-workbench").first().scrollIntoViewIfNeeded().catch(() => {}); },
|
||||
M24: async () => { await domClick(page.getByRole("button", { name: "编辑", exact: true })); await page.getByRole("menuitem", { name: "偏好设置" }).first().click().catch(() => {}); await page.getByTestId("preferences-window").waitFor({ timeout: 20_000 }).catch(() => {}); },
|
||||
outro: async () => { await page.keyboard.press("Escape"); await workspace("Layout"); },
|
||||
};
|
||||
|
||||
try {
|
||||
for (const chapter of chapters) {
|
||||
if (only && !only.has(chapter.id)) continue;
|
||||
await page.keyboard.press("Escape").catch(() => {});
|
||||
await sleep(150);
|
||||
const startMs = Date.now() - t0;
|
||||
await caption(chapter.title);
|
||||
const action = actions[chapter.id];
|
||||
if (action) await action().catch((error) => console.log(`chapter ${chapter.id} action failed: ${error.message}`));
|
||||
const target = startMs + durationOf(chapter.id) + 8000;
|
||||
while (Date.now() - t0 < target) await sleep(250);
|
||||
const endMs = Date.now() - t0;
|
||||
timeline.push({ id: chapter.id, title: chapter.title, startMs, endMs });
|
||||
report.chapters.push({ id: chapter.id, title: chapter.title, startMs, endMs, narrationMs: durationOf(chapter.id) });
|
||||
console.log(`${chapter.id} ${startMs}-${endMs}ms`);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
await caption("").catch(() => {});
|
||||
const video = page.video();
|
||||
await context.close();
|
||||
await browser.close();
|
||||
if (video && !only && !fs.existsSync(path.join(OUT, "screencast.webm"))) {
|
||||
try { await video.saveAs(path.join(OUT, "screencast.webm")); }
|
||||
catch {
|
||||
// Playwright already writes the page recording into recordVideo.dir at
|
||||
// close; saveAs can reject once the page is gone. Use that file.
|
||||
const recorded = fs.readdirSync(OUT).filter((name) => /^page@[0-9a-f]+\.webm$/.test(name))
|
||||
.map((name) => ({ name, mtime: fs.statSync(path.join(OUT, name)).mtimeMs }))
|
||||
.sort((a, b) => b.mtime - a.mtime)[0];
|
||||
if (recorded) fs.renameSync(path.join(OUT, recorded.name), path.join(OUT, "screencast.webm"));
|
||||
}
|
||||
}
|
||||
report.timeline = timeline;
|
||||
report.finishedAt = new Date().toISOString();
|
||||
if (fs.existsSync(path.join(OUT, "screencast.webm"))) report.screencastSha256 = sha256File(path.join(OUT, "screencast.webm"));
|
||||
fs.writeFileSync(path.join(OUT, "timeline.json"), `${JSON.stringify({ chapters: timeline }, null, 2)}\n`);
|
||||
fs.writeFileSync(path.join(OUT, "record-report.json"), `${JSON.stringify(report, null, 2)}\n`);
|
||||
console.log(JSON.stringify({ chapters: report.chapters.length, out: OUT, final: FINAL }, null, 2));
|
||||
}
|
||||
Reference in New Issue
Block a user