@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.
@@ -158,8 +158,7 @@ class Loader {
158
158
  this.abortController = new AbortController();
159
159
  }
160
160
  dispose() {
161
- this.abortController.abort();
162
- this.abortController = undefined;
161
+ this.cancel();
163
162
  }
164
163
  isSupport(file, format) {
165
164
  return false;
@@ -178,10 +177,10 @@ class Loader {
178
177
  extractFileName(file) {
179
178
  const regex = /[^/\\?#:]+(?=\?|#|$)/;
180
179
  if (typeof file === "string")
181
- return (file.match(regex) || [])[0];
180
+ return (file.match(regex) || [])[0] || "";
182
181
  else if (file instanceof globalThis.File)
183
- return (file.name.match(regex) || [])[0];
184
- return undefined;
182
+ return (file.name.match(regex) || [])[0] || "";
183
+ return "";
185
184
  }
186
185
  }
187
186
 
@@ -304,23 +303,36 @@ class Options {
304
303
  }
305
304
  }
306
305
  resetToDefaults(fields) {
306
+ const defaults = Options.defaults();
307
307
  if (fields !== undefined) {
308
- const defaults = Options.defaults();
309
- const resetData = fields.reduce((acc, field) => {
310
- acc[field] = defaults[field];
311
- return acc;
312
- }, {});
313
- this.data = { ...this.data, ...resetData };
308
+ const resetData = {};
309
+ for (const field of fields) {
310
+ if (field in defaults)
311
+ resetData[field] = defaults[field];
312
+ }
313
+ this.data = resetData;
314
314
  }
315
315
  else {
316
- this.data = { ...this.data, ...Options.defaults() };
316
+ this.data = defaults;
317
+ }
318
+ }
319
+ setProperty(key, value = Options.defaults()[key]) {
320
+ if (this._data[key] !== value) {
321
+ this._data[key] = value;
322
+ this.change();
317
323
  }
318
324
  }
319
325
  get data() {
320
326
  return this._data;
321
327
  }
322
328
  set data(value) {
323
- this._data = { ...Options.defaults(), ...this._data, ...value };
329
+ const defaults = Options.defaults();
330
+ const merged = { ...defaults, ...this._data, ...value };
331
+ for (const key of Object.keys(defaults)) {
332
+ if (merged[key] === undefined)
333
+ merged[key] = defaults[key];
334
+ }
335
+ this._data = merged;
324
336
  if (this._data.enablePartialMode) {
325
337
  this._data.enableStreamingMode = true;
326
338
  this._data.sceneGraph = false;
@@ -337,84 +349,74 @@ class Options {
337
349
  return this._data.showWCS;
338
350
  }
339
351
  set showWCS(value) {
340
- this._data.showWCS = value;
341
- this.change();
352
+ this.setProperty("showWCS", value);
342
353
  }
343
354
  get cameraAnimation() {
344
355
  return this._data.cameraAnimation;
345
356
  }
346
357
  set cameraAnimation(value) {
347
- this._data.cameraAnimation = value;
348
- this.change();
358
+ this.setProperty("cameraAnimation", value);
349
359
  }
350
360
  get antialiasing() {
351
361
  return this._data.antialiasing;
352
362
  }
353
363
  set antialiasing(value) {
354
- this._data.antialiasing = value;
355
- this.change();
364
+ this.setProperty("antialiasing", value);
356
365
  }
357
366
  get groundShadow() {
358
367
  return this._data.groundShadow;
359
368
  }
360
369
  set groundShadow(value) {
361
- this._data.groundShadow = value;
362
- this.change();
370
+ this.setProperty("groundShadow", value);
363
371
  }
364
372
  get shadows() {
365
373
  return this._data.shadows;
366
374
  }
367
375
  set shadows(value) {
368
- this._data.shadows = value;
369
- this.change();
376
+ this.setProperty("shadows", value);
370
377
  }
371
378
  get cameraAxisXSpeed() {
372
379
  return this._data.cameraAxisXSpeed;
373
380
  }
374
381
  set cameraAxisXSpeed(value) {
375
- this._data.cameraAxisXSpeed = value;
376
- this.change();
382
+ this.setProperty("cameraAxisXSpeed", value);
377
383
  }
378
384
  get cameraAxisYSpeed() {
379
385
  return this._data.cameraAxisYSpeed;
380
386
  }
381
387
  set cameraAxisYSpeed(value) {
382
- this.cameraAxisYSpeed = value;
383
- this.change();
388
+ this.setProperty("cameraAxisYSpeed", value);
384
389
  }
385
390
  get ambientOcclusion() {
386
391
  return this._data.ambientOcclusion;
387
392
  }
388
393
  set ambientOcclusion(value) {
389
- this._data.ambientOcclusion = value;
390
- this.change();
394
+ this.setProperty("ambientOcclusion", value);
391
395
  }
392
396
  get enableStreamingMode() {
393
397
  return this._data.enableStreamingMode;
394
398
  }
395
399
  set enableStreamingMode(value) {
396
- this._data.enableStreamingMode = value;
397
- if (!value)
398
- this._data.enablePartialMode = false;
399
- this.change();
400
+ this.setProperty("enableStreamingMode", value);
401
+ if (!value) {
402
+ this.setProperty("enablePartialMode", false);
403
+ }
400
404
  }
401
405
  get enablePartialMode() {
402
406
  return this._data.enablePartialMode;
403
407
  }
404
408
  set enablePartialMode(value) {
405
- this._data.enablePartialMode = value;
409
+ this.setProperty("enablePartialMode", value);
406
410
  if (value) {
407
- this._data.enableStreamingMode = true;
408
- this._data.sceneGraph = false;
411
+ this.setProperty("enableStreamingMode", true);
412
+ this.setProperty("sceneGraph", false);
409
413
  }
410
- this.change();
411
414
  }
412
415
  get memoryLimit() {
413
416
  return this._data.memoryLimit;
414
417
  }
415
418
  set memoryLimit(value) {
416
- this._data.memoryLimit = value;
417
- this.change();
419
+ this.setProperty("memoryLimit", value);
418
420
  }
419
421
  get cuttingPlaneFillColor() {
420
422
  console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
@@ -426,189 +428,176 @@ class Options {
426
428
  }
427
429
  set cuttingPlaneFillColor(value) {
428
430
  console.warn("Options.cuttingPlaneFillColor has been deprecated since 27.5 and will be removed in a future release, use sectionFillColor instead");
429
- this._data.sectionFillColor = {
431
+ this.setProperty("sectionFillColor", {
430
432
  r: value.red,
431
433
  g: value.green,
432
434
  b: value.blue,
433
- };
434
- this.change();
435
+ });
435
436
  }
436
437
  get enableSectionFill() {
437
438
  return this._data.enableSectionFill;
438
439
  }
439
440
  set enableSectionFill(value) {
440
- this._data.enableSectionFill = value;
441
- this.change();
441
+ this.setProperty("enableSectionFill", value);
442
442
  }
443
443
  get sectionFillColor() {
444
444
  return this._data.sectionFillColor;
445
445
  }
446
446
  set sectionFillColor(value) {
447
- this._data.sectionFillColor = value;
448
- this.change();
447
+ this.setProperty("sectionFillColor", value);
449
448
  }
450
449
  get sectionUseObjectColor() {
451
450
  return this._data.sectionUseObjectColor;
452
451
  }
453
452
  set sectionUseObjectColor(value) {
454
- this._data.sectionUseObjectColor = value;
455
- this.change();
453
+ this.setProperty("sectionUseObjectColor", value);
456
454
  }
457
455
  get enableSectionHatch() {
458
456
  return this._data.enableSectionHatch;
459
457
  }
460
458
  set enableSectionHatch(value) {
461
- this._data.enableSectionHatch = value;
462
- this.change();
459
+ this.setProperty("enableSectionHatch", value);
463
460
  }
464
461
  get sectionHatchColor() {
465
462
  return this._data.sectionHatchColor;
466
463
  }
467
464
  set sectionHatchColor(value) {
468
- this._data.sectionHatchColor = value;
469
- this.change();
465
+ this.setProperty("sectionHatchColor", value);
470
466
  }
471
467
  get sectionHatchScale() {
472
468
  return this._data.sectionHatchScale;
473
469
  }
474
470
  set sectionHatchScale(value) {
475
- this._data.sectionHatchScale = value;
476
- this.change();
471
+ this.setProperty("sectionHatchScale", value);
477
472
  }
478
473
  get enableSectionOutline() {
479
474
  return this._data.enableSectionOutline;
480
475
  }
481
476
  set enableSectionOutline(value) {
482
- this._data.enableSectionOutline = value;
483
- this.change();
477
+ this.setProperty("enableSectionOutline", value);
484
478
  }
485
479
  get sectionOutlineColor() {
486
480
  return this._data.sectionOutlineColor;
487
481
  }
488
482
  set sectionOutlineColor(value) {
489
- this._data.sectionOutlineColor = value;
490
- this.change();
483
+ this.setProperty("sectionOutlineColor", value);
491
484
  }
492
485
  get sectionOutlineWidth() {
493
486
  return this._data.sectionOutlineWidth;
494
487
  }
495
488
  set sectionOutlineWidth(value) {
496
- this._data.sectionOutlineWidth = value;
497
- this.change();
489
+ this.setProperty("sectionOutlineWidth", value);
498
490
  }
499
491
  get edgesColor() {
500
492
  return this._data.edgesColor;
501
493
  }
502
494
  set edgesColor(value) {
503
- this._data.edgesColor = value;
504
- this.change();
495
+ this.setProperty("edgesColor", value);
505
496
  }
506
497
  get facesColor() {
507
498
  return this._data.facesColor;
508
499
  }
509
500
  set facesColor(value) {
510
- this._data.facesColor = value;
511
- this.change();
501
+ this.setProperty("facesColor", value);
512
502
  }
513
503
  get edgesVisibility() {
514
504
  return this._data.edgesVisibility;
515
505
  }
516
506
  set edgesVisibility(value) {
517
- this._data.edgesVisibility = value;
518
- this.change();
507
+ this.setProperty("edgesVisibility", value);
519
508
  }
520
509
  get edgesOverlap() {
521
510
  return this._data.edgesOverlap;
522
511
  }
523
512
  set edgesOverlap(value) {
524
- this._data.edgesOverlap = value;
525
- this.change();
513
+ this.setProperty("edgesOverlap", value);
526
514
  }
527
515
  get facesOverlap() {
528
516
  return this._data.facesOverlap;
529
517
  }
530
518
  set facesOverlap(value) {
531
- this._data.facesOverlap = value;
532
- this.change();
519
+ this.setProperty("facesOverlap", value);
533
520
  }
534
521
  get facesTransparancy() {
535
522
  return this._data.facesTransparancy;
536
523
  }
537
524
  set facesTransparancy(value) {
538
- this._data.facesTransparancy = value;
539
- this.change();
525
+ this.setProperty("facesTransparancy", value);
540
526
  }
541
527
  get enableCustomHighlight() {
542
528
  return this._data.enableCustomHighlight;
543
529
  }
544
530
  set enableCustomHighlight(value) {
545
- this._data.enableCustomHighlight = value;
546
- this.change();
531
+ this.setProperty("enableCustomHighlight", value);
547
532
  }
548
533
  get sceneGraph() {
549
534
  return this._data.sceneGraph;
550
535
  }
551
536
  set sceneGraph(value) {
552
- this._data.sceneGraph = value;
553
- if (value)
554
- this._data.enablePartialMode = false;
555
- this.change();
537
+ this.setProperty("sceneGraph", value);
538
+ if (value) {
539
+ this.setProperty("enablePartialMode", false);
540
+ }
556
541
  }
557
542
  get edgeModel() {
558
543
  return Boolean(this._data.edgeModel);
559
544
  }
560
545
  set edgeModel(value) {
561
- this._data.edgeModel = Boolean(value);
562
- this.change();
546
+ this.setProperty("edgeModel", value);
563
547
  }
564
548
  get reverseZoomWheel() {
565
549
  return this._data.reverseZoomWheel;
566
550
  }
567
551
  set reverseZoomWheel(value) {
568
- this._data.reverseZoomWheel = !!value;
569
- this.change();
552
+ this.setProperty("reverseZoomWheel", value);
570
553
  }
571
554
  get enableZoomWheel() {
572
555
  return this._data.enableZoomWheel;
573
556
  }
574
557
  set enableZoomWheel(value) {
575
- this._data.enableZoomWheel = !!value;
576
- this.change();
558
+ this.setProperty("enableZoomWheel", value);
577
559
  }
578
560
  get enableGestures() {
579
561
  return this._data.enableGestures;
580
562
  }
581
563
  set enableGestures(value) {
582
- this._data.enableGestures = !!value;
583
- this.change();
564
+ this.setProperty("enableGestures", value);
584
565
  }
585
566
  get geometryType() {
586
567
  return this._data.geometryType;
587
568
  }
588
569
  set geometryType(value) {
589
- this._data.geometryType = value;
590
- this.change();
570
+ this.setProperty("geometryType", value);
591
571
  }
592
572
  get rulerUnit() {
593
573
  return this._data.rulerUnit;
594
574
  }
595
575
  set rulerUnit(value) {
596
- this._data.rulerUnit = value;
597
- this.change();
576
+ this.setProperty("rulerUnit", value);
598
577
  }
599
578
  get rulerPrecision() {
600
579
  return this._data.rulerPrecision;
601
580
  }
602
581
  set rulerPrecision(value) {
603
- this._data.rulerPrecision = value;
604
- this.change();
582
+ this.setProperty("rulerPrecision", value);
605
583
  }
606
584
  get cameraMode() {
607
585
  return this._data.cameraMode || "perspective";
608
586
  }
609
587
  set cameraMode(value) {
610
- this._data.cameraMode = value;
611
- this.change();
588
+ this.setProperty("cameraMode", value);
589
+ }
590
+ get snapshotMimeType() {
591
+ return this._data.snapshotMimeType;
592
+ }
593
+ set snapshotMimeType(value) {
594
+ this.setProperty("snapshotMimeType", value);
595
+ }
596
+ get snapshotQuality() {
597
+ return this._data.snapshotQuality;
598
+ }
599
+ set snapshotQuality(value) {
600
+ this.setProperty("snapshotQuality", value);
612
601
  }
613
602
  }
614
603