@inweb/viewer-core 27.5.0 → 27.6.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/dist/viewer-core.js +138 -125
- package/dist/viewer-core.js.map +1 -1
- package/dist/viewer-core.module.js +138 -125
- package/dist/viewer-core.module.js.map +1 -1
- package/lib/options/IOptions.d.ts +39 -45
- package/lib/options/Options.d.ts +17 -7
- package/package.json +3 -3
- package/src/loaders/Loader.ts +4 -5
- package/src/loaders/Loaders.ts +1 -1
- package/src/options/IOptions.ts +39 -46
- package/src/options/Options.ts +198 -157
package/dist/viewer-core.js
CHANGED
|
@@ -164,8 +164,7 @@
|
|
|
164
164
|
this.abortController = new AbortController();
|
|
165
165
|
}
|
|
166
166
|
dispose() {
|
|
167
|
-
this.
|
|
168
|
-
this.abortController = undefined;
|
|
167
|
+
this.cancel();
|
|
169
168
|
}
|
|
170
169
|
isSupport(file, format) {
|
|
171
170
|
return false;
|
|
@@ -184,10 +183,10 @@
|
|
|
184
183
|
extractFileName(file) {
|
|
185
184
|
const regex = /[^/\\?#:]+(?=\?|#|$)/;
|
|
186
185
|
if (typeof file === "string")
|
|
187
|
-
return (file.match(regex) || [])[0];
|
|
186
|
+
return (file.match(regex) || [])[0] || "";
|
|
188
187
|
else if (file instanceof globalThis.File)
|
|
189
|
-
return (file.name.match(regex) || [])[0];
|
|
190
|
-
return
|
|
188
|
+
return (file.name.match(regex) || [])[0] || "";
|
|
189
|
+
return "";
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
192
|
|
|
@@ -272,21 +271,44 @@
|
|
|
272
271
|
};
|
|
273
272
|
}
|
|
274
273
|
|
|
274
|
+
function isColorRGB(value) {
|
|
275
|
+
return (typeof value === "object" &&
|
|
276
|
+
value !== null &&
|
|
277
|
+
typeof value.r === "number" &&
|
|
278
|
+
typeof value.g === "number" &&
|
|
279
|
+
typeof value.b === "number");
|
|
280
|
+
}
|
|
281
|
+
function isLegacyRGB(value) {
|
|
282
|
+
return (typeof value === "object" &&
|
|
283
|
+
value !== null &&
|
|
284
|
+
typeof value.red === "number" &&
|
|
285
|
+
typeof value.green === "number" &&
|
|
286
|
+
typeof value.blue === "number");
|
|
287
|
+
}
|
|
275
288
|
class Options {
|
|
276
289
|
constructor(emitter) {
|
|
290
|
+
this._updateCount = 0;
|
|
277
291
|
this._emitter = emitter;
|
|
278
|
-
this._data =
|
|
292
|
+
this._data = Options.defaults();
|
|
293
|
+
this._defaults = Options.defaults();
|
|
279
294
|
this.loadFromStorage();
|
|
280
295
|
}
|
|
281
296
|
static defaults() {
|
|
282
297
|
return defaultOptions();
|
|
283
298
|
}
|
|
284
299
|
change() {
|
|
285
|
-
if (this._emitter !== undefined) {
|
|
300
|
+
if (this._emitter !== undefined && this._updateCount === 0) {
|
|
286
301
|
this.saveToStorage();
|
|
287
302
|
this._emitter.emit({ type: "optionschange", data: this });
|
|
288
303
|
}
|
|
289
304
|
}
|
|
305
|
+
beginUpdate() {
|
|
306
|
+
this._updateCount++;
|
|
307
|
+
}
|
|
308
|
+
endUpdate() {
|
|
309
|
+
this._updateCount--;
|
|
310
|
+
this.change();
|
|
311
|
+
}
|
|
290
312
|
saveToStorage() {
|
|
291
313
|
if (typeof window !== "undefined")
|
|
292
314
|
try {
|
|
@@ -300,321 +322,312 @@
|
|
|
300
322
|
if (typeof window !== "undefined")
|
|
301
323
|
try {
|
|
302
324
|
const item = localStorage.getItem("od-client-settings");
|
|
303
|
-
if (item)
|
|
304
|
-
|
|
305
|
-
this.data = { ...data };
|
|
306
|
-
}
|
|
325
|
+
if (item)
|
|
326
|
+
this.data = JSON.parse(item);
|
|
307
327
|
}
|
|
308
328
|
catch (error) {
|
|
309
329
|
console.error("Cannot load client settings.", error);
|
|
310
330
|
}
|
|
311
331
|
}
|
|
312
|
-
resetToDefaults(fields) {
|
|
313
|
-
if (fields
|
|
314
|
-
const
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
this.data =
|
|
332
|
+
resetToDefaults(fields, defaults = this._defaults) {
|
|
333
|
+
if (Array.isArray(fields)) {
|
|
334
|
+
const resetData = {};
|
|
335
|
+
for (const field of fields) {
|
|
336
|
+
if (field in defaults)
|
|
337
|
+
resetData[field] = defaults[field];
|
|
338
|
+
}
|
|
339
|
+
this.data = resetData;
|
|
320
340
|
}
|
|
321
341
|
else {
|
|
322
|
-
this.data =
|
|
342
|
+
this.data = defaults;
|
|
323
343
|
}
|
|
324
344
|
}
|
|
345
|
+
setProperty(key, value = this._defaults[key], accept = this.isValidValue(key, value)) {
|
|
346
|
+
if (!accept) {
|
|
347
|
+
console.warn(`Options.${key}: Invalid value`, value);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (this._data[key] !== value) {
|
|
351
|
+
this._data[key] = value;
|
|
352
|
+
this.change();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
isValidValue(key, value) {
|
|
356
|
+
return typeof value === typeof this._defaults[key];
|
|
357
|
+
}
|
|
325
358
|
get data() {
|
|
326
359
|
return this._data;
|
|
327
360
|
}
|
|
328
361
|
set data(value) {
|
|
329
|
-
this.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
362
|
+
this.beginUpdate();
|
|
363
|
+
try {
|
|
364
|
+
for (const key of Object.keys(value)) {
|
|
365
|
+
if (key in this._defaults)
|
|
366
|
+
this[key] = value[key];
|
|
367
|
+
else
|
|
368
|
+
this._data[key] = value[key];
|
|
369
|
+
}
|
|
370
|
+
if ("enablePartialMode" in value) {
|
|
371
|
+
this.enablePartialMode = value.enablePartialMode;
|
|
372
|
+
}
|
|
373
|
+
if ("sectionFillColor" in value) {
|
|
374
|
+
this.sectionFillColor = value.sectionFillColor;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
finally {
|
|
378
|
+
this.endUpdate();
|
|
333
379
|
}
|
|
334
|
-
if (!value.sectionFillColor && value.cuttingPlaneFillColor)
|
|
335
|
-
this._data.sectionFillColor = {
|
|
336
|
-
r: value.cuttingPlaneFillColor.red,
|
|
337
|
-
g: value.cuttingPlaneFillColor.green,
|
|
338
|
-
b: value.cuttingPlaneFillColor.blue,
|
|
339
|
-
};
|
|
340
|
-
this.change();
|
|
341
380
|
}
|
|
342
381
|
get showWCS() {
|
|
343
382
|
return this._data.showWCS;
|
|
344
383
|
}
|
|
345
384
|
set showWCS(value) {
|
|
346
|
-
this.
|
|
347
|
-
this.change();
|
|
385
|
+
this.setProperty("showWCS", value);
|
|
348
386
|
}
|
|
349
387
|
get cameraAnimation() {
|
|
350
388
|
return this._data.cameraAnimation;
|
|
351
389
|
}
|
|
352
390
|
set cameraAnimation(value) {
|
|
353
|
-
this.
|
|
354
|
-
this.change();
|
|
391
|
+
this.setProperty("cameraAnimation", value);
|
|
355
392
|
}
|
|
356
393
|
get antialiasing() {
|
|
357
394
|
return this._data.antialiasing;
|
|
358
395
|
}
|
|
359
396
|
set antialiasing(value) {
|
|
360
|
-
this.
|
|
361
|
-
this.change();
|
|
397
|
+
this.setProperty("antialiasing", value, typeof value === "boolean" || typeof value === "string");
|
|
362
398
|
}
|
|
363
399
|
get groundShadow() {
|
|
364
400
|
return this._data.groundShadow;
|
|
365
401
|
}
|
|
366
402
|
set groundShadow(value) {
|
|
367
|
-
this.
|
|
368
|
-
this.change();
|
|
403
|
+
this.setProperty("groundShadow", value);
|
|
369
404
|
}
|
|
370
405
|
get shadows() {
|
|
371
406
|
return this._data.shadows;
|
|
372
407
|
}
|
|
373
408
|
set shadows(value) {
|
|
374
|
-
this.
|
|
375
|
-
this.change();
|
|
409
|
+
this.setProperty("shadows", value);
|
|
376
410
|
}
|
|
377
411
|
get cameraAxisXSpeed() {
|
|
378
412
|
return this._data.cameraAxisXSpeed;
|
|
379
413
|
}
|
|
380
414
|
set cameraAxisXSpeed(value) {
|
|
381
|
-
this.
|
|
382
|
-
this.change();
|
|
415
|
+
this.setProperty("cameraAxisXSpeed", value);
|
|
383
416
|
}
|
|
384
417
|
get cameraAxisYSpeed() {
|
|
385
418
|
return this._data.cameraAxisYSpeed;
|
|
386
419
|
}
|
|
387
420
|
set cameraAxisYSpeed(value) {
|
|
388
|
-
this.cameraAxisYSpeed
|
|
389
|
-
this.change();
|
|
421
|
+
this.setProperty("cameraAxisYSpeed", value);
|
|
390
422
|
}
|
|
391
423
|
get ambientOcclusion() {
|
|
392
424
|
return this._data.ambientOcclusion;
|
|
393
425
|
}
|
|
394
426
|
set ambientOcclusion(value) {
|
|
395
|
-
this.
|
|
396
|
-
this.change();
|
|
427
|
+
this.setProperty("ambientOcclusion", value);
|
|
397
428
|
}
|
|
398
429
|
get enableStreamingMode() {
|
|
399
430
|
return this._data.enableStreamingMode;
|
|
400
431
|
}
|
|
401
432
|
set enableStreamingMode(value) {
|
|
402
|
-
this.
|
|
403
|
-
|
|
404
|
-
this._data.enablePartialMode = false;
|
|
405
|
-
this.change();
|
|
433
|
+
this.setProperty("enableStreamingMode", value);
|
|
434
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && this.enableStreamingMode);
|
|
406
435
|
}
|
|
407
436
|
get enablePartialMode() {
|
|
408
437
|
return this._data.enablePartialMode;
|
|
409
438
|
}
|
|
410
439
|
set enablePartialMode(value) {
|
|
411
|
-
this.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
this._data.sceneGraph = false;
|
|
415
|
-
}
|
|
416
|
-
this.change();
|
|
440
|
+
this.setProperty("enablePartialMode", value);
|
|
441
|
+
this.setProperty("enableStreamingMode", this.enableStreamingMode || this.enablePartialMode);
|
|
442
|
+
this.setProperty("sceneGraph", this.sceneGraph && !this.enablePartialMode);
|
|
417
443
|
}
|
|
418
444
|
get memoryLimit() {
|
|
419
445
|
return this._data.memoryLimit;
|
|
420
446
|
}
|
|
421
447
|
set memoryLimit(value) {
|
|
422
|
-
this.
|
|
423
|
-
this.change();
|
|
448
|
+
this.setProperty("memoryLimit", value);
|
|
424
449
|
}
|
|
425
450
|
get cuttingPlaneFillColor() {
|
|
426
|
-
|
|
427
|
-
return {
|
|
428
|
-
red: this._data.sectionFillColor.r,
|
|
429
|
-
green: this._data.sectionFillColor.g,
|
|
430
|
-
blue: this._data.sectionFillColor.b,
|
|
431
|
-
};
|
|
451
|
+
return this._data.cuttingPlaneFillColor;
|
|
432
452
|
}
|
|
433
453
|
set cuttingPlaneFillColor(value) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
454
|
+
if (this._updateCount === 0) {
|
|
455
|
+
console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
|
|
456
|
+
}
|
|
457
|
+
this.setProperty("cuttingPlaneFillColor", value, isLegacyRGB(value));
|
|
458
|
+
this.setProperty("sectionFillColor", {
|
|
459
|
+
r: this._data.cuttingPlaneFillColor.red,
|
|
460
|
+
g: this._data.cuttingPlaneFillColor.green,
|
|
461
|
+
b: this._data.cuttingPlaneFillColor.blue,
|
|
462
|
+
}, true);
|
|
441
463
|
}
|
|
442
464
|
get enableSectionFill() {
|
|
443
465
|
return this._data.enableSectionFill;
|
|
444
466
|
}
|
|
445
467
|
set enableSectionFill(value) {
|
|
446
|
-
this.
|
|
447
|
-
this.change();
|
|
468
|
+
this.setProperty("enableSectionFill", value);
|
|
448
469
|
}
|
|
449
470
|
get sectionFillColor() {
|
|
450
471
|
return this._data.sectionFillColor;
|
|
451
472
|
}
|
|
452
473
|
set sectionFillColor(value) {
|
|
453
|
-
this.
|
|
454
|
-
this.
|
|
474
|
+
this.setProperty("sectionFillColor", value, isColorRGB(value));
|
|
475
|
+
this.setProperty("cuttingPlaneFillColor", {
|
|
476
|
+
red: this._data.sectionFillColor.r,
|
|
477
|
+
green: this._data.sectionFillColor.g,
|
|
478
|
+
blue: this._data.sectionFillColor.b,
|
|
479
|
+
}, true);
|
|
455
480
|
}
|
|
456
481
|
get sectionUseObjectColor() {
|
|
457
482
|
return this._data.sectionUseObjectColor;
|
|
458
483
|
}
|
|
459
484
|
set sectionUseObjectColor(value) {
|
|
460
|
-
this.
|
|
461
|
-
this.change();
|
|
485
|
+
this.setProperty("sectionUseObjectColor", value);
|
|
462
486
|
}
|
|
463
487
|
get enableSectionHatch() {
|
|
464
488
|
return this._data.enableSectionHatch;
|
|
465
489
|
}
|
|
466
490
|
set enableSectionHatch(value) {
|
|
467
|
-
this.
|
|
468
|
-
this.change();
|
|
491
|
+
this.setProperty("enableSectionHatch", value);
|
|
469
492
|
}
|
|
470
493
|
get sectionHatchColor() {
|
|
471
494
|
return this._data.sectionHatchColor;
|
|
472
495
|
}
|
|
473
496
|
set sectionHatchColor(value) {
|
|
474
|
-
this.
|
|
475
|
-
this.change();
|
|
497
|
+
this.setProperty("sectionHatchColor", value, isColorRGB(value));
|
|
476
498
|
}
|
|
477
499
|
get sectionHatchScale() {
|
|
478
500
|
return this._data.sectionHatchScale;
|
|
479
501
|
}
|
|
480
502
|
set sectionHatchScale(value) {
|
|
481
|
-
this.
|
|
482
|
-
this.change();
|
|
503
|
+
this.setProperty("sectionHatchScale", value);
|
|
483
504
|
}
|
|
484
505
|
get enableSectionOutline() {
|
|
485
506
|
return this._data.enableSectionOutline;
|
|
486
507
|
}
|
|
487
508
|
set enableSectionOutline(value) {
|
|
488
|
-
this.
|
|
489
|
-
this.change();
|
|
509
|
+
this.setProperty("enableSectionOutline", value);
|
|
490
510
|
}
|
|
491
511
|
get sectionOutlineColor() {
|
|
492
512
|
return this._data.sectionOutlineColor;
|
|
493
513
|
}
|
|
494
514
|
set sectionOutlineColor(value) {
|
|
495
|
-
this.
|
|
496
|
-
this.change();
|
|
515
|
+
this.setProperty("sectionOutlineColor", value, isColorRGB(value));
|
|
497
516
|
}
|
|
498
517
|
get sectionOutlineWidth() {
|
|
499
518
|
return this._data.sectionOutlineWidth;
|
|
500
519
|
}
|
|
501
520
|
set sectionOutlineWidth(value) {
|
|
502
|
-
this.
|
|
503
|
-
this.change();
|
|
521
|
+
this.setProperty("sectionOutlineWidth", value);
|
|
504
522
|
}
|
|
505
523
|
get edgesColor() {
|
|
506
524
|
return this._data.edgesColor;
|
|
507
525
|
}
|
|
508
526
|
set edgesColor(value) {
|
|
509
|
-
this.
|
|
510
|
-
this.change();
|
|
527
|
+
this.setProperty("edgesColor", value, isColorRGB(value));
|
|
511
528
|
}
|
|
512
529
|
get facesColor() {
|
|
513
530
|
return this._data.facesColor;
|
|
514
531
|
}
|
|
515
532
|
set facesColor(value) {
|
|
516
|
-
this.
|
|
517
|
-
this.change();
|
|
533
|
+
this.setProperty("facesColor", value, isColorRGB(value));
|
|
518
534
|
}
|
|
519
535
|
get edgesVisibility() {
|
|
520
536
|
return this._data.edgesVisibility;
|
|
521
537
|
}
|
|
522
538
|
set edgesVisibility(value) {
|
|
523
|
-
this.
|
|
524
|
-
this.change();
|
|
539
|
+
this.setProperty("edgesVisibility", value);
|
|
525
540
|
}
|
|
526
541
|
get edgesOverlap() {
|
|
527
542
|
return this._data.edgesOverlap;
|
|
528
543
|
}
|
|
529
544
|
set edgesOverlap(value) {
|
|
530
|
-
this.
|
|
531
|
-
this.change();
|
|
545
|
+
this.setProperty("edgesOverlap", value);
|
|
532
546
|
}
|
|
533
547
|
get facesOverlap() {
|
|
534
548
|
return this._data.facesOverlap;
|
|
535
549
|
}
|
|
536
550
|
set facesOverlap(value) {
|
|
537
|
-
this.
|
|
538
|
-
this.change();
|
|
551
|
+
this.setProperty("facesOverlap", value);
|
|
539
552
|
}
|
|
540
553
|
get facesTransparancy() {
|
|
541
554
|
return this._data.facesTransparancy;
|
|
542
555
|
}
|
|
543
556
|
set facesTransparancy(value) {
|
|
544
|
-
this.
|
|
545
|
-
this.change();
|
|
557
|
+
this.setProperty("facesTransparancy", value);
|
|
546
558
|
}
|
|
547
559
|
get enableCustomHighlight() {
|
|
548
560
|
return this._data.enableCustomHighlight;
|
|
549
561
|
}
|
|
550
562
|
set enableCustomHighlight(value) {
|
|
551
|
-
this.
|
|
552
|
-
this.change();
|
|
563
|
+
this.setProperty("enableCustomHighlight", value);
|
|
553
564
|
}
|
|
554
565
|
get sceneGraph() {
|
|
555
566
|
return this._data.sceneGraph;
|
|
556
567
|
}
|
|
557
568
|
set sceneGraph(value) {
|
|
558
|
-
this.
|
|
559
|
-
|
|
560
|
-
this._data.enablePartialMode = false;
|
|
561
|
-
this.change();
|
|
569
|
+
this.setProperty("sceneGraph", value);
|
|
570
|
+
this.setProperty("enablePartialMode", this.enablePartialMode && !this.sceneGraph);
|
|
562
571
|
}
|
|
563
572
|
get edgeModel() {
|
|
564
573
|
return Boolean(this._data.edgeModel);
|
|
565
574
|
}
|
|
566
575
|
set edgeModel(value) {
|
|
567
|
-
this.
|
|
568
|
-
this.change();
|
|
576
|
+
this.setProperty("edgeModel", value);
|
|
569
577
|
}
|
|
570
578
|
get reverseZoomWheel() {
|
|
571
579
|
return this._data.reverseZoomWheel;
|
|
572
580
|
}
|
|
573
581
|
set reverseZoomWheel(value) {
|
|
574
|
-
this.
|
|
575
|
-
this.change();
|
|
582
|
+
this.setProperty("reverseZoomWheel", value);
|
|
576
583
|
}
|
|
577
584
|
get enableZoomWheel() {
|
|
578
585
|
return this._data.enableZoomWheel;
|
|
579
586
|
}
|
|
580
587
|
set enableZoomWheel(value) {
|
|
581
|
-
this.
|
|
582
|
-
this.change();
|
|
588
|
+
this.setProperty("enableZoomWheel", value);
|
|
583
589
|
}
|
|
584
590
|
get enableGestures() {
|
|
585
591
|
return this._data.enableGestures;
|
|
586
592
|
}
|
|
587
593
|
set enableGestures(value) {
|
|
588
|
-
this.
|
|
589
|
-
this.change();
|
|
594
|
+
this.setProperty("enableGestures", value);
|
|
590
595
|
}
|
|
591
596
|
get geometryType() {
|
|
592
597
|
return this._data.geometryType;
|
|
593
598
|
}
|
|
594
599
|
set geometryType(value) {
|
|
595
|
-
this.
|
|
596
|
-
this.change();
|
|
600
|
+
this.setProperty("geometryType", value);
|
|
597
601
|
}
|
|
598
602
|
get rulerUnit() {
|
|
599
603
|
return this._data.rulerUnit;
|
|
600
604
|
}
|
|
601
605
|
set rulerUnit(value) {
|
|
602
|
-
this.
|
|
603
|
-
this.change();
|
|
606
|
+
this.setProperty("rulerUnit", value);
|
|
604
607
|
}
|
|
605
608
|
get rulerPrecision() {
|
|
606
609
|
return this._data.rulerPrecision;
|
|
607
610
|
}
|
|
608
611
|
set rulerPrecision(value) {
|
|
609
|
-
this.
|
|
610
|
-
this.change();
|
|
612
|
+
this.setProperty("rulerPrecision", value, typeof value === "number" || value === "Default" || value === "Auto");
|
|
611
613
|
}
|
|
612
614
|
get cameraMode() {
|
|
613
|
-
return this._data.cameraMode
|
|
615
|
+
return this._data.cameraMode;
|
|
614
616
|
}
|
|
615
617
|
set cameraMode(value) {
|
|
616
|
-
this.
|
|
617
|
-
|
|
618
|
+
this.setProperty("cameraMode", value, value === "perspective" || value === "orthographic");
|
|
619
|
+
}
|
|
620
|
+
get snapshotMimeType() {
|
|
621
|
+
return this._data.snapshotMimeType;
|
|
622
|
+
}
|
|
623
|
+
set snapshotMimeType(value) {
|
|
624
|
+
this.setProperty("snapshotMimeType", value);
|
|
625
|
+
}
|
|
626
|
+
get snapshotQuality() {
|
|
627
|
+
return this._data.snapshotQuality;
|
|
628
|
+
}
|
|
629
|
+
set snapshotQuality(value) {
|
|
630
|
+
this.setProperty("snapshotQuality", value);
|
|
618
631
|
}
|
|
619
632
|
}
|
|
620
633
|
|