@file-viewer/renderer-3d 3.1.1 → 3.2.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/GEO3D.md +505 -0
- package/GEO3D_THIRD_PARTY_NOTICES.md +63 -0
- package/IFC.md +14 -1
- package/README.en.md +3 -35
- package/README.md +3 -35
- package/bin/copy-geo3d-assets.mjs +143 -0
- package/bin/copy-ifc-assets.mjs +52 -16
- package/dist/geo3d-workers/geotiff-worker.js +9 -0
- package/dist/geo3d-workers/las-worker.js +3858 -0
- package/dist/geo3d-workers/licenses/_giro3d_giro3d-LICENSE +10 -0
- package/dist/geo3d-workers/licenses/copc-license +21 -0
- package/dist/geo3d-workers/licenses/cross-fetch-LICENSE +21 -0
- package/dist/geo3d-workers/licenses/laz-perf-COPYING.txt +202 -0
- package/dist/geo3d-workers/licenses/mgrs-license.md +19 -0
- package/dist/geo3d-workers/licenses/ol-LICENSE.md +25 -0
- package/dist/geo3d-workers/licenses/proj4-LICENSE.md +29 -0
- package/dist/geo3d-workers/licenses/three-LICENSE +21 -0
- package/dist/geo3d-workers/licenses/wkt-parser-LICENSE.md +29 -0
- package/dist/geo3d-workers/manifest.json +203 -0
- package/dist/geo3d-workers/raster-licenses/_giro3d_giro3d-LICENSE +10 -0
- package/dist/geo3d-workers/raster-licenses/_petamoriken_float16-LICENSE +21 -0
- package/dist/geo3d-workers/raster-licenses/geotiff-LICENSE +22 -0
- package/dist/geo3d-workers/raster-licenses/lerc-LICENSE +101 -0
- package/dist/geo3d-workers/raster-licenses/lerc-NOTICE +23 -0
- package/dist/geo3d-workers/raster-licenses/pako-LICENSE +21 -0
- package/dist/geo3d-workers/raster-licenses/quick-lru-license +9 -0
- package/dist/geo3d-workers/raster-licenses/web-worker-LICENSE +201 -0
- package/dist/geo3d-workers/raster-licenses/xml-utils-LICENSE +121 -0
- package/dist/geo3d-workers/raster-licenses/zstddec-LICENSE +54 -0
- package/dist/geo3d-workers/texture-worker.js +1 -0
- package/dist/geo3d.d.ts +10 -0
- package/dist/geo3d.js +38 -0
- package/dist/geo3dArchive.d.ts +25 -0
- package/dist/geo3dArchive.js +393 -0
- package/dist/geo3dCityJson.d.ts +65 -0
- package/dist/geo3dCityJson.js +354 -0
- package/dist/geo3dCrs.d.ts +8 -0
- package/dist/geo3dCrs.js +18 -0
- package/dist/geo3dHooks.d.ts +4 -0
- package/dist/geo3dHooks.js +91 -0
- package/dist/geo3dInspect.d.ts +32 -0
- package/dist/geo3dInspect.js +410 -0
- package/dist/geo3dLasWorkers.d.ts +6 -0
- package/dist/geo3dLasWorkers.js +59 -0
- package/dist/geo3dOwnedWorkerPool.d.ts +31 -0
- package/dist/geo3dOwnedWorkerPool.js +209 -0
- package/dist/geo3dPointFactories.js +3835 -0
- package/dist/geo3dPointMaterial.d.ts +2 -0
- package/dist/geo3dPointMaterial.js +54 -0
- package/dist/geo3dRange.d.ts +11 -0
- package/dist/geo3dRange.js +151 -0
- package/dist/geo3dRasterFactories.js +32 -0
- package/dist/geo3dRasterWorkers.d.ts +14 -0
- package/dist/geo3dRasterWorkers.js +48 -0
- package/dist/geo3dRuntime.d.ts +144 -0
- package/dist/geo3dRuntime.js +378 -0
- package/dist/geo3dUrl.d.ts +1 -0
- package/dist/geo3dUrl.js +5 -0
- package/dist/ifc-import.worker.js +0 -2
- package/dist/ifc.d.ts +0 -9
- package/dist/ifc.js +0 -1
- package/dist/ifcRuntime.js +4 -9
- package/dist/ifcSettings.d.ts +0 -3
- package/dist/ifcSettings.js +0 -3
- package/dist/model.js +0 -4
- package/dist/occtModel.js +0 -2
- package/licenses/laz-perf-COPYING.txt +202 -0
- package/licenses/laz-perf-PROVENANCE.md +22 -0
- package/licenses/lerc-LICENSE +101 -0
- package/licenses/lerc-NOTICE +23 -0
- package/licenses/lerc-PROVENANCE.md +37 -0
- package/licenses/thatopen-components-MIT.txt +18 -0
- package/package.json +115 -29
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
const aborted = (signal) => signal?.reason ?? new DOMException('Geo3D decoder disposed.', 'AbortError');
|
|
2
|
+
export class Geo3dOwnedWorkerPool {
|
|
3
|
+
options;
|
|
4
|
+
slots = new Set();
|
|
5
|
+
waiting = [];
|
|
6
|
+
concurrency;
|
|
7
|
+
maxQueued;
|
|
8
|
+
timeoutMs;
|
|
9
|
+
nextId = 0;
|
|
10
|
+
disposed = false;
|
|
11
|
+
pumping = false;
|
|
12
|
+
abortOwner;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
this.concurrency = options.concurrency ?? 2;
|
|
16
|
+
this.maxQueued = options.maxQueued ?? 128;
|
|
17
|
+
this.timeoutMs = options.timeoutMs ?? 60000;
|
|
18
|
+
if (!Number.isSafeInteger(this.concurrency) || this.concurrency < 1 || this.concurrency > 16 ||
|
|
19
|
+
!Number.isSafeInteger(this.maxQueued) || this.maxQueued < 0 || this.maxQueued > 4096 ||
|
|
20
|
+
!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs < 1 || this.timeoutMs > 300000) {
|
|
21
|
+
throw new RangeError('Invalid Geo3D worker pool limits.');
|
|
22
|
+
}
|
|
23
|
+
this.abortOwner = () => this.dispose(aborted(options.signal));
|
|
24
|
+
options.signal?.addEventListener('abort', this.abortOwner, { once: true });
|
|
25
|
+
if (options.signal?.aborted)
|
|
26
|
+
this.abortOwner();
|
|
27
|
+
}
|
|
28
|
+
queue(type, payload, transfer = [], signal) {
|
|
29
|
+
if (this.disposed || signal?.aborted)
|
|
30
|
+
return Promise.reject(aborted(signal ?? this.options.signal));
|
|
31
|
+
if (this.waiting.length >= this.maxQueued &&
|
|
32
|
+
this.slots.size >= this.concurrency && [...this.slots].every(slot => slot.job)) {
|
|
33
|
+
return Promise.reject(new Error('Geo3D decoder queue limit exceeded.'));
|
|
34
|
+
}
|
|
35
|
+
if (!Number.isSafeInteger(this.nextId))
|
|
36
|
+
return Promise.reject(new Error('Geo3D decoder message ID limit exceeded.'));
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const job = { id: this.nextId++, type, payload, transfer, resolve: value => resolve(value), reject, signal };
|
|
39
|
+
job.abort = () => {
|
|
40
|
+
const index = this.waiting.indexOf(job);
|
|
41
|
+
if (index >= 0) {
|
|
42
|
+
this.waiting.splice(index, 1);
|
|
43
|
+
this.finish(job, false, aborted(signal));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const slot = [...this.slots].find(item => item.job === job);
|
|
47
|
+
if (slot)
|
|
48
|
+
this.failSlot(slot, aborted(signal));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
signal?.addEventListener('abort', job.abort, { once: true });
|
|
52
|
+
this.waiting.push(job);
|
|
53
|
+
this.pump();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
finish(job, ok, value) {
|
|
57
|
+
if (job.timer !== undefined)
|
|
58
|
+
clearTimeout(job.timer);
|
|
59
|
+
if (job.abort)
|
|
60
|
+
job.signal?.removeEventListener('abort', job.abort);
|
|
61
|
+
job.payload = undefined;
|
|
62
|
+
job.transfer = [];
|
|
63
|
+
if (ok)
|
|
64
|
+
job.resolve(value);
|
|
65
|
+
else
|
|
66
|
+
job.reject(value);
|
|
67
|
+
}
|
|
68
|
+
removeSlot(slot) {
|
|
69
|
+
if (!this.slots.delete(slot))
|
|
70
|
+
return;
|
|
71
|
+
const worker = slot.handle.worker;
|
|
72
|
+
try {
|
|
73
|
+
worker.removeEventListener('message', slot.message);
|
|
74
|
+
}
|
|
75
|
+
catch { }
|
|
76
|
+
try {
|
|
77
|
+
worker.removeEventListener('error', slot.error);
|
|
78
|
+
}
|
|
79
|
+
catch { }
|
|
80
|
+
try {
|
|
81
|
+
worker.removeEventListener('messageerror', slot.messageerror);
|
|
82
|
+
}
|
|
83
|
+
catch { }
|
|
84
|
+
try {
|
|
85
|
+
worker.terminate();
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
slot.handle.release?.();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
failSlot(slot, reason) {
|
|
92
|
+
const job = slot.job;
|
|
93
|
+
slot.job = undefined;
|
|
94
|
+
try {
|
|
95
|
+
this.removeSlot(slot);
|
|
96
|
+
}
|
|
97
|
+
catch { }
|
|
98
|
+
if (job)
|
|
99
|
+
this.finish(job, false, reason);
|
|
100
|
+
this.pump();
|
|
101
|
+
}
|
|
102
|
+
makeSlot() {
|
|
103
|
+
const handle = this.options.createWorker();
|
|
104
|
+
const slot = {
|
|
105
|
+
handle,
|
|
106
|
+
message: event => {
|
|
107
|
+
const job = slot.job;
|
|
108
|
+
if (!job)
|
|
109
|
+
return;
|
|
110
|
+
const result = event.data;
|
|
111
|
+
if (!result || typeof result !== 'object' || result.requestId !== job.id ||
|
|
112
|
+
(!('error' in result) && !('payload' in result))) {
|
|
113
|
+
this.failSlot(slot, new Error('Invalid Geo3D decoder response.'));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
slot.job = undefined;
|
|
117
|
+
this.finish(job, !('error' in result), 'error' in result ? new Error(String(result.error)) : result.payload);
|
|
118
|
+
this.pump();
|
|
119
|
+
},
|
|
120
|
+
error: event => {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
this.failSlot(slot, new Error(event.message || 'Geo3D decoder Worker failed.'));
|
|
123
|
+
},
|
|
124
|
+
messageerror: () => this.failSlot(slot, new Error('Geo3D decoder response could not be deserialized.'))
|
|
125
|
+
};
|
|
126
|
+
this.slots.add(slot);
|
|
127
|
+
try {
|
|
128
|
+
handle.worker.addEventListener('message', slot.message);
|
|
129
|
+
handle.worker.addEventListener('error', slot.error);
|
|
130
|
+
handle.worker.addEventListener('messageerror', slot.messageerror);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
try {
|
|
134
|
+
this.removeSlot(slot);
|
|
135
|
+
}
|
|
136
|
+
catch { }
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
return slot;
|
|
140
|
+
}
|
|
141
|
+
pump() {
|
|
142
|
+
if (this.pumping || this.disposed)
|
|
143
|
+
return;
|
|
144
|
+
this.pumping = true;
|
|
145
|
+
try {
|
|
146
|
+
while (!this.disposed && this.waiting.length) {
|
|
147
|
+
let slot = [...this.slots].find(item => !item.job);
|
|
148
|
+
if (!slot && this.slots.size >= this.concurrency)
|
|
149
|
+
return;
|
|
150
|
+
const job = this.waiting.shift();
|
|
151
|
+
if (job.signal?.aborted) {
|
|
152
|
+
this.finish(job, false, aborted(job.signal));
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (!slot) {
|
|
156
|
+
try {
|
|
157
|
+
slot = this.makeSlot();
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
this.finish(job, false, error);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (this.disposed) {
|
|
165
|
+
try {
|
|
166
|
+
this.removeSlot(slot);
|
|
167
|
+
}
|
|
168
|
+
catch { }
|
|
169
|
+
this.finish(job, false, aborted(this.options.signal));
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (job.signal?.aborted) {
|
|
173
|
+
this.finish(job, false, aborted(job.signal));
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
slot.job = job;
|
|
177
|
+
const current = slot;
|
|
178
|
+
job.timer = setTimeout(() => this.failSlot(current, new Error('Geo3D decoder job timed out.')), this.timeoutMs);
|
|
179
|
+
try {
|
|
180
|
+
slot.handle.worker.postMessage({ id: job.id, type: job.type, payload: job.payload }, job.transfer);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
this.failSlot(slot, error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
this.pumping = false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
dispose(reason = aborted()) {
|
|
192
|
+
if (this.disposed)
|
|
193
|
+
return;
|
|
194
|
+
this.disposed = true;
|
|
195
|
+
this.options.signal?.removeEventListener('abort', this.abortOwner);
|
|
196
|
+
for (const job of this.waiting.splice(0))
|
|
197
|
+
this.finish(job, false, reason);
|
|
198
|
+
for (const slot of [...this.slots]) {
|
|
199
|
+
const job = slot.job;
|
|
200
|
+
slot.job = undefined;
|
|
201
|
+
try {
|
|
202
|
+
this.removeSlot(slot);
|
|
203
|
+
}
|
|
204
|
+
catch { }
|
|
205
|
+
if (job)
|
|
206
|
+
this.finish(job, false, reason);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|