@thatopen/services 0.3.15 → 0.3.16
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.
- package/dist/built-in/index.d.ts +165 -2
- package/dist/cli.js +23 -12
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +46 -36
- package/docs/ai-quickstart.md +130 -130
- package/docs/builtin/paths.json +94 -86
- package/docs/cloud/GaussianSplatConverter.md +43 -43
- package/docs/cloud/PointCloudConverter.md +53 -53
- package/docs/revit-collab-quickstart.md +256 -256
- package/package.json +95 -95
- package/src/built-in/UIManager/src/app/examples/ProjectFileStorage/example.ts +150 -0
- package/src/built-in/UIManager/src/clashes-panel/example.ts +183 -160
- package/src/built-in/UIManager/src/models-list/example.ts +122 -122
- package/src/built-in/UIManager/src/topics-panel/example.ts +170 -0
- package/src/built-in/index.ts +1048 -881
- package/src/cli/templates/app/README.md +217 -217
- package/src/cli/templates/app/src/app.ts +37 -37
- package/src/cli/templates/app/src/assets/tool-placeholder.ts +50 -50
- package/src/cli/templates/app/src/main.ts +199 -199
- package/src/cli/templates/app/src/setups/reality-capture/lib/hidden-tiles-plugin.ts +88 -88
- package/src/cli/templates/app/src/setups/reality-capture/lib/point-tile-plugin.ts +166 -166
- package/src/cli/templates/app/src/setups/reality-capture/lib/render-frame.ts +31 -31
- package/src/cli/templates/app/src/setups/reality-capture/lib/splat-tile-plugin.ts +51 -51
- package/src/cli/templates/app/src/setups/reality-capture-viewer.ts +1383 -1383
|
@@ -1,160 +1,183 @@
|
|
|
1
|
-
/* MD
|
|
2
|
-
## clashes-panel
|
|
3
|
-
---
|
|
4
|
-
BIM coordinators need a dedicated review environment where they can see all
|
|
5
|
-
detected clashes, filter by status, navigate to each issue in the 3D viewer,
|
|
6
|
-
and mark items as resolved — without writing any UI code themselves.
|
|
7
|
-
|
|
8
|
-
`clashes-panel` is a ready-made web component that delivers exactly that. It
|
|
9
|
-
connects to `ClashesManager` automatically and manages the entire review
|
|
10
|
-
workflow: the detection matrix, the clash table with status filters, sphere
|
|
11
|
-
markers and element highlights in the viewer, run controls with live progress,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import
|
|
25
|
-
import * as
|
|
26
|
-
import * as
|
|
27
|
-
import * as
|
|
28
|
-
import * as
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
app.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
the
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
1
|
+
/* MD
|
|
2
|
+
## clashes-panel
|
|
3
|
+
---
|
|
4
|
+
BIM coordinators need a dedicated review environment where they can see all
|
|
5
|
+
detected clashes, filter by status, navigate to each issue in the 3D viewer,
|
|
6
|
+
and mark items as resolved — without writing any UI code themselves.
|
|
7
|
+
|
|
8
|
+
`clashes-panel` is a ready-made web component that delivers exactly that. It
|
|
9
|
+
connects to `ClashesManager` automatically and manages the entire review
|
|
10
|
+
workflow: the detection matrix, the clash table with status filters, sphere
|
|
11
|
+
markers and element highlights in the viewer, run controls with live progress,
|
|
12
|
+
a loading skeleton while fresh data reloads after a run completes, and
|
|
13
|
+
turning a cluster of clashes into a tracked BCF topic in one click.
|
|
14
|
+
|
|
15
|
+
This tutorial covers the prerequisites before mounting the panel; dropping it
|
|
16
|
+
into a `top-app` layout alongside a 3D viewer; and a detailed breakdown of
|
|
17
|
+
everything the panel handles automatically so you know what you do not need to
|
|
18
|
+
implement yourself.
|
|
19
|
+
|
|
20
|
+
By the end, you'll have a fully working clash-review environment running in
|
|
21
|
+
your application with a single line of markup.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { html } from "lit";
|
|
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, UIManager, ClashesManager, TopicsManager } from "@thatopen/services";
|
|
31
|
+
import type { App } from "../app/index";
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/* MD
|
|
35
|
+
### ✅ Prerequisites
|
|
36
|
+
|
|
37
|
+
Three conditions must be met before the panel mounts:
|
|
38
|
+
|
|
39
|
+
1. **`UIManager` must be in the setup call.** It registers all platform web
|
|
40
|
+
components, including `<top-clashes-panel>` itself. Without it the element is
|
|
41
|
+
unknown to the browser and renders as an empty box.
|
|
42
|
+
|
|
43
|
+
2. **`ClashesManager.init(client)` must have resolved.** The panel reads all
|
|
44
|
+
its initial data from the manager in `connectedCallback`. If `init` has not
|
|
45
|
+
finished, the panel mounts into an empty state and never catches up because
|
|
46
|
+
it only subscribes to change events — it does not poll.
|
|
47
|
+
|
|
48
|
+
3. **`TopicsManager.init(client)` must have resolved too.** The panel's
|
|
49
|
+
"Create topic" button (turns a selection of clashes into a tracked BCF
|
|
50
|
+
topic) needs `Viewpoints.world` set to capture the camera, and `BCFTopics`
|
|
51
|
+
configured with `version: "3"` for the clash↔topic link to survive a
|
|
52
|
+
reload — `TopicsManager.init` is what sets both up. Skip it and the button
|
|
53
|
+
still works, but the topic it creates is subtly broken.
|
|
54
|
+
|
|
55
|
+
All three are naturally satisfied when you call both `init`s before appending
|
|
56
|
+
`top-app` to the document, which is the pattern shown below.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
const client = PlatformClient.fromPlatformContext();
|
|
60
|
+
|
|
61
|
+
const { components } = (await client.setup(
|
|
62
|
+
{ OBC, OBF, BUI, THREE, FRAGS },
|
|
63
|
+
{ uuid: UIManager.uuid },
|
|
64
|
+
{ uuid: ClashesManager.uuid },
|
|
65
|
+
{ uuid: TopicsManager.uuid },
|
|
66
|
+
)) as { components: OBC.Components };
|
|
67
|
+
|
|
68
|
+
components.get(UIManager).init();
|
|
69
|
+
|
|
70
|
+
// Both inits must resolve before top-app (and therefore clashes-panel) mounts.
|
|
71
|
+
// Independent of each other — safe to run in parallel.
|
|
72
|
+
await Promise.all([
|
|
73
|
+
components.get(ClashesManager).init(client),
|
|
74
|
+
components.get(TopicsManager).init(client),
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
/* MD
|
|
78
|
+
### 🖥️ Wiring the panel
|
|
79
|
+
|
|
80
|
+
Add `clashes-panel` as a named area in `app.elements` and reference it in your
|
|
81
|
+
layout template. A side-by-side layout with the 3D viewer is the most natural
|
|
82
|
+
arrangement — the panel controls markers and highlights directly in the scene.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
const app = document.createElement("top-app") as unknown as App;
|
|
86
|
+
|
|
87
|
+
app.setup = (waitUntil) => {
|
|
88
|
+
waitUntil(
|
|
89
|
+
(async () => {
|
|
90
|
+
const fragments = components.get(OBC.FragmentsManager);
|
|
91
|
+
const workerUrl = await FRAGS.FragmentsModels.getWorker();
|
|
92
|
+
fragments.init(await FRAGS.toClassicWorker(workerUrl), { classicWorker: true });
|
|
93
|
+
})(),
|
|
94
|
+
"Fragments Core",
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
waitUntil(
|
|
98
|
+
(async () => {
|
|
99
|
+
const loader = components.get(OBC.IfcLoader);
|
|
100
|
+
await loader.setup();
|
|
101
|
+
})(),
|
|
102
|
+
"IFC Loader",
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return { components, client };
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
app.elements = {
|
|
109
|
+
viewer: () => html`<top-viewer><top-viewer-tools></top-viewer-tools></top-viewer>`,
|
|
110
|
+
clashes: () => html`<top-clashes-panel></top-clashes-panel>`,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
app.layouts = {
|
|
114
|
+
main: {
|
|
115
|
+
label: "Main",
|
|
116
|
+
icon: "solar:3d-square-bold",
|
|
117
|
+
template: `"viewer clashes" 1fr / 1fr 22rem`,
|
|
118
|
+
},
|
|
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";
|
|
126
|
+
|
|
127
|
+
/* MD
|
|
128
|
+
### 🤖 What the panel manages automatically
|
|
129
|
+
|
|
130
|
+
Once mounted, `clashes-panel` takes ownership of the following without any
|
|
131
|
+
further code from you:
|
|
132
|
+
|
|
133
|
+
**Data synchronization** — the panel subscribes to every `ClashesManager`
|
|
134
|
+
event (`onJobsChanged`, `onRunsChanged`, `onClashesChanged`,
|
|
135
|
+
`onClashStatusChanged`, `onQueriesChanged`, `onRunningJobsChanged`) and keeps
|
|
136
|
+
its tables in sync. Changes made programmatically through the manager API are
|
|
137
|
+
reflected in the panel immediately.
|
|
138
|
+
|
|
139
|
+
**Run lifecycle** — a progress callout appears as soon as a run starts
|
|
140
|
+
(`onRunProgress`), updates its percentage and message in real time, and
|
|
141
|
+
disappears when the run completes or errors. If a run was already in progress
|
|
142
|
+
when the page loaded, the panel calls `reconnectIfRunning` automatically when
|
|
143
|
+
the user opens that job.
|
|
144
|
+
|
|
145
|
+
**Post-run reload skeleton** — after a successful run the manager reloads clash
|
|
146
|
+
data from storage. During that window (`onReloadingChanged = true`) the panel
|
|
147
|
+
replaces its entire content with an animated skeleton so the user is never left
|
|
148
|
+
looking at stale results that appear final.
|
|
149
|
+
|
|
150
|
+
**Sphere markers** — entering a job view places colored spheres in the 3D scene
|
|
151
|
+
at each clash location, transformed from IFC world space to viewer space.
|
|
152
|
+
Selecting a clash in the table zooms the camera, ghosts unrelated elements, and
|
|
153
|
+
re-focuses the markers on the selection. Leaving the job view removes all
|
|
154
|
+
markers and restores the full scene.
|
|
155
|
+
|
|
156
|
+
**Element highlights** — element A is highlighted green and element B red for
|
|
157
|
+
every new or active clash in the current job. Selecting a single clash refines
|
|
158
|
+
the highlight to that pair only. Clearing the selection or changing status
|
|
159
|
+
restores the full job highlight.
|
|
160
|
+
|
|
161
|
+
**Model awareness** — the panel tracks which fragment models are currently
|
|
162
|
+
loaded in the scene. Markers and highlights are activated only when the relevant
|
|
163
|
+
models are present, and are cleaned up automatically if a model is disposed
|
|
164
|
+
while the panel is open.
|
|
165
|
+
|
|
166
|
+
**Create topic from clash** — selecting one or more clashes and clicking
|
|
167
|
+
"Create topic" builds a BCF topic with an auto-generated title/description
|
|
168
|
+
summarizing the pair(s) and a viewpoint capturing the same selection and
|
|
169
|
+
red/green coloring shown in the table. The link back to the source clash(es)
|
|
170
|
+
is recorded separately so it survives independently of the topic's own BCF
|
|
171
|
+
fields. The button is disabled while the camera is still flying to a
|
|
172
|
+
selection or no models are loaded yet, so it can't fire on an empty scene.
|
|
173
|
+
|
|
174
|
+
**Save indicator** — every persisted change (clashes, queries, matrices,
|
|
175
|
+
topics created from a selection) routes through `top-app`'s shared
|
|
176
|
+
`projectStorageContext`, the same one `topics-panel` uses. A small indicator
|
|
177
|
+
reflects the real debounce-then-upload cycle: just an icon while a save is
|
|
178
|
+
pending, the full "Saving..." pill once the upload is actually in flight.
|
|
179
|
+
|
|
180
|
+
**Disconnection cleanup** — when the panel is removed from the DOM it calls
|
|
181
|
+
`hideMarkers` and `clearClashHighlight` on the manager, leaving the 3D scene
|
|
182
|
+
clean regardless of what was selected at the time.
|
|
183
|
+
*/
|
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
/* MD
|
|
2
|
-
## top-models-list
|
|
3
|
-
---
|
|
4
|
-
top-models-list is the project's 3D-viewable-files tree: it mirrors the real storage folder structure, converts IFC to fragments, and loads `.frag`/`.potree`/`.splat` models into the 3D scene. Its loaders are PLUGGABLE — the panel owns the UI and the orchestration (progress, refresh, association), but the HOST decides how each extra file format is loaded, so you can teach it new formats without forking the built-in.
|
|
5
|
-
|
|
6
|
-
This tutorial covers the two extension points. First, registering a custom loader for a file extension — either imperatively with `registerLoader(ext, fn)` or up front via the `loaders` property; a loader receives `(fileId, ctx)` where `ctx` carries the engine (`components`), the platform `client`, and per-file alignment persistence. Second, overriding the IFC to fragments `converter` — omit it to use the built-in default (which drives the project's IfcFragmenter cloud component, resolved by its stable name — see `adrs/resolve-ifc-fragmenter-by-stable-name.md`), or provide one to run conversion elsewhere.
|
|
7
|
-
|
|
8
|
-
A behaviour worth knowing: registering a loader does NOT control whether a file shows up in the tree — the tree always mirrors the project's real storage folders, so an unrecognized file is still listed as long as it's a source (IFC/LAS/PLY) or derivative (`.frag`/`.potree`/`.splat`) extension; the loaders registry only decides whether a file's row gets a load action or none.
|
|
9
|
-
|
|
10
|
-
Known gaps (intentionally deferred, not forgotten): file upload and the base-model/auto-coordinate settings aren't ported, so `allow-upload` is currently a no-op. Everything else per-file is here, including editable attach/detach via a picker — MINUS delete, dropped on purpose. See `models-list/legacy-example.ts` + `models-list/impl.ts` for the retired implementation those gaps would be ported from.
|
|
11
|
-
|
|
12
|
-
By the end you'll have a files tree that knows how to load a custom format and how to run a custom IFC conversion, with the panel's UI untouched.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { html } from "lit";
|
|
16
|
-
import * as THREE from "three";
|
|
17
|
-
import * as OBC from "@thatopen/components";
|
|
18
|
-
import * as OBF from "@thatopen/components-front";
|
|
19
|
-
import * as FRAGS from "@thatopen/fragments";
|
|
20
|
-
import * as BUI from "@thatopen/ui";
|
|
21
|
-
import { PlatformClient, UIManager } from "@thatopen/services";
|
|
22
|
-
import type { App } from "../app/index";
|
|
23
|
-
import type { ModelsListV2 } from "./src/v2/models-list-panel";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const client = PlatformClient.fromPlatformContext();
|
|
27
|
-
|
|
28
|
-
// UIManager registers every platform web component (top-app, top-viewer,
|
|
29
|
-
// top-models-list, …) before the DOM renders.
|
|
30
|
-
const { components } = (await client.setup(
|
|
31
|
-
{ OBC, OBF, BUI, THREE, FRAGS },
|
|
32
|
-
{ uuid: UIManager.uuid },
|
|
33
|
-
)) as { components: OBC.Components };
|
|
34
|
-
|
|
35
|
-
components.get(UIManager).init();
|
|
36
|
-
|
|
37
|
-
const app = document.createElement("top-app") as unknown as App;
|
|
38
|
-
|
|
39
|
-
app.setup = (waitUntil) => {
|
|
40
|
-
waitUntil(
|
|
41
|
-
(async () => {
|
|
42
|
-
const fragments = components.get(OBC.FragmentsManager);
|
|
43
|
-
const workerUrl = await FRAGS.FragmentsModels.getWorker();
|
|
44
|
-
fragments.init(await FRAGS.toClassicWorker(workerUrl), {
|
|
45
|
-
classicWorker: true,
|
|
46
|
-
});
|
|
47
|
-
})(),
|
|
48
|
-
"Fragments Core",
|
|
49
|
-
);
|
|
50
|
-
return { components, client };
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// One stable <top-models-list>, kept by reference so re-rendering top-app
|
|
54
|
-
// reuses it. The loaders are read LIVE, so registration can happen at any time.
|
|
55
|
-
const modelsList = document.createElement("top-models-list") as ModelsListV2;
|
|
56
|
-
|
|
57
|
-
// ── Extension point 1: a custom loader, keyed by file extension ──────────────
|
|
58
|
-
// A ModelLoader is `(fileId, ctx) => void | Promise<void>`. The panel calls it
|
|
59
|
-
// when the user loads a file whose extension matches. `ctx` gives you everything
|
|
60
|
-
// you need: { name, ext, components, client, getAlignment, setAlignment }. Do
|
|
61
|
-
// whatever it takes to put the file in the scene — fetch it via the client,
|
|
62
|
-
// parse it, and add geometry to a world from `components`.
|
|
63
|
-
modelsList.registerLoader("xyz", async (fileId, ctx) => {
|
|
64
|
-
// const buffer = await ctx.client
|
|
65
|
-
// .downloadFile(fileId)
|
|
66
|
-
// .then((r: Response) => r.arrayBuffer());
|
|
67
|
-
// ...parse `buffer` and add it to the world here...
|
|
68
|
-
// Persist/restore a placement matrix across reloads via the panel's app-data:
|
|
69
|
-
// const saved = ctx.getAlignment(fileId);
|
|
70
|
-
// ctx.setAlignment(fileId, matrix.toArray());
|
|
71
|
-
console.log(`[xyz loader] would load "${ctx.name}" (${fileId})`, ctx.components);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Equivalent declarative form — hand the whole registry over at once:
|
|
75
|
-
// modelsList.loaders = { xyz: async (fileId, ctx) => { ... } };
|
|
76
|
-
//
|
|
77
|
-
// Registering a loader for an extension gives its files a load action here —
|
|
78
|
-
// but doesn't control visibility (see the note above). For a CONVERT-style
|
|
79
|
-
// action — e.g. a PLY that runs a PLY→3D-tiles cloud component then views the
|
|
80
|
-
// result — register a RICH entry so the button reads correctly:
|
|
81
|
-
// modelsList.registerLoader("ply", {
|
|
82
|
-
// label: "Generate 3D tiles",
|
|
83
|
-
// icon: "mdi:cube-scan",
|
|
84
|
-
// fn: async (fileId, ctx) => {
|
|
85
|
-
// // const { executionId } = await ctx.client.executeComponent(...);
|
|
86
|
-
// // ...poll until done, then open the produced tileset...
|
|
87
|
-
// },
|
|
88
|
-
// });
|
|
89
|
-
|
|
90
|
-
// ── Extension point 2: override the IFC → fragments converter ────────────────
|
|
91
|
-
// OMIT this to keep the built-in default (drives the project's IfcFragmenter
|
|
92
|
-
// cloud component via the platform client). Provide it to run conversion
|
|
93
|
-
// elsewhere / differently — the panel keeps the progress bar, reload-survival,
|
|
94
|
-
// association and refresh; your converter just `start`s and is `poll`ed.
|
|
95
|
-
modelsList.converter = {
|
|
96
|
-
async start(fileId) {
|
|
97
|
-
// kick off your conversion; return an execution id to poll
|
|
98
|
-
return `exec-${fileId}`;
|
|
99
|
-
},
|
|
100
|
-
async poll(executionId) {
|
|
101
|
-
// report progress; when done, hand back the produced .frag id
|
|
102
|
-
return { done: true, ok: true, fragId: "demo-frag", message: "Converted" };
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// Mount the panel into a one-area layout. (In a real app it sits beside a
|
|
107
|
-
// top-viewer so loaded models have a world to render into.)
|
|
108
|
-
app.elements = {
|
|
109
|
-
files: () => html`${modelsList}`,
|
|
110
|
-
};
|
|
111
|
-
app.layouts = {
|
|
112
|
-
main: {
|
|
113
|
-
label: "Files",
|
|
114
|
-
icon: "mdi:folder-multiple-outline",
|
|
115
|
-
template: `"files" 1fr / 1fr`,
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
app.layout = "main";
|
|
119
|
-
|
|
120
|
-
const container = document.getElementById("that-open-app") ?? document.body;
|
|
121
|
-
container.appendChild(app);
|
|
122
|
-
document.body.style.margin = "0";
|
|
1
|
+
/* MD
|
|
2
|
+
## top-models-list
|
|
3
|
+
---
|
|
4
|
+
top-models-list is the project's 3D-viewable-files tree: it mirrors the real storage folder structure, converts IFC to fragments, and loads `.frag`/`.potree`/`.splat` models into the 3D scene. Its loaders are PLUGGABLE — the panel owns the UI and the orchestration (progress, refresh, association), but the HOST decides how each extra file format is loaded, so you can teach it new formats without forking the built-in.
|
|
5
|
+
|
|
6
|
+
This tutorial covers the two extension points. First, registering a custom loader for a file extension — either imperatively with `registerLoader(ext, fn)` or up front via the `loaders` property; a loader receives `(fileId, ctx)` where `ctx` carries the engine (`components`), the platform `client`, and per-file alignment persistence. Second, overriding the IFC to fragments `converter` — omit it to use the built-in default (which drives the project's IfcFragmenter cloud component, resolved by its stable name — see `adrs/resolve-ifc-fragmenter-by-stable-name.md`), or provide one to run conversion elsewhere.
|
|
7
|
+
|
|
8
|
+
A behaviour worth knowing: registering a loader does NOT control whether a file shows up in the tree — the tree always mirrors the project's real storage folders, so an unrecognized file is still listed as long as it's a source (IFC/LAS/PLY) or derivative (`.frag`/`.potree`/`.splat`) extension; the loaders registry only decides whether a file's row gets a load action or none.
|
|
9
|
+
|
|
10
|
+
Known gaps (intentionally deferred, not forgotten): file upload and the base-model/auto-coordinate settings aren't ported, so `allow-upload` is currently a no-op. Everything else per-file is here, including editable attach/detach via a picker — MINUS delete, dropped on purpose. See `models-list/legacy-example.ts` + `models-list/impl.ts` for the retired implementation those gaps would be ported from.
|
|
11
|
+
|
|
12
|
+
By the end you'll have a files tree that knows how to load a custom format and how to run a custom IFC conversion, with the panel's UI untouched.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { html } from "lit";
|
|
16
|
+
import * as THREE from "three";
|
|
17
|
+
import * as OBC from "@thatopen/components";
|
|
18
|
+
import * as OBF from "@thatopen/components-front";
|
|
19
|
+
import * as FRAGS from "@thatopen/fragments";
|
|
20
|
+
import * as BUI from "@thatopen/ui";
|
|
21
|
+
import { PlatformClient, UIManager } from "@thatopen/services";
|
|
22
|
+
import type { App } from "../app/index";
|
|
23
|
+
import type { ModelsListV2 } from "./src/v2/models-list-panel";
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const client = PlatformClient.fromPlatformContext();
|
|
27
|
+
|
|
28
|
+
// UIManager registers every platform web component (top-app, top-viewer,
|
|
29
|
+
// top-models-list, …) before the DOM renders.
|
|
30
|
+
const { components } = (await client.setup(
|
|
31
|
+
{ OBC, OBF, BUI, THREE, FRAGS },
|
|
32
|
+
{ uuid: UIManager.uuid },
|
|
33
|
+
)) as { components: OBC.Components };
|
|
34
|
+
|
|
35
|
+
components.get(UIManager).init();
|
|
36
|
+
|
|
37
|
+
const app = document.createElement("top-app") as unknown as App;
|
|
38
|
+
|
|
39
|
+
app.setup = (waitUntil) => {
|
|
40
|
+
waitUntil(
|
|
41
|
+
(async () => {
|
|
42
|
+
const fragments = components.get(OBC.FragmentsManager);
|
|
43
|
+
const workerUrl = await FRAGS.FragmentsModels.getWorker();
|
|
44
|
+
fragments.init(await FRAGS.toClassicWorker(workerUrl), {
|
|
45
|
+
classicWorker: true,
|
|
46
|
+
});
|
|
47
|
+
})(),
|
|
48
|
+
"Fragments Core",
|
|
49
|
+
);
|
|
50
|
+
return { components, client };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// One stable <top-models-list>, kept by reference so re-rendering top-app
|
|
54
|
+
// reuses it. The loaders are read LIVE, so registration can happen at any time.
|
|
55
|
+
const modelsList = document.createElement("top-models-list") as ModelsListV2;
|
|
56
|
+
|
|
57
|
+
// ── Extension point 1: a custom loader, keyed by file extension ──────────────
|
|
58
|
+
// A ModelLoader is `(fileId, ctx) => void | Promise<void>`. The panel calls it
|
|
59
|
+
// when the user loads a file whose extension matches. `ctx` gives you everything
|
|
60
|
+
// you need: { name, ext, components, client, getAlignment, setAlignment }. Do
|
|
61
|
+
// whatever it takes to put the file in the scene — fetch it via the client,
|
|
62
|
+
// parse it, and add geometry to a world from `components`.
|
|
63
|
+
modelsList.registerLoader("xyz", async (fileId, ctx) => {
|
|
64
|
+
// const buffer = await ctx.client
|
|
65
|
+
// .downloadFile(fileId)
|
|
66
|
+
// .then((r: Response) => r.arrayBuffer());
|
|
67
|
+
// ...parse `buffer` and add it to the world here...
|
|
68
|
+
// Persist/restore a placement matrix across reloads via the panel's app-data:
|
|
69
|
+
// const saved = ctx.getAlignment(fileId);
|
|
70
|
+
// ctx.setAlignment(fileId, matrix.toArray());
|
|
71
|
+
console.log(`[xyz loader] would load "${ctx.name}" (${fileId})`, ctx.components);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Equivalent declarative form — hand the whole registry over at once:
|
|
75
|
+
// modelsList.loaders = { xyz: async (fileId, ctx) => { ... } };
|
|
76
|
+
//
|
|
77
|
+
// Registering a loader for an extension gives its files a load action here —
|
|
78
|
+
// but doesn't control visibility (see the note above). For a CONVERT-style
|
|
79
|
+
// action — e.g. a PLY that runs a PLY→3D-tiles cloud component then views the
|
|
80
|
+
// result — register a RICH entry so the button reads correctly:
|
|
81
|
+
// modelsList.registerLoader("ply", {
|
|
82
|
+
// label: "Generate 3D tiles",
|
|
83
|
+
// icon: "mdi:cube-scan",
|
|
84
|
+
// fn: async (fileId, ctx) => {
|
|
85
|
+
// // const { executionId } = await ctx.client.executeComponent(...);
|
|
86
|
+
// // ...poll until done, then open the produced tileset...
|
|
87
|
+
// },
|
|
88
|
+
// });
|
|
89
|
+
|
|
90
|
+
// ── Extension point 2: override the IFC → fragments converter ────────────────
|
|
91
|
+
// OMIT this to keep the built-in default (drives the project's IfcFragmenter
|
|
92
|
+
// cloud component via the platform client). Provide it to run conversion
|
|
93
|
+
// elsewhere / differently — the panel keeps the progress bar, reload-survival,
|
|
94
|
+
// association and refresh; your converter just `start`s and is `poll`ed.
|
|
95
|
+
modelsList.converter = {
|
|
96
|
+
async start(fileId) {
|
|
97
|
+
// kick off your conversion; return an execution id to poll
|
|
98
|
+
return `exec-${fileId}`;
|
|
99
|
+
},
|
|
100
|
+
async poll(executionId) {
|
|
101
|
+
// report progress; when done, hand back the produced .frag id
|
|
102
|
+
return { done: true, ok: true, fragId: "demo-frag", message: "Converted" };
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Mount the panel into a one-area layout. (In a real app it sits beside a
|
|
107
|
+
// top-viewer so loaded models have a world to render into.)
|
|
108
|
+
app.elements = {
|
|
109
|
+
files: () => html`${modelsList}`,
|
|
110
|
+
};
|
|
111
|
+
app.layouts = {
|
|
112
|
+
main: {
|
|
113
|
+
label: "Files",
|
|
114
|
+
icon: "mdi:folder-multiple-outline",
|
|
115
|
+
template: `"files" 1fr / 1fr`,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
app.layout = "main";
|
|
119
|
+
|
|
120
|
+
const container = document.getElementById("that-open-app") ?? document.body;
|
|
121
|
+
container.appendChild(app);
|
|
122
|
+
document.body.style.margin = "0";
|