@inweb/viewer-core 27.5.0 → 27.6.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/viewer-core.js +83 -94
- package/dist/viewer-core.js.map +1 -1
- package/dist/viewer-core.module.js +83 -94
- package/dist/viewer-core.module.js.map +1 -1
- package/lib/options/IOptions.d.ts +34 -40
- package/lib/options/Options.d.ts +11 -6
- package/package.json +3 -3
- package/src/loaders/Loader.ts +4 -5
- package/src/loaders/Loaders.ts +1 -1
- package/src/options/IOptions.ts +34 -41
- package/src/options/Options.ts +118 -121
package/src/options/Options.ts
CHANGED
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { IEventEmitter } from "@inweb/eventemitter2";
|
|
25
25
|
import { CameraMode, defaultOptions, IOptions, RGB } from "./IOptions";
|
|
26
26
|
|
|
27
27
|
export class Options implements IOptions {
|
|
28
|
-
protected _emitter?:
|
|
28
|
+
protected _emitter?: IEventEmitter;
|
|
29
29
|
protected _data: IOptions;
|
|
30
30
|
|
|
31
|
-
constructor(emitter?:
|
|
31
|
+
constructor(emitter?: IEventEmitter) {
|
|
32
32
|
this._emitter = emitter;
|
|
33
33
|
this._data = defaultOptions();
|
|
34
34
|
this.loadFromStorage();
|
|
@@ -73,15 +73,23 @@ export class Options implements IOptions {
|
|
|
73
73
|
* @param fields - Name of fields to be reset. Specify `undefined` to reset all.
|
|
74
74
|
*/
|
|
75
75
|
resetToDefaults(fields?: string[]): void {
|
|
76
|
+
const defaults = Options.defaults();
|
|
76
77
|
if (fields !== undefined) {
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.data = { ...this.data, ...resetData };
|
|
78
|
+
const resetData: Partial<IOptions> = {};
|
|
79
|
+
for (const field of fields) {
|
|
80
|
+
if (field in defaults) resetData[field] = defaults[field];
|
|
81
|
+
}
|
|
82
|
+
this.data = resetData;
|
|
83
83
|
} else {
|
|
84
|
-
this.data =
|
|
84
|
+
this.data = defaults;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setProperty<K extends keyof IOptions>(key: K, value = Options.defaults()[key]): void {
|
|
89
|
+
// for object-valued fields any new literal counts as a change
|
|
90
|
+
if (this._data[key] !== value) {
|
|
91
|
+
this._data[key] = value;
|
|
92
|
+
this.change();
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
|
|
@@ -89,8 +97,14 @@ export class Options implements IOptions {
|
|
|
89
97
|
return this._data;
|
|
90
98
|
}
|
|
91
99
|
|
|
92
|
-
set data(value: IOptions) {
|
|
93
|
-
|
|
100
|
+
set data(value: Partial<IOptions>) {
|
|
101
|
+
const defaults = Options.defaults();
|
|
102
|
+
const merged: IOptions = { ...defaults, ...this._data, ...value };
|
|
103
|
+
// replace undefined to default value for known properties
|
|
104
|
+
for (const key of Object.keys(defaults)) {
|
|
105
|
+
if (merged[key] === undefined) merged[key] = defaults[key];
|
|
106
|
+
}
|
|
107
|
+
this._data = merged;
|
|
94
108
|
// partial mode first
|
|
95
109
|
if (this._data.enablePartialMode) {
|
|
96
110
|
this._data.enableStreamingMode = true;
|
|
@@ -111,8 +125,7 @@ export class Options implements IOptions {
|
|
|
111
125
|
}
|
|
112
126
|
|
|
113
127
|
set showWCS(value: boolean) {
|
|
114
|
-
this.
|
|
115
|
-
this.change();
|
|
128
|
+
this.setProperty("showWCS", value);
|
|
116
129
|
}
|
|
117
130
|
|
|
118
131
|
get cameraAnimation(): boolean {
|
|
@@ -120,8 +133,7 @@ export class Options implements IOptions {
|
|
|
120
133
|
}
|
|
121
134
|
|
|
122
135
|
set cameraAnimation(value: boolean) {
|
|
123
|
-
this.
|
|
124
|
-
this.change();
|
|
136
|
+
this.setProperty("cameraAnimation", value);
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
get antialiasing(): boolean | string {
|
|
@@ -129,8 +141,7 @@ export class Options implements IOptions {
|
|
|
129
141
|
}
|
|
130
142
|
|
|
131
143
|
set antialiasing(value: boolean | string) {
|
|
132
|
-
this.
|
|
133
|
-
this.change();
|
|
144
|
+
this.setProperty("antialiasing", value);
|
|
134
145
|
}
|
|
135
146
|
|
|
136
147
|
get groundShadow(): boolean {
|
|
@@ -138,8 +149,7 @@ export class Options implements IOptions {
|
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
set groundShadow(value: boolean) {
|
|
141
|
-
this.
|
|
142
|
-
this.change();
|
|
152
|
+
this.setProperty("groundShadow", value);
|
|
143
153
|
}
|
|
144
154
|
|
|
145
155
|
get shadows(): boolean {
|
|
@@ -147,8 +157,7 @@ export class Options implements IOptions {
|
|
|
147
157
|
}
|
|
148
158
|
|
|
149
159
|
set shadows(value: boolean) {
|
|
150
|
-
this.
|
|
151
|
-
this.change();
|
|
160
|
+
this.setProperty("shadows", value);
|
|
152
161
|
}
|
|
153
162
|
|
|
154
163
|
get cameraAxisXSpeed(): number {
|
|
@@ -156,8 +165,7 @@ export class Options implements IOptions {
|
|
|
156
165
|
}
|
|
157
166
|
|
|
158
167
|
set cameraAxisXSpeed(value: number) {
|
|
159
|
-
this.
|
|
160
|
-
this.change();
|
|
168
|
+
this.setProperty("cameraAxisXSpeed", value);
|
|
161
169
|
}
|
|
162
170
|
|
|
163
171
|
get cameraAxisYSpeed(): number {
|
|
@@ -165,8 +173,7 @@ export class Options implements IOptions {
|
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
set cameraAxisYSpeed(value: number) {
|
|
168
|
-
this.cameraAxisYSpeed
|
|
169
|
-
this.change();
|
|
176
|
+
this.setProperty("cameraAxisYSpeed", value);
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
get ambientOcclusion(): boolean {
|
|
@@ -174,8 +181,7 @@ export class Options implements IOptions {
|
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
set ambientOcclusion(value: boolean) {
|
|
177
|
-
this.
|
|
178
|
-
this.change();
|
|
184
|
+
this.setProperty("ambientOcclusion", value);
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
get enableStreamingMode(): boolean {
|
|
@@ -183,9 +189,10 @@ export class Options implements IOptions {
|
|
|
183
189
|
}
|
|
184
190
|
|
|
185
191
|
set enableStreamingMode(value: boolean) {
|
|
186
|
-
this.
|
|
187
|
-
if (!value)
|
|
188
|
-
|
|
192
|
+
this.setProperty("enableStreamingMode", value);
|
|
193
|
+
if (!value) {
|
|
194
|
+
this.setProperty("enablePartialMode", false);
|
|
195
|
+
}
|
|
189
196
|
}
|
|
190
197
|
|
|
191
198
|
get enablePartialMode(): boolean {
|
|
@@ -193,12 +200,11 @@ export class Options implements IOptions {
|
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
set enablePartialMode(value: boolean) {
|
|
196
|
-
this.
|
|
203
|
+
this.setProperty("enablePartialMode", value);
|
|
197
204
|
if (value) {
|
|
198
|
-
this.
|
|
199
|
-
this.
|
|
205
|
+
this.setProperty("enableStreamingMode", true);
|
|
206
|
+
this.setProperty("sceneGraph", false);
|
|
200
207
|
}
|
|
201
|
-
this.change();
|
|
202
208
|
}
|
|
203
209
|
|
|
204
210
|
get memoryLimit(): number {
|
|
@@ -206,8 +212,7 @@ export class Options implements IOptions {
|
|
|
206
212
|
}
|
|
207
213
|
|
|
208
214
|
set memoryLimit(value: number) {
|
|
209
|
-
this.
|
|
210
|
-
this.change();
|
|
215
|
+
this.setProperty("memoryLimit", value);
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
get cuttingPlaneFillColor(): RGB {
|
|
@@ -225,12 +230,11 @@ export class Options implements IOptions {
|
|
|
225
230
|
console.warn(
|
|
226
231
|
"Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead"
|
|
227
232
|
);
|
|
228
|
-
this.
|
|
233
|
+
this.setProperty("sectionFillColor", {
|
|
229
234
|
r: value.red,
|
|
230
235
|
g: value.green,
|
|
231
236
|
b: value.blue,
|
|
232
|
-
};
|
|
233
|
-
this.change();
|
|
237
|
+
});
|
|
234
238
|
}
|
|
235
239
|
|
|
236
240
|
get enableSectionFill(): boolean {
|
|
@@ -238,17 +242,15 @@ export class Options implements IOptions {
|
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
set enableSectionFill(value: boolean) {
|
|
241
|
-
this.
|
|
242
|
-
this.change();
|
|
245
|
+
this.setProperty("enableSectionFill", value);
|
|
243
246
|
}
|
|
244
247
|
|
|
245
|
-
get sectionFillColor() {
|
|
248
|
+
get sectionFillColor(): { r: number; g: number; b: number } {
|
|
246
249
|
return this._data.sectionFillColor;
|
|
247
250
|
}
|
|
248
251
|
|
|
249
|
-
set sectionFillColor(value) {
|
|
250
|
-
this.
|
|
251
|
-
this.change();
|
|
252
|
+
set sectionFillColor(value: { r: number; g: number; b: number }) {
|
|
253
|
+
this.setProperty("sectionFillColor", value);
|
|
252
254
|
}
|
|
253
255
|
|
|
254
256
|
get sectionUseObjectColor(): boolean {
|
|
@@ -256,8 +258,7 @@ export class Options implements IOptions {
|
|
|
256
258
|
}
|
|
257
259
|
|
|
258
260
|
set sectionUseObjectColor(value: boolean) {
|
|
259
|
-
this.
|
|
260
|
-
this.change();
|
|
261
|
+
this.setProperty("sectionUseObjectColor", value);
|
|
261
262
|
}
|
|
262
263
|
|
|
263
264
|
get enableSectionHatch(): boolean {
|
|
@@ -265,17 +266,15 @@ export class Options implements IOptions {
|
|
|
265
266
|
}
|
|
266
267
|
|
|
267
268
|
set enableSectionHatch(value: boolean) {
|
|
268
|
-
this.
|
|
269
|
-
this.change();
|
|
269
|
+
this.setProperty("enableSectionHatch", value);
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
get sectionHatchColor() {
|
|
272
|
+
get sectionHatchColor(): { r: number; g: number; b: number } {
|
|
273
273
|
return this._data.sectionHatchColor;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
set sectionHatchColor(value) {
|
|
277
|
-
this.
|
|
278
|
-
this.change();
|
|
276
|
+
set sectionHatchColor(value: { r: number; g: number; b: number }) {
|
|
277
|
+
this.setProperty("sectionHatchColor", value);
|
|
279
278
|
}
|
|
280
279
|
|
|
281
280
|
get sectionHatchScale(): number {
|
|
@@ -283,8 +282,7 @@ export class Options implements IOptions {
|
|
|
283
282
|
}
|
|
284
283
|
|
|
285
284
|
set sectionHatchScale(value: number) {
|
|
286
|
-
this.
|
|
287
|
-
this.change();
|
|
285
|
+
this.setProperty("sectionHatchScale", value);
|
|
288
286
|
}
|
|
289
287
|
|
|
290
288
|
get enableSectionOutline(): boolean {
|
|
@@ -292,17 +290,15 @@ export class Options implements IOptions {
|
|
|
292
290
|
}
|
|
293
291
|
|
|
294
292
|
set enableSectionOutline(value: boolean) {
|
|
295
|
-
this.
|
|
296
|
-
this.change();
|
|
293
|
+
this.setProperty("enableSectionOutline", value);
|
|
297
294
|
}
|
|
298
295
|
|
|
299
|
-
get sectionOutlineColor() {
|
|
296
|
+
get sectionOutlineColor(): { r: number; g: number; b: number } {
|
|
300
297
|
return this._data.sectionOutlineColor;
|
|
301
298
|
}
|
|
302
299
|
|
|
303
|
-
set sectionOutlineColor(value) {
|
|
304
|
-
this.
|
|
305
|
-
this.change();
|
|
300
|
+
set sectionOutlineColor(value: { r: number; g: number; b: number }) {
|
|
301
|
+
this.setProperty("sectionOutlineColor", value);
|
|
306
302
|
}
|
|
307
303
|
|
|
308
304
|
get sectionOutlineWidth(): number {
|
|
@@ -310,126 +306,114 @@ export class Options implements IOptions {
|
|
|
310
306
|
}
|
|
311
307
|
|
|
312
308
|
set sectionOutlineWidth(value: number) {
|
|
313
|
-
this.
|
|
314
|
-
this.change();
|
|
309
|
+
this.setProperty("sectionOutlineWidth", value);
|
|
315
310
|
}
|
|
316
311
|
|
|
317
|
-
get edgesColor() {
|
|
312
|
+
get edgesColor(): { r: number; g: number; b: number } {
|
|
318
313
|
return this._data.edgesColor;
|
|
319
314
|
}
|
|
320
315
|
|
|
321
|
-
set edgesColor(value) {
|
|
322
|
-
this.
|
|
323
|
-
this.change();
|
|
316
|
+
set edgesColor(value: { r: number; g: number; b: number }) {
|
|
317
|
+
this.setProperty("edgesColor", value);
|
|
324
318
|
}
|
|
325
319
|
|
|
326
|
-
get facesColor() {
|
|
320
|
+
get facesColor(): { r: number; g: number; b: number } {
|
|
327
321
|
return this._data.facesColor;
|
|
328
322
|
}
|
|
329
323
|
|
|
330
|
-
set facesColor(value) {
|
|
331
|
-
this.
|
|
332
|
-
this.change();
|
|
324
|
+
set facesColor(value: { r: number; g: number; b: number }) {
|
|
325
|
+
this.setProperty("facesColor", value);
|
|
333
326
|
}
|
|
334
327
|
|
|
335
|
-
get edgesVisibility() {
|
|
328
|
+
get edgesVisibility(): boolean {
|
|
336
329
|
return this._data.edgesVisibility;
|
|
337
330
|
}
|
|
338
331
|
|
|
339
|
-
set edgesVisibility(value) {
|
|
340
|
-
this.
|
|
341
|
-
this.change();
|
|
332
|
+
set edgesVisibility(value: boolean) {
|
|
333
|
+
this.setProperty("edgesVisibility", value);
|
|
342
334
|
}
|
|
343
335
|
|
|
344
|
-
get edgesOverlap() {
|
|
336
|
+
get edgesOverlap(): boolean {
|
|
345
337
|
return this._data.edgesOverlap;
|
|
346
338
|
}
|
|
347
339
|
|
|
348
|
-
set edgesOverlap(value) {
|
|
349
|
-
this.
|
|
350
|
-
this.change();
|
|
340
|
+
set edgesOverlap(value: boolean) {
|
|
341
|
+
this.setProperty("edgesOverlap", value);
|
|
351
342
|
}
|
|
352
343
|
|
|
353
|
-
get facesOverlap() {
|
|
344
|
+
get facesOverlap(): boolean {
|
|
354
345
|
return this._data.facesOverlap;
|
|
355
346
|
}
|
|
356
347
|
|
|
357
|
-
set facesOverlap(value) {
|
|
358
|
-
this.
|
|
359
|
-
this.change();
|
|
348
|
+
set facesOverlap(value: boolean) {
|
|
349
|
+
this.setProperty("facesOverlap", value);
|
|
360
350
|
}
|
|
361
351
|
|
|
362
|
-
get facesTransparancy() {
|
|
352
|
+
get facesTransparancy(): number {
|
|
363
353
|
return this._data.facesTransparancy;
|
|
364
354
|
}
|
|
365
355
|
|
|
366
|
-
set facesTransparancy(value) {
|
|
367
|
-
this.
|
|
368
|
-
this.change();
|
|
356
|
+
set facesTransparancy(value: number) {
|
|
357
|
+
this.setProperty("facesTransparancy", value);
|
|
369
358
|
}
|
|
370
359
|
|
|
371
|
-
get enableCustomHighlight() {
|
|
360
|
+
get enableCustomHighlight(): boolean {
|
|
372
361
|
return this._data.enableCustomHighlight;
|
|
373
362
|
}
|
|
374
363
|
|
|
375
|
-
set enableCustomHighlight(value) {
|
|
376
|
-
this.
|
|
377
|
-
this.change();
|
|
364
|
+
set enableCustomHighlight(value: boolean) {
|
|
365
|
+
this.setProperty("enableCustomHighlight", value);
|
|
378
366
|
}
|
|
379
367
|
|
|
380
|
-
get sceneGraph() {
|
|
368
|
+
get sceneGraph(): boolean {
|
|
381
369
|
return this._data.sceneGraph;
|
|
382
370
|
}
|
|
383
371
|
|
|
384
|
-
set sceneGraph(value) {
|
|
385
|
-
this.
|
|
386
|
-
if (value)
|
|
387
|
-
|
|
372
|
+
set sceneGraph(value: boolean) {
|
|
373
|
+
this.setProperty("sceneGraph", value);
|
|
374
|
+
if (value) {
|
|
375
|
+
this.setProperty("enablePartialMode", false);
|
|
376
|
+
}
|
|
388
377
|
}
|
|
389
378
|
|
|
390
|
-
get edgeModel() {
|
|
379
|
+
get edgeModel(): boolean {
|
|
391
380
|
return Boolean(this._data.edgeModel);
|
|
392
381
|
}
|
|
393
382
|
|
|
394
|
-
set edgeModel(value) {
|
|
395
|
-
this.
|
|
396
|
-
this.change();
|
|
383
|
+
set edgeModel(value: boolean) {
|
|
384
|
+
this.setProperty("edgeModel", value);
|
|
397
385
|
}
|
|
398
386
|
|
|
399
|
-
get reverseZoomWheel() {
|
|
387
|
+
get reverseZoomWheel(): boolean {
|
|
400
388
|
return this._data.reverseZoomWheel;
|
|
401
389
|
}
|
|
402
390
|
|
|
403
391
|
set reverseZoomWheel(value: boolean) {
|
|
404
|
-
this.
|
|
405
|
-
this.change();
|
|
392
|
+
this.setProperty("reverseZoomWheel", value);
|
|
406
393
|
}
|
|
407
394
|
|
|
408
|
-
get enableZoomWheel() {
|
|
395
|
+
get enableZoomWheel(): boolean {
|
|
409
396
|
return this._data.enableZoomWheel;
|
|
410
397
|
}
|
|
411
398
|
|
|
412
399
|
set enableZoomWheel(value: boolean) {
|
|
413
|
-
this.
|
|
414
|
-
this.change();
|
|
400
|
+
this.setProperty("enableZoomWheel", value);
|
|
415
401
|
}
|
|
416
402
|
|
|
417
|
-
get enableGestures() {
|
|
403
|
+
get enableGestures(): boolean {
|
|
418
404
|
return this._data.enableGestures;
|
|
419
405
|
}
|
|
420
406
|
|
|
421
407
|
set enableGestures(value: boolean) {
|
|
422
|
-
this.
|
|
423
|
-
this.change();
|
|
408
|
+
this.setProperty("enableGestures", value);
|
|
424
409
|
}
|
|
425
410
|
|
|
426
|
-
get geometryType() {
|
|
411
|
+
get geometryType(): string {
|
|
427
412
|
return this._data.geometryType;
|
|
428
413
|
}
|
|
429
414
|
|
|
430
415
|
set geometryType(value: string) {
|
|
431
|
-
this.
|
|
432
|
-
this.change();
|
|
416
|
+
this.setProperty("geometryType", value);
|
|
433
417
|
}
|
|
434
418
|
|
|
435
419
|
get rulerUnit(): string {
|
|
@@ -437,17 +421,15 @@ export class Options implements IOptions {
|
|
|
437
421
|
}
|
|
438
422
|
|
|
439
423
|
set rulerUnit(value: string) {
|
|
440
|
-
this.
|
|
441
|
-
this.change();
|
|
424
|
+
this.setProperty("rulerUnit", value);
|
|
442
425
|
}
|
|
443
426
|
|
|
444
|
-
get rulerPrecision():
|
|
427
|
+
get rulerPrecision(): "Default" | "Auto" | number {
|
|
445
428
|
return this._data.rulerPrecision;
|
|
446
429
|
}
|
|
447
430
|
|
|
448
|
-
set rulerPrecision(value:
|
|
449
|
-
this.
|
|
450
|
-
this.change();
|
|
431
|
+
set rulerPrecision(value: "Default" | "Auto" | number) {
|
|
432
|
+
this.setProperty("rulerPrecision", value);
|
|
451
433
|
}
|
|
452
434
|
|
|
453
435
|
get cameraMode(): CameraMode {
|
|
@@ -455,7 +437,22 @@ export class Options implements IOptions {
|
|
|
455
437
|
}
|
|
456
438
|
|
|
457
439
|
set cameraMode(value: CameraMode) {
|
|
458
|
-
this.
|
|
459
|
-
|
|
440
|
+
this.setProperty("cameraMode", value);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
get snapshotMimeType(): string {
|
|
444
|
+
return this._data.snapshotMimeType;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
set snapshotMimeType(value: string) {
|
|
448
|
+
this.setProperty("snapshotMimeType", value);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
get snapshotQuality(): number {
|
|
452
|
+
return this._data.snapshotQuality;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
set snapshotQuality(value: number) {
|
|
456
|
+
this.setProperty("snapshotQuality", value);
|
|
460
457
|
}
|
|
461
458
|
}
|