@thatopen/services 0.36.0 → 0.37.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.
- package/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/templates/app/README.md +12 -7
- package/src/cli/templates/app/package.json +1 -1
- package/src/cli/templates/app/src/main.history.ts +14 -37
- package/src/cli/templates/app/src/main.ts +18 -74
- package/src/cli/templates/app/src/webgpu/webgl-addons-stub.mjs +61 -0
- package/src/cli/templates/app/src/webgpu/webgpu-lines.mjs +104 -0
- package/src/cli/templates/app/vite.config.js +17 -1
- package/src/cli/templates/app/src/setups/reality-capture/lib/hidden-tiles-plugin.ts +0 -88
- package/src/cli/templates/app/src/setups/reality-capture/lib/point-tile-plugin.ts +0 -166
- package/src/cli/templates/app/src/setups/reality-capture/lib/render-frame.ts +0 -31
- package/src/cli/templates/app/src/setups/reality-capture/lib/splat-tile-plugin.ts +0 -51
- package/src/cli/templates/app/src/setups/reality-capture-viewer.ts +0 -1383
package/package.json
CHANGED
|
@@ -77,12 +77,17 @@ place with plain HTML/`BUI.html`:
|
|
|
77
77
|
|
|
78
78
|
- `<top-app>` — the app shell: a CSS-grid layout system with a sidebar (activity bar)
|
|
79
79
|
for switching named layouts.
|
|
80
|
-
- `<top-viewer>` — the
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
- `<top-file-viewer>` — the document viewer, as the platform's apps have it: each file opened
|
|
81
|
+
with its viewer (3D, PDF, text). Given no viewers, it brings the platform's own: a 3D viewer
|
|
82
|
+
ready for streamed models, with its tools and its bar (3D/2D, projection, the colours softened
|
|
83
|
+
by default).
|
|
84
|
+
- `<top-documents-panel reads-project>` — the project's documents; a click opens one in the viewer.
|
|
85
|
+
IFC files are converted by the platform when uploaded, not in the browser.
|
|
86
|
+
- Side panels — `<top-model-tree>`, `<top-properties-panel>`, `<top-data-table-panel>`,
|
|
87
|
+
`<top-settings-panel>`, … — each self-wires from the contexts `<top-app>` provides
|
|
88
|
+
(no `components` plumbing needed).
|
|
89
|
+
- WebGPU: the app is built on three's WebGPU build (`src/webgpu/`), as the platform's apps; where
|
|
90
|
+
the browser has no WebGPU, three draws with WebGL2.
|
|
86
91
|
|
|
87
92
|
The scaffolded `src/main.ts` already sets this up. The shape is:
|
|
88
93
|
|
|
@@ -184,7 +189,7 @@ const fileBuffer = await (await client.downloadFile(fileId)).arrayBuffer();
|
|
|
184
189
|
await fragments.core.load(fileBuffer, { modelId: "my-model" });
|
|
185
190
|
```
|
|
186
191
|
|
|
187
|
-
(The scaffold's
|
|
192
|
+
(The scaffold's documents panel already opens the models the user picks, so you
|
|
188
193
|
usually don't need to do this by hand.)
|
|
189
194
|
|
|
190
195
|
## PlatformClient API (commonly used in apps)
|
|
@@ -27,13 +27,15 @@ import { setAppContext } from "./app";
|
|
|
27
27
|
async function main() {
|
|
28
28
|
const client = PlatformClient.fromPlatformContext();
|
|
29
29
|
|
|
30
|
-
// Brand accent
|
|
31
|
-
document.documentElement.style.setProperty("--bim-ui_accent-base", "
|
|
30
|
+
// Brand accent: the library's own purple (UI colours only from @thatopen/ui's variables), as the platform's apps.
|
|
31
|
+
document.documentElement.style.setProperty("--bim-ui_accent-base", "var(--bim-ui_main-base)");
|
|
32
32
|
|
|
33
33
|
// The dev `thatopen serve` wrapper HTML doesn't zero the UA body margin (8px),
|
|
34
34
|
// which insets the whole app inside the platform iframe. Kill it here so it's
|
|
35
35
|
// fixed in both dev and production regardless of the host page.
|
|
36
36
|
document.body.style.margin = "0";
|
|
37
|
+
// The library's background, set by the app and not by the host page, so it holds inside the platform too.
|
|
38
|
+
document.body.style.background = "var(--bim-ui_bg-base)";
|
|
37
39
|
|
|
38
40
|
// 1 ── UIManager registers the platform web components (top-app, top-viewer, …)
|
|
39
41
|
// before the DOM renders. GitHistoryManager is the headless half of the history
|
|
@@ -46,12 +48,13 @@ async function main() {
|
|
|
46
48
|
);
|
|
47
49
|
components.get(UIManager).init();
|
|
48
50
|
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
viewerEl
|
|
51
|
+
// The platform's document viewer, as the Hub's and the Coordinator's: each file opened with its viewer (3D, PDF,
|
|
52
|
+
// text), the 3D scene kept alive between them. Given no viewers it brings the platform's own: a 3D viewer ready for
|
|
53
|
+
// streamed models, its bar (3D/2D, projection, the colours softened by default), undo of section planes and measures.
|
|
54
|
+
// One STABLE node, returned by reference so re-rendering top-app reuses it instead of rebuilding its world.
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
const viewerEl = document.createElement("top-file-viewer") as any;
|
|
57
|
+
viewerEl.keepScene = true;
|
|
55
58
|
|
|
56
59
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
60
|
const app = document.createElement("top-app") as any;
|
|
@@ -103,40 +106,15 @@ async function main() {
|
|
|
103
106
|
// at the top of this file before moving this line.
|
|
104
107
|
await components.get(GitHistoryManager).init(client);
|
|
105
108
|
|
|
106
|
-
// Pluggable loaders for <top-models-list>. Heavy, app-specific loaders are
|
|
107
|
-
// registered here so they stay OUT of the built-in's bundle.
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
|
-
let rcViewer: any = null;
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
-
const modelLoaders: Record<string, any> = {
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
-
"3tz": async (fileId: string, ctx: any) => {
|
|
114
|
-
if (!rcViewer) {
|
|
115
|
-
const { realityCaptureViewer } = await import(
|
|
116
|
-
"./setups/reality-capture-viewer"
|
|
117
|
-
);
|
|
118
|
-
rcViewer = realityCaptureViewer(ctx.components, client);
|
|
119
|
-
}
|
|
120
|
-
const saved = ctx.getAlignment(fileId) as number[] | undefined;
|
|
121
|
-
await rcViewer.loadIntoWorld(fileId, {
|
|
122
|
-
keepPostproduction: true,
|
|
123
|
-
transform: saved ? new THREE.Matrix4().fromArray(saved) : undefined,
|
|
124
|
-
onTransformChange: (m: THREE.Matrix4) =>
|
|
125
|
-
ctx.setAlignment(fileId, m.toArray()),
|
|
126
|
-
});
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
109
|
// The stable viewer + the panels, under named layouts with the activity-bar
|
|
131
110
|
// sidebar. All panels are built-ins that self-wire from top-app's contexts.
|
|
132
111
|
app.elements = {
|
|
133
112
|
viewer: () => BUI.html`${viewerEl}`,
|
|
134
113
|
tree: () => BUI.html`<top-model-tree></top-model-tree>`,
|
|
135
114
|
properties: () => BUI.html`<top-properties-panel></top-properties-panel>`,
|
|
136
|
-
|
|
137
|
-
|
|
115
|
+
// The project's documents, as every platform app lists them: a click opens one in the viewer.
|
|
116
|
+
files: () => BUI.html`<top-documents-panel reads-project></top-documents-panel>`,
|
|
138
117
|
dataTable: () => BUI.html`<top-data-table-panel></top-data-table-panel>`,
|
|
139
|
-
objects: () => BUI.html`<top-objects-panel></top-objects-panel>`,
|
|
140
118
|
settings: () => BUI.html`<top-settings-panel></top-settings-panel>`,
|
|
141
119
|
history: () => BUI.html`<top-git-history></top-git-history>`,
|
|
142
120
|
};
|
|
@@ -147,7 +125,7 @@ async function main() {
|
|
|
147
125
|
},
|
|
148
126
|
Assets: {
|
|
149
127
|
icon: "mdi:folder-multiple-outline",
|
|
150
|
-
template: `"files viewer" 1fr "
|
|
128
|
+
template: `"files viewer" 1fr "properties viewer" 1fr / 22rem 1fr`,
|
|
151
129
|
},
|
|
152
130
|
Data: {
|
|
153
131
|
icon: "mdi:table",
|
|
@@ -167,7 +145,6 @@ async function main() {
|
|
|
167
145
|
app.layout = "History";
|
|
168
146
|
app.sidebar = true;
|
|
169
147
|
|
|
170
|
-
viewerEl.appendChild(document.createElement("top-viewer-toolbar"));
|
|
171
148
|
|
|
172
149
|
// The history panel lights up once a revit-flow model is loaded. Load it from the
|
|
173
150
|
// Assets panel, or auto-load it here if this app only ever shows one model.
|
|
@@ -10,27 +10,20 @@ import { PlatformClient, UIManager } from "@thatopen/services";
|
|
|
10
10
|
import { setAppContext } from "./app";
|
|
11
11
|
import { setupChannel } from "./setups/channel";
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// built-ins into the single UIManager built-in, which ships `top-app` (shell +
|
|
16
|
-
// layout) and `top-viewer` (deferred-PEN viewport). This boots the bim-viewer on
|
|
17
|
-
// that model.
|
|
18
|
-
// Phase 1 — top-app shell hosting one top-viewer + auto-load. [done]
|
|
19
|
-
// Phase 2 — re-dock the side panels (tree/properties/files/data/objects/
|
|
20
|
-
// settings) into top-app's layouts + sidebar. [this file]
|
|
21
|
-
// Phase 3 — the viewer-overlay tools (fps/HUD/gizmo/bottom toolbar/measure +
|
|
22
|
-
// clip handles) that mount over the canvas. [next]
|
|
23
|
-
// The pre-A2 rich main is preserved at `main.rich.ts.bak`.
|
|
13
|
+
// A platform app made of the platform's own pieces, as the Hub and the Coordinator are: the project's documents on the
|
|
14
|
+
// left, the document viewer on the right, the model's tree, properties and data beside it. Built on WebGPU (`src/webgpu/`).
|
|
24
15
|
async function main() {
|
|
25
16
|
const client = PlatformClient.fromPlatformContext();
|
|
26
17
|
|
|
27
|
-
// Brand accent
|
|
28
|
-
document.documentElement.style.setProperty("--bim-ui_accent-base", "
|
|
18
|
+
// Brand accent: the library's own purple (UI colours only from @thatopen/ui's variables), as the platform's apps.
|
|
19
|
+
document.documentElement.style.setProperty("--bim-ui_accent-base", "var(--bim-ui_main-base)");
|
|
29
20
|
|
|
30
21
|
// The dev `thatopen serve` wrapper HTML doesn't zero the UA body margin (8px),
|
|
31
22
|
// which insets the whole app inside the platform iframe. Kill it here so it's
|
|
32
23
|
// fixed in both dev and production regardless of the host page.
|
|
33
24
|
document.body.style.margin = "0";
|
|
25
|
+
// The library's background, set by the app and not by the host page, so it holds inside the platform too.
|
|
26
|
+
document.body.style.background = "var(--bim-ui_bg-base)";
|
|
34
27
|
|
|
35
28
|
// UIManager must be in the setup call: it registers the platform web
|
|
36
29
|
// components (top-app, top-viewer, top-viewer-tools, …) before the DOM renders.
|
|
@@ -54,20 +47,13 @@ async function main() {
|
|
|
54
47
|
console.warn("[channel] unavailable outside the platform:", error);
|
|
55
48
|
}
|
|
56
49
|
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
// its
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
const viewerEl = document.createElement("top-viewer");
|
|
63
|
-
|
|
64
|
-
// + 0.75rem radius). top-viewer's host is already overflow:hidden, so the
|
|
65
|
-
// radius clips the canvas corners; border-box keeps the 1px inside the grid
|
|
66
|
-
// area. Done here (not in top-viewer) so the CDE's top-file-viewer, which draws
|
|
67
|
-
// its own frame, never double-borders.
|
|
68
|
-
viewerEl.style.border = "1px solid var(--bim-ui_bg-contrast-20)";
|
|
69
|
-
viewerEl.style.borderRadius = "0.75rem";
|
|
70
|
-
viewerEl.style.boxSizing = "border-box";
|
|
50
|
+
// The platform's document viewer, as the Hub's and the Coordinator's: each file opened with its viewer (3D, PDF,
|
|
51
|
+
// text), the 3D scene kept alive between them. Given no viewers it brings the platform's own: a 3D viewer ready for
|
|
52
|
+
// streamed models, its bar (3D/2D, projection, the colours softened by default), undo of section planes and measures.
|
|
53
|
+
// One STABLE node, returned by reference so re-rendering top-app reuses it instead of rebuilding its world.
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
const viewerEl = document.createElement("top-file-viewer") as any;
|
|
56
|
+
viewerEl.keepScene = true;
|
|
71
57
|
|
|
72
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
59
|
const app = document.createElement("top-app") as any;
|
|
@@ -101,9 +87,7 @@ async function main() {
|
|
|
101
87
|
const container = document.getElementById("that-open-app") ?? document.body;
|
|
102
88
|
container.appendChild(app);
|
|
103
89
|
|
|
104
|
-
// Wait for
|
|
105
|
-
// The viewer tool suite + dynamic-anchor pivot dot are now baked into
|
|
106
|
-
// <top-viewer> (setupViewerTools), so the app no longer wires them.
|
|
90
|
+
// Wait for the viewer's world to exist before building world-dependent panels.
|
|
107
91
|
await firstWorld(components.get(OBC.Worlds));
|
|
108
92
|
|
|
109
93
|
// Platform client + project data for the AppManager-shim consumers
|
|
@@ -129,34 +113,6 @@ async function main() {
|
|
|
129
113
|
}
|
|
130
114
|
setAppContext(client, projectData);
|
|
131
115
|
|
|
132
|
-
// Pluggable loaders for <top-models-list>. The built-in ships the lightweight
|
|
133
|
-
// defaults (.frag load, IFC→fragments convert); heavy/app-specific loaders are
|
|
134
|
-
// registered here so they stay OUT of the built-in's bundle. The reality-capture
|
|
135
|
-
// .3tz viewer pulls Spark + 3d-tiles-renderer, so it's lazy-imported app-side
|
|
136
|
-
// and plugged in via the loader registry. Alignment persists through the panel's
|
|
137
|
-
// app-data via the loader context (getAlignment/setAlignment).
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
-
let rcViewer: any = null;
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
141
|
-
const modelLoaders: Record<string, any> = {
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
143
|
-
"3tz": async (fileId: string, ctx: any) => {
|
|
144
|
-
if (!rcViewer) {
|
|
145
|
-
const { realityCaptureViewer } = await import(
|
|
146
|
-
"./setups/reality-capture-viewer"
|
|
147
|
-
);
|
|
148
|
-
rcViewer = realityCaptureViewer(ctx.components, client);
|
|
149
|
-
}
|
|
150
|
-
const saved = ctx.getAlignment(fileId) as number[] | undefined;
|
|
151
|
-
await rcViewer.loadIntoWorld(fileId, {
|
|
152
|
-
keepPostproduction: true,
|
|
153
|
-
transform: saved ? new THREE.Matrix4().fromArray(saved) : undefined,
|
|
154
|
-
onTransformChange: (m: THREE.Matrix4) =>
|
|
155
|
-
ctx.setAlignment(fileId, m.toArray()),
|
|
156
|
-
});
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
|
|
160
116
|
// Re-dock: the stable viewer + the panels, under the bim-viewer's named layouts
|
|
161
117
|
// with the activity-bar sidebar (Explorer · Assets · Data · Settings). All panels
|
|
162
118
|
// are now built-ins that self-wire from top-app's componentsContext/clientContext
|
|
@@ -165,10 +121,9 @@ async function main() {
|
|
|
165
121
|
viewer: () => BUI.html`${viewerEl}`,
|
|
166
122
|
tree: () => BUI.html`<top-model-tree></top-model-tree>`,
|
|
167
123
|
properties: () => BUI.html`<top-properties-panel></top-properties-panel>`,
|
|
168
|
-
|
|
169
|
-
|
|
124
|
+
// The project's documents, as every platform app lists them: a click opens one in the viewer.
|
|
125
|
+
files: () => BUI.html`<top-documents-panel reads-project></top-documents-panel>`,
|
|
170
126
|
dataTable: () => BUI.html`<top-data-table-panel></top-data-table-panel>`,
|
|
171
|
-
objects: () => BUI.html`<top-objects-panel></top-objects-panel>`,
|
|
172
127
|
settings: () => BUI.html`<top-settings-panel></top-settings-panel>`,
|
|
173
128
|
};
|
|
174
129
|
// No `label` → the sidebar renders icon-only activity-bar buttons (matching
|
|
@@ -180,7 +135,7 @@ async function main() {
|
|
|
180
135
|
},
|
|
181
136
|
Assets: {
|
|
182
137
|
icon: "mdi:folder-multiple-outline",
|
|
183
|
-
template: `"files viewer" 1fr "
|
|
138
|
+
template: `"files viewer" 1fr "properties viewer" 1fr / 22rem 1fr`,
|
|
184
139
|
},
|
|
185
140
|
Data: {
|
|
186
141
|
icon: "mdi:table",
|
|
@@ -194,18 +149,7 @@ async function main() {
|
|
|
194
149
|
app.layout = "Explorer";
|
|
195
150
|
app.sidebar = true;
|
|
196
151
|
|
|
197
|
-
//
|
|
198
|
-
// world + components contexts top-viewer provides). The rich bottom toolbar +
|
|
199
|
-
// active-tool HUD + clip/measure/walkthrough tools all live in
|
|
200
|
-
// <top-viewer-toolbar>; the side panels share the SAME tool singletons via
|
|
201
|
-
// components.get (OBC.Component-wrapped).
|
|
202
|
-
viewerEl.appendChild(document.createElement("top-viewer-toolbar"));
|
|
203
|
-
|
|
204
|
-
// Navigation gizmo is now baked into <top-viewer> (setupViewerTools), so the
|
|
205
|
-
// app no longer mounts it. (Cascade: the rest of the overlay tools follow.)
|
|
206
|
-
|
|
207
|
-
// No auto-load: the viewer opens empty. Users add models from the Assets
|
|
208
|
-
// (files) panel — top-models-list loads the .frag they pick into the world.
|
|
152
|
+
// No auto-load: the viewer opens empty. A document clicked in the Assets panel opens in it.
|
|
209
153
|
}
|
|
210
154
|
|
|
211
155
|
/** Resolves with the first world once it exists (top-viewer creates it async). */
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// WebGL-only addon STUB for a page that runs the WebGPU build of three.
|
|
2
|
+
//
|
|
3
|
+
// Under the one-graph rule ("three" IS three.webgpu.js), modules like
|
|
4
|
+
// three/examples/jsm/lines/LineMaterial and postprocessing/GTAOPass cannot
|
|
5
|
+
// even LINK — they import ShaderLib/UniformsLib, which the webgpu build does
|
|
6
|
+
// not export. The earlier engine's gpu page never imports them; this stack's
|
|
7
|
+
// WebGL branches do (fat-line edges, the GLSL Postproduction), statically,
|
|
8
|
+
// even though no webgpu code path ever CONSTRUCTS them.
|
|
9
|
+
//
|
|
10
|
+
// So such a page aliases those two addon directories here in its bundler: every name the
|
|
11
|
+
// graph imports exists (the module links), and CONSTRUCTING one throws with
|
|
12
|
+
// the reason (a webgl branch running under webgpu is a bug to hear about,
|
|
13
|
+
// never a silent no-op).
|
|
14
|
+
import * as THREE from "three";
|
|
15
|
+
|
|
16
|
+
const refusal = (name) =>
|
|
17
|
+
class {
|
|
18
|
+
constructor() {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`${name} is a WebGL-only addon and this page runs the webgpu build ` +
|
|
21
|
+
`of three: a WebGL code path is executing ` +
|
|
22
|
+
`under webgpu mode, which is the bug to report.`,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const LineMaterial = refusal("LineMaterial");
|
|
28
|
+
export const Line2 = refusal("Line2");
|
|
29
|
+
export const LineGeometry = refusal("LineGeometry");
|
|
30
|
+
export const LineSegments2 = refusal("LineSegments2");
|
|
31
|
+
export const LineSegmentsGeometry = refusal("LineSegmentsGeometry");
|
|
32
|
+
export const EffectComposer = refusal("EffectComposer");
|
|
33
|
+
export const GTAOPass = refusal("GTAOPass");
|
|
34
|
+
export const OutputPass = refusal("OutputPass");
|
|
35
|
+
export const SMAAPass = refusal("SMAAPass");
|
|
36
|
+
|
|
37
|
+
// `Pass` is EXTENDED at class-definition time (front's custom passes), so a
|
|
38
|
+
// refusal-on-construct base class is exactly right: the subclass declares
|
|
39
|
+
// fine and explodes only if something instantiates it under webgpu.
|
|
40
|
+
export class Pass {
|
|
41
|
+
constructor() {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Pass is a WebGL-only addon base and this page runs the webgpu build ` +
|
|
44
|
+
`of three: a WebGL code path is executing ` +
|
|
45
|
+
`under webgpu mode, which is the bug to report.`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Some passes reference Pass.FullScreenQuad-style statics; keep the shape.
|
|
50
|
+
export class FullScreenQuad {
|
|
51
|
+
constructor() {
|
|
52
|
+
throw new Error("FullScreenQuad is WebGL-only and this page runs the webgpu build of three.");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Type-only import in TS files; harmless value here.
|
|
57
|
+
export const LineMaterialParameters = {};
|
|
58
|
+
|
|
59
|
+
// Keep the namespace referenced so tree-shakers cannot decide the module is
|
|
60
|
+
// empty (and so the stub demonstrably shares the page's three).
|
|
61
|
+
export const __three = THREE.REVISION;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// The FAT LINES family under the webgpu build: the FUNCTIONAL replacement for
|
|
2
|
+
// the refusal stub. The gpu server resolves every import of
|
|
3
|
+
// `three/(examples/jsm|addons)/lines/*` here, and this module re-exports, UNDER
|
|
4
|
+
// THE SAME NAMES, the webgpu variants three 0.185 already ships:
|
|
5
|
+
//
|
|
6
|
+
// Line2 / LineSegments2 / Wireframe -> three/examples/jsm/lines/webgpu/*
|
|
7
|
+
// LineGeometry / LineSegmentsGeometry / WireframeGeometry2 -> the shared
|
|
8
|
+
// ones (geometry only, build-agnostic; the webgpu classes reuse them as is)
|
|
9
|
+
// LineMaterial -> a wrapper around Line2NodeMaterial (TSL) with the surface
|
|
10
|
+
// consumers touch, `resolution` included (see below)
|
|
11
|
+
//
|
|
12
|
+
// With this, the TEN consumers (measurements, ClipStyler, civil, dimension-line,
|
|
13
|
+
// NearPlaneLineMaterial and the rest) do not change A SINGLE LINE: the server's
|
|
14
|
+
// resolution decides what "Line2" means, which is exactly the one-graph rule.
|
|
15
|
+
// The refusal stub is left for the postprocessing family alone.
|
|
16
|
+
//
|
|
17
|
+
// Documented divergence v1: NearPlaneLineMaterial's near-plane guard is GLSL
|
|
18
|
+
// surgery on vertexShader and does not apply here (there is no vertexShader);
|
|
19
|
+
// its constructor skips it with type guards. Under webgpu the "streak" risk
|
|
20
|
+
// with both ends behind the camera comes back until that guard is ported to TSL
|
|
21
|
+
// over Line2NodeMaterial, which is open as #213.
|
|
22
|
+
import * as THREE from "three";
|
|
23
|
+
import { float } from "three/tsl";
|
|
24
|
+
|
|
25
|
+
export { Line2 } from "three/examples/jsm/lines/webgpu/Line2.js";
|
|
26
|
+
export { LineSegments2 } from "three/examples/jsm/lines/webgpu/LineSegments2.js";
|
|
27
|
+
export { Wireframe } from "three/examples/jsm/lines/webgpu/Wireframe.js";
|
|
28
|
+
export { LineGeometry } from "three/examples/jsm/lines/LineGeometry.js";
|
|
29
|
+
export { LineSegmentsGeometry } from "three/examples/jsm/lines/LineSegmentsGeometry.js";
|
|
30
|
+
export { WireframeGeometry2 } from "three/examples/jsm/lines/WireframeGeometry2.js";
|
|
31
|
+
|
|
32
|
+
// The LineMaterialParameters type is erased at compile time, but some consumer
|
|
33
|
+
// imports it without `type`, and esbuild then demands a runtime export.
|
|
34
|
+
export const LineMaterialParameters = {};
|
|
35
|
+
|
|
36
|
+
const Base = THREE.Line2NodeMaterial;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 🔴 WHAT MAKES A FAT LINE READ THE SIZE OF THE PASS IT IS DRAWN IN, EVERY TIME.
|
|
40
|
+
*
|
|
41
|
+
* `Line2NodeMaterial` turns `linewidth` into clip space by dividing by the viewport, which it reads from a node
|
|
42
|
+
* three refreshes once per render. But WHETHER a drawn object refreshes its uniforms at all is decided per
|
|
43
|
+
* shader, not per object (`NodeMaterialObserver.needsRefresh`): the first object drawn with a shader in a
|
|
44
|
+
* render refreshes, and every other one only if its material, its geometry or its matrix has changed. The
|
|
45
|
+
* viewport is none of those. So of five lines sharing a shader, four kept the viewport of the render they
|
|
46
|
+
* were first drawn in, for good.
|
|
47
|
+
*
|
|
48
|
+
* Measured on a canvas that photographs each view at the size it is seen: a view first photographed at 256
|
|
49
|
+
* px and then at 512 drew its 3.6 px cut lines 8 px wide, first photographed at 128 it drew them 14, and
|
|
50
|
+
* neither a new photograph, a new target nor rebuilding the material moved them; halving the pixel ratio
|
|
51
|
+
* and doubling the viewport by hand, in the node itself, changed not one pixel. The same view photographed
|
|
52
|
+
* at 512 from the start was right.
|
|
53
|
+
*
|
|
54
|
+
* A material that carries a node as a property is refreshed on every draw (`containsNode`), which is what a
|
|
55
|
+
* line needs. ONE node for all of them: a node's id is part of the shader's cache key, and one each would
|
|
56
|
+
* compile one shader per material.
|
|
57
|
+
*/
|
|
58
|
+
const READS_THE_PASS = float(0);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* `LineMaterial` with three's TSL class underneath. Line2NodeMaterial takes the
|
|
62
|
+
* same style parameters (color, linewidth, worldUnits, dashed and so on); what
|
|
63
|
+
* it does NOT have is the `resolution` uniform, because the TSL reads the
|
|
64
|
+
* viewport by itself. WebGL consumers call `material.resolution.set(w, h)` on
|
|
65
|
+
* every resize, and here that has to be a harmless no-op, so a writable Vector2
|
|
66
|
+
* nobody reads is exposed.
|
|
67
|
+
*/
|
|
68
|
+
export class LineMaterial extends Base {
|
|
69
|
+
constructor(parameters = {}) {
|
|
70
|
+
super(parameters);
|
|
71
|
+
if (!this.resolution) {
|
|
72
|
+
this.resolution = new THREE.Vector2(1, 1);
|
|
73
|
+
}
|
|
74
|
+
// Consumers DISCRIMINATE on this flag, not with instanceof (clip-edges
|
|
75
|
+
// picks fat LineSegments2 over flat THREE.LineSegments with
|
|
76
|
+
// `isLineMaterial`). Without it the TSL material ended up on a flat
|
|
77
|
+
// BufferGeometry, with no uv/instanceStart/instanceEnd, and the pipeline's
|
|
78
|
+
// WGSL was invalid: that was ClipStyler's failure on the sweep.
|
|
79
|
+
this.isLineMaterial = true;
|
|
80
|
+
// See `READS_THE_PASS`: without it the line keeps the viewport of its first draw.
|
|
81
|
+
this.readsThePass = READS_THE_PASS;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A see-through line is laid over what is under it by BLENDING, as the classic `LineMaterial` lays it.
|
|
86
|
+
*
|
|
87
|
+
* `Line2NodeMaterial` does something else when it is `transparent`: it mixes its colour, in the shader, with a
|
|
88
|
+
* copy of what has been drawn behind it (`viewportOpaqueMipTexture`), and blends on top of that. Drawn into a
|
|
89
|
+
* layer of its own, which is where every overlay goes (section lines, a drawing's hatch, plan symbols), that
|
|
90
|
+
* copy is not the picture and the line comes out as nothing at all: measured on a set of six sheets, 99 line
|
|
91
|
+
* objects drawn in every pass and not one of them on the photograph, trees, contours and property lines among
|
|
92
|
+
* them; the same objects marked opaque, all there. `transparent` here means what it means everywhere else:
|
|
93
|
+
* which list it is drawn in, and that it blends.
|
|
94
|
+
*/
|
|
95
|
+
setupDiffuseColor(builder) {
|
|
96
|
+
const seeThrough = this.transparent;
|
|
97
|
+
this.transparent = false;
|
|
98
|
+
try {
|
|
99
|
+
super.setupDiffuseColor(builder);
|
|
100
|
+
} finally {
|
|
101
|
+
this.transparent = seeThrough;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -29,9 +29,23 @@ function getBetaAliases() {
|
|
|
29
29
|
// URL back to the bare package name and let it resolve from node_modules.
|
|
30
30
|
const CDN_ESM = /^https:\/\/cdn\.jsdelivr\.net\/npm\/((?:@[^/]+\/)?[^@/]+)(?:@[^/]+)?\/\+esm$/;
|
|
31
31
|
|
|
32
|
+
// On WebGPU, as the platform's apps and as `thatopen serve` builds it: three's WebGPU build answers `three`, and its
|
|
33
|
+
// WebGL-only addons (fat lines, postprocessing passes) go to the stand-ins in `src/webgpu/`.
|
|
34
|
+
const webgpuAliases = existsSync('src/webgpu/webgpu-lines.mjs')
|
|
35
|
+
? [
|
|
36
|
+
{ find: /^three(\/webgpu)?$/, replacement: resolve(__dirname, 'node_modules/three/build/three.webgpu.js') },
|
|
37
|
+
{
|
|
38
|
+
find: /^three\/(examples\/jsm|addons)\/lines\/(Line2|LineSegments2|LineMaterial|Wireframe)\.js$/,
|
|
39
|
+
replacement: resolve(__dirname, 'src/webgpu/webgpu-lines.mjs'),
|
|
40
|
+
},
|
|
41
|
+
{ find: /^three\/(examples\/jsm|addons)\/postprocessing\/.*$/, replacement: resolve(__dirname, 'src/webgpu/webgl-addons-stub.mjs') },
|
|
42
|
+
]
|
|
43
|
+
: [];
|
|
44
|
+
|
|
32
45
|
export default defineConfig({
|
|
33
46
|
resolve: {
|
|
34
47
|
alias: [
|
|
48
|
+
...webgpuAliases,
|
|
35
49
|
{ find: CDN_ESM, replacement: '$1' },
|
|
36
50
|
...Object.entries(getBetaAliases()).map(([find, replacement]) => ({
|
|
37
51
|
find,
|
|
@@ -47,7 +61,9 @@ export default defineConfig({
|
|
|
47
61
|
fileName: () => 'bundle.js',
|
|
48
62
|
},
|
|
49
63
|
outDir: 'dist',
|
|
50
|
-
|
|
64
|
+
// No source map in the published bundle: with it, building a 19 MB app took ~4.5 GB and ran out of Node's memory, so
|
|
65
|
+
// `npm run build` and `thatopen publish` failed on a new app (24-11). `thatopen serve` keeps its maps for development.
|
|
66
|
+
sourcemap: false,
|
|
51
67
|
rollupOptions: {
|
|
52
68
|
output: {
|
|
53
69
|
entryFileNames: 'bundle.js',
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
// 3DTilesRendererJS plugin: serve a STANDARD loose 3D Tiles dataset whose tiles
|
|
2
|
-
// are stored as platform HIDDEN files, streamed one-file-per-tile.
|
|
3
|
-
//
|
|
4
|
-
// Seam: the renderer's `fetchData(url, options)` hook (intercepts BOTH the root
|
|
5
|
-
// tileset and every tile content fetch). Point the TilesRenderer at
|
|
6
|
-
// `<baseUrl>/tileset.json`; relative content URIs then resolve to
|
|
7
|
-
// `<baseUrl>/<relUri>` (e.g. "mem://t/tiles/n12_d3.spz"), which we strip back to
|
|
8
|
-
// the dataset-relative path (`relUri`) and look up in the `hiddenFiles` map to
|
|
9
|
-
// find the platform hidden-file id to download.
|
|
10
|
-
//
|
|
11
|
-
// SHARED CONTRACT (matches the converters): the main visible file is a standard
|
|
12
|
-
// `tileset.json`; each tile `content.uri` is a relative path under "tiles/".
|
|
13
|
-
// tileset.json carries a top-level `hiddenFiles: { "<content.uri>": "<id>" }`
|
|
14
|
-
// map. We fetch a tile blob with `client.downloadHiddenFile(id)` -> Response.
|
|
15
|
-
//
|
|
16
|
-
// Per-tile streaming = one `downloadHiddenFile` per visible tile; the controller's
|
|
17
|
-
// Q1 LRU/count-budget governor bounds how many are resident/loading at once.
|
|
18
|
-
|
|
19
|
-
// Structural type for the platform client: download a normal file by id (the
|
|
20
|
-
// tileset main file) and a hidden file by id (each tile). PlatformClient /
|
|
21
|
-
// EngineServicesClient satisfy this.
|
|
22
|
-
export interface HiddenTilesClient {
|
|
23
|
-
downloadFile(fileId: string, params?: any): Promise<Response>;
|
|
24
|
-
downloadHiddenFile(hiddenId: string): Promise<Response>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface HiddenTilesOptions {
|
|
28
|
-
baseUrl: string; // synthetic base the TilesRenderer is pointed at, e.g. "mem://t"
|
|
29
|
-
tilesetBytes: Uint8Array; // the already-downloaded tileset.json bytes
|
|
30
|
-
hiddenFiles: Record<string, string>; // content.uri -> hidden file id
|
|
31
|
-
client: HiddenTilesClient;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class HiddenTilesPlugin {
|
|
35
|
-
name = "HIDDEN_TILES_PLUGIN";
|
|
36
|
-
private baseUrl: string;
|
|
37
|
-
private tilesetBytes: Uint8Array;
|
|
38
|
-
private hiddenFiles: Record<string, string>;
|
|
39
|
-
private client: HiddenTilesClient;
|
|
40
|
-
|
|
41
|
-
constructor({ baseUrl, tilesetBytes, hiddenFiles, client }: HiddenTilesOptions) {
|
|
42
|
-
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
43
|
-
this.tilesetBytes = tilesetBytes;
|
|
44
|
-
this.hiddenFiles = hiddenFiles;
|
|
45
|
-
this.client = client;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// dataset-relative path for URLs under our synthetic base, else null.
|
|
49
|
-
private rel(url: string): string | null {
|
|
50
|
-
const prefix = this.baseUrl + "/";
|
|
51
|
-
return url.startsWith(prefix) ? url.slice(prefix.length) : null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// The renderer fetch hook. Return a Response, or null to let the default fetch
|
|
55
|
-
// run (URLs that aren't under our base).
|
|
56
|
-
async fetchData(url: string, _options: any): Promise<Response | null> {
|
|
57
|
-
const rel = this.rel(url);
|
|
58
|
-
if (rel === null) return null;
|
|
59
|
-
|
|
60
|
-
// Root tileset request: serve the bytes we already downloaded.
|
|
61
|
-
if (rel === "tileset.json") {
|
|
62
|
-
// copy out into a standalone ArrayBuffer for the Response
|
|
63
|
-
const b = this.tilesetBytes;
|
|
64
|
-
const ab = (b.byteOffset === 0 && b.byteLength === b.buffer.byteLength
|
|
65
|
-
? b.buffer
|
|
66
|
-
: b.slice().buffer) as ArrayBuffer;
|
|
67
|
-
return new Response(ab, {
|
|
68
|
-
status: 200,
|
|
69
|
-
headers: { "Content-Type": "application/json" },
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Content (tile) request: strip query/fragment, look up the hidden id.
|
|
74
|
-
const relUri = decodeURIComponent(rel.split("?")[0].split("#")[0]);
|
|
75
|
-
const hiddenId = this.hiddenFiles[relUri];
|
|
76
|
-
if (!hiddenId) {
|
|
77
|
-
// not a known tile -> 404 so the renderer treats it as a failed fetch.
|
|
78
|
-
return new Response(null, { status: 404, statusText: "Not Found" });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const res = await this.client.downloadHiddenFile(hiddenId);
|
|
82
|
-
const buf = await res.arrayBuffer();
|
|
83
|
-
return new Response(buf, {
|
|
84
|
-
status: 200,
|
|
85
|
-
headers: { "Content-Type": "application/octet-stream" },
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|