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