@thatopen/services 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +59 -59
  2. package/dist/built-in/index.d.ts +486 -563
  3. package/dist/cli.js +10 -0
  4. package/dist/index.cjs.js +2 -2
  5. package/dist/index.es.js +3 -5
  6. package/dist/vite-env.d.ts +1 -1
  7. package/docs/builtin/paths.json +74 -70
  8. package/docs/cli/create.md +28 -28
  9. package/docs/cli/local-server.md +38 -38
  10. package/docs/cli/login.md +32 -32
  11. package/docs/cli/publish.md +31 -31
  12. package/docs/cli/run.md +26 -26
  13. package/docs/cli/serve.md +43 -43
  14. package/docs/cli/swap.md +30 -30
  15. package/package.json +100 -100
  16. package/resources/AGENTS.md +40 -40
  17. package/src/built-in/CDEManager/example.ts +214 -214
  18. package/src/built-in/CDEManager/examples/FileEditing/example.ts +226 -226
  19. package/src/built-in/CDEManager/examples/FileMoves/example.ts +186 -186
  20. package/src/built-in/CDEManager/examples/FileOperations/example.ts +295 -295
  21. package/src/built-in/CDEManager/examples/FileTransfers/example.ts +210 -210
  22. package/src/built-in/CDEManager/examples/FolderManagement/example.ts +230 -230
  23. package/src/built-in/CDEManager/examples/MetadataSchema/example.ts +230 -230
  24. package/src/built-in/CDEManager/examples/MetadataViews/example.ts +166 -166
  25. package/src/built-in/CDEManager/examples/ProjectConfig/example.ts +177 -177
  26. package/src/built-in/UIManager/src/app/example.ts +99 -99
  27. package/src/built-in/UIManager/src/app/examples/AppState/example.ts +142 -142
  28. package/src/built-in/UIManager/src/app/examples/Banner/example.ts +161 -0
  29. package/src/built-in/UIManager/src/app/examples/Contexts/example.ts +125 -125
  30. package/src/built-in/UIManager/src/app/examples/FileDrop/example.ts +126 -0
  31. package/src/built-in/UIManager/src/app/examples/FloatingLayout/example.ts +92 -92
  32. package/src/built-in/UIManager/src/app/examples/Modal/example.ts +165 -0
  33. package/src/built-in/UIManager/src/app/examples/Notifications/example.ts +135 -161
  34. package/src/built-in/UIManager/src/app/examples/Sidebar/example.ts +104 -104
  35. package/src/built-in/index.ts +649 -755
  36. package/src/cli/templates/app/README.md +241 -241
  37. package/src/cli/templates/app/index.html +35 -27
  38. package/src/cli/templates/app/package.json +31 -27
  39. package/src/cli/templates/app/src/app.ts +37 -0
  40. package/src/cli/templates/app/src/assets/tool-placeholder.ts +50 -0
  41. package/src/cli/templates/app/src/bim-components/CloudRunner/index.ts +95 -87
  42. package/src/cli/templates/app/src/bim-components/CloudRunner/src/index.ts +1 -1
  43. package/src/cli/templates/app/src/bim-components/CloudRunner/src/types.ts +5 -5
  44. package/src/cli/templates/app/src/bim-components/index.ts +1 -1
  45. package/src/cli/templates/app/src/globals.ts +1 -0
  46. package/src/cli/templates/app/src/main.ts +340 -56
  47. package/src/cli/templates/app/src/setups/active-tool-hud.ts +69 -0
  48. package/src/cli/templates/app/src/setups/camera-tools.ts +63 -0
  49. package/src/cli/templates/app/src/setups/camera-views.ts +201 -0
  50. package/src/cli/templates/app/src/setups/card-header.ts +35 -0
  51. package/src/cli/templates/app/src/setups/clipper-panel.ts +167 -0
  52. package/src/cli/templates/app/src/setups/clipper-tool.ts +754 -0
  53. package/src/cli/templates/app/src/setups/clipper.ts +75 -0
  54. package/src/cli/templates/app/src/setups/cloud-runner.ts +13 -9
  55. package/src/cli/templates/app/src/setups/commands-panel.ts +239 -0
  56. package/src/cli/templates/app/src/setups/data-table-panel.ts +2224 -0
  57. package/src/cli/templates/app/src/setups/exploded-view.ts +246 -0
  58. package/src/cli/templates/app/src/setups/file-format-icons.ts +95 -0
  59. package/src/cli/templates/app/src/setups/files-panel.ts +1503 -0
  60. package/src/cli/templates/app/src/setups/fps-indicator.ts +63 -0
  61. package/src/cli/templates/app/src/setups/graphics-panel.ts +490 -0
  62. package/src/cli/templates/app/src/setups/helper-panel.ts +88 -0
  63. package/src/cli/templates/app/src/setups/hider.ts +98 -0
  64. package/src/cli/templates/app/src/setups/index.ts +33 -3
  65. package/src/cli/templates/app/src/setups/inspection.ts +136 -0
  66. package/src/cli/templates/app/src/setups/measurement-panel.ts +188 -0
  67. package/src/cli/templates/app/src/setups/measurement-settings-panel.ts +161 -0
  68. package/src/cli/templates/app/src/setups/measurement-tool.ts +570 -0
  69. package/src/cli/templates/app/src/setups/measurements.ts +133 -0
  70. package/src/cli/templates/app/src/setups/model-tree.ts +797 -0
  71. package/src/cli/templates/app/src/setups/navigation-gizmo.ts +316 -0
  72. package/src/cli/templates/app/src/setups/objects-panel.ts +127 -0
  73. package/src/cli/templates/app/src/setups/plans-panel.ts +619 -0
  74. package/src/cli/templates/app/src/setups/properties-panel.ts +1048 -0
  75. package/src/cli/templates/app/src/setups/reality-capture/lib/hidden-tiles-plugin.ts +88 -0
  76. package/src/cli/templates/app/src/setups/reality-capture/lib/point-tile-plugin.ts +166 -0
  77. package/src/cli/templates/app/src/setups/reality-capture/lib/render-frame.ts +31 -0
  78. package/src/cli/templates/app/src/setups/reality-capture/lib/splat-tile-plugin.ts +51 -0
  79. package/src/cli/templates/app/src/setups/reality-capture-viewer.ts +1383 -0
  80. package/src/cli/templates/app/src/setups/right-sidebar.ts +178 -0
  81. package/src/cli/templates/app/src/setups/settings-panel.ts +94 -0
  82. package/src/cli/templates/app/src/setups/styles-panel.ts +110 -0
  83. package/src/cli/templates/app/src/setups/styles.ts +375 -0
  84. package/src/cli/templates/app/src/setups/tool-mode-manager.ts +150 -0
  85. package/src/cli/templates/app/src/setups/tool-mode.ts +23 -0
  86. package/src/cli/templates/app/src/setups/toolbar.ts +229 -0
  87. package/src/cli/templates/app/src/setups/ui-manager.ts +27 -0
  88. package/src/cli/templates/app/src/setups/visibility-toolbar.ts +498 -0
  89. package/src/cli/templates/app/src/setups/walkthrough.ts +528 -0
  90. package/src/cli/templates/app/src/ui-components/app-info-section/index.ts +26 -0
  91. package/src/cli/templates/app/src/ui-components/app-info-section/src/index.ts +1 -0
  92. package/src/cli/templates/app/src/ui-components/app-info-section/src/types.ts +15 -0
  93. package/src/cli/templates/app/src/ui-components/cloud-runner-section/index.ts +37 -0
  94. package/src/cli/templates/app/src/ui-components/cloud-runner-section/src/index.ts +1 -0
  95. package/src/cli/templates/app/src/ui-components/cloud-runner-section/src/types.ts +14 -0
  96. package/src/cli/templates/app/src/ui-components/index.ts +2 -1
  97. package/src/cli/templates/app/tsconfig.json +16 -17
  98. package/src/cli/templates/app/vite.config.js +45 -42
  99. package/src/cli/templates/cloud-component/README.md +205 -205
  100. package/src/cli/templates/cloud-component/_thatopen +5 -5
  101. package/src/cli/templates/cloud-component/declarations.json +4 -4
  102. package/src/cli/templates/cloud-component/package.json +21 -21
  103. package/src/cli/templates/cloud-component/src/main.ts +70 -70
  104. package/src/cli/templates/cloud-component/tsconfig.json +16 -16
  105. package/src/cli/templates/cloud-component/vite.config.js +46 -46
  106. package/src/cli/templates/shared/AGENTS.md +8 -8
  107. package/src/cli/templates/shared/CLAUDE.md +1 -1
  108. package/src/cli/templates/shared/_gitignore +5 -5
  109. package/src/built-in/AppManager/example.ts +0 -86
  110. package/src/built-in/FileList/example.ts +0 -107
  111. package/src/built-in/TabbedNavigation/example.ts +0 -115
  112. package/src/built-in/ViewportsManager/example.ts +0 -106
  113. package/src/cli/templates/app/src/setups/fragments.ts +0 -18
  114. package/src/cli/templates/app/src/setups/ifc-loader.ts +0 -12
  115. package/src/cli/templates/app/src/ui-components/AppPanel/index.ts +0 -160
