@thatopen/services 0.35.0 → 0.35.1
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/README.md +66 -66
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/vite-env.d.ts +1 -1
- package/docs/ai-quickstart.md +548 -548
- package/docs/builtin/paths.json +130 -130
- package/docs/cli/create.md +29 -29
- package/docs/cli/local-server.md +38 -38
- package/docs/cli/login.md +32 -32
- package/docs/cli/mcp.md +46 -46
- package/docs/cli/publish.md +31 -31
- package/docs/cli/run.md +26 -26
- package/docs/cli/serve.md +43 -43
- package/docs/cli/swap.md +30 -30
- package/docs/cloud/GaussianSplatConverter.md +43 -43
- package/docs/cloud/PointCloudConverter.md +53 -53
- package/docs/flow-architecture.md +393 -393
- package/docs/flow-plugin-guide.md +354 -354
- package/docs/platform-token.md +81 -81
- package/docs/rate-limits.md +133 -133
- package/docs/recipes-guide.md +243 -243
- package/docs/revit-collab-quickstart.md +445 -445
- package/docs/rhino-interop-quickstart.md +387 -387
- package/docs/sheet-sets-guide.md +69 -69
- package/package.json +1 -1
- package/resources/AGENTS.md +57 -57
- package/src/built-in/CDEManager/example.ts +214 -214
- package/src/built-in/CDEManager/examples/FileEditing/example.ts +226 -226
- package/src/built-in/CDEManager/examples/FileMoves/example.ts +186 -186
- package/src/built-in/CDEManager/examples/FileOperations/example.ts +295 -295
- package/src/built-in/CDEManager/examples/FileTransfers/example.ts +210 -210
- package/src/built-in/CDEManager/examples/FolderManagement/example.ts +230 -230
- package/src/built-in/CDEManager/examples/MetadataSchema/example.ts +230 -230
- package/src/built-in/CDEManager/examples/MetadataViews/example.ts +166 -166
- package/src/built-in/CDEManager/examples/ProjectConfig/example.ts +177 -177
- package/src/built-in/ClashesManager/example.ts +283 -283
- package/src/built-in/GISManager/example.ts +355 -355
- package/src/built-in/ProjectManager/example.ts +124 -124
- package/src/built-in/UIManager/src/app/example.ts +97 -97
- package/src/built-in/UIManager/src/app/examples/AppState/example.ts +140 -140
- package/src/built-in/UIManager/src/app/examples/Banner/example.ts +159 -159
- package/src/built-in/UIManager/src/app/examples/Contexts/example.ts +123 -123
- package/src/built-in/UIManager/src/app/examples/FileDrop/example.ts +124 -124
- package/src/built-in/UIManager/src/app/examples/FloatingLayout/example.ts +90 -90
- package/src/built-in/UIManager/src/app/examples/Modal/example.ts +163 -163
- package/src/built-in/UIManager/src/app/examples/Notifications/example.ts +133 -133
- package/src/built-in/UIManager/src/app/examples/ProjectFileStorage/example.ts +150 -150
- package/src/built-in/UIManager/src/app/examples/Sidebar/example.ts +105 -105
- package/src/built-in/UIManager/src/clashes-panel/example.ts +183 -183
- package/src/built-in/UIManager/src/gis-panel/example.ts +163 -163
- package/src/built-in/UIManager/src/gis-properties-panel/example.ts +168 -168
- package/src/built-in/UIManager/src/git-history-panel/example.ts +70 -70
- package/src/built-in/UIManager/src/map-panel/example.ts +189 -189
- package/src/built-in/UIManager/src/models-list/example.ts +181 -181
- package/src/built-in/UIManager/src/settings-panel/example.ts +303 -303
- package/src/built-in/UIManager/src/topics-panel/example.ts +170 -170
- package/src/built-in/UIManager/src/viewer/example.ts +182 -182
- package/src/built-in/UIManager/src/viewer-toolbar/example.ts +376 -376
- package/src/built-in/index.ts +2995 -2995
- package/src/cli/templates/app/README.md +250 -250
- package/src/cli/templates/app/index.html +35 -35
- package/src/cli/templates/app/package.json +32 -32
- 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/bim-components/CloudRunner/index.ts +95 -95
- package/src/cli/templates/app/src/bim-components/CloudRunner/src/index.ts +1 -1
- package/src/cli/templates/app/src/bim-components/CloudRunner/src/types.ts +5 -5
- package/src/cli/templates/app/src/bim-components/index.ts +1 -1
- package/src/cli/templates/app/src/globals.ts +1 -1
- package/src/cli/templates/app/src/main.history.ts +191 -191
- package/src/cli/templates/app/src/main.ts +226 -226
- package/src/cli/templates/app/src/setups/channel.ts +76 -76
- 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
- package/src/cli/templates/app/src/ui-components/app-info-section/index.ts +26 -26
- package/src/cli/templates/app/src/ui-components/app-info-section/src/index.ts +1 -1
- package/src/cli/templates/app/src/ui-components/app-info-section/src/types.ts +15 -15
- package/src/cli/templates/app/src/ui-components/cloud-runner-section/index.ts +37 -37
- package/src/cli/templates/app/src/ui-components/cloud-runner-section/src/index.ts +1 -1
- package/src/cli/templates/app/src/ui-components/cloud-runner-section/src/types.ts +14 -14
- package/src/cli/templates/app/src/ui-components/index.ts +2 -2
- package/src/cli/templates/app/tsconfig.json +16 -16
- package/src/cli/templates/app/vite.config.js +57 -57
- package/src/cli/templates/cloud-component/README.md +205 -205
- package/src/cli/templates/cloud-component/_thatopen +5 -5
- package/src/cli/templates/cloud-component/declarations.json +4 -4
- package/src/cli/templates/cloud-component/package.json +21 -21
- package/src/cli/templates/cloud-component/src/main.ts +70 -70
- package/src/cli/templates/cloud-component/tsconfig.json +16 -16
- package/src/cli/templates/cloud-component/vite.config.js +46 -46
- package/src/cli/templates/shared/AGENTS.md +8 -8
- package/src/cli/templates/shared/CLAUDE.md +1 -1
- package/src/cli/templates/shared/_gitignore +5 -5
- package/src/core/examples/.env.example +7 -7
- package/src/core/examples/apps.ts +67 -67
- package/src/core/examples/batch-reads.ts +99 -99
- package/src/core/examples/channel.ts +65 -65
- package/src/core/examples/components.ts +91 -91
- package/src/core/examples/execution.ts +75 -75
- package/src/core/examples/file-metadata.ts +94 -94
- package/src/core/examples/files.ts +81 -81
- package/src/core/examples/folders.ts +82 -82
- package/src/core/examples/hidden-files.ts +88 -88
- package/src/core/examples/history.ts +103 -103
- package/src/core/examples/icons.ts +68 -68
- package/src/core/examples/permissions.ts +87 -87
|
@@ -1,376 +1,376 @@
|
|
|
1
|
-
/* MD
|
|
2
|
-
## top-viewer-toolbar
|
|
3
|
-
---
|
|
4
|
-
A 3D viewport is only as useful as the controls around it: selecting a
|
|
5
|
-
target set, hiding/isolating/ghosting elements, clipping, measuring,
|
|
6
|
-
walking through the model. Building that toolbar — and keeping every
|
|
7
|
-
button in sync with tool state and with each other — is real work, before
|
|
8
|
-
you've customized anything.
|
|
9
|
-
|
|
10
|
-
`top-viewer-toolbar` is a ready-made web component that delivers exactly
|
|
11
|
-
that. Mounted as-is, it's a complete, self-wiring bottom toolbar. But it's
|
|
12
|
-
also built out of standalone, individually-importable
|
|
13
|
-
`<top-viewer-*-button>` elements — so if the default layout isn't what your
|
|
14
|
-
app needs, you can drop the bar it builds for you and compose your own out
|
|
15
|
-
of the same pieces, mixed freely with your own custom buttons.
|
|
16
|
-
|
|
17
|
-
This tutorial covers the prerequisites; the default, batteries-included
|
|
18
|
-
toolbar; what it manages automatically; composing a custom layout with
|
|
19
|
-
`headless`; docking a vertical toolbar; and the full list of standalone
|
|
20
|
-
buttons available.
|
|
21
|
-
|
|
22
|
-
By the end, you'll have both a working default toolbar and a fully custom
|
|
23
|
-
one running side by side in the same viewport.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import { html } from "lit";
|
|
27
|
-
import * as THREE from "three";
|
|
28
|
-
import * as OBC from "@thatopen/components";
|
|
29
|
-
import * as OBF from "@thatopen/components-front";
|
|
30
|
-
import * as FRAGS from "@thatopen/fragments";
|
|
31
|
-
import * as BUI from "@thatopen/ui";
|
|
32
|
-
import { PlatformClient, UIManager } from "@thatopen/services";
|
|
33
|
-
import type { App } from "../app/index";
|
|
34
|
-
|
|
35
|
-
/* MD
|
|
36
|
-
### ✅ Prerequisites
|
|
37
|
-
|
|
38
|
-
`<top-viewer-toolbar>` must be mounted as a descendant of `<top-viewer>` —
|
|
39
|
-
it consumes the `componentsContext`/`worldContext` that `<top-viewer>`
|
|
40
|
-
provides, and the standalone buttons it's built from consume the same
|
|
41
|
-
contexts. `UIManager` must be in the setup call so both custom elements are
|
|
42
|
-
registered. Nothing else is required — no manager to `init`, no extra
|
|
43
|
-
config.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
const client = PlatformClient.fromPlatformContext();
|
|
47
|
-
|
|
48
|
-
const { components } = (await client.setup(
|
|
49
|
-
{ OBC, OBF, BUI, THREE, FRAGS },
|
|
50
|
-
{ uuid: UIManager.uuid },
|
|
51
|
-
)) as { components: OBC.Components };
|
|
52
|
-
|
|
53
|
-
components.get(UIManager).init();
|
|
54
|
-
|
|
55
|
-
/* MD
|
|
56
|
-
### 🖥️ Default toolbar (batteries included)
|
|
57
|
-
|
|
58
|
-
Add it as a plain child of `<top-viewer>` — no `slot` needed, it docks
|
|
59
|
-
into `"bottom"` on its own:
|
|
60
|
-
|
|
61
|
-
```html
|
|
62
|
-
<top-viewer>
|
|
63
|
-
<top-viewer-toolbar></top-viewer-toolbar>
|
|
64
|
-
</top-viewer>
|
|
65
|
-
```
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
const app = document.createElement("top-app") as unknown as App;
|
|
69
|
-
|
|
70
|
-
app.setup = (waitUntil) => {
|
|
71
|
-
waitUntil(
|
|
72
|
-
(async () => {
|
|
73
|
-
const fragments = components.get(OBC.FragmentsManager);
|
|
74
|
-
const workerUrl = await FRAGS.FragmentsModels.getWorker();
|
|
75
|
-
fragments.init(await FRAGS.toClassicWorker(workerUrl), { classicWorker: true });
|
|
76
|
-
})(),
|
|
77
|
-
"Fragments Core",
|
|
78
|
-
);
|
|
79
|
-
return { components, client };
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
app.elements = {
|
|
83
|
-
viewer: () => html`
|
|
84
|
-
<top-viewer>
|
|
85
|
-
<top-viewer-toolbar></top-viewer-toolbar>
|
|
86
|
-
</top-viewer>
|
|
87
|
-
`,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
app.layouts = {
|
|
91
|
-
main: {
|
|
92
|
-
label: "Main",
|
|
93
|
-
icon: "solar:3d-square-bold",
|
|
94
|
-
template: `"viewer" 1fr / 1fr`,
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
app.layout = "main";
|
|
99
|
-
|
|
100
|
-
const container = document.getElementById("that-open-app") ?? document.body;
|
|
101
|
-
container.appendChild(app);
|
|
102
|
-
document.body.style.margin = "0";
|
|
103
|
-
|
|
104
|
-
/* MD
|
|
105
|
-
### 🤖 What the default toolbar manages automatically
|
|
106
|
-
|
|
107
|
-
**Target mode** — a toggle between "Selected" and "Unselected", which every
|
|
108
|
-
visibility button below operates on. Empty selection while targeting
|
|
109
|
-
"Selected" means the target is empty (actions no-op); targeting
|
|
110
|
-
"Unselected" with an empty selection means the target is the whole model.
|
|
111
|
-
|
|
112
|
-
**Visibility actions** (each reversible via Show/Reset) — Hide, Show,
|
|
113
|
-
Isolate, Ghost (semi-transparent), Focus, and a global Reset that restores
|
|
114
|
-
full visibility and opacity regardless of target mode.
|
|
115
|
-
|
|
116
|
-
**Inspect tab** — Select (default tool), Clip, and six measurement modes
|
|
117
|
-
(length, area, angle, edge, face, volume), all sharing one active-tool
|
|
118
|
-
manager so switching tools un-highlights whichever was active before.
|
|
119
|
-
|
|
120
|
-
**Projection + walkthrough** — a Perspective⇄Orthographic toggle and a
|
|
121
|
-
first-person walkthrough toggle, each reflecting live state.
|
|
122
|
-
|
|
123
|
-
**Active-tool HUD** — a floating overlay over the 3D viewport itself
|
|
124
|
-
showing context for whichever tool is currently active (e.g. clip plane
|
|
125
|
-
controls, measurement readouts).
|
|
126
|
-
|
|
127
|
-
All of the above are per-`components` singletons — any other UI in your
|
|
128
|
-
app that resolves the same tool (e.g. via `components.get(...)`) shares
|
|
129
|
-
the exact same state, not a second, independent instance.
|
|
130
|
-
|
|
131
|
-
### 🧱 Composing a custom layout with `headless`
|
|
132
|
-
|
|
133
|
-
Set the `headless` attribute to skip the default bar's own assembly, while
|
|
134
|
-
everything else — providing context to descendants, the active-tool HUD —
|
|
135
|
-
keeps running. Slot your own buttons as light-DOM children: they consume
|
|
136
|
-
the same context the default bar's buttons do, wherever you place them.
|
|
137
|
-
|
|
138
|
-
```html
|
|
139
|
-
<top-viewer>
|
|
140
|
-
<top-viewer-toolbar headless>
|
|
141
|
-
<!-- your own content goes here as light-DOM children -->
|
|
142
|
-
</top-viewer-toolbar>
|
|
143
|
-
</top-viewer>
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Mixing standalone buttons with a plain, app-owned `bim-button` in the same
|
|
147
|
-
bar — built with lit's `render`/`html` into a plain container element
|
|
148
|
-
(never `document.createElement` for the `bim-*` tags themselves, see the
|
|
149
|
-
gotcha below), then appended as the toolbar's light-DOM content:
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
import { html, render } from "lit";
|
|
153
|
-
|
|
154
|
-
const headlessBar = document.createElement("top-viewer-toolbar");
|
|
155
|
-
headlessBar.toggleAttribute("headless", true);
|
|
156
|
-
|
|
157
|
-
// A plain container — the `<bim-toolbar>` itself is rendered inside it.
|
|
158
|
-
const toolbarHost = document.createElement("div");
|
|
159
|
-
toolbarHost.style.pointerEvents = "auto";
|
|
160
|
-
render(
|
|
161
|
-
html`
|
|
162
|
-
<bim-toolbar>
|
|
163
|
-
<bim-toolbar-section label-hidden style="background: transparent;">
|
|
164
|
-
<top-viewer-mode-toggle-button></top-viewer-mode-toggle-button>
|
|
165
|
-
<top-viewer-hide-button></top-viewer-hide-button>
|
|
166
|
-
<top-viewer-select-button></top-viewer-select-button>
|
|
167
|
-
</bim-toolbar-section>
|
|
168
|
-
<bim-toolbar-section label-hidden style="background: transparent;">
|
|
169
|
-
<bim-button
|
|
170
|
-
icon="mdi:fit-to-page-outline"
|
|
171
|
-
@click=${() => myOwnFitToViewLogic()}
|
|
172
|
-
><bim-tooltip placement="top">Zoom to fit</bim-tooltip></bim-button>
|
|
173
|
-
</bim-toolbar-section>
|
|
174
|
-
</bim-toolbar>
|
|
175
|
-
`,
|
|
176
|
-
toolbarHost,
|
|
177
|
-
);
|
|
178
|
-
headlessBar.appendChild(toolbarHost);
|
|
179
|
-
// headlessBar can now be appended anywhere inside <top-viewer>.
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### 📐 Docking a vertical toolbar
|
|
183
|
-
|
|
184
|
-
The host centers its own content via flexbox, controllable through CSS
|
|
185
|
-
custom properties — including flipping to a vertical stack for a
|
|
186
|
-
sidebar-style dock:
|
|
187
|
-
|
|
188
|
-
```html
|
|
189
|
-
<top-viewer-toolbar
|
|
190
|
-
headless
|
|
191
|
-
slot="right"
|
|
192
|
-
style="--top-viewer-toolbar-direction: column;"
|
|
193
|
-
>
|
|
194
|
-
...
|
|
195
|
-
</top-viewer-toolbar>
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
- `--top-viewer-toolbar-direction` — `row` (default) or `column`.
|
|
199
|
-
- `--top-viewer-toolbar-justify` — alignment along the main axis (default
|
|
200
|
-
`center`).
|
|
201
|
-
- `--top-viewer-toolbar-align` — alignment along the cross axis (default
|
|
202
|
-
`center`).
|
|
203
|
-
|
|
204
|
-
Pair `--top-viewer-toolbar-direction: column` with `bim-toolbar`'s own
|
|
205
|
-
`vertical` attribute on the content you render inside, so the buttons
|
|
206
|
-
themselves stack the same way the bar does.
|
|
207
|
-
|
|
208
|
-
### ⚠️ Gotchas
|
|
209
|
-
|
|
210
|
-
- **Never `document.createElement` a `bim-*` element.** `bim-button`,
|
|
211
|
-
`bim-toolbar`, `bim-toolbar-section`, and every other `@thatopen/ui`
|
|
212
|
-
component set attributes on themselves in their own constructor, which
|
|
213
|
-
Custom Elements v1 forbids for elements created imperatively —
|
|
214
|
-
`document.createElement("bim-button")` throws `NotSupportedError`.
|
|
215
|
-
Render them with lit's `render(html\`...\`, container)` instead, exactly
|
|
216
|
-
like the `toolbarHost` container above — never build them by hand.
|
|
217
|
-
- **`bim-button` sizes itself** — square when it's icon-only, a consistent
|
|
218
|
-
height when it has a label. Don't set `width`/`height`/`min-width`
|
|
219
|
-
inline on it; that only fights its own layout and produces buttons that
|
|
220
|
-
look inconsistent next to the rest of the bar.
|
|
221
|
-
- **Centering/alignment belongs on the toolbar's host**, via the CSS custom
|
|
222
|
-
properties above — not on the content you slot into it. Setting
|
|
223
|
-
`justify-self` (or similar) on your own buttons instead of using
|
|
224
|
-
`--top-viewer-toolbar-justify` only works by accident, if at all.
|
|
225
|
-
- **A standalone button works from anywhere in the DOM**, as long as it
|
|
226
|
-
ends up a descendant of a `<top-viewer-toolbar>` inside a `<top-viewer>`
|
|
227
|
-
— context requests bubble through shadow-DOM boundaries. It does *not*
|
|
228
|
-
need to be a direct child of the bar it visually sits in.
|
|
229
|
-
|
|
230
|
-
### 🧩 Standalone buttons reference
|
|
231
|
-
|
|
232
|
-
Every button the default bar uses is independently importable/usable as
|
|
233
|
-
its own custom element. They render icon-only with a tooltip; set the
|
|
234
|
-
optional `label` attribute on any of them to show text next to the icon
|
|
235
|
-
(the tooltip stays as it is):
|
|
236
|
-
|
|
237
|
-
```html
|
|
238
|
-
<top-viewer-hide-button label="Hide"></top-viewer-hide-button>
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
| Element | Does |
|
|
242
|
-
|---|---|
|
|
243
|
-
| `<top-viewer-mode-toggle-button>` | Toggles target: Selected ⇄ Unselected |
|
|
244
|
-
| `<top-viewer-hide-button>` | Hides the target set |
|
|
245
|
-
| `<top-viewer-show-button>` | Un-hides the target set |
|
|
246
|
-
| `<top-viewer-isolate-button>` | Shows only the target set |
|
|
247
|
-
| `<top-viewer-ghost-button>` | Renders the target set semi-transparent |
|
|
248
|
-
| `<top-viewer-gis-ghost-button>` | Makes the GIS map (the 3D tiles of `GISManager`) see-through ⇄ opaque; disabled until the tiles are loaded; the optional `opacity` attribute (0 to 1, default `0.3`) sets the see-through level |
|
|
249
|
-
| `<top-viewer-focus-button>` | Frames the camera on the target set |
|
|
250
|
-
| `<top-viewer-reset-button>` | Shows everything and clears ghosting (global); the optional `reset` attribute can also remove sections and measurements (see below) |
|
|
251
|
-
| `<top-viewer-select-button>` | Activates the default Select tool |
|
|
252
|
-
| `<top-viewer-clip-button>` | Clipping planes: face-placing mode by default, or axis planes / a mode menu via `modes` (see below) |
|
|
253
|
-
| `<top-viewer-measure-length-button>` | Activates length measurement |
|
|
254
|
-
| `<top-viewer-measure-area-button>` | Activates area measurement |
|
|
255
|
-
| `<top-viewer-measure-angle-button>` | Activates angle measurement |
|
|
256
|
-
| `<top-viewer-measure-edge-button>` | Activates edge measurement |
|
|
257
|
-
| `<top-viewer-measure-face-button>` | Activates face measurement |
|
|
258
|
-
| `<top-viewer-measure-volume-button>` | Activates volume measurement |
|
|
259
|
-
| `<top-viewer-measure-button>` | All measurement modes in one button (a menu by default), or a chosen subset via `modes` (see below) |
|
|
260
|
-
| `<top-viewer-projection-toggle-button>` | Toggles Perspective ⇄ Orthographic |
|
|
261
|
-
| `<top-viewer-walkthrough-button>` | Toggles first-person walkthrough |
|
|
262
|
-
| `<top-viewer-navigation-button>` | Switches between orbit and first-person navigation (a menu by default), or a single chosen mode via `modes` (see below) |
|
|
263
|
-
|
|
264
|
-
Each one self-wires from context — drop it anywhere under `<top-viewer>`
|
|
265
|
-
and it works, with no props to pass in.
|
|
266
|
-
|
|
267
|
-
### ✂️ Clip button modes
|
|
268
|
-
|
|
269
|
-
Without any attribute, `<top-viewer-clip-button>` enters face-placing mode:
|
|
270
|
-
double-click a face in the model and a clip plane is dropped on it. The
|
|
271
|
-
optional `modes` attribute changes what the button offers — a whitespace-
|
|
272
|
-
(or comma-) separated list of `x`, `y`, `z` and `face` (case-insensitive;
|
|
273
|
-
unknown tokens are ignored, duplicates dropped, the order you write is the
|
|
274
|
-
order shown):
|
|
275
|
-
|
|
276
|
-
```html
|
|
277
|
-
<!-- a menu with four entries: X axis, Y axis, Z axis, Face -->
|
|
278
|
-
<top-viewer-clip-button modes="x y z face"></top-viewer-clip-button>
|
|
279
|
-
|
|
280
|
-
<!-- one mode = no menu; a click creates a horizontal cut right away -->
|
|
281
|
-
<top-viewer-clip-button modes="y"></top-viewer-clip-button>
|
|
282
|
-
|
|
283
|
-
<!-- default: face-placing mode -->
|
|
284
|
-
<top-viewer-clip-button></top-viewer-clip-button>
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
- **One mode** — the button runs it directly on click. `face` is the
|
|
288
|
-
default face-placing behavior.
|
|
289
|
-
- **Two or more** — clicking opens a menu with one entry per mode ("X
|
|
290
|
-
axis", "Y axis", "Z axis", "Face"); picking one runs it and closes the
|
|
291
|
-
menu.
|
|
292
|
-
- **Axis modes** create a single plane through the center of the bounding
|
|
293
|
-
box of all loaded models (nothing happens if no model is loaded). Axes
|
|
294
|
-
follow the three.js convention — **Y is vertical**, so `y` is a
|
|
295
|
-
horizontal cut. The plane's normal is the *negative* axis — `(-1, 0, 0)`,
|
|
296
|
-
`(0, -1, 0)`, `(0, 0, -1)` — so the plane clips what lies on the
|
|
297
|
-
positive side of the axis (`y` removes everything above the middle of
|
|
298
|
-
the model). Axis planes behave exactly like face-placed ones: same
|
|
299
|
-
section styling, listed in the objects outliner, draggable by their
|
|
300
|
-
gizmo, removable with Delete.
|
|
301
|
-
- The button shows as active only while face-placing mode is on.
|
|
302
|
-
|
|
303
|
-
### 📏 Measure button modes
|
|
304
|
-
|
|
305
|
-
`<top-viewer-measure-button>` puts the measurement tools behind a single
|
|
306
|
-
button. Without any attribute it offers all six modes — `length`, `area`,
|
|
307
|
-
`angle`, `edge`, `face`, `volume` — in a menu. The optional `modes`
|
|
308
|
-
attribute picks a subset (whitespace- or comma-separated, case-insensitive;
|
|
309
|
-
unknown tokens are ignored, duplicates dropped, your order is kept):
|
|
310
|
-
|
|
311
|
-
```html
|
|
312
|
-
<!-- default: a menu with all six modes -->
|
|
313
|
-
<top-viewer-measure-button></top-viewer-measure-button>
|
|
314
|
-
|
|
315
|
-
<!-- a menu with just these three, in this order -->
|
|
316
|
-
<top-viewer-measure-button modes="length area volume"></top-viewer-measure-button>
|
|
317
|
-
|
|
318
|
-
<!-- one mode = no menu; a click starts that measurement right away -->
|
|
319
|
-
<top-viewer-measure-button modes="length"></top-viewer-measure-button>
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
- **One mode** — a click activates it directly, exactly like the matching
|
|
323
|
-
standalone button (`length` and `area` measure freely; `edge` and `face`
|
|
324
|
-
snap to edges and faces).
|
|
325
|
-
- **Two or more** — a click opens a menu with one text-labelled entry per
|
|
326
|
-
mode ("Length", "Area", "Angle", "Edge", "Face", "Volume"); picking one
|
|
327
|
-
activates it and closes the menu.
|
|
328
|
-
- The button shows as active while any of its modes is the active
|
|
329
|
-
measurement mode, and its icon switches to that mode's icon (a ruler
|
|
330
|
-
otherwise). In the menu, the active mode's entry is marked.
|
|
331
|
-
|
|
332
|
-
### 🧭 Navigation button modes
|
|
333
|
-
|
|
334
|
-
`<top-viewer-navigation-button>` switches how the camera moves. Without any
|
|
335
|
-
attribute it offers both modes — `orbit` and `first-person` — in a menu.
|
|
336
|
-
The optional `modes` attribute narrows or reorders them (whitespace- or
|
|
337
|
-
comma-separated, case-insensitive; unknown tokens are ignored, duplicates
|
|
338
|
-
dropped, your order is kept):
|
|
339
|
-
|
|
340
|
-
```html
|
|
341
|
-
<!-- default: a menu with "Orbit" and "First person" -->
|
|
342
|
-
<top-viewer-navigation-button></top-viewer-navigation-button>
|
|
343
|
-
|
|
344
|
-
<!-- one mode = no menu; a click switches straight to it -->
|
|
345
|
-
<top-viewer-navigation-button modes="orbit"></top-viewer-navigation-button>
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
- `orbit` turns first-person navigation off (nothing happens if it already
|
|
349
|
-
is); `first-person` turns it on (nothing happens if it already is) — the
|
|
350
|
-
same first-person navigation `<top-viewer-walkthrough-button>` toggles.
|
|
351
|
-
- The button's icon always shows the current mode, and the button is active
|
|
352
|
-
while first-person is on. In the menu, the current mode's entry is marked.
|
|
353
|
-
### ♻️ Reset button options
|
|
354
|
-
|
|
355
|
-
By default `<top-viewer-reset-button>` restores full visibility and clears
|
|
356
|
-
ghosting. The optional `reset` attribute lists what it resets — any of
|
|
357
|
-
`visibility`, `sections` (every clipping plane and its section styling)
|
|
358
|
-
and `measurements` (every measurement), whitespace- or comma-separated,
|
|
359
|
-
case-insensitive, unknown tokens ignored:
|
|
360
|
-
|
|
361
|
-
```html
|
|
362
|
-
<!-- default: visibility only -->
|
|
363
|
-
<top-viewer-reset-button></top-viewer-reset-button>
|
|
364
|
-
|
|
365
|
-
<!-- reset everything -->
|
|
366
|
-
<top-viewer-reset-button reset="visibility sections measurements"></top-viewer-reset-button>
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
- Parts always run in the order visibility, sections, measurements, and one
|
|
370
|
-
failing part doesn't stop the others.
|
|
371
|
-
- When `sections` or `measurements` is listed, the viewer returns to the
|
|
372
|
-
default Select tool afterwards, so nobody is left inside a half-finished
|
|
373
|
-
measure or clip mode.
|
|
374
|
-
- The tooltip describes what the button resets, and first-person navigation
|
|
375
|
-
is left as it is.
|
|
376
|
-
*/
|
|
1
|
+
/* MD
|
|
2
|
+
## top-viewer-toolbar
|
|
3
|
+
---
|
|
4
|
+
A 3D viewport is only as useful as the controls around it: selecting a
|
|
5
|
+
target set, hiding/isolating/ghosting elements, clipping, measuring,
|
|
6
|
+
walking through the model. Building that toolbar — and keeping every
|
|
7
|
+
button in sync with tool state and with each other — is real work, before
|
|
8
|
+
you've customized anything.
|
|
9
|
+
|
|
10
|
+
`top-viewer-toolbar` is a ready-made web component that delivers exactly
|
|
11
|
+
that. Mounted as-is, it's a complete, self-wiring bottom toolbar. But it's
|
|
12
|
+
also built out of standalone, individually-importable
|
|
13
|
+
`<top-viewer-*-button>` elements — so if the default layout isn't what your
|
|
14
|
+
app needs, you can drop the bar it builds for you and compose your own out
|
|
15
|
+
of the same pieces, mixed freely with your own custom buttons.
|
|
16
|
+
|
|
17
|
+
This tutorial covers the prerequisites; the default, batteries-included
|
|
18
|
+
toolbar; what it manages automatically; composing a custom layout with
|
|
19
|
+
`headless`; docking a vertical toolbar; and the full list of standalone
|
|
20
|
+
buttons available.
|
|
21
|
+
|
|
22
|
+
By the end, you'll have both a working default toolbar and a fully custom
|
|
23
|
+
one running side by side in the same viewport.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { html } from "lit";
|
|
27
|
+
import * as THREE from "three";
|
|
28
|
+
import * as OBC from "@thatopen/components";
|
|
29
|
+
import * as OBF from "@thatopen/components-front";
|
|
30
|
+
import * as FRAGS from "@thatopen/fragments";
|
|
31
|
+
import * as BUI from "@thatopen/ui";
|
|
32
|
+
import { PlatformClient, UIManager } from "@thatopen/services";
|
|
33
|
+
import type { App } from "../app/index";
|
|
34
|
+
|
|
35
|
+
/* MD
|
|
36
|
+
### ✅ Prerequisites
|
|
37
|
+
|
|
38
|
+
`<top-viewer-toolbar>` must be mounted as a descendant of `<top-viewer>` —
|
|
39
|
+
it consumes the `componentsContext`/`worldContext` that `<top-viewer>`
|
|
40
|
+
provides, and the standalone buttons it's built from consume the same
|
|
41
|
+
contexts. `UIManager` must be in the setup call so both custom elements are
|
|
42
|
+
registered. Nothing else is required — no manager to `init`, no extra
|
|
43
|
+
config.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
const client = PlatformClient.fromPlatformContext();
|
|
47
|
+
|
|
48
|
+
const { components } = (await client.setup(
|
|
49
|
+
{ OBC, OBF, BUI, THREE, FRAGS },
|
|
50
|
+
{ uuid: UIManager.uuid },
|
|
51
|
+
)) as { components: OBC.Components };
|
|
52
|
+
|
|
53
|
+
components.get(UIManager).init();
|
|
54
|
+
|
|
55
|
+
/* MD
|
|
56
|
+
### 🖥️ Default toolbar (batteries included)
|
|
57
|
+
|
|
58
|
+
Add it as a plain child of `<top-viewer>` — no `slot` needed, it docks
|
|
59
|
+
into `"bottom"` on its own:
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<top-viewer>
|
|
63
|
+
<top-viewer-toolbar></top-viewer-toolbar>
|
|
64
|
+
</top-viewer>
|
|
65
|
+
```
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
const app = document.createElement("top-app") as unknown as App;
|
|
69
|
+
|
|
70
|
+
app.setup = (waitUntil) => {
|
|
71
|
+
waitUntil(
|
|
72
|
+
(async () => {
|
|
73
|
+
const fragments = components.get(OBC.FragmentsManager);
|
|
74
|
+
const workerUrl = await FRAGS.FragmentsModels.getWorker();
|
|
75
|
+
fragments.init(await FRAGS.toClassicWorker(workerUrl), { classicWorker: true });
|
|
76
|
+
})(),
|
|
77
|
+
"Fragments Core",
|
|
78
|
+
);
|
|
79
|
+
return { components, client };
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
app.elements = {
|
|
83
|
+
viewer: () => html`
|
|
84
|
+
<top-viewer>
|
|
85
|
+
<top-viewer-toolbar></top-viewer-toolbar>
|
|
86
|
+
</top-viewer>
|
|
87
|
+
`,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
app.layouts = {
|
|
91
|
+
main: {
|
|
92
|
+
label: "Main",
|
|
93
|
+
icon: "solar:3d-square-bold",
|
|
94
|
+
template: `"viewer" 1fr / 1fr`,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
app.layout = "main";
|
|
99
|
+
|
|
100
|
+
const container = document.getElementById("that-open-app") ?? document.body;
|
|
101
|
+
container.appendChild(app);
|
|
102
|
+
document.body.style.margin = "0";
|
|
103
|
+
|
|
104
|
+
/* MD
|
|
105
|
+
### 🤖 What the default toolbar manages automatically
|
|
106
|
+
|
|
107
|
+
**Target mode** — a toggle between "Selected" and "Unselected", which every
|
|
108
|
+
visibility button below operates on. Empty selection while targeting
|
|
109
|
+
"Selected" means the target is empty (actions no-op); targeting
|
|
110
|
+
"Unselected" with an empty selection means the target is the whole model.
|
|
111
|
+
|
|
112
|
+
**Visibility actions** (each reversible via Show/Reset) — Hide, Show,
|
|
113
|
+
Isolate, Ghost (semi-transparent), Focus, and a global Reset that restores
|
|
114
|
+
full visibility and opacity regardless of target mode.
|
|
115
|
+
|
|
116
|
+
**Inspect tab** — Select (default tool), Clip, and six measurement modes
|
|
117
|
+
(length, area, angle, edge, face, volume), all sharing one active-tool
|
|
118
|
+
manager so switching tools un-highlights whichever was active before.
|
|
119
|
+
|
|
120
|
+
**Projection + walkthrough** — a Perspective⇄Orthographic toggle and a
|
|
121
|
+
first-person walkthrough toggle, each reflecting live state.
|
|
122
|
+
|
|
123
|
+
**Active-tool HUD** — a floating overlay over the 3D viewport itself
|
|
124
|
+
showing context for whichever tool is currently active (e.g. clip plane
|
|
125
|
+
controls, measurement readouts).
|
|
126
|
+
|
|
127
|
+
All of the above are per-`components` singletons — any other UI in your
|
|
128
|
+
app that resolves the same tool (e.g. via `components.get(...)`) shares
|
|
129
|
+
the exact same state, not a second, independent instance.
|
|
130
|
+
|
|
131
|
+
### 🧱 Composing a custom layout with `headless`
|
|
132
|
+
|
|
133
|
+
Set the `headless` attribute to skip the default bar's own assembly, while
|
|
134
|
+
everything else — providing context to descendants, the active-tool HUD —
|
|
135
|
+
keeps running. Slot your own buttons as light-DOM children: they consume
|
|
136
|
+
the same context the default bar's buttons do, wherever you place them.
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<top-viewer>
|
|
140
|
+
<top-viewer-toolbar headless>
|
|
141
|
+
<!-- your own content goes here as light-DOM children -->
|
|
142
|
+
</top-viewer-toolbar>
|
|
143
|
+
</top-viewer>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Mixing standalone buttons with a plain, app-owned `bim-button` in the same
|
|
147
|
+
bar — built with lit's `render`/`html` into a plain container element
|
|
148
|
+
(never `document.createElement` for the `bim-*` tags themselves, see the
|
|
149
|
+
gotcha below), then appended as the toolbar's light-DOM content:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { html, render } from "lit";
|
|
153
|
+
|
|
154
|
+
const headlessBar = document.createElement("top-viewer-toolbar");
|
|
155
|
+
headlessBar.toggleAttribute("headless", true);
|
|
156
|
+
|
|
157
|
+
// A plain container — the `<bim-toolbar>` itself is rendered inside it.
|
|
158
|
+
const toolbarHost = document.createElement("div");
|
|
159
|
+
toolbarHost.style.pointerEvents = "auto";
|
|
160
|
+
render(
|
|
161
|
+
html`
|
|
162
|
+
<bim-toolbar>
|
|
163
|
+
<bim-toolbar-section label-hidden style="background: transparent;">
|
|
164
|
+
<top-viewer-mode-toggle-button></top-viewer-mode-toggle-button>
|
|
165
|
+
<top-viewer-hide-button></top-viewer-hide-button>
|
|
166
|
+
<top-viewer-select-button></top-viewer-select-button>
|
|
167
|
+
</bim-toolbar-section>
|
|
168
|
+
<bim-toolbar-section label-hidden style="background: transparent;">
|
|
169
|
+
<bim-button
|
|
170
|
+
icon="mdi:fit-to-page-outline"
|
|
171
|
+
@click=${() => myOwnFitToViewLogic()}
|
|
172
|
+
><bim-tooltip placement="top">Zoom to fit</bim-tooltip></bim-button>
|
|
173
|
+
</bim-toolbar-section>
|
|
174
|
+
</bim-toolbar>
|
|
175
|
+
`,
|
|
176
|
+
toolbarHost,
|
|
177
|
+
);
|
|
178
|
+
headlessBar.appendChild(toolbarHost);
|
|
179
|
+
// headlessBar can now be appended anywhere inside <top-viewer>.
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 📐 Docking a vertical toolbar
|
|
183
|
+
|
|
184
|
+
The host centers its own content via flexbox, controllable through CSS
|
|
185
|
+
custom properties — including flipping to a vertical stack for a
|
|
186
|
+
sidebar-style dock:
|
|
187
|
+
|
|
188
|
+
```html
|
|
189
|
+
<top-viewer-toolbar
|
|
190
|
+
headless
|
|
191
|
+
slot="right"
|
|
192
|
+
style="--top-viewer-toolbar-direction: column;"
|
|
193
|
+
>
|
|
194
|
+
...
|
|
195
|
+
</top-viewer-toolbar>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
- `--top-viewer-toolbar-direction` — `row` (default) or `column`.
|
|
199
|
+
- `--top-viewer-toolbar-justify` — alignment along the main axis (default
|
|
200
|
+
`center`).
|
|
201
|
+
- `--top-viewer-toolbar-align` — alignment along the cross axis (default
|
|
202
|
+
`center`).
|
|
203
|
+
|
|
204
|
+
Pair `--top-viewer-toolbar-direction: column` with `bim-toolbar`'s own
|
|
205
|
+
`vertical` attribute on the content you render inside, so the buttons
|
|
206
|
+
themselves stack the same way the bar does.
|
|
207
|
+
|
|
208
|
+
### ⚠️ Gotchas
|
|
209
|
+
|
|
210
|
+
- **Never `document.createElement` a `bim-*` element.** `bim-button`,
|
|
211
|
+
`bim-toolbar`, `bim-toolbar-section`, and every other `@thatopen/ui`
|
|
212
|
+
component set attributes on themselves in their own constructor, which
|
|
213
|
+
Custom Elements v1 forbids for elements created imperatively —
|
|
214
|
+
`document.createElement("bim-button")` throws `NotSupportedError`.
|
|
215
|
+
Render them with lit's `render(html\`...\`, container)` instead, exactly
|
|
216
|
+
like the `toolbarHost` container above — never build them by hand.
|
|
217
|
+
- **`bim-button` sizes itself** — square when it's icon-only, a consistent
|
|
218
|
+
height when it has a label. Don't set `width`/`height`/`min-width`
|
|
219
|
+
inline on it; that only fights its own layout and produces buttons that
|
|
220
|
+
look inconsistent next to the rest of the bar.
|
|
221
|
+
- **Centering/alignment belongs on the toolbar's host**, via the CSS custom
|
|
222
|
+
properties above — not on the content you slot into it. Setting
|
|
223
|
+
`justify-self` (or similar) on your own buttons instead of using
|
|
224
|
+
`--top-viewer-toolbar-justify` only works by accident, if at all.
|
|
225
|
+
- **A standalone button works from anywhere in the DOM**, as long as it
|
|
226
|
+
ends up a descendant of a `<top-viewer-toolbar>` inside a `<top-viewer>`
|
|
227
|
+
— context requests bubble through shadow-DOM boundaries. It does *not*
|
|
228
|
+
need to be a direct child of the bar it visually sits in.
|
|
229
|
+
|
|
230
|
+
### 🧩 Standalone buttons reference
|
|
231
|
+
|
|
232
|
+
Every button the default bar uses is independently importable/usable as
|
|
233
|
+
its own custom element. They render icon-only with a tooltip; set the
|
|
234
|
+
optional `label` attribute on any of them to show text next to the icon
|
|
235
|
+
(the tooltip stays as it is):
|
|
236
|
+
|
|
237
|
+
```html
|
|
238
|
+
<top-viewer-hide-button label="Hide"></top-viewer-hide-button>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
| Element | Does |
|
|
242
|
+
|---|---|
|
|
243
|
+
| `<top-viewer-mode-toggle-button>` | Toggles target: Selected ⇄ Unselected |
|
|
244
|
+
| `<top-viewer-hide-button>` | Hides the target set |
|
|
245
|
+
| `<top-viewer-show-button>` | Un-hides the target set |
|
|
246
|
+
| `<top-viewer-isolate-button>` | Shows only the target set |
|
|
247
|
+
| `<top-viewer-ghost-button>` | Renders the target set semi-transparent |
|
|
248
|
+
| `<top-viewer-gis-ghost-button>` | Makes the GIS map (the 3D tiles of `GISManager`) see-through ⇄ opaque; disabled until the tiles are loaded; the optional `opacity` attribute (0 to 1, default `0.3`) sets the see-through level |
|
|
249
|
+
| `<top-viewer-focus-button>` | Frames the camera on the target set |
|
|
250
|
+
| `<top-viewer-reset-button>` | Shows everything and clears ghosting (global); the optional `reset` attribute can also remove sections and measurements (see below) |
|
|
251
|
+
| `<top-viewer-select-button>` | Activates the default Select tool |
|
|
252
|
+
| `<top-viewer-clip-button>` | Clipping planes: face-placing mode by default, or axis planes / a mode menu via `modes` (see below) |
|
|
253
|
+
| `<top-viewer-measure-length-button>` | Activates length measurement |
|
|
254
|
+
| `<top-viewer-measure-area-button>` | Activates area measurement |
|
|
255
|
+
| `<top-viewer-measure-angle-button>` | Activates angle measurement |
|
|
256
|
+
| `<top-viewer-measure-edge-button>` | Activates edge measurement |
|
|
257
|
+
| `<top-viewer-measure-face-button>` | Activates face measurement |
|
|
258
|
+
| `<top-viewer-measure-volume-button>` | Activates volume measurement |
|
|
259
|
+
| `<top-viewer-measure-button>` | All measurement modes in one button (a menu by default), or a chosen subset via `modes` (see below) |
|
|
260
|
+
| `<top-viewer-projection-toggle-button>` | Toggles Perspective ⇄ Orthographic |
|
|
261
|
+
| `<top-viewer-walkthrough-button>` | Toggles first-person walkthrough |
|
|
262
|
+
| `<top-viewer-navigation-button>` | Switches between orbit and first-person navigation (a menu by default), or a single chosen mode via `modes` (see below) |
|
|
263
|
+
|
|
264
|
+
Each one self-wires from context — drop it anywhere under `<top-viewer>`
|
|
265
|
+
and it works, with no props to pass in.
|
|
266
|
+
|
|
267
|
+
### ✂️ Clip button modes
|
|
268
|
+
|
|
269
|
+
Without any attribute, `<top-viewer-clip-button>` enters face-placing mode:
|
|
270
|
+
double-click a face in the model and a clip plane is dropped on it. The
|
|
271
|
+
optional `modes` attribute changes what the button offers — a whitespace-
|
|
272
|
+
(or comma-) separated list of `x`, `y`, `z` and `face` (case-insensitive;
|
|
273
|
+
unknown tokens are ignored, duplicates dropped, the order you write is the
|
|
274
|
+
order shown):
|
|
275
|
+
|
|
276
|
+
```html
|
|
277
|
+
<!-- a menu with four entries: X axis, Y axis, Z axis, Face -->
|
|
278
|
+
<top-viewer-clip-button modes="x y z face"></top-viewer-clip-button>
|
|
279
|
+
|
|
280
|
+
<!-- one mode = no menu; a click creates a horizontal cut right away -->
|
|
281
|
+
<top-viewer-clip-button modes="y"></top-viewer-clip-button>
|
|
282
|
+
|
|
283
|
+
<!-- default: face-placing mode -->
|
|
284
|
+
<top-viewer-clip-button></top-viewer-clip-button>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
- **One mode** — the button runs it directly on click. `face` is the
|
|
288
|
+
default face-placing behavior.
|
|
289
|
+
- **Two or more** — clicking opens a menu with one entry per mode ("X
|
|
290
|
+
axis", "Y axis", "Z axis", "Face"); picking one runs it and closes the
|
|
291
|
+
menu.
|
|
292
|
+
- **Axis modes** create a single plane through the center of the bounding
|
|
293
|
+
box of all loaded models (nothing happens if no model is loaded). Axes
|
|
294
|
+
follow the three.js convention — **Y is vertical**, so `y` is a
|
|
295
|
+
horizontal cut. The plane's normal is the *negative* axis — `(-1, 0, 0)`,
|
|
296
|
+
`(0, -1, 0)`, `(0, 0, -1)` — so the plane clips what lies on the
|
|
297
|
+
positive side of the axis (`y` removes everything above the middle of
|
|
298
|
+
the model). Axis planes behave exactly like face-placed ones: same
|
|
299
|
+
section styling, listed in the objects outliner, draggable by their
|
|
300
|
+
gizmo, removable with Delete.
|
|
301
|
+
- The button shows as active only while face-placing mode is on.
|
|
302
|
+
|
|
303
|
+
### 📏 Measure button modes
|
|
304
|
+
|
|
305
|
+
`<top-viewer-measure-button>` puts the measurement tools behind a single
|
|
306
|
+
button. Without any attribute it offers all six modes — `length`, `area`,
|
|
307
|
+
`angle`, `edge`, `face`, `volume` — in a menu. The optional `modes`
|
|
308
|
+
attribute picks a subset (whitespace- or comma-separated, case-insensitive;
|
|
309
|
+
unknown tokens are ignored, duplicates dropped, your order is kept):
|
|
310
|
+
|
|
311
|
+
```html
|
|
312
|
+
<!-- default: a menu with all six modes -->
|
|
313
|
+
<top-viewer-measure-button></top-viewer-measure-button>
|
|
314
|
+
|
|
315
|
+
<!-- a menu with just these three, in this order -->
|
|
316
|
+
<top-viewer-measure-button modes="length area volume"></top-viewer-measure-button>
|
|
317
|
+
|
|
318
|
+
<!-- one mode = no menu; a click starts that measurement right away -->
|
|
319
|
+
<top-viewer-measure-button modes="length"></top-viewer-measure-button>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
- **One mode** — a click activates it directly, exactly like the matching
|
|
323
|
+
standalone button (`length` and `area` measure freely; `edge` and `face`
|
|
324
|
+
snap to edges and faces).
|
|
325
|
+
- **Two or more** — a click opens a menu with one text-labelled entry per
|
|
326
|
+
mode ("Length", "Area", "Angle", "Edge", "Face", "Volume"); picking one
|
|
327
|
+
activates it and closes the menu.
|
|
328
|
+
- The button shows as active while any of its modes is the active
|
|
329
|
+
measurement mode, and its icon switches to that mode's icon (a ruler
|
|
330
|
+
otherwise). In the menu, the active mode's entry is marked.
|
|
331
|
+
|
|
332
|
+
### 🧭 Navigation button modes
|
|
333
|
+
|
|
334
|
+
`<top-viewer-navigation-button>` switches how the camera moves. Without any
|
|
335
|
+
attribute it offers both modes — `orbit` and `first-person` — in a menu.
|
|
336
|
+
The optional `modes` attribute narrows or reorders them (whitespace- or
|
|
337
|
+
comma-separated, case-insensitive; unknown tokens are ignored, duplicates
|
|
338
|
+
dropped, your order is kept):
|
|
339
|
+
|
|
340
|
+
```html
|
|
341
|
+
<!-- default: a menu with "Orbit" and "First person" -->
|
|
342
|
+
<top-viewer-navigation-button></top-viewer-navigation-button>
|
|
343
|
+
|
|
344
|
+
<!-- one mode = no menu; a click switches straight to it -->
|
|
345
|
+
<top-viewer-navigation-button modes="orbit"></top-viewer-navigation-button>
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
- `orbit` turns first-person navigation off (nothing happens if it already
|
|
349
|
+
is); `first-person` turns it on (nothing happens if it already is) — the
|
|
350
|
+
same first-person navigation `<top-viewer-walkthrough-button>` toggles.
|
|
351
|
+
- The button's icon always shows the current mode, and the button is active
|
|
352
|
+
while first-person is on. In the menu, the current mode's entry is marked.
|
|
353
|
+
### ♻️ Reset button options
|
|
354
|
+
|
|
355
|
+
By default `<top-viewer-reset-button>` restores full visibility and clears
|
|
356
|
+
ghosting. The optional `reset` attribute lists what it resets — any of
|
|
357
|
+
`visibility`, `sections` (every clipping plane and its section styling)
|
|
358
|
+
and `measurements` (every measurement), whitespace- or comma-separated,
|
|
359
|
+
case-insensitive, unknown tokens ignored:
|
|
360
|
+
|
|
361
|
+
```html
|
|
362
|
+
<!-- default: visibility only -->
|
|
363
|
+
<top-viewer-reset-button></top-viewer-reset-button>
|
|
364
|
+
|
|
365
|
+
<!-- reset everything -->
|
|
366
|
+
<top-viewer-reset-button reset="visibility sections measurements"></top-viewer-reset-button>
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
- Parts always run in the order visibility, sections, measurements, and one
|
|
370
|
+
failing part doesn't stop the others.
|
|
371
|
+
- When `sections` or `measurements` is listed, the viewer returns to the
|
|
372
|
+
default Select tool afterwards, so nobody is left inside a half-finished
|
|
373
|
+
measure or clip mode.
|
|
374
|
+
- The tooltip describes what the button resets, and first-person navigation
|
|
375
|
+
is left as it is.
|
|
376
|
+
*/
|