From aebcedaf71d77521096f874ce97394c0b8ed7b4e Mon Sep 17 00:00:00 2001 From: 134 Date: Mon, 27 Jul 2026 19:20:20 +0800 Subject: [PATCH] fix: frame complete HiCAD models after generation --- scripts/vendor-zoo-modeling-app.mjs | 19 +++++++++++++++++++ .../routes/hicad-embedded-performance.test.ts | 14 ++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/scripts/vendor-zoo-modeling-app.mjs b/scripts/vendor-zoo-modeling-app.mjs index 391df5af4..bc596e1f6 100644 --- a/scripts/vendor-zoo-modeling-app.mjs +++ b/scripts/vendor-zoo-modeling-app.mjs @@ -269,6 +269,25 @@ function patchOfficialSource() { ` // We need a padding of 0.1 for zoom_to_fit for all E2E tests since they were originally\n // written with zoom_to_fit with padding 0.1\n const padding = 0.1\n if (isPlaywright()) {`, ` // Keep the official E2E framing stable while giving HiCAD users enough\n // breathing room to see the complete model after generation and file loads.\n const padding = isPlaywright() ? 0.1 : 0.35\n if (isPlaywright()) {` ); + replaceSource( + "src/lib/resetCameraPosition.ts", + ` await engineViewIsometric({ + engineCommandManager, + padding, + })`, + ` await engineViewIsometric({ + engineCommandManager, + padding, + }) + + // view_isometric changes the direction but can preserve the previous + // close-up distance. Refit against every generated entity so newly + // completed models open fully framed instead of showing a local detail. + await engineStreamZoomToFit({ + engineCommandManager, + padding, + })` + ); replaceSource( "src/lib/commandBarConfigs/standardViewsConfig.ts", "engineStreamZoomToFit({ engineCommandManager, padding: 0.1 })", diff --git a/tests/routes/hicad-embedded-performance.test.ts b/tests/routes/hicad-embedded-performance.test.ts index 40e936a5f..32f56b122 100644 --- a/tests/routes/hicad-embedded-performance.test.ts +++ b/tests/routes/hicad-embedded-performance.test.ts @@ -40,4 +40,18 @@ test.describe("HiCAD embedded startup", () => { /location = \/vendor\/zoo-modeling-app\/kcl_wasm_lib_bg\.wasm \{[\s\S]*?gzip_static on;/ ); }); + + test("fits the complete generated model after selecting the isometric view", () => { + const vendorScript = fs.readFileSync( + path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"), + "utf8" + ); + + expect(vendorScript).toMatch( + /await engineViewIsometric\(\{[\s\S]*?await engineStreamZoomToFit\(\{\s*engineCommandManager,\s*padding,/ + ); + expect(vendorScript).toContain( + "Refit against every generated entity so newly" + ); + }); });