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

@@ -44,6 +44,7 @@ Read only the branches needed for the current task:
2. Select the branch. 2. Select the branch.
- Use standard line extraction for architectural DWG/DXF plans. - Use standard line extraction for architectural DWG/DXF plans.
- Use `detect_sheet_frames.py` for multi-frame sheets. - Use `detect_sheet_frames.py` for multi-frame sheets.
- Treat detector clips as proposals. If two titles share the same clip, split the common sheet by title/wall clusters; the area and cross-floor gates must pass before modeling.
- Model each building separately before campus assembly. - Model each building separately before campus assembly.
- For multi-building/campus requests, write `scope_manifest.json` before modeling. Copy every requested building ID from the user/source inventory; never shrink scope to the easiest drawing set. - For multi-building/campus requests, write `scope_manifest.json` before modeling. Copy every requested building ID from the user/source inventory; never shrink scope to the easiest drawing set.
- Use `--converter oda` plus `extract_3d_solids.py` for known 3DSOLID/ACIS drawings. - Use `--converter oda` plus `extract_3d_solids.py` for known 3DSOLID/ACIS drawings.
@@ -65,7 +66,7 @@ Read only the branches needed for the current task:
5. Verify actual deliverables. 5. Verify actual deliverables.
- Require `verify_showcase.py --strict` and `verify_delivery.py` to pass. - Require `verify_showcase.py --strict` and `verify_delivery.py` to pass.
- Inspect at least one iso/front/side/plan render personally. - Inspect at least one iso/front/side/plan render personally.
- For served Web output, use `cad_showcase.py run --web`; it starts a temporary local server, runs `web_smoke_test.mjs` at desktop and 390px widths, and feeds the report to final verification automatically. - For served Web output, use `cad_showcase.py run --web`; it Draco-compresses Trimesh GLBs, starts a temporary local server, runs `web_smoke_test.mjs` at real 1440×900 and 390×844 viewports, and feeds the report to final verification automatically.
- Confirm idle `window.__renders` does not grow, GLBs decode, variants exist, controls work, and console errors are zero. - Confirm idle `window.__renders` does not grow, GLBs decode, variants exist, controls work, and console errors are zero.
6. Report confidence and limits. 6. Report confidence and limits.
@@ -85,7 +86,7 @@ Do not hand over a model unless every applicable item has evidence:
7. Campus output has a `scope_manifest.json` containing every requested building. Every building and the site is `PASS`, with existing artifacts; a `BLOCKED` entry means the campus request is not complete. 7. Campus output has a `scope_manifest.json` containing every requested building. Every building and the site is `PASS`, with existing artifacts; a `BLOCKED` entry means the campus request is not complete.
8. Campus output has proven transforms, no unexplained overlap, numeric neighbour gaps, boundary containment, and a top-view placement image. 8. Campus output has proven transforms, no unexplained overlap, numeric neighbour gaps, boundary containment, and a top-view placement image.
9. `verify_delivery.py` writes `evidence_manifest.json` with overall `PASS`; `BLOCKED`/`FAIL` must never be described as complete, and a human has looked at the render. 9. `verify_delivery.py` writes `evidence_manifest.json` with overall `PASS`; `BLOCKED`/`FAIL` must never be described as complete, and a human has looked at the render.
10. Served Web delivery includes a passing desktop/mobile browser smoke report. If Chromium cannot run, report `BLOCKED`; do not substitute the offline viewer for the requested Web template. 10. Served Web delivery includes a passing desktop/mobile browser smoke report whose viewport checks prove 1440×900 and 390×844. If Chromium cannot run, report `BLOCKED`; do not substitute the offline viewer for the requested Web template.
11. After any script/schema/template change, run: 11. After any script/schema/template change, run:
- `pytest tests/test_contracts.py tests/test_delivery.py` - `pytest tests/test_contracts.py tests/test_delivery.py`
- `python3 tests/test_extraction_pipeline.py` - `python3 tests/test_extraction_pipeline.py`

View File

