Compare commits

..

11 Commits

Author SHA1 Message Date
919b35391d fix: tighten viewer framing and localize site controls
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 21:10:43 +08:00
84a591c95a fix: resolve CAD paths from task workdir
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 17:14:19 +08:00
adbd476957 test: target generated floor labels in smoke
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 15:37:03 +08:00
d18c2fcc41 test: wait for viewer floor controls before smoke
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 15:32:54 +08:00
6c207b0538 test: exercise floor state in browser smoke
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 15:30:24 +08:00
f2c24f4590 fix: preserve Unicode floor state in viewer URLs
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 15:20:43 +08:00
8cc64f2e58 fix: generate showcase thumbnails deterministically
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 14:53:23 +08:00
e0cd974c6b fix: distinguish Revit view wrappers from family blocks
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 14:38:30 +08:00
20ef26db9f fix: codify split roof and campus assembly
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 14:05:06 +08:00
a38e5796ea fix: resolve Node outside daemon PATH
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 13:52:41 +08:00
a3be794e19 fix: make CAD conversion recovery deterministic
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
2026-07-21 13:49:18 +08:00
11 changed files with 338 additions and 35 deletions

View File

@@ -46,9 +46,11 @@ Read only the branches needed for the current task:
- Use `detect_sheet_frames.py` for multi-frame sheets. If the source report finds two or more plan identities in one drawing, `--frames` is mandatory; do not let `frame_ledger` become `NOT_APPLICABLE`.
- Treat detector clips as proposals. If Revit views share world coordinates, keep the detector's per-floor `include_block_names` plus top-level `expand_block_names`; clips alone cannot separate overlapping views. For non-Revit overlap, split by title/wall clusters. Area and cross-floor gates must pass before modeling.
- Keep `屋面平面图` (`RF`) and `机房小屋面` (`PH`) as distinct source identities. One overlapping RF clip may not satisfy both; resolve their view-suffixed blocks, heights, and roof-cap roles from the drawing evidence.
- When RF and PH are both floor keys, put them in separate `cap_groups` and give each an explicit evidence-derived `roof_specs` elevation. This prevents the automatic setback-cap calculation from creating a duplicate full-roof plate between the main roof and machine-room roof.
- Model each building separately before campus assembly.
- A campus request must run and audit one config per building, then use `assemble_campus.py`; do not merge building configs into one shortcut run, even when their source coordinates already share a site system.
- 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. For ordinary DWG input, `--converter auto` tries native LibreDWG, then the packaged WASM bridge, then ODA; do not manually assemble the WASM commands unless the report records a converter failure.
- Stop and request DWG/DXF/vector conversion for PDF-only input.
3. Write and validate an explicit config.
@@ -72,6 +74,7 @@ Read only the branches needed for the current task:
- Require `verify_showcase.py --strict` and `verify_delivery.py` to pass.
- Inspect at least one iso/front/side/plan render personally.
- 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.
- Use the `thumbnail.png` emitted by the Web smoke. It is exported directly from the WebGL canvas with the canonical camera; do not manually crop the browser screenshot or iterate on UI-free framing.
- For `--offline`, the pipeline embeds the retained uncompressed `standard.raw.glb`, opens `viewer.html` through a real `file://` Chromium page, and records `offline_browser_smoke_report.json`. Never embed a Draco GLB in the r147 offline viewer unless a matching offline decoder is bundled and tested.
- Confirm idle `window.__renders` does not grow, GLBs decode, variants exist, controls work, and console errors are zero.

View File

