fix: automate GLB compression and real viewport smoke

This commit is contained in:
2026-07-10 13:19:47 +08:00
parent 78ec1fbdcc
commit cab4d320c0
6 changed files with 43 additions and 10 deletions

View File

@@ -199,9 +199,12 @@ def wait_for_http(url: str, timeout: float = 20.0) -> None:
def run_browser_smoke(pipeline: Pipeline, web_dir: Path, report: Path, screenshots: Path) -> None:
"""Serve the formal Web bundle and mechanically prove desktop/mobile loading."""
pipeline.run(
"browser_dependencies",
"node_dependencies",
["npm", "install", "--prefix", str(ROOT), "--ignore-scripts"],
[ROOT / "node_modules" / "playwright" / "package.json"],
[
ROOT / "node_modules" / "playwright" / "package.json",
ROOT / "node_modules" / "@gltf-transform" / "core" / "package.json",
],
)
pipeline.run(
"browser_runtime",
@@ -295,6 +298,7 @@ def build_with_trimesh(pipeline: Pipeline, bundle: Path) -> list[Path]:
for key in ("overview", "standard", "detail"):
spec = bundle / "variant_specs" / f"{key}.json"
out_dir = bundle / "variants" / key
raw_glb = out_dir / f"{key}.raw.glb"
glb = out_dir / f"{key}.glb"
metadata = out_dir / "model_metadata.json"
pipeline.run(
@@ -304,15 +308,20 @@ def build_with_trimesh(pipeline: Pipeline, bundle: Path) -> list[Path]:
"--spec",
str(spec),
"--out",
str(glb),
str(raw_glb),
"--metadata-out",
str(metadata),
"--name",
key,
),
[glb, metadata],
[raw_glb, metadata],
forbidden_stderr=("WARNING mesh_from_polygons",),
)
pipeline.run(
f"compress_{key}",
["node", str(ROOT / "tools" / "compress.mjs"), str(raw_glb), str(glb)],
[glb],
)
glbs.append(glb)
return glbs
@@ -408,6 +417,14 @@ def run_pipeline(args: argparse.Namespace) -> int:
variant_cmd.extend(["--blender", args.blender])
pipeline.run("variants", variant_cmd, [manifest, bundle / "variant_specs" / "standard.json"])
if args.backend == "trimesh":
pipeline.run(
"node_dependencies",
["npm", "install", "--prefix", str(ROOT), "--ignore-scripts"],
[
ROOT / "node_modules" / "playwright" / "package.json",
ROOT / "node_modules" / "@gltf-transform" / "core" / "package.json",
],
)
glbs = build_with_trimesh(pipeline, bundle)
else:
glbs = [bundle / "variants" / key / f"{key}.glb" for key in ("overview", "standard", "detail")]

View File

@@ -31,7 +31,7 @@ const failedRequests = [];
const checks = [];
async function inspect(viewport, name) {
const page = await browser.newPage({ viewportSize: viewport });
const page = await browser.newPage({ viewport });
page.on("console", (message) => {
if (message.type() === "error") consoleErrors.push(message.text());
});
@@ -39,6 +39,13 @@ async function inspect(viewport, name) {
page.on("requestfailed", (request) => failedRequests.push(`${request.url()} ${request.failure()?.errorText || "failed"}`));
await page.goto(url, { waitUntil: "networkidle", timeout: 60000 });
await page.waitForSelector("#loading", { state: "hidden", timeout: 60000 });
const actualViewport = await page.evaluate(() => ({ width: window.innerWidth, height: window.innerHeight }));
const viewportMatches = actualViewport.width === viewport.width && actualViewport.height === viewport.height;
checks.push({
name: `${name}:viewport`,
status: viewportMatches ? "PASS" : "FAIL",
detail: `${actualViewport.width}x${actualViewport.height} expected ${viewport.width}x${viewport.height}`,
});
const selectors = ["#floor-controls", "#category-controls", "#explode", "#section", "#snapshot"];
for (const selector of selectors) {
const visible = await page.locator(selector).isVisible();