@@ -1,125 +1,125 @@
1
- /* MD
2
- ## Consuming platform contexts in child components
3
- ---
4
- Developers building custom BIM panels need access to the 3D engine, the platform
5
- API, and the current project's metadata — but threading these objects down through
6
- props across multiple component layers forces every intermediate element to know
7
- about data it doesn't use, making trees brittle and hard to refactor.
8
-
9
- top-app publishes the engine instance, the platform client, and the current
10
- project data as named reactive contexts, so any descendant component can subscribe
11
- to exactly what it needs without any prop drilling from the root.
12
-
13
- This tutorial covers defining a custom panel that subscribes to the engine
14
- context, the platform client context, and the project data context; handling the
15
- intermediate loading state before contexts become available after boot; and
16
- mounting the panel inside a top-app layout.
17
-
18
- By the end, you'll have a custom info panel that reads the project name and engine
19
- state directly from context, with no objects passed down as props from the app root.
20
- */
21
-
22
- import { html, LitElement } from "lit";
23
- import { customElement, state } from "lit/decorators.js";
24
- import { consume } from "@lit/context";
25
- import * as THREE from "three";
26
- import * as OBC from "@thatopen/components";
27
- import * as OBF from "@thatopen/components-front";
28
- import * as FRAGS from "@thatopen/fragments";
29
- import * as BUI from "@thatopen/ui";
30
- import { PlatformClient, ProjectData } from "thatopen-services";
31
- import uiManagerDef from "../../../../index";
32
- import {
33
- componentsContext,
34
- clientContext,
35
- projectDataContext,
36
- appStateContext,
37
- type App,
38
- type AppState,
39
- } from "../../index";
40
-
41
- // appStateContext is provided by top-app immediately — before setup completes.
42
- // componentsContext, clientContext, and projectDataContext become available only
43
- // after app.setup returns and all waitUntil promises resolve.
44
- @customElement("project-info-panel")
45
- class ProjectInfoPanel extends LitElement {
46
- @consume({ context: appStateContext, subscribe: true })
47
- @state()
48
- private _appState?: AppState;
49
-
50
- @consume({ context: componentsContext, subscribe: true })
51
- @state()
52
- private _components?: OBC.Components;
53
-
54
- @consume({ context: clientContext, subscribe: true })
55
- @state()
56
- private _client?: PlatformClient;
57
-
58
- @consume({ context: projectDataContext, subscribe: true })
59
- @state()
60
- private _projectData?: ProjectData;
61
-
62
- render() {
63
- if (!this._components || !this._client || !this._projectData) {
64
- return html`<bim-label>Loading…</bim-label>`;
65
- }
66
- return html`
67
- <bim-panel label="Project Info">
68
- <bim-panel-section label="Project" icon="solar:buildings-bold">
69
- <bim-label .value=${this._projectData.name}></bim-label>
70
- </bim-panel-section>
71
- <bim-panel-section label="Engine" icon="solar:cpu-bold">
72
- <bim-label>Components ready</bim-label>
73
- </bim-panel-section>
74
- </bim-panel>
75
- `;
76
- }
77
- }
78
-
79
- // ---- app wiring ----
80
-
81
- const UIManager = uiManagerDef.componentDefinition;
82
- const client = PlatformClient.fromPlatformContext();
83
- const { components } = (await client.setup(
84
- { OBC, OBF, BUI, THREE, FRAGS },
85
- { uuid: UIManager.uuid },
86
- )) as { components: OBC.Components };
87
- components.get(UIManager).init();
88
-
89
- const app = document.createElement("top-app") as unknown as App;
90
-
91
- app.setup = (waitUntil) => {
92
- waitUntil(
93
- (async () => {
94
- const fragments = components.get(OBC.FragmentsManager);
95
- const workerUrl = await FRAGS.FragmentsModels.getWorker();
96
- fragments.init(await FRAGS.toClassicWorker(workerUrl), {
97
- classicWorker: true,
98
- });
99
- })(),
100
- "Fragments Core",
101
- );
102
- return { components, client };
103
- };
104
-
105
- app.elements = {
106
- viewer: () =>
107
- html`<top-viewer><top-viewer-tools></top-viewer-tools></top-viewer>`,
108
-
109
- // Any element rendered inside top-app can consume the contexts above.
110
- info: () => html`<project-info-panel></project-info-panel>`,
111
- };
112
-
113
- app.base = "viewer";
114
- app.layouts = {
115
- main: {
116
- label: "Main",
117
- icon: "solar:home-bold",
118
- template: `"info" 1fr / 22rem`,
119
- },
120
- };
121
- app.layout = "main";
122
-
123
- const container = document.getElementById("that-open-app") ?? document.body;
124
- container.appendChild(app);
125
- document.body.style.margin = "0";
1
+ /* MD
2
+ ## Consuming platform contexts in child components
3
+ ---
4
+ Developers building custom BIM panels need access to the 3D engine, the platform
5
+ API, and the current project's metadata — but threading these objects down through
6
+ props across multiple component layers forces every intermediate element to know
7
+ about data it doesn't use, making trees brittle and hard to refactor.
8
+
9
+ top-app publishes the engine instance, the platform client, and the current
10
+ project data as named reactive contexts, so any descendant component can subscribe
11
+ to exactly what it needs without any prop drilling from the root.
12
+
13
+ This tutorial covers defining a custom panel that subscribes to the engine
14
+ context, the platform client context, and the project data context; handling the
15
+ intermediate loading state before contexts become available after boot; and
16
+ mounting the panel inside a top-app layout.
17
+
18
+ By the end, you'll have a custom info panel that reads the project name and engine
19
+ state directly from context, with no objects passed down as props from the app root.
20
+ */
21
+
22
+ import { html, LitElement } from "lit";
23
+ import { customElement, state } from "lit/decorators.js";
24
+ import { consume } from "@lit/context";
25
+ import * as THREE from "three";
26
+ import * as OBC from "@thatopen/components";
27
+ import * as OBF from "@thatopen/components-front";
28
+ import * as FRAGS from "@thatopen/fragments";
29
+ import * as BUI from "@thatopen/ui";
30
+ import { PlatformClient, ProjectData } from "thatopen-services";
31
+ import uiManagerDef from "../../../../index";
32
+ import {
33
+ componentsContext,
34
+ clientContext,
35
+ projectDataContext,
36
+ appStateContext,
37
+ type App,
38
+ type AppState,
39
+ } from "../../index";
40
+
41
+ // appStateContext is provided by top-app immediately — before setup completes.
42
+ // componentsContext, clientContext, and projectDataContext become available only
43
+ // after app.setup returns and all waitUntil promises resolve.
44
+ @customElement("project-info-panel")
45
+ class ProjectInfoPanel extends LitElement {
46
+ @consume({ context: appStateContext, subscribe: true })
47
+ @state()
48
+ private _appState?: AppState;
49
+
50
+ @consume({ context: componentsContext, subscribe: true })
51
+ @state()
52
+ private _components?: OBC.Components;
53
+
54
+ @consume({ context: clientContext, subscribe: true })
55
+ @state()
56
+ private _client?: PlatformClient;
57
+
58
+ @consume({ context: projectDataContext, subscribe: true })
59
+ @state()
60
+ private _projectData?: ProjectData;
61
+
62
+ render() {
63
+ if (!this._components || !this._client || !this._projectData) {
64
+ return html`<bim-label>Loading…</bim-label>`;
65
+ }
66
+ return html`
67
+ <bim-panel label="Project Info">
68
+ <bim-panel-section label="Project" icon="solar:buildings-bold">
69
+ <bim-label .value=${this._projectData.name}></bim-label>
70
+ </bim-panel-section>
71
+ <bim-panel-section label="Engine" icon="solar:cpu-bold">
72
+ <bim-label>Components ready</bim-label>
73
+ </bim-panel-section>
74
+ </bim-panel>
75
+ `;
76
+ }
77
+ }
78
+
79
+ // ---- app wiring ----
80
+
81
+ const UIManager = uiManagerDef.componentDefinition;
82
+ const client = PlatformClient.fromPlatformContext();
83
+ const { components } = (await client.setup(
84
+ { OBC, OBF, BUI, THREE, FRAGS },
85
+ { uuid: UIManager.uuid },
86
+ )) as { components: OBC.Components };
87
+ components.get(UIManager).init();
88
+
89
+ const app = document.createElement("top-app") as unknown as App;
90
+
91
+ app.setup = (waitUntil) => {
92
+ waitUntil(
93
+ (async () => {
94
+ const fragments = components.get(OBC.FragmentsManager);
95
+ const workerUrl = await FRAGS.FragmentsModels.getWorker();
96
+ fragments.init(await FRAGS.toClassicWorker(workerUrl), {
97
+ classicWorker: true,
98
+ });
99
+ })(),
100
+ "Fragments Core",
101
+ );
102
+ return { components, client };
103
+ };
104
+
105
+ app.elements = {
106
+ viewer: () =>
107
+ html`<top-viewer><top-viewer-tools></top-viewer-tools></top-viewer>`,
108
+
109
+ // Any element rendered inside top-app can consume the contexts above.
110
+ info: () => html`<project-info-panel></project-info-panel>`,
111
+ };
112
+
113
+ app.base = "viewer";
114
+ app.layouts = {
115
+ main: {
116
+ label: "Main",
117
+ icon: "solar:home-bold",
118
+ template: `"info" 1fr / 22rem`,
119
+ },
120
+ };
121
+ app.layout = "main";
122
+
123
+ const container = document.getElementById("that-open-app") ?? document.body;
124
+ container.appendChild(app);
125
+ document.body.style.margin = "0";
@@ -0,0 +1,126 @@
1
+ /* MD
2
+ ## File drag-and-drop with top:files-dropped
3
+ ---
4
+ Desktop BIM workflows often rely on dragging files straight from the OS file
5
+ manager onto the browser window — but wiring a document-level dragenter,
6
+ dragover, dragleave, and drop handler that correctly tracks nested enter/leave
7
+ counts, shows a visual overlay, and forwards the files to the right component
8
+ is tedious boilerplate to repeat for every app.
9
+
10
+ top-app handles all of that automatically. It listens for file drag events on
11
+ the document, shows a configurable overlay while files are in flight, and fires
12
+ a single top:files-dropped event when the user releases the files. The drop
13
+ message can be a static string or a function evaluated at render time, so it
14
+ can reflect live application state.
15
+
16
+ This tutorial covers receiving dropped files via top:files-dropped; filtering
17
+ them by extension and surfacing a warning when none are supported; setting
18
+ dropMessage as a function that reads a live model counter so the hint text
19
+ updates as models are loaded; and showing a toast on success using the
20
+ top:notification event from the same handler.
21
+
22
+ By the end, you'll have an app with a drag-and-drop zone whose overlay message
23
+ adapts to how many models are already loaded, and that reports unsupported
24
+ files with a warning toast.
25
+ */
26
+
27
+ import { html } from "lit";
28
+ import * as THREE from "three";
29
+ import * as OBC from "@thatopen/components";
30
+ import * as OBF from "@thatopen/components-front";
31
+ import * as FRAGS from "@thatopen/fragments";
32
+ import * as BUI from "@thatopen/ui";
33
+ import { PlatformClient } from "thatopen-services";
34
+ import uiManagerDef from "../../../../index";
35
+ import type { App, AppReadyEvent } from "../../index";
36
+
37
+ const UIManager = uiManagerDef.componentDefinition;
38
+ const client = PlatformClient.fromPlatformContext();
39
+ const { components } = (await client.setup(
40
+ { OBC, OBF, BUI, THREE, FRAGS },
41
+ { uuid: UIManager.uuid },
42
+ )) as { components: OBC.Components };
43
+ components.get(UIManager).init();
44
+
45
+ const app = document.createElement("top-app") as unknown as App;
46
+
47
+ app.setup = (waitUntil) => {
48
+ waitUntil(
49
+ (async () => {
50
+ const fragments = components.get(OBC.FragmentsManager);
51
+ const workerUrl = await FRAGS.FragmentsModels.getWorker();
52
+ fragments.init(await FRAGS.toClassicWorker(workerUrl), {
53
+ classicWorker: true,
54
+ });
55
+ })(),
56
+ "Fragments Core",
57
+ );
58
+ return { components, client };
59
+ };
60
+
61
+ app.elements = {
62
+ viewer: () =>
63
+ html`<top-viewer><top-viewer-tools></top-viewer-tools></top-viewer>`,
64
+ };
65
+
66
+ app.base = "viewer";
67
+ app.layouts = {
68
+ main: {
69
+ label: "Main",
70
+ icon: "solar:home-bold",
71
+ template: `"_" 1fr / 1fr`,
72
+ },
73
+ };
74
+ app.layout = "main";
75
+
76
+ // dropMessage as a function is evaluated at render time so it can read live state.
77
+ // Here it reads how many models are already loaded and adjusts the hint text.
78
+ let loadedCount = 0;
79
+ app.dropMessage = () =>
80
+ loadedCount === 0
81
+ ? "Drop an IFC or FRAG file to load your first model"
82
+ : `Drop a file to add to the ${loadedCount} loaded model${loadedCount === 1 ? "" : "s"}`;
83
+
84
+ // top:files-dropped fires when the user drops files onto the window.
85
+ // e.detail.files is a File[]. Handle upload, load, or validation here.
86
+ app.addEventListener("top:files-dropped", (e) => {
87
+ const { files } = (e as CustomEvent<{ files: File[] }>).detail;
88
+
89
+ const supported = files.filter(
90
+ (f) => f.name.endsWith(".ifc") || f.name.endsWith(".frag"),
91
+ );
92
+
93
+ // Dispatch top:notification to surface feedback without a reference to top-app.
94
+ if (!supported.length) {
95
+ app.dispatchEvent(
96
+ new CustomEvent("top:notification", {
97
+ bubbles: true,
98
+ composed: true,
99
+ detail: { message: "No supported files dropped", type: "warning" },
100
+ }),
101
+ );
102
+ return;
103
+ }
104
+
105
+ loadedCount += supported.length;
106
+ app.dispatchEvent(
107
+ new CustomEvent("top:notification", {
108
+ bubbles: true,
109
+ composed: true,
110
+ detail: {
111
+ message: `${supported.length} file${supported.length === 1 ? "" : "s"} received`,
112
+ type: "success",
113
+ description: supported.map((f) => f.name).join(", "),
114
+ },
115
+ }),
116
+ );
117
+ });
118
+
119
+ app.addEventListener("top:app-ready", (e) => {
120
+ const { app: readyApp } = (e as AppReadyEvent).detail;
121
+ readyApp.showToast("App ready — try dropping an IFC or FRAG file", "info");
122
+ });
123
+
124
+ const container = document.getElementById("that-open-app") ?? document.body;
125
+ container.appendChild(app);
126
+ document.body.style.margin = "0";
@@ -1,92 +1,92 @@
1
- /* MD
2
- ## Floating layout
3
- ---
4
- Developers building BIM coordination tools often want the 3D model to fill the
5
- entire window while control panels float above it — but standard grid layouts
6
- give every area equal standing, shrinking the viewer into one cell and leaving
7
- visible seams between it and the panels.
8
-
9
- top-app supports a floating mode where one element is mounted as an absolute
10
- background that fills the container edge-to-edge, and all other layout areas
11
- render as a transparent overlay on top of it with independent pointer events.
12
-
13
- This tutorial covers assigning the viewer as the absolute background of the app;
14
- defining an overlay layout where a side panel floats above the viewer without
15
- sharing grid space; and annotating why the base element is excluded from the
16
- layout template.
17
-
18
- By the end, you'll have a full-screen 3D viewer with a floating side panel
19
- hovering above it, with the model filling the entire window and the panel
20
- receiving its own pointer events.
21
- */
22
-
23
- import { html } from "lit";
24
- import * as THREE from "three";
25
- import * as OBC from "@thatopen/components";
26
- import * as OBF from "@thatopen/components-front";
27
- import * as FRAGS from "@thatopen/fragments";
28
- import * as BUI from "@thatopen/ui";
29
- import { PlatformClient } from "thatopen-services";
30
- import uiManagerDef from "../../../../index";
31
- import type { App } from "../../index";
32
-
33
- const UIManager = uiManagerDef.componentDefinition;
34
- const client = PlatformClient.fromPlatformContext();
35
- const { components } = (await client.setup(
36
- { OBC, OBF, BUI, THREE, FRAGS },
37
- { uuid: UIManager.uuid },
38
- )) as { components: OBC.Components };
39
- components.get(UIManager).init();
40
-
41
- const app = document.createElement("top-app") as unknown as App;
42
-
43
- app.setup = (waitUntil) => {
44
- waitUntil(
45
- (async () => {
46
- const fragments = components.get(OBC.FragmentsManager);
47
- const workerUrl = await FRAGS.FragmentsModels.getWorker();
48
- fragments.init(await FRAGS.toClassicWorker(workerUrl), {
49
- classicWorker: true,
50
- });
51
- })(),
52
- "Fragments Core",
53
- );
54
- return { components, client };
55
- };
56
-
57
- app.elements = {
58
- // "viewer" is referenced by app.base — rendered as a position:absolute layer
59
- // behind all layout content so it fills the container edge-to-edge.
60
- viewer: () =>
61
- html`<top-viewer><top-viewer-tools></top-viewer-tools></top-viewer>`,
62
-
63
- // Panels declared here appear in the floating content grid on top of the viewer.
64
- // Their container has pointer-events: none; each child re-enables them individually.
65
- panel: () => html`
66
- <bim-panel>
67
- <bim-panel-section label="Models" icon="solar:layers-bold">
68
- <bim-label>Load models here</bim-label>
69
- </bim-panel-section>
70
- </bim-panel>
71
- `,
72
- };
73
-
74
- // Setting app.base to an element key mounts that element as the absolute background.
75
- // Layout templates then only list the floating overlay areas — not the base element.
76
- // Without app.base, every area in the template is a peer grid cell (inline mode).
77
- app.base = "viewer";
78
-
79
- app.layouts = {
80
- main: {
81
- label: "Main",
82
- icon: "solar:home-bold",
83
- // Only overlay areas appear here. "viewer" is not listed because it is the base.
84
- template: `"panel" 1fr / 22rem`,
85
- },
86
- };
87
-
88
- app.layout = "main";
89
-
90
- const container = document.getElementById("that-open-app") ?? document.body;
91
- container.appendChild(app);
92
- document.body.style.margin = "0";
1
+ /* MD
2
+ ## Floating layout
3
+ ---
4
+ Developers building BIM coordination tools often want the 3D model to fill the
5
+ entire window while control panels float above it — but standard grid layouts
6
+ give every area equal standing, shrinking the viewer into one cell and leaving
7
+ visible seams between it and the panels.
8
+
9
+ top-app supports a floating mode where one element is mounted as an absolute
10
+ background that fills the container edge-to-edge, and all other layout areas
11
+ render as a transparent overlay on top of it with independent pointer events.
12
+
13
+ This tutorial covers assigning the viewer as the absolute background of the app;
14
+ defining an overlay layout where a side panel floats above the viewer without
15
+ sharing grid space; and annotating why the base element is excluded from the
16
+ layout template.
17
+
18
+ By the end, you'll have a full-screen 3D viewer with a floating side panel
19
+ hovering above it, with the model filling the entire window and the panel
20
+ receiving its own pointer events.
21
+ */
22
+
23
+ import { html } from "lit";
24
+ import * as THREE from "three";
25
+ import * as OBC from "@thatopen/components";
26
+ import * as OBF from "@thatopen/components-front";
27
+ import * as FRAGS from "@thatopen/fragments";
28
+ import * as BUI from "@thatopen/ui";
29
+ import { PlatformClient } from "thatopen-services";
30
+ import uiManagerDef from "../../../../index";
31
+ import type { App } from "../../index";
32
+
33
+ const UIManager = uiManagerDef.componentDefinition;
34
+ const client = PlatformClient.fromPlatformContext();
35
+ const { components } = (await client.setup(
36
+ { OBC, OBF, BUI, THREE, FRAGS },
37
+ { uuid: UIManager.uuid },
38
+ )) as { components: OBC.Components };
39
+ components.get(UIManager).init();
40
+
41
+ const app = document.createElement("top-app") as unknown as App;
42
+
43
+ app.setup = (waitUntil) => {
44
+ waitUntil(
45
+ (async () => {
46
+ const fragments = components.get(OBC.FragmentsManager);
47
+ const workerUrl = await FRAGS.FragmentsModels.getWorker();
48
+ fragments.init(await FRAGS.toClassicWorker(workerUrl), {
49
+ classicWorker: true,
50
+ });
51
+ })(),
52
+ "Fragments Core",
53
+ );
54
+ return { components, client };
55
+ };
56
+
57
+ app.elements = {
58
+ // "viewer" is referenced by app.base — rendered as a position:absolute layer
59
+ // behind all layout content so it fills the container edge-to-edge.
60
+ viewer: () =>
61
+ html`<top-viewer><top-viewer-tools></top-viewer-tools></top-viewer>`,
62
+
63
+ // Panels declared here appear in the floating content grid on top of the viewer.
64
+ // Their container has pointer-events: none; each child re-enables them individually.
65
+ panel: () => html`
66
+ <bim-panel>
67
+ <bim-panel-section label="Models" icon="solar:layers-bold">
68
+ <bim-label>Load models here</bim-label>
69
+ </bim-panel-section>
70
+ </bim-panel>
71
+ `,
72
+ };
73
+
74
+ // Setting app.base to an element key mounts that element as the absolute background.
75
+ // Layout templates then only list the floating overlay areas — not the base element.
76
+ // Without app.base, every area in the template is a peer grid cell (inline mode).
77
+ app.base = "viewer";
78
+
79
+ app.layouts = {
80
+ main: {
81
+ label: "Main",
82
+ icon: "solar:home-bold",
83
+ // Only overlay areas appear here. "viewer" is not listed because it is the base.
84
+ template: `"panel" 1fr / 22rem`,
85
+ },
86
+ };
87
+
88
+ app.layout = "main";
89
+
90
+ const container = document.getElementById("that-open-app") ?? document.body;
91
+ container.appendChild(app);
92
+ document.body.style.margin = "0";