@@ -22,6 +22,8 @@ The detector:
Pass every detector output config to audit with `--frames`. Account for every detected plan frame in extraction config or `discarded_frames` with a nonempty reason. Pass every detector output config to audit with `--frames`. Account for every detected plan frame in extraction config or `discarded_frames` with a nonempty reason.
The detector emits sheet-level proposals. Two different plan titles can sit inside one title-block/frame INSERT and therefore receive the same broad clip (for example `一层平面图` plus `夹层平面图`, or `二层平面图` plus `十六层平面图`). Never duplicate that shared clip across floors. Split it at the wall-cluster gap between title positions, then recompute each floor offset. Use independent declared area/storey evidence to prove the split; a roughly 2× footprint is the characteristic failure signal.
## Alignment Evidence ## Alignment Evidence
Prefer structural-grid voting. TArch grids often live on `DOTE`, not `AXIS`. When through grids are absent, accept tick-grid voting. When no axes exist, use wall-profile correlation independently in X/Y. Use clip-corner anchoring only as a weak fallback. Prefer structural-grid voting. TArch grids often live on `DOTE`, not `AXIS`. When through grids are absent, accept tick-grid voting. When no axes exist, use wall-profile correlation independently in X/Y. Use clip-corner anchoring only as a weak fallback.
@@ -38,7 +40,7 @@ Set explicit `z`, `height`, and `floor_order`. The schema rejects floor-order ga
## Clip Risks ## Clip Risks
Title-block or refined clips can still swallow adjacent rows, details, legends, or revision tables. Investigate when a footprint dimension is 2-4x its siblings or contains distant sliver polygons. Tighten the clip band or use isolated-cluster filtering; do not simply raise noise thresholds until the artifact disappears. Title-block or refined clips can still swallow adjacent rows, details, legends, or revision tables. Investigate when a footprint dimension is 2-4x its siblings, exceeds declared area, or contains distant sliver polygons. Tighten both X/Y clip bands or use evidence-backed isolated-cluster filtering; do not simply raise noise thresholds until the artifact disappears. Inspect the final browser screenshot too: repeated floating strips at every storey usually mean off-envelope plan symbols survived the clip.
## TArch Mapping Preset ## TArch Mapping Preset

View File

