Skip to content

Commit 4b21f22

Browse files
agviegasclaude
andcommitted
fix(app-template): frame the viewer + open empty (no auto-load)
- Border + 0.75rem radius on the viewport so it matches the side panels. - Remove autoLoadFirstModel: the viewer opens empty and users add models from the Assets panel instead of a building loading by default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7e1e258 commit 4b21f22

1 file changed

Lines changed: 10 additions & 34 deletions

File tree

src/cli/templates/app/src/main.ts

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ async function main() {
4545
// visibility/inspect toolbar (see below), so the platform default would just
4646
// duplicate it.
4747
const viewerEl = document.createElement("top-viewer");
48+
// Frame the viewport to match the side panels (BUI bim-panel host = 1px border
49+
// + 0.75rem radius). top-viewer's host is already overflow:hidden, so the
50+
// radius clips the canvas corners; border-box keeps the 1px inside the grid
51+
// area. Done here (not in top-viewer) so the CDE's top-file-viewer, which draws
52+
// its own frame, never double-borders.
53+
viewerEl.style.border = "1px solid var(--bim-ui_bg-contrast-20)";
54+
viewerEl.style.borderRadius = "0.75rem";
55+
viewerEl.style.boxSizing = "border-box";
4856

4957
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5058
const app = document.createElement("top-app") as any;
@@ -169,8 +177,8 @@ async function main() {
169177
// Navigation gizmo is now baked into <top-viewer> (setupViewerTools), so the
170178
// app no longer mounts it. (Cascade: the rest of the overlay tools follow.)
171179

172-
// Auto-load one model (top-viewer's world wires fragments→scene itself).
173-
void autoLoadFirstModel(components, client);
180+
// No auto-load: the viewer opens empty. Users add models from the Assets
181+
// (files) panel — top-models-list loads the .frag they pick into the world.
174182
}
175183

176184
/** Resolves with the first world once it exists (top-viewer creates it async). */
@@ -188,36 +196,4 @@ function firstWorld(worlds: any): Promise<any> {
188196
});
189197
}
190198

191-
192-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
193-
async function autoLoadFirstModel(components: OBC.Components, client: any) {
194-
const fragments = components.get(OBC.FragmentsManager);
195-
const projectId: string | undefined = client?.context?.projectId;
196-
if (!projectId) {
197-
console.warn("[a2] no projectId — skipping auto-load");
198-
return;
199-
}
200-
try {
201-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
202-
const items = (await client.listFiles({ projectId })) as any[];
203-
const frags = items.filter((it) =>
204-
(it.name ?? "").toLowerCase().endsWith(".frag"),
205-
);
206-
const frag =
207-
frags.find((it) => (it.name ?? "").toLowerCase().includes("bloxhub")) ??
208-
frags[0];
209-
if (!frag) {
210-
console.warn("[a2] no .frag in project to auto-load");
211-
return;
212-
}
213-
const resp = await client.downloadFile(String(frag._id));
214-
const buffer = await resp.arrayBuffer();
215-
await fragments.core.load(buffer, { modelId: String(frag._id) });
216-
await fragments.core.update(true);
217-
console.log("[a2] auto-loaded model:", frag.name);
218-
} catch (error) {
219-
console.warn("[a2] auto-load failed", error);
220-
}
221-
}
222-
223199
main().catch(console.error);

0 commit comments

Comments
 (0)