@@ -31,6 +31,12 @@ const preferredCategoryOrder = [
"slab", "roof", "walls", "glazing", "columns", "beams",
"railings", "doors", "detail_lines", "floor_lines", "grid",
];
const SCENE_FLOOR_LABELS = {
SITE: "场地",
ROADS: "道路",
FENCE: "围墙",
TREES: "绿化",
};
const CACHE_BUST = "{{BUILD}}";
// Tour presets — cycle through these viewpoints
@@ -360,7 +366,7 @@ function buildFloorControls(meta) {
floorList.append(
createToggle({
key: fk,
label: fk,
label: SCENE_FLOOR_LABELS[fk] || fk,
checked: state.floors[fk],
onChange: (checked) => {
state.floors[fk] = checked;
@@ -790,11 +796,12 @@ function fitCamera(preset) {
const size = box.getSize(new THREE.Vector3());
const maxSize = Math.max(size.x, size.y, size.z, 1);
if (preset === "top") {
camera.position.set(center.x, center.y + maxSize * 1.45, center.z);
camera.position.set(center.x, center.y + maxSize * 1.22, center.z);
} else if (preset === "side") {
camera.position.set(center.x, center.y + maxSize * 0.18, center.z + maxSize * 1.35);
camera.position.set(center.x, center.y + maxSize * 0.18, center.z + maxSize * 1.15);
} else {
const d = maxSize * 1.4;
// 园区模型默认占据更多画面;OrbitControls 仍允许用户自由拉远。
const d = maxSize * 1.15;
const L = Math.hypot(0.55, 1.0, 0.7);
camera.position.set(center.x - (0.55 / L) * d, center.y + (1.0 / L) * d, center.z + (0.7 / L) * d);
}
@@ -855,6 +862,21 @@ function renderBookmarkList() {
}
// ───────────────────────── URL Hash State ─────────────────────────
function encodeHashState(value) {
const bytes = new TextEncoder().encode(value);
let binary = "";
for (let index = 0; index < bytes.length; index += 0x8000) {
binary += String.fromCharCode(...bytes.subarray(index, index + 0x8000));
}
return btoa(binary).replace(/=/g, "");
}
function decodeHashState(value) {
const padded = value + "=".repeat((4 - (value.length % 4)) % 4);
const binary = atob(padded);
return new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));
}
function serializeStateToHash() {
const hash = {
f: Object.entries(state.floors).filter(([, v]) => !v).map(([k]) => k), // only store disabled
@@ -867,7 +889,7 @@ function serializeStateToHash() {
},
b: bookmarks,
};
const encoded = btoa(JSON.stringify(hash)).replace(/=/g, "");
const encoded = encodeHashState(JSON.stringify(hash));
history.replaceState(null, "", `#${encoded}`);
}
@@ -875,7 +897,7 @@ function restoreStateFromHash() {
try {
const raw = window.location.hash.slice(1);
if (!raw) return;
const hash = JSON.parse(atob(raw));
const hash = JSON.parse(decodeHashState(raw));
if (hash.f) for (const fk of hash.f) { if (fk in state.floors) state.floors[fk] = false; }
if (hash.c) for (const ck of hash.c) { if (ck in state.categories) state.categories[ck] = false; }
if (hash.s) { sectionInput.value = hash.s; applySection(Number(hash.s)); }

10
package-lock.json generated
View File

@@ -9,6 +9,7 @@
"@gltf-transform/core": "^4.4.1",
"@gltf-transform/extensions": "^4.4.1",
"@gltf-transform/functions": "^4.4.1",
"@mlightcad/libredwg-web": "0.7.8",
"draco3dgltf": "^1.5.7"
},
"devDependencies": {
@@ -532,6 +533,15 @@
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@mlightcad/libredwg-web": {
"version": "0.7.8",
"resolved": "https://registry.npmjs.org/@mlightcad/libredwg-web/-/libredwg-web-0.7.8.tgz",
"integrity": "sha512-3ol9nxsCr5YJarcUs8Pv5WM8MvF45H3Gi8M3/GA4o8sahwG0Ehfz8Nh3OnxuX+pxQCt+pm9n8DFCeOf7kaU81A==",
"license": "GPL-3.0",
"engines": {
"node": ">=20"
}
},
"node_modules/@types/ndarray": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/@types/ndarray/-/ndarray-1.0.14.tgz",

View File

@@ -10,6 +10,7 @@
"playwright": "^1.52.0"
},
"dependencies": {
"@mlightcad/libredwg-web": "0.7.8",
"@gltf-transform/core": "^4.4.1",
"@gltf-transform/extensions": "^4.4.1",
"@gltf-transform/functions": "^4.4.1",

View File

@@ -30,7 +30,8 @@ Tool discovery is environment variable, PATH, then platform defaults:
ODA requires existing absolute input/output directories. On macOS the command shape is `ODAFileConverter <abs_in_dir> <abs_out_dir> ACAD2004 DXF 0 1 "*.dwg"`; create both directories first. Bad arguments are often reported only through a GUI dialog, with empty stderr, and the process may return exit 0 while producing nothing. Treat “exit 0 + no DXF” as failure, check the screen for a blocked dialog, and keep the script's ASCII staging plus produced-file verification.
If native converters are unavailable, use the tested WASM bridge:
If native converters are unavailable, `--converter auto` uses the packaged WASM bridge after `npm install`.
For diagnosis or a manual one-file conversion, the equivalent commands are:
```bash
npm install --prefix work/vendor-js @mlightcad/libredwg-web

View File

@@ -17,6 +17,8 @@ from pathlib import Path
CAD_SUFFIXES = {".dwg", ".dxf"}
SCRIPT_DIR = Path(__file__).resolve().parent
ROOT = SCRIPT_DIR.parent
def parse_args() -> argparse.Namespace:
@@ -93,6 +95,121 @@ def run_dwg2dxf(source: Path, dest: Path) -> dict:
}
def libredwg_wasm_module_dir() -> Path | None:
"""Resolve the packaged WASM libredwg module without installing at runtime."""
override = os.environ.get("CAD_LIBREDWG_MODULE_DIR")
candidates = [Path(override)] if override else []
candidates.append(ROOT / "node_modules")
for candidate in candidates:
package = candidate / "@mlightcad" / "libredwg-web"
if (package / "dist" / "libredwg-web.js").exists() and (package / "wasm").is_dir():
return candidate
return None
def node_executable() -> str | None:
"""Resolve Node from env, PATH, or common platform install locations."""
override = os.environ.get("NODE")
if override:
return override if Path(override).exists() else None
found = shutil.which("node")
if found:
return found
candidates = []
if sys.platform == "darwin":
candidates.extend((Path("/opt/homebrew/bin/node"), Path("/usr/local/bin/node")))
elif sys.platform == "win32":
candidates.extend(
Path(path) / "nodejs" / "node.exe"
for path in (os.environ.get("ProgramFiles"), os.environ.get("ProgramFiles(x86)"))
if path
)
for candidate in candidates:
if candidate.exists():
return str(candidate)
return None
def run_wasm_libredwg(source: Path, dest: Path, work_dir: Path, vendor_dir: Path) -> dict:
"""Convert one DWG through the packaged libredwg WASM bridge."""
node = node_executable()
module_dir = libredwg_wasm_module_dir()
if not node:
return {
"source": str(source),
"dest": str(dest),
"status": "missing_node",
"message": "Install Node.js or set NODE to its executable path.",
}
if module_dir is None:
return {
"source": str(source),
"dest": str(dest),
"status": "missing_libredwg_wasm",
"message": (
"Install the toolchain Node dependencies with `npm install` or set "
"CAD_LIBREDWG_MODULE_DIR to a node_modules directory containing "
"@mlightcad/libredwg-web."
),
}
dump_dir = work_dir / "dwg_json"
dump_dir.mkdir(parents=True, exist_ok=True)
dump = dump_dir / f"{dest.stem}.json"
dest.parent.mkdir(parents=True, exist_ok=True)
try:
dump_proc = subprocess.run(
[
node,
str(SCRIPT_DIR / "dwg_dump_json.mjs"),
str(source),
str(dump),
"--module-dir",
str(module_dir),
],
capture_output=True,
timeout=600,
)
if dump_proc.returncode != 0 or not dump.exists():
return {
"source": str(source),
"dest": str(dest),
"status": "wasm_dump_failed",
"returncode": dump_proc.returncode,
"stdout": dump_proc.stdout.decode("utf-8", errors="replace")[-2000:],
"stderr": dump_proc.stderr.decode("utf-8", errors="replace")[-2000:],
}
rebuild_proc = subprocess.run(
[
sys.executable,
str(SCRIPT_DIR / "dwgjson_to_dxf.py"),
"--json",
str(dump),
"--out",
str(dest),
"--vendor-dir",
str(vendor_dir),
],
capture_output=True,
timeout=600,
)
except subprocess.TimeoutExpired as exc:
return {
"source": str(source),
"dest": str(dest),
"status": "wasm_timeout",
"message": str(exc),
}
return {
"source": str(source),
"dest": str(dest),
"status": "wasm_ok" if rebuild_proc.returncode == 0 and dest.exists() else "wasm_rebuild_failed",
"returncode": rebuild_proc.returncode,
"stdout": rebuild_proc.stdout.decode("utf-8", errors="replace")[-2000:],
"stderr": rebuild_proc.stderr.decode("utf-8", errors="replace")[-2000:],
}
def oda_converter() -> str | None:
"""ODA File Converter: env ODA_CONVERTER > PATH > macOS app-bundle default."""
override = os.environ.get("ODA_CONVERTER")
@@ -583,6 +700,21 @@ def main() -> int:
if args.allow_partial and not (args.partial_reason or "").strip():
raise SystemExit("--allow-partial requires --partial-reason")
cad_files = find_cad_files(input_dir)
generated_inputs = []
for source in cad_files:
resolved = source.resolve()
for generated_dir in (raw_dir.resolve(), clean_dir.resolve()):
if resolved == generated_dir or generated_dir in resolved.parents:
generated_inputs.append(source)
break
if generated_inputs:
examples = ", ".join(str(path) for path in generated_inputs[:3])
raise SystemExit(
"Input CAD files are inside generated work directories and would be deleted before inspection: "
f"{examples}. Use a separate --input directory such as out/dxf_src."
)
# These folders are generated intermediates. Recreate them so a source
# removed between runs cannot survive as a stale DXF and enter modeling.
shutil.rmtree(raw_dir, ignore_errors=True)
@@ -590,7 +722,6 @@ def main() -> int:
raw_dir.mkdir(parents=True, exist_ok=True)
clean_dir.mkdir(parents=True, exist_ok=True)
cad_files = find_cad_files(input_dir)
used_names: set[str] = set()
conversions: list[dict] = []
raw_dxfs: list[Path] = []
@@ -615,8 +746,10 @@ def main() -> int:
conversion = {"source": str(source), "dest": str(dest), "status": "oda_failed"}
else:
conversion = run_dwg2dxf(source, dest)
if conversion["status"] != "ok":
conversion = run_wasm_libredwg(source, dest, work_dir, vendor_dir)
conversions.append(conversion)
if conversion["status"] in {"ok", "oda_ok"}:
if conversion["status"] in {"ok", "wasm_ok", "oda_ok"}:
raw_dxfs.append(dest)
else:
if source.resolve() != dest.resolve():
@@ -648,7 +781,7 @@ def main() -> int:
if src and (item.get("status") == "failed" or item.get("modelspace_entities") == 0):
retry[item["file"]] = src
for c in list(conversions):
if c.get("status") in {"failed", "missing_dwg2dxf"} and str(c.get("source", "")).lower().endswith(".dwg"):
if c.get("status") not in {"ok", "wasm_ok", "oda_ok"} and str(c.get("source", "")).lower().endswith(".dwg"):
name = Path(c["dest"]).name if c.get("dest") else Path(c["source"]).with_suffix(".dxf").name
retry.setdefault(name, Path(c["source"]))
if retry and args.converter == "auto":
@@ -690,7 +823,9 @@ def main() -> int:
# hard gate until every DWG is converted or the run is explicitly partial.
dwg_sources = {str(path) for path in cad_files if path.suffix.lower() == ".dwg"}
successful_dwg_sources = {
str(item.get("source")) for item in conversions if item.get("status") in {"ok", "oda_ok", "oda_fallback_ok"}
str(item.get("source"))
for item in conversions
if item.get("status") in {"ok", "wasm_ok", "oda_ok", "oda_fallback_ok"}
}
unresolved_dwgs = sorted(dwg_sources - successful_dwg_sources)
failed_files = [item.get("file", "?") for item in results if item.get("status") != "ok"]

View File

@@ -373,7 +373,7 @@ def ensure_node_runtime(pipeline: Pipeline, *, browser: bool) -> 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, thumbnail: Path) -> None:
"""Serve the formal Web bundle and mechanically prove desktop/mobile loading."""
report.parent.mkdir(parents=True, exist_ok=True)
port = available_port()
@@ -405,8 +405,10 @@ def run_browser_smoke(pipeline: Pipeline, web_dir: Path, report: Path, screensho
str(report),
"--screenshots-dir",
str(screenshots),
"--thumbnail-out",
str(thumbnail),
),
[report, screenshots],
[report, screenshots, thumbnail],
)
finally:
server.terminate()
@@ -451,6 +453,14 @@ def doctor() -> int:
except SystemExit:
path = None
checks.append({"name": executable, "status": "PASS" if path else "OPTIONAL", "path": path})
wasm_module = ROOT / "node_modules" / "@mlightcad" / "libredwg-web"
checks.append(
{
"name": "libredwg-wasm",
"status": "PASS" if (wasm_module / "dist" / "libredwg-web.js").exists() else "OPTIONAL",
"path": str(wasm_module) if wasm_module.exists() else None,
}
)
for executable, resolver in (("ODAFileConverter", oda_converter), ("blender", default_blender)):
candidate = resolver()
path = candidate if candidate and Path(candidate).exists() else None
@@ -460,16 +470,24 @@ def doctor() -> int:
def inspect_command(args: argparse.Namespace) -> int:
# Internal pipeline scripts run from ROOT so their bundled assets and
# schemas have a stable base. User-provided paths, however, are relative
# to the directory where cad_showcase.py was invoked (the Task workdir),
# not to this repository. Resolve them before crossing that cwd boundary.
input_dir = Path(args.input).resolve()
work_dir = Path(args.work).resolve()
output_dir = Path(args.output).resolve()
vendor_dir = Path(args.vendor_dir).resolve()
command = python_script(
"cad_dxf_report.py",
"--input",
args.input,
str(input_dir),
"--work",
args.work,
str(work_dir),
"--output",
args.output,
str(output_dir),
"--vendor-dir",
args.vendor_dir,
str(vendor_dir),
"--converter",
args.converter,
)
@@ -519,6 +537,7 @@ def run_pipeline(args: argparse.Namespace) -> int:
source_report = Path(args.source_report).resolve()
scope_manifest = Path(args.scope_manifest).resolve()
frame_inputs = tuple(Path(path).resolve() for path in args.frames)
vendor_dir = Path(args.vendor_dir).resolve()
try:
waivers = parse_waivers(args.waiver)
except ValueError as exc:
@@ -590,7 +609,7 @@ def run_pipeline(args: argparse.Namespace) -> int:
"--out",
str(spec),
"--vendor-dir",
args.vendor_dir,
str(vendor_dir),
),
[spec],
forbidden_stderr=DERIVE_FORBIDDEN_WARNINGS,
@@ -606,10 +625,10 @@ def run_pipeline(args: argparse.Namespace) -> int:
"--out",
str(audit),
"--vendor-dir",
args.vendor_dir,
str(vendor_dir),
)
if args.frames:
audit_cmd.extend(["--frames", *args.frames])
if frame_inputs:
audit_cmd.extend(["--frames", *[str(path) for path in frame_inputs]])
pipeline.run("audit", audit_cmd, [audit, audit_md])
audit_report = json.loads(audit.read_text(encoding="utf-8"))
invalid_waivers = preflight_waiver_targets(args, report, audit_report, scope_manifest, waivers)
@@ -635,7 +654,7 @@ def run_pipeline(args: argparse.Namespace) -> int:
"--out-dir",
str(overlays),
"--vendor-dir",
args.vendor_dir,
str(vendor_dir),
),
[overlays],
)
@@ -687,7 +706,13 @@ def run_pipeline(args: argparse.Namespace) -> int:
browser_report = (
Path(args.browser_report).resolve() if args.browser_report else out_dir / "browser_smoke_report.json"
)
run_browser_smoke(pipeline, web_dir, browser_report, out_dir / "browser_smoke")
run_browser_smoke(
pipeline,
web_dir,
browser_report,
out_dir / "browser_smoke",
out_dir / "thumbnail.png",
)
standard = bundle / "variants" / "standard" / "standard.glb"
offline = out_dir / "viewer.html"

View File

@@ -718,7 +718,12 @@ def main() -> int:
"layer": "INSERT_NAME",
"_clip_hint": clip_hint,
"_preserve_component_union": key in preserve_component_union_keys,
"_include_block_names": [f"*-{label}"],
# Only a small number of large top-level view wrappers can be
# used as root INSERT selectors. Repeated family/component
# blocks also end in the view name in many Revit exports; using
# their suffix as a root filter drops unrelated wall/column
# INSERTs from the same floor.
**({"_include_block_names": [f"*-{label}"]} if 1 <= len(points) <= 3 and len(expanded) >= 50 else {}),
}
)

View File

@@ -12,6 +12,7 @@ function arg(name, fallback = null) {
const url = arg("--url");
const out = arg("--out", "browser_smoke_report.json");
const shots = arg("--screenshots-dir", "browser_smoke");
const thumbnailOut = arg("--thumbnail-out");
if (!url) {
throw new Error("Usage: web_smoke_test.mjs --url http://127.0.0.1:8188 --out report.json");
}
@@ -24,6 +25,7 @@ try {
}
await fs.mkdir(shots, { recursive: true });
if (thumbnailOut) await fs.mkdir(path.dirname(thumbnailOut), { recursive: true });
const browser = await chromium.launch({ headless: true });
const consoleErrors = [];
const pageErrors = [];
@@ -38,6 +40,10 @@ async function inspect(viewport, name) {
page.on("pageerror", (error) => pageErrors.push(error.message));
page.on("requestfailed", (request) => failedRequests.push(`${request.url()} ${request.failure()?.errorText || "failed"}`));
await page.goto(url, { waitUntil: "networkidle", timeout: 60000 });
// The loading overlay starts hidden, then becomes visible while metadata and
// the first GLB load. Waiting for "hidden" alone can pass before loading has
// even started. A rendered floor control is the first stable readiness fact.
await page.waitForSelector("#floor-controls label", { state: "visible", 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;
@@ -56,6 +62,36 @@ async function inspect(viewport, name) {
await page.waitForTimeout(1500);
const after = await page.evaluate(() => window.__renders || 0);
checks.push({ name: `${name}:idle-render`, status: after === before ? "PASS" : "FAIL", detail: `${before}->${after}` });
if (name === "desktop") {
const floorLabels = page.locator("#floor-controls label");
const floorLabelCount = await floorLabels.count();
if (floorLabelCount > 0) {
const floorLabel = floorLabels.nth(0);
const label = (await floorLabel.innerText()).trim();
await floorLabel.click();
await page.waitForTimeout(150);
const hashWritten = await page.evaluate(() => window.location.hash.length > 1);
await floorLabel.click();
await page.waitForTimeout(150);
checks.push({
name: "desktop:floor-state",
status: hashWritten ? "PASS" : "FAIL",
detail: hashWritten ? `Floor label serialized to URL hash: ${label}` : `URL hash was not written: ${label}`,
});
}
}
if (name === "desktop" && thumbnailOut) {
// Export the renderer itself. Cropping a page screenshot retains UI panels
// and makes Agents guess at a dark-background crop; the canvas is already
// the canonical customer model view. Zoom out a fixed amount so the white
// model remains a compact subject on the dark exhibit background.
const canvas = page.locator("#scene");
await canvas.hover();
await page.mouse.wheel(0, 1800);
await page.waitForTimeout(500);
const dataUrl = await canvas.evaluate((element) => element.toDataURL("image/png"));
await fs.writeFile(thumbnailOut, Buffer.from(dataUrl.split(",", 2)[1], "base64"));
}
await page.screenshot({ path: path.join(shots, `${name}.png`), fullPage: true });
await page.close();
}

View File

@@ -501,6 +501,37 @@ def test_report_empty_input_is_a_hard_failure(tmp_path: Path) -> None:
assert "all_sources_converted_and_readable" in proc.stderr
def test_inspect_resolves_relative_paths_from_invocation_directory(tmp_path: Path) -> None:
source_dir = tmp_path / "in" / "cad"
source_dir.mkdir(parents=True)
doc = ezdxf.new("R2010")
doc.modelspace().add_line((0, 0), (1000, 0), dxfattribs={"layer": "WALL"})
doc.saveas(source_dir / "plan.dxf")
proc = subprocess.run(
[
sys.executable,
str(ROOT / "scripts" / "cad_showcase.py"),
"inspect",
"--input",
"in/cad",
"--work",
"out/work",
"--output",
"out/report",
"--no-convert",
],
cwd=tmp_path,
text=True,
capture_output=True,
)
assert proc.returncode == 0, proc.stderr
report = json.loads((tmp_path / "out" / "report" / "cad_read_report.json").read_text(encoding="utf-8"))
assert report["gate"]["status"] == "PASS"
assert (tmp_path / "out" / "work" / "dxf_sanitized" / "plan.dxf").is_file()
def test_partial_report_requires_and_records_a_reason(tmp_path: Path) -> None:
proc = subprocess.run(
[
@@ -549,6 +580,34 @@ def test_no_convert_cannot_hide_dwg_sources(tmp_path: Path) -> None:
assert "unconverted.dwg" in report["gate"]["detail"]
def test_report_refuses_to_delete_input_inside_generated_work_dir(tmp_path: Path) -> None:
work = tmp_path / "work"
source_dir = work / "dxf_raw"
source_dir.mkdir(parents=True)
source = source_dir / "roof.dxf"
ezdxf.new("R2010").saveas(source)
proc = subprocess.run(
[
sys.executable,
str(ROOT / "scripts" / "cad_dxf_report.py"),
"--input",
str(source_dir),
"--work",
str(work),
"--output",
str(tmp_path / "report"),
"--no-convert",
],
text=True,
capture_output=True,
)
assert proc.returncode != 0
assert "would be deleted before inspection" in proc.stderr
assert source.exists()
def test_variants_manifest_is_versioned(tmp_path: Path) -> None:
spec_path = tmp_path / "spec.json"
spec_path.write_text(json.dumps(minimal_spec()), encoding="utf-8")

View File

@@ -210,16 +210,17 @@ def make_revit_overlapping_roof_dxf(path: Path) -> None:
for layer in ("I-WALL", "S-GRID", "A-DOOR"):
doc.layers.add(layer)
msp = doc.modelspace()
for i in range(12):
x = 4000.0 * i
msp.add_line((x, 0), (x, 24000), dxfattribs={"layer": "I-WALL"})
for y in (0, 8000, 16000, 24000):
msp.add_line((0, y), (44000, y), dxfattribs={"layer": "S-GRID"})
for title in ("屋面平面图", "机房小屋面"):
block = doc.blocks.new(name=f"屋面构件-{title}")
block.add_line((0, 0), (900, 0), dxfattribs={"layer": "A-DOOR"})
for i in range(12):
msp.add_blockref(block.name, (4000.0 * i, 2000.0 * (i % 10)))
for index, title in enumerate(("屋面平面图", "机房小屋面"), start=1):
# True view wrapper: one large root INSERT carries the whole plan. This
# is intentionally different from repeated family blocks whose names
# also end in a floor title.
block = doc.blocks.new(name=f"NY-ARCH_rvt-{index}-{title}")
for i in range(55):
x = 800.0 * i
block.add_line((x, 0), (x, 24000), dxfattribs={"layer": "I-WALL"})
for y in (0, 4000, 8000, 12000, 16000, 20000, 24000):
block.add_line((0, y), (43200, y), dxfattribs={"layer": "S-GRID"})
msp.add_blockref(block.name, (0, 0))
doc.saveas(path)
@@ -870,6 +871,11 @@ def main() -> int:
revit_clips = {f["key"]: f["clip"] for f in revit_floors}
separated = revit_clips.get("F1", [0, 0, 0, 0])[2] < revit_clips.get("F2", [0, 0, 0, 0])[0]
check("Revit INSERT-name clips stay spatially separated", separated, str(revit_clips))
check(
"repeated Revit family suffixes do not become root selectors",
all("include_block_names" not in floor for floor in revit_floors),
str(revit_floors),
)
roof_path = revit_dir / "A212 - 主楼屋顶平面图.dxf"
make_revit_overlapping_roof_dxf(roof_path)