@@ -18,6 +18,8 @@ Deliver three variants for Web/digital-twin presentation:
Generate them with `build_showcase_variants.py` or `cad_showcase.py run`. Validate `variants_manifest.json` and every variant spec. Keep `source_file==site` floors intact across variants. Generate them with `build_showcase_variants.py` or `cad_showcase.py run`. Validate `variants_manifest.json` and every variant spec. Keep `source_file==site` floors intact across variants.
The Trimesh branch of `cad_showcase.py run` writes a retained `.raw.glb` and then runs `tools/compress.mjs` (weld, dedup, prune, Draco) to produce each delivered `.glb`. The Blender branch uses Blender's Draco export. `verify_showcase.py --strict` must see `draco=True` and every delivered variant within the size budget.
Both GLB backends consume versioned `building_spec.json`. They must preserve `<floor>__<category>` names and glTF Y-up. `floor.caps` is canonical; exporters must not independently infer different cap groups. Both GLB backends consume versioned `building_spec.json`. They must preserve `<floor>__<category>` names and glTF Y-up. `floor.caps` is canonical; exporters must not independently infer different cap groups.
## Served Viewer ## Served Viewer
@@ -45,7 +47,7 @@ node scripts/web_smoke_test.mjs \
--screenshots-dir outputs/<project>/browser_smoke --screenshots-dir outputs/<project>/browser_smoke
``` ```
Install Playwright/Chromium first when needed. The script checks desktop/mobile control visibility, console/page/request failures, and idle render behavior. Feed the report to final verification with `--browser-report`. Supplying `--web-dir` makes the report mandatory: no report is `BLOCKED`, never PASS. Install Playwright/Chromium first when needed. The script checks real 1440×900/390×844 viewport dimensions, desktop/mobile control visibility, console/page/request failures, and idle render behavior. Feed the report to final verification with `--browser-report`. Supplying `--web-dir` makes the report mandatory: no report is `BLOCKED`, never PASS.
When an execution tool already has a `run_in_background` option, launch `python3 -m http.server ...` as the foreground command of that background process. Do not append shell `&`; the child server can die with the wrapper. Before presenting the viewer, probe the URL and keep that server process alive. Present the formal `web/index.html` URL when Web was requested; `viewer.html` is a separate offline fallback, not a substitute. When an execution tool already has a `run_in_background` option, launch `python3 -m http.server ...` as the foreground command of that background process. Do not append shell `&`; the child server can die with the wrapper. Before presenting the viewer, probe the URL and keep that server process alive. Present the formal `web/index.html` URL when Web was requested; `viewer.html` is a separate offline fallback, not a substitute.

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: 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.""" """Serve the formal Web bundle and mechanically prove desktop/mobile loading."""
pipeline.run( pipeline.run(
"browser_dependencies", "node_dependencies",
["npm", "install", "--prefix", str(ROOT), "--ignore-scripts"], ["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( pipeline.run(
"browser_runtime", "browser_runtime",
@@ -295,6 +298,7 @@ def build_with_trimesh(pipeline: Pipeline, bundle: Path) -> list[Path]:
for key in ("overview", "standard", "detail"): for key in ("overview", "standard", "detail"):
spec = bundle / "variant_specs" / f"{key}.json" spec = bundle / "variant_specs" / f"{key}.json"
out_dir = bundle / "variants" / key out_dir = bundle / "variants" / key
raw_glb = out_dir / f"{key}.raw.glb"
glb = out_dir / f"{key}.glb" glb = out_dir / f"{key}.glb"
metadata = out_dir / "model_metadata.json" metadata = out_dir / "model_metadata.json"
pipeline.run( pipeline.run(
@@ -304,15 +308,20 @@ def build_with_trimesh(pipeline: Pipeline, bundle: Path) -> list[Path]:
"--spec", "--spec",
str(spec), str(spec),
"--out", "--out",
str(glb), str(raw_glb),
"--metadata-out", "--metadata-out",
str(metadata), str(metadata),
"--name", "--name",
key, key,
), ),
[glb, metadata], [raw_glb, metadata],
forbidden_stderr=("WARNING mesh_from_polygons",), 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) glbs.append(glb)
return glbs return glbs
@@ -408,6 +417,14 @@ def run_pipeline(args: argparse.Namespace) -> int:
variant_cmd.extend(["--blender", args.blender]) variant_cmd.extend(["--blender", args.blender])
pipeline.run("variants", variant_cmd, [manifest, bundle / "variant_specs" / "standard.json"]) pipeline.run("variants", variant_cmd, [manifest, bundle / "variant_specs" / "standard.json"])
if args.backend == "trimesh": 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) glbs = build_with_trimesh(pipeline, bundle)
else: else:
glbs = [bundle / "variants" / key / f"{key}.glb" for key in ("overview", "standard", "detail")] glbs = [bundle / "variants" / key / f"{key}.glb" for key in ("overview", "standard", "detail")]

View File

@@ -31,7 +31,7 @@ const failedRequests = [];
const checks = []; const checks = [];
async function inspect(viewport, name) { async function inspect(viewport, name) {
const page = await browser.newPage({ viewportSize: viewport }); const page = await browser.newPage({ viewport });
page.on("console", (message) => { page.on("console", (message) => {
if (message.type() === "error") consoleErrors.push(message.text()); 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"}`)); page.on("requestfailed", (request) => failedRequests.push(`${request.url()} ${request.failure()?.errorText || "failed"}`));
await page.goto(url, { waitUntil: "networkidle", timeout: 60000 }); await page.goto(url, { waitUntil: "networkidle", timeout: 60000 });
await page.waitForSelector("#loading", { state: "hidden", 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"]; const selectors = ["#floor-controls", "#category-controls", "#explode", "#section", "#snapshot"];
for (const selector of selectors) { for (const selector of selectors) {
const visible = await page.locator(selector).isVisible(); const visible = await page.locator(selector).isVisible();

View File

@@ -78,7 +78,11 @@ def test_served_viewer_in_desktop_and_mobile(tmp_path: Path) -> None:
capture_output=True, capture_output=True,
) )
assert proc.returncode == 0, proc.stderr assert proc.returncode == 0, proc.stderr
assert json.loads(report.read_text(encoding="utf-8"))["status"] == "PASS" result = json.loads(report.read_text(encoding="utf-8"))
assert result["status"] == "PASS"
checks = {item["name"]: item for item in result["checks"]}
assert checks["desktop:viewport"]["detail"] == "1440x900 expected 1440x900"
assert checks["mobile:viewport"]["detail"] == "390x844 expected 390x844"
finally: finally:
server.terminate() server.terminate()
server.wait(timeout=10) server.wait(timeout=10)