@inweb/viewer-visualize 26.10.6 → 26.12.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.
Files changed (41) hide show
  1. package/README.md +6 -4
  2. package/dist/viewer-visualize.js +659 -496
  3. package/dist/viewer-visualize.js.map +1 -1
  4. package/dist/viewer-visualize.min.js +1 -1
  5. package/dist/viewer-visualize.module.js +585 -484
  6. package/dist/viewer-visualize.module.js.map +1 -1
  7. package/lib/Viewer/Commands/GetSelected2.d.ts +2 -0
  8. package/lib/Viewer/Commands/SetSelected.d.ts +1 -1
  9. package/lib/Viewer/Commands/SetSelected2.d.ts +2 -0
  10. package/lib/Viewer/Components/index.d.ts +8 -7
  11. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +5 -1
  12. package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +3 -2
  13. package/lib/Viewer/Loaders/VSFXCloudLoader.d.ts +1 -1
  14. package/lib/Viewer/Loaders/VSFXCloudPartialLoader.d.ts +1 -1
  15. package/lib/Viewer/Loaders/index.d.ts +14 -9
  16. package/lib/Viewer/Models/IModelImpl.d.ts +5 -0
  17. package/lib/Viewer/Models/ModelImpl.d.ts +5 -0
  18. package/lib/Viewer/Viewer.d.ts +130 -136
  19. package/package.json +5 -5
  20. package/src/Viewer/Commands/ClearSelected.ts +3 -1
  21. package/src/Viewer/Commands/GetSelected2.ts +33 -0
  22. package/src/Viewer/Commands/HideSelected.ts +3 -1
  23. package/src/Viewer/Commands/SelectModel.ts +2 -3
  24. package/src/Viewer/Commands/SetSelected.ts +5 -2
  25. package/src/Viewer/Commands/SetSelected2.ts +39 -0
  26. package/src/Viewer/Commands/index.ts +4 -0
  27. package/src/Viewer/Components/index.ts +8 -7
  28. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +3 -2
  29. package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +44 -13
  30. package/src/Viewer/Draggers/MeasureLineDragger/index.ts +53 -18
  31. package/src/Viewer/Draggers/OdJoyStickDragger.ts +2 -2
  32. package/src/Viewer/Loaders/VSFCloudLoader.ts +6 -0
  33. package/src/Viewer/Loaders/VSFFileLoader.ts +7 -1
  34. package/src/Viewer/Loaders/VSFXCloudLoader.ts +7 -1
  35. package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +8 -2
  36. package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +7 -1
  37. package/src/Viewer/Loaders/VSFXFileLoader.ts +7 -1
  38. package/src/Viewer/Loaders/index.ts +14 -9
  39. package/src/Viewer/Models/IModelImpl.ts +29 -0
  40. package/src/Viewer/Models/ModelImpl.ts +32 -0
  41. package/src/Viewer/Viewer.ts +784 -775
@@ -21,7 +21,7 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- import { CANVAS_EVENTS, draggersRegistry, commandsRegistry, componentsRegistry, Loader, loadersRegistry, Options } from '@inweb/viewer-core';
24
+ import { CANVAS_EVENTS, draggersRegistry, commandsRegistry, componentsRegistry, Loader, loadersRegistry, Options, Info } from '@inweb/viewer-core';
25
25
  export * from '@inweb/viewer-core';
26
26
  import { EventEmitter2 } from '@inweb/eventemitter2';
27
27
  import { Markup } from '@inweb/markup';
@@ -213,8 +213,8 @@ class OdBaseDragger extends OdaGeAction {
213
213
  viewer.select(x, y, x, y);
214
214
  this.subject.update();
215
215
  const selectionSet = viewer.getSelected();
216
- const handles = this.subject.getSelected();
217
- this.onmessage({ type: "select", data: selectionSet, handles });
216
+ this.onmessage({ type: "select", data: selectionSet, handles: this.subject.getSelected() });
217
+ this.onmessage({ type: "select2", data: selectionSet, handles: this.subject.getSelected2() });
218
218
  }
219
219
  }
220
220
  dblclick(ev) {
@@ -402,8 +402,9 @@ class MeasureLineItem {
402
402
  this.htmlElemTitle = null;
403
403
  this.startPoint = null;
404
404
  this.endPoint = null;
405
- this.unit = "";
406
405
  this.scale = 1.0;
406
+ this.unit = "";
407
+ this.precision = 2;
407
408
  this.size = 10.0;
408
409
  this.lineThickness = 2;
409
410
  this.style = {
@@ -488,10 +489,9 @@ class MeasureLineItem {
488
489
  this.htmlElemLine.style.background = this.style.background;
489
490
  this.htmlElemLine.style.zIndex = "1";
490
491
  this.htmlElemLine.style.height = `${height}px`;
491
- const distance = `${this.getDistance()} ${this.unit}`;
492
+ const distance = this.getDistance();
492
493
  const pX = p1.x + dx / 2;
493
494
  const pY = p1.y + dy / 2;
494
- const widthTitle = distance.length * 10;
495
495
  this.htmlElemTitle = createHtmlElementIfNeed(this.htmlElemTitle, this.targetElement, "ruler-value");
496
496
  this.htmlElemTitle.style.display = "block";
497
497
  this.htmlElemTitle.style.cursor = "pointer";
@@ -499,9 +499,8 @@ class MeasureLineItem {
499
499
  this.htmlElemTitle.style.color = "white";
500
500
  this.htmlElemTitle.style.position = "Absolute";
501
501
  this.htmlElemTitle.style.top = `${pY}px`;
502
- this.htmlElemTitle.style.left = `${pX - widthTitle / 2}px`;
503
- this.htmlElemTitle.style.width = `${widthTitle}px`;
504
- this.htmlElemTitle.style.transformOrigin = "0px 0px";
502
+ this.htmlElemTitle.style.left = `${pX}px`;
503
+ this.htmlElemTitle.style.transform = "translate(-50%, -50%)";
505
504
  this.htmlElemTitle.style.borderRadius = "5px";
506
505
  this.htmlElemTitle.style.boxShadow = this.style.boxShadow;
507
506
  this.htmlElemTitle.style.border = "none";
@@ -509,7 +508,7 @@ class MeasureLineItem {
509
508
  this.htmlElemTitle.style.zIndex = "3";
510
509
  this.htmlElemTitle.style.padding = "2px";
511
510
  this.htmlElemTitle.style.textAlign = "center";
512
- this.htmlElemTitle.innerHTML = `${distance}`;
511
+ this.htmlElemTitle.innerHTML = this.formatDistance(distance);
513
512
  }
514
513
  else {
515
514
  this.htmlElemLine.style.display = "none";
@@ -519,11 +518,43 @@ class MeasureLineItem {
519
518
  }
520
519
  getDistance() {
521
520
  let distance = getDistance(this.startPoint, this.endPoint, this.moduleInstance);
522
- if (Math.abs(this.scale - 1.0) > 10e-5) {
523
- distance = (distance / this.scale).toFixed(2);
524
- }
521
+ if (Math.abs(this.scale) > 1e-10)
522
+ distance /= this.scale;
525
523
  return distance;
526
524
  }
525
+ calculatePrecision(value) {
526
+ const distance = Math.abs(value);
527
+ if (distance >= 1000)
528
+ return 0;
529
+ if (distance >= 10)
530
+ return 1;
531
+ if (distance >= 0.1)
532
+ return 2;
533
+ if (distance >= 0.001)
534
+ return 3;
535
+ return distance > 0 ? Math.floor(-Math.log10(distance)) + 1 : 2;
536
+ }
537
+ formatDistance(distance) {
538
+ let digits;
539
+ if (this.precision === "Auto")
540
+ digits = this.calculatePrecision(distance);
541
+ else if (Number.isFinite(this.precision))
542
+ digits = this.precision;
543
+ else
544
+ digits = parseFloat(this.precision);
545
+ if (!Number.isFinite(digits))
546
+ digits = 2;
547
+ else if (digits < 0)
548
+ digits = 0;
549
+ else if (digits > 10)
550
+ digits = 10;
551
+ let result = distance.toFixed(digits);
552
+ if (this.precision === "Auto")
553
+ result = result.replace(/\.0+$/, "").replace(/\.$/, "");
554
+ if (+result !== distance)
555
+ result = "~ " + result;
556
+ return `${result} ${this.unit}`;
557
+ }
527
558
  setStartPoint(gePoint) {
528
559
  this.startPoint = gePoint;
529
560
  this.drawMeasureLine();
@@ -556,6 +587,10 @@ class MeasureLineItem {
556
587
  this.scale = scale;
557
588
  this.drawMeasureLine();
558
589
  }
590
+ setPrecision(precision) {
591
+ this.precision = precision;
592
+ this.drawMeasureLine();
593
+ }
559
594
  setStyle(style) {
560
595
  this.style = style;
561
596
  this.drawMeasureLine();
@@ -578,14 +613,14 @@ function renameUnit(table, unit) {
578
613
  }
579
614
  class MeasureLineDragger extends OdBaseDragger {
580
615
  constructor(subject) {
581
- var _a;
616
+ var _a, _b;
582
617
  super(subject);
583
618
  this.lineThickness = 2;
584
619
  this.press = false;
585
620
  this.gripingRadius = 5.0;
586
621
  this.firstPoint = null;
587
622
  this.secondPoint = null;
588
- this.renameUnitTable = {
623
+ this.rulerUnitTable = {
589
624
  Millimeters: "mm",
590
625
  Centimeters: "cm",
591
626
  Meters: "m",
@@ -595,13 +630,14 @@ class MeasureLineDragger extends OdBaseDragger {
595
630
  Kilometers: "km",
596
631
  Miles: "mi",
597
632
  Micrometers: "µm",
633
+ Mils: "mil",
598
634
  MicroInches: "µin",
599
635
  Default: "unit",
600
636
  };
637
+ this.rulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
638
+ this.rulerPrecision = (_b = subject.options.rulerPrecision) !== null && _b !== void 0 ? _b : "Default";
601
639
  this.items = [];
602
- this.canvasEvents.push("resize");
603
- this.oldRulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
604
- this.optionsChange = this.optionsChange.bind(this);
640
+ this.canvasEvents.push("resize", "optionsChange");
605
641
  }
606
642
  initialize() {
607
643
  super.initialize();
@@ -696,8 +732,9 @@ class MeasureLineDragger extends OdBaseDragger {
696
732
  const viewer = this.m_module.getViewer();
697
733
  const item = new MeasureLineItem(this.m_overlayElement, viewer, this.m_module);
698
734
  item.lineThickness = this.lineThickness || item.lineThickness;
699
- const isDefaultUnit = !this.subject.options.rulerUnit || this.subject.options.rulerUnit === "Default";
700
- item.setUnit(renameUnit(this.renameUnitTable, isDefaultUnit ? viewer.getUnit() : this.subject.options.rulerUnit));
735
+ const isDefaultUnit = this.rulerUnit === "Default";
736
+ const isDefaultPrecision = this.rulerPrecision === "Default";
737
+ item.setUnit(renameUnit(this.rulerUnitTable, isDefaultUnit ? viewer.getUnit() : this.rulerUnit));
701
738
  if (!isDefaultUnit) {
702
739
  const fromUnit = this.getKUnitByName(viewer.getUnit());
703
740
  const toUnit = this.getKUnitByName(this.subject.options.rulerUnit);
@@ -708,29 +745,49 @@ class MeasureLineDragger extends OdBaseDragger {
708
745
  else {
709
746
  item.setConversionFactor(1.0);
710
747
  }
748
+ if (!isDefaultPrecision) {
749
+ item.setPrecision(this.rulerPrecision);
750
+ }
751
+ else {
752
+ item.setPrecision(2);
753
+ }
711
754
  this.items.push(item);
712
755
  return item;
713
756
  }
714
757
  optionsChange(event) {
715
- var _a;
758
+ var _a, _b;
716
759
  const options = event.data;
717
760
  const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
718
- if (this.oldRulerUnit === toUnitName)
761
+ const toPrecision = (_b = options.rulerPrecision) !== null && _b !== void 0 ? _b : "Default";
762
+ const unitChanged = this.rulerUnit !== toUnitName;
763
+ const precisionChanged = this.rulerPrecision !== toPrecision;
764
+ if (!unitChanged && !precisionChanged)
719
765
  return;
720
- this.oldRulerUnit = toUnitName;
766
+ this.rulerUnit = toUnitName;
767
+ this.rulerPrecision = toPrecision;
721
768
  const drawingUnit = this.m_module.getViewer().getUnit();
722
769
  const eToUnit = this.getKUnitByName(toUnitName);
723
770
  const eFromUnit = this.getKUnitByName(drawingUnit);
724
771
  this.items.forEach((item) => {
725
- if (toUnitName === "Default") {
726
- item.setUnit(renameUnit(this.renameUnitTable, drawingUnit));
727
- item.setConversionFactor(1.0);
772
+ if (unitChanged) {
773
+ if (toUnitName === "Default") {
774
+ item.setUnit(renameUnit(this.rulerUnitTable, drawingUnit));
775
+ item.setConversionFactor(1.0);
776
+ }
777
+ else {
778
+ item.setUnit(renameUnit(this.rulerUnitTable, toUnitName));
779
+ const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
780
+ this.conversionFactor = 1 / multiplier;
781
+ item.setConversionFactor(this.conversionFactor);
782
+ }
728
783
  }
729
- else {
730
- item.setUnit(renameUnit(this.renameUnitTable, toUnitName));
731
- const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
732
- this.conversionFactor = 1 / multiplier;
733
- item.setConversionFactor(this.conversionFactor);
784
+ if (precisionChanged) {
785
+ if (toPrecision === "Default") {
786
+ item.setPrecision(2);
787
+ }
788
+ else {
789
+ item.setPrecision(toPrecision);
790
+ }
734
791
  }
735
792
  });
736
793
  }
@@ -764,6 +821,9 @@ class MeasureLineDragger extends OdBaseDragger {
764
821
  case "Micrometers":
765
822
  eUnit = this.m_module.Units.kMicrometers;
766
823
  break;
824
+ case "Mils":
825
+ eUnit = this.m_module.Units.kMils;
826
+ break;
767
827
  case "MicroInches":
768
828
  eUnit = this.m_module.Units.kMicroInches;
769
829
  break;
@@ -819,7 +879,7 @@ class OdJoyStickDragger {
819
879
  callback({
820
880
  x: 100 * ((movedX - centerX) / maxMoveStick),
821
881
  y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
822
- global: global,
882
+ global,
823
883
  });
824
884
  }
825
885
  };
@@ -834,7 +894,7 @@ class OdJoyStickDragger {
834
894
  callback({
835
895
  x: 100 * ((movedX - centerX) / maxMoveStick),
836
896
  y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
837
- global: global,
897
+ global,
838
898
  });
839
899
  };
840
900
  this.drawExternal = () => {
@@ -2325,7 +2385,8 @@ function clearSelected(viewer) {
2325
2385
  const visViewer = viewer.visViewer();
2326
2386
  visViewer.unselect();
2327
2387
  viewer.update();
2328
- viewer.emitEvent({ type: "select", data: undefined, handles: [] });
2388
+ viewer.emitEvent({ type: "select", handles: [] });
2389
+ viewer.emitEvent({ type: "select2", handles: [] });
2329
2390
  }
2330
2391
 
2331
2392
  function clearSlices(viewer) {
@@ -2401,6 +2462,13 @@ function getSelected(viewer) {
2401
2462
  return handles;
2402
2463
  }
2403
2464
 
2465
+ function getSelected2(viewer) {
2466
+ const handles = viewer.executeCommand("getSelected");
2467
+ const model = viewer.models[0];
2468
+ const handles2 = handles.map((handle) => `${model.id}:${handle}`);
2469
+ return handles2;
2470
+ }
2471
+
2404
2472
  function hideSelected(viewer) {
2405
2473
  if (!viewer.visualizeJs)
2406
2474
  return;
@@ -2408,7 +2476,8 @@ function hideSelected(viewer) {
2408
2476
  visViewer.hideSelectedObjects(false);
2409
2477
  viewer.update();
2410
2478
  viewer.emitEvent({ type: "hide" });
2411
- viewer.emitEvent({ type: "select", data: undefined, handles: [] });
2479
+ viewer.emitEvent({ type: "select", handles: [] });
2480
+ viewer.emitEvent({ type: "select2", handles: [] });
2412
2481
  }
2413
2482
 
2414
2483
  function isolateSelected(viewer) {
@@ -2456,9 +2525,9 @@ function selectModel(viewer, handle) {
2456
2525
  if (modelPtr.getDatabaseHandle() === handle) {
2457
2526
  const selectionSet = activeView.selectCrossing([0, 9999, 9999, 0], modelPtr);
2458
2527
  visViewer.setSelected(selectionSet);
2459
- const handles = viewer.getSelected();
2460
2528
  viewer.update();
2461
- viewer.emitEvent({ type: "select", data: selectionSet, handles });
2529
+ viewer.emitEvent({ type: "select", handles: viewer.getSelected() });
2530
+ viewer.emitEvent({ type: "select2", handles: viewer.getSelected2() });
2462
2531
  selectionSet.delete();
2463
2532
  break;
2464
2533
  }
@@ -2485,13 +2554,14 @@ function setMarkupColor(viewer, r = 255, g = 0, b = 0) {
2485
2554
  viewer.markup.setMarkupColor(r, g, b);
2486
2555
  }
2487
2556
 
2488
- function setSelected(viewer, handles = []) {
2557
+ function setSelected(viewer, handles2 = []) {
2489
2558
  if (!viewer.visualizeJs)
2490
2559
  return;
2560
+ const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
2491
2561
  const visLib = viewer.visLib();
2492
2562
  const visViewer = viewer.visViewer();
2493
2563
  const selectionSet = new visLib.OdTvSelectionSet();
2494
- handles === null || handles === void 0 ? void 0 : handles.forEach((handle) => {
2564
+ handles.forEach((handle) => {
2495
2565
  const entityId = visViewer.getEntityByOriginalHandle(handle + "");
2496
2566
  if (!entityId.isNull())
2497
2567
  selectionSet.appendEntity(entityId);
@@ -2499,9 +2569,25 @@ function setSelected(viewer, handles = []) {
2499
2569
  visViewer.setSelected(selectionSet);
2500
2570
  viewer.update();
2501
2571
  viewer.emitEvent({ type: "select", data: selectionSet, handles });
2572
+ viewer.emitEvent({ type: "select2", data: selectionSet, handles: handles2 });
2502
2573
  selectionSet.delete();
2503
2574
  }
2504
2575
 
2576
+ function setSelected2(viewer, handles2 = []) {
2577
+ const handles = [];
2578
+ handles2.forEach((handle) => {
2579
+ if (!handle.includes(":")) {
2580
+ handles.push(handle);
2581
+ }
2582
+ else
2583
+ viewer.models.forEach((model) => {
2584
+ if (handle.split(":", 1)[0] === model.id + "")
2585
+ handles.push(handle);
2586
+ });
2587
+ });
2588
+ return viewer.executeCommand("setSelected", handles);
2589
+ }
2590
+
2505
2591
  function showAll(viewer) {
2506
2592
  if (!viewer.visualizeJs)
2507
2593
  return;
@@ -2624,6 +2710,7 @@ commands.registerCommand("collect", collect);
2624
2710
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
2625
2711
  commands.registerCommand("getModels", getModels);
2626
2712
  commands.registerCommand("getSelected", getSelected);
2713
+ commands.registerCommand("getSelected2", getSelected2);
2627
2714
  commands.registerCommand("hideSelected", hideSelected);
2628
2715
  commands.registerCommand("isolateSelected", isolateSelected);
2629
2716
  commands.registerCommand("regenerateAll", regenerateAll);
@@ -2633,6 +2720,7 @@ commands.registerCommand("setActiveDragger", setActiveDragger);
2633
2720
  commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
2634
2721
  commands.registerCommand("setMarkupColor", setMarkupColor);
2635
2722
  commands.registerCommand("setSelected", setSelected);
2723
+ commands.registerCommand("setSelected2", setSelected2);
2636
2724
  commands.registerCommand("showAll", showAll);
2637
2725
  commands.registerCommand("zoomToExtents", zoomToExtents);
2638
2726
  commands.registerCommand("zoomToObjects", zoomToObjects);
@@ -2981,6 +3069,10 @@ components.registerComponent("ZoomWheelComponent", (viewer) => new ZoomWheelComp
2981
3069
  components.registerComponent("GestureManagerComponent", (viewer) => new GestureManagerComponent(viewer));
2982
3070
  components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));
2983
3071
 
3072
+ class ModelImpl {
3073
+ dispose() { }
3074
+ }
3075
+
2984
3076
  class FileLoader {
2985
3077
  constructor() {
2986
3078
  this.requestHeader = {};
@@ -3064,7 +3156,7 @@ class VSFFileLoader extends Loader {
3064
3156
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
3065
3157
  /vsf$/i.test(format));
3066
3158
  }
3067
- async load(file, format, params) {
3159
+ async load(file, format, params = {}) {
3068
3160
  if (!this.viewer.visualizeJs)
3069
3161
  return this;
3070
3162
  const visViewer = this.viewer.visViewer();
@@ -3088,6 +3180,9 @@ class VSFFileLoader extends Loader {
3088
3180
  console.error("VSF parse error.", error);
3089
3181
  throw error;
3090
3182
  }
3183
+ const modelImpl = new ModelImpl();
3184
+ modelImpl.id = params.modelId || this.extractFileName(file);
3185
+ this.viewer.models.push(modelImpl);
3091
3186
  this.viewer.syncOptions();
3092
3187
  this.viewer.syncOverlay();
3093
3188
  this.viewer.update(true);
@@ -3131,6 +3226,9 @@ class VSFCloudLoader extends Loader {
3131
3226
  throw error;
3132
3227
  }
3133
3228
  if (i === 0) {
3229
+ const modelImpl = new ModelImpl();
3230
+ modelImpl.id = model.file.id;
3231
+ this.viewer.models.push(modelImpl);
3134
3232
  this.viewer.syncOptions();
3135
3233
  this.viewer.syncOverlay();
3136
3234
  this.viewer.update(true);
@@ -3155,7 +3253,7 @@ class VSFXFileLoader extends Loader {
3155
3253
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
3156
3254
  /vsfx$/i.test(format));
3157
3255
  }
3158
- async load(file, format, params) {
3256
+ async load(file, format, params = {}) {
3159
3257
  if (!this.viewer.visualizeJs)
3160
3258
  return this;
3161
3259
  const visViewer = this.viewer.visViewer();
@@ -3179,6 +3277,9 @@ class VSFXFileLoader extends Loader {
3179
3277
  console.error("VSFX parse error.", error);
3180
3278
  throw error;
3181
3279
  }
3280
+ const modelImpl = new ModelImpl();
3281
+ modelImpl.id = params.modelId || this.extractFileName(file);
3282
+ this.viewer.models.push(modelImpl);
3182
3283
  this.viewer.syncOptions();
3183
3284
  this.viewer.syncOverlay();
3184
3285
  this.viewer.update(true);
@@ -3199,7 +3300,7 @@ class VSFXCloudLoader extends Loader {
3199
3300
  /.vsfx$/i.test(file.database) &&
3200
3301
  this.viewer.options.enableStreamingMode === false);
3201
3302
  }
3202
- async load(model, format, params = {}) {
3303
+ async load(model) {
3203
3304
  if (!this.viewer.visualizeJs)
3204
3305
  return Promise.resolve(this);
3205
3306
  const visViewer = this.viewer.visViewer();
@@ -3218,6 +3319,9 @@ class VSFXCloudLoader extends Loader {
3218
3319
  console.error("VSFX parse error.", error);
3219
3320
  throw error;
3220
3321
  }
3322
+ const modelImpl = new ModelImpl();
3323
+ modelImpl.id = model.file.id;
3324
+ this.viewer.models.push(modelImpl);
3221
3325
  this.viewer.syncOptions();
3222
3326
  this.viewer.syncOverlay();
3223
3327
  this.viewer.update(true);
@@ -3296,6 +3400,9 @@ class VSFXCloudStreamingLoader extends Loader {
3296
3400
  isDatabaseChunk = true;
3297
3401
  }
3298
3402
  if (isDatabaseChunk) {
3403
+ const modelImpl = new ModelImpl();
3404
+ modelImpl.id = model.file.id;
3405
+ this.viewer.models.push(modelImpl);
3299
3406
  this.viewer.syncOptions();
3300
3407
  this.viewer.syncOverlay();
3301
3408
  updateController.update(UpdateType.kForce);
@@ -3330,7 +3437,7 @@ class VSFXCloudPartialLoader extends Loader {
3330
3437
  /.vsfx$/i.test(file.database) &&
3331
3438
  (this.viewer.options.enablePartialMode === true || /.rcs$/i.test(file.name)));
3332
3439
  }
3333
- async load(model, format) {
3440
+ async load(model) {
3334
3441
  if (!this.viewer.visualizeJs)
3335
3442
  return this;
3336
3443
  const visViewer = this.viewer.visViewer();
@@ -3356,6 +3463,9 @@ class VSFXCloudPartialLoader extends Loader {
3356
3463
  }
3357
3464
  this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
3358
3465
  if (isDatabaseChunk) {
3466
+ const modelImpl = new ModelImpl();
3467
+ modelImpl.id = model.file.id;
3468
+ this.viewer.models.push(modelImpl);
3359
3469
  this.viewer.syncOptions();
3360
3470
  this.viewer.syncOverlay();
3361
3471
  updateController.update(UpdateType.kForce);
@@ -3844,27 +3954,35 @@ class Viewer extends EventEmitter2 {
3844
3954
  super();
3845
3955
  this._visualizeJsUrl = "";
3846
3956
  this.configure(params);
3847
- this._options = new Options(this);
3848
3957
  this.client = client;
3958
+ this.options = new Options(this);
3849
3959
  this.loaders = [];
3960
+ this.models = [];
3961
+ this.info = new Info();
3962
+ this.canvasEvents = CANVAS_EVENTS.slice();
3963
+ this.canvaseventlistener = (event) => this.emit(event);
3850
3964
  this._activeDragger = null;
3851
3965
  this._components = [];
3966
+ this._renderNeeded = false;
3852
3967
  this._renderTime = 0;
3853
- this.canvasEvents = CANVAS_EVENTS.slice();
3854
- this.canvaseventlistener = (event) => this.emit(event);
3855
3968
  this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
3856
- this._renderNeeded = false;
3857
3969
  this._isRunAsyncUpdate = false;
3858
3970
  this.render = this.render.bind(this);
3859
3971
  this.update = this.update.bind(this);
3860
3972
  this._markup = MarkupFactory.createMarkup(params.markupType);
3861
3973
  }
3862
- get options() {
3863
- return this._options;
3864
- }
3865
3974
  get visualizeJsUrl() {
3866
3975
  return this._visualizeJsUrl;
3867
3976
  }
3977
+ get visualizeJs() {
3978
+ return this._visualizeJs;
3979
+ }
3980
+ visLib() {
3981
+ return this._visualizeJs;
3982
+ }
3983
+ visViewer() {
3984
+ return this._viewer;
3985
+ }
3868
3986
  get markup() {
3869
3987
  return this._markup;
3870
3988
  }
@@ -3873,13 +3991,20 @@ class Viewer extends EventEmitter2 {
3873
3991
  this._crossOrigin = params.crossOrigin;
3874
3992
  return this;
3875
3993
  }
3994
+ get draggers() {
3995
+ return [...draggers.getDraggers().keys()];
3996
+ }
3997
+ get components() {
3998
+ return [...components.getComponents().keys()];
3999
+ }
3876
4000
  async initialize(canvas, onProgress) {
3877
4001
  this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
4002
+ const pixelRatio = window.devicePixelRatio;
3878
4003
  const rect = canvas.parentElement.getBoundingClientRect();
3879
4004
  const width = rect.width || 1;
3880
4005
  const height = rect.height || 1;
3881
- canvas.width = Math.round(width * window.devicePixelRatio);
3882
- canvas.height = Math.round(height * window.devicePixelRatio);
4006
+ canvas.width = Math.round(width * pixelRatio);
4007
+ canvas.height = Math.round(height * pixelRatio);
3883
4008
  canvas.style.width = width + "px";
3884
4009
  canvas.style.height = height + "px";
3885
4010
  canvas.parentElement.style.touchAction = "none";
@@ -3947,6 +4072,26 @@ class Viewer extends EventEmitter2 {
3947
4072
  this.update(true);
3948
4073
  this.emitEvent({ type: "resize", width, height });
3949
4074
  }
4075
+ resize() {
4076
+ console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
4077
+ if (!this.visualizeJs)
4078
+ return this;
4079
+ if (!this.canvas.parentElement)
4080
+ return this;
4081
+ const { width, height } = this.canvas.parentElement.getBoundingClientRect();
4082
+ if (!width || !height)
4083
+ return this;
4084
+ this.setSize(width, height);
4085
+ return this;
4086
+ }
4087
+ update(force = false) {
4088
+ if (this._enableAutoUpdate) {
4089
+ this._renderNeeded = true;
4090
+ if (force)
4091
+ this.render();
4092
+ }
4093
+ this.emitEvent({ type: "update", data: force });
4094
+ }
3950
4095
  render(time) {
3951
4096
  var _a, _b;
3952
4097
  if (!this.visualizeJs)
@@ -3965,133 +4110,222 @@ class Viewer extends EventEmitter2 {
3965
4110
  (_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
3966
4111
  this.emitEvent({ type: "render", time, deltaTime });
3967
4112
  }
3968
- resize() {
3969
- console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
4113
+ async loadReferences(model) {
4114
+ var _a;
3970
4115
  if (!this.visualizeJs)
3971
4116
  return this;
3972
- if (!this.canvas.parentElement)
4117
+ if (!this.client)
3973
4118
  return this;
3974
- const { width, height } = this.canvas.parentElement.getBoundingClientRect();
3975
- if (!width || !height)
4119
+ if (!model.getReferences)
3976
4120
  return this;
3977
- this.setSize(width, height);
3978
- return this;
3979
- }
3980
- update(force = false) {
3981
- if (this._enableAutoUpdate) {
3982
- this._renderNeeded = true;
3983
- if (force)
3984
- this.render();
4121
+ const abortController = new AbortController();
4122
+ (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
4123
+ this._abortControllerForReferences = abortController;
4124
+ let references = [];
4125
+ await model
4126
+ .getReferences(abortController.signal)
4127
+ .then((data) => (references = data.references))
4128
+ .catch((e) => console.error("Cannot load model references.", e));
4129
+ for (const file of references) {
4130
+ await this.client
4131
+ .downloadFile(file.id, undefined, abortController.signal)
4132
+ .then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
4133
+ .catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
3985
4134
  }
3986
- this.emitEvent({ type: "update", data: force });
4135
+ return this;
3987
4136
  }
3988
- scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
3989
- return new Promise((resolve, reject) => {
3990
- setTimeout(() => {
3991
- var _a, _b, _c;
3992
- try {
3993
- if (this._enableAutoUpdate) {
3994
- (_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
3995
- (_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
3996
- }
3997
- this.emitEvent({ type: "update", data: false });
3998
- resolve();
3999
- }
4000
- catch (e) {
4001
- console.error(e);
4002
- reject();
4003
- }
4004
- }, 0);
4005
- });
4137
+ applyModelTransformMatrix(model) {
4138
+ this.executeCommand("applyModelTransform", model);
4006
4139
  }
4007
- async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
4140
+ applySceneGraphSettings(options = this.options) {
4008
4141
  if (!this.visualizeJs)
4009
4142
  return;
4010
- this._isRunAsyncUpdate = true;
4143
+ const visLib = this.visLib();
4144
+ const visViewer = this.visViewer();
4145
+ const device = visViewer.getActiveDevice();
4146
+ if (isExist(options.sceneGraph)) {
4147
+ device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
4148
+ }
4149
+ device.delete();
4150
+ this.update();
4151
+ }
4152
+ async open(file, params = {}) {
4153
+ if (!this.visualizeJs)
4154
+ return this;
4155
+ this.cancel();
4156
+ this.clear();
4157
+ this.emitEvent({ type: "open", mode: "file", file });
4158
+ let model = file;
4159
+ if (model && typeof model.getModels === "function") {
4160
+ const models = await model.getModels();
4161
+ model = models.find((model) => model.default) || models[0] || file;
4162
+ }
4163
+ if (model && typeof model.database === "string") {
4164
+ file = model.file;
4165
+ }
4166
+ if (!model)
4167
+ throw new Error(`Format not supported`);
4168
+ let format = params.format;
4169
+ if (!format && typeof file["type"] === "string")
4170
+ format = file["type"].split(".").pop();
4171
+ if (!format && typeof file === "string")
4172
+ format = file.split(".").pop();
4173
+ if (!format && file instanceof globalThis.File)
4174
+ format = file.name.split(".").pop();
4175
+ const loader = loaders.createLoader(this, model, format);
4176
+ if (!loader)
4177
+ throw new Error(`Format not supported`);
4178
+ this.loaders.push(loader);
4179
+ this.emitEvent({ type: "geometrystart", file, model });
4011
4180
  try {
4012
- const device = this.visViewer().getActiveDevice();
4013
- for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
4014
- await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
4015
- }
4016
- await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
4181
+ await this.loadReferences(model);
4182
+ await loader.load(model, format, params);
4017
4183
  }
4018
- catch (e) {
4019
- console.error(e);
4184
+ catch (error) {
4185
+ this.emitEvent({ type: "geometryerror", data: error, file, model });
4186
+ throw error;
4020
4187
  }
4021
- finally {
4022
- this._isRunAsyncUpdate = false;
4188
+ this.emitEvent({ type: "geometryend", file, model });
4189
+ if (this.visualizeJs) {
4190
+ this.applyModelTransformMatrix(model);
4191
+ this.applySceneGraphSettings();
4023
4192
  }
4193
+ return this;
4024
4194
  }
4025
- get visualizeJs() {
4026
- return this._visualizeJs;
4027
- }
4028
- visLib() {
4029
- return this._visualizeJs;
4030
- }
4031
- visViewer() {
4032
- return this._viewer;
4033
- }
4034
- syncOpenCloudVisualStyle() {
4195
+ openVsfFile(buffer) {
4196
+ console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
4035
4197
  if (!this.visualizeJs)
4036
4198
  return this;
4037
- const visLib = this.visLib();
4199
+ this.cancel();
4200
+ this.clear();
4201
+ this.emitEvent({ type: "open", mode: "file", file: "", buffer });
4038
4202
  const visViewer = this.visViewer();
4039
- const device = visViewer.getActiveDevice();
4040
- if (device.isNull())
4041
- return this;
4042
- const view = device.getActiveView();
4043
- view.enableDefaultLighting(true, visLib.DefaultLightingType.kTwoLights);
4044
- view.setDefaultLightingIntensity(1.25);
4045
- let visualStyleId;
4203
+ this.emitEvent({ type: "geometrystart", file: "", buffer });
4046
4204
  try {
4047
- visualStyleId = visViewer.findVisualStyle("OpenCloud");
4048
- }
4049
- catch {
4050
- visualStyleId = undefined;
4205
+ const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
4206
+ visViewer.parseFile(data);
4207
+ this.syncOptions();
4208
+ this.syncOverlay();
4209
+ this.update(true);
4210
+ this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
4211
+ this.emitEvent({ type: "databasechunk", data, file: "", buffer });
4051
4212
  }
4052
- if (!visualStyleId || visualStyleId.isNull()) {
4053
- visualStyleId = visViewer.createVisualStyle("OpenCloud");
4054
- const colorDef = new visLib.OdTvColorDef(66, 66, 66);
4055
- const shadedVsId = visViewer.findVisualStyle("Realistic");
4056
- const visualStylePtr = visualStyleId.openObject();
4057
- visualStylePtr.copyFrom(shadedVsId);
4058
- visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kFaceModifiers, 0, visLib.VisualStyleOperations.kSet);
4059
- visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModel, 2, visLib.VisualStyleOperations.kSet);
4060
- visualStylePtr.setOptionDouble(visLib.VisualStyleOptions.kEdgeCreaseAngle, 60, visLib.VisualStyleOperations.kSet);
4061
- visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeStyles, 0, visLib.VisualStyleOperations.kSet);
4062
- visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModifiers, 8, visLib.VisualStyleOperations.kSet);
4063
- visualStylePtr.setOptionColor(visLib.VisualStyleOptions.kEdgeColorValue, colorDef, visLib.VisualStyleOperations.kSet);
4064
- visualStylePtr.delete();
4213
+ catch (error) {
4214
+ this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
4215
+ throw error;
4065
4216
  }
4066
- view.visualStyle = visualStyleId;
4067
- view.delete();
4068
- device.delete();
4217
+ this.emitEvent({ type: "geometryend", file: "", buffer });
4069
4218
  return this;
4070
4219
  }
4071
- syncOptions(options = this.options) {
4220
+ openVsfxFile(buffer) {
4221
+ console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
4072
4222
  if (!this.visualizeJs)
4073
4223
  return this;
4074
- this.syncOpenCloudVisualStyle();
4075
- const visLib = this.visLib();
4224
+ this.cancel();
4225
+ this.clear();
4226
+ this.emitEvent({ type: "open", mode: "file", file: "", buffer });
4076
4227
  const visViewer = this.visViewer();
4077
- const device = visViewer.getActiveDevice();
4078
- if (device.isNull())
4079
- return this;
4080
- if (options.showWCS !== visViewer.getEnableWCS()) {
4081
- visViewer.setEnableWCS(options.showWCS);
4082
- }
4083
- if (options.cameraAnimation !== visViewer.getEnableAnimation()) {
4084
- visViewer.setEnableAnimation(options.cameraAnimation);
4085
- }
4086
- const antialiasing = options.antialiasing === true || options.antialiasing === "fxaa";
4087
- if (antialiasing !== visViewer.fxaaAntiAliasing3d) {
4088
- visViewer.fxaaAntiAliasing3d = antialiasing;
4228
+ this.emitEvent({ type: "geometrystart", file: "", buffer });
4229
+ try {
4230
+ const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
4231
+ visViewer.parseVsfx(data);
4232
+ this.syncOptions();
4233
+ this.syncOverlay();
4234
+ this.update(true);
4235
+ this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
4236
+ this.emitEvent({ type: "databasechunk", data, file: "", buffer });
4237
+ }
4238
+ catch (error) {
4239
+ this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
4240
+ throw error;
4241
+ }
4242
+ this.emitEvent({ type: "geometryend", file: "", buffer });
4243
+ return this;
4244
+ }
4245
+ cancel() {
4246
+ var _a;
4247
+ (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
4248
+ this._abortControllerForReferences = undefined;
4249
+ this.loaders.forEach((loader) => loader.cancel());
4250
+ this.emitEvent({ type: "cancel" });
4251
+ return this;
4252
+ }
4253
+ clear() {
4254
+ if (!this.visualizeJs)
4255
+ return this;
4256
+ const visViewer = this.visViewer();
4257
+ this.setActiveDragger();
4258
+ this.clearSlices();
4259
+ this.clearOverlay();
4260
+ this.clearSelected();
4261
+ this.loaders.forEach((loader) => loader.dispose());
4262
+ this.loaders = [];
4263
+ this.models.forEach((model) => model.dispose());
4264
+ this.models = [];
4265
+ visViewer.clear();
4266
+ visViewer.createLocalDatabase();
4267
+ this.syncOptions();
4268
+ this.syncOverlay();
4269
+ this.update(true);
4270
+ this.emitEvent({ type: "clear" });
4271
+ return this;
4272
+ }
4273
+ is3D() {
4274
+ if (!this.visualizeJs)
4275
+ return false;
4276
+ const visViewer = this.visViewer();
4277
+ const ext = visViewer.getActiveExtents();
4278
+ const min = ext.min();
4279
+ const max = ext.max();
4280
+ const extHeight = max[2] - min[2];
4281
+ return extHeight !== 0;
4282
+ }
4283
+ syncOptions(options = this.options) {
4284
+ if (!this.visualizeJs)
4285
+ return this;
4286
+ const visLib = this.visLib();
4287
+ const visViewer = this.visViewer();
4288
+ const device = visViewer.getActiveDevice();
4289
+ if (device.isNull())
4290
+ return this;
4291
+ const view = device.getActiveView();
4292
+ view.enableDefaultLighting(true, visLib.DefaultLightingType.kTwoLights);
4293
+ view.setDefaultLightingIntensity(1.25);
4294
+ let visualStyleId;
4295
+ try {
4296
+ visualStyleId = visViewer.findVisualStyle("OpenCloud");
4297
+ }
4298
+ catch {
4299
+ visualStyleId = undefined;
4300
+ }
4301
+ if (!visualStyleId || visualStyleId.isNull()) {
4302
+ visualStyleId = visViewer.createVisualStyle("OpenCloud");
4303
+ const colorDef = new visLib.OdTvColorDef(66, 66, 66);
4304
+ const shadedVsId = visViewer.findVisualStyle("Realistic");
4305
+ const visualStylePtr = visualStyleId.openObject();
4306
+ visualStylePtr.copyFrom(shadedVsId);
4307
+ visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kFaceModifiers, 0, visLib.VisualStyleOperations.kSet);
4308
+ visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModel, 2, visLib.VisualStyleOperations.kSet);
4309
+ visualStylePtr.setOptionDouble(visLib.VisualStyleOptions.kEdgeCreaseAngle, 60, visLib.VisualStyleOperations.kSet);
4310
+ visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeStyles, 0, visLib.VisualStyleOperations.kSet);
4311
+ visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModifiers, 8, visLib.VisualStyleOperations.kSet);
4312
+ visualStylePtr.setOptionColor(visLib.VisualStyleOptions.kEdgeColorValue, colorDef, visLib.VisualStyleOperations.kSet);
4313
+ visualStylePtr.delete();
4314
+ }
4315
+ view.visualStyle = visualStyleId;
4316
+ if (options.showWCS !== visViewer.getEnableWCS()) {
4317
+ visViewer.setEnableWCS(options.showWCS);
4318
+ }
4319
+ if (options.cameraAnimation !== visViewer.getEnableAnimation()) {
4320
+ visViewer.setEnableAnimation(options.cameraAnimation);
4321
+ }
4322
+ const antialiasing = options.antialiasing === true || options.antialiasing === "fxaa";
4323
+ if (antialiasing !== visViewer.fxaaAntiAliasing3d) {
4324
+ visViewer.fxaaAntiAliasing3d = antialiasing;
4089
4325
  visViewer.fxaaQuality = 5;
4090
4326
  }
4091
4327
  if (options.shadows !== visViewer.shadows) {
4092
4328
  visViewer.shadows = options.shadows;
4093
- const canvas = visLib.canvas;
4094
- device.invalidate([0, canvas.width, canvas.height, 0]);
4095
4329
  }
4096
4330
  if (options.groundShadow !== visViewer.groundShadow) {
4097
4331
  visViewer.groundShadow = options.groundShadow;
@@ -4117,17 +4351,7 @@ class Viewer extends EventEmitter2 {
4117
4351
  visualStyleId.delete();
4118
4352
  activeView.delete();
4119
4353
  }
4120
- device.delete();
4121
- this.syncHighlightingOptions(options);
4122
- this.update();
4123
- return this;
4124
- }
4125
- syncHighlightingOptions(options = this.options) {
4126
- if (!this.visualizeJs)
4127
- return this;
4128
4354
  const params = options.enableCustomHighlight ? options : Options.defaults();
4129
- const visLib = this.visLib();
4130
- const visViewer = this.visViewer();
4131
4355
  const { Entry, OdTvRGBColorDef } = visLib;
4132
4356
  const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
4133
4357
  const highlightStylePtr = highlightStyleId.openObject();
@@ -4154,19 +4378,80 @@ class Viewer extends EventEmitter2 {
4154
4378
  const visibility = !isExist(params.edgesVisibility) ? true : params.edgesVisibility;
4155
4379
  highlightStylePtr.setEdgesVisibility(Entry.k2DTop.value | Entry.k3DTop.value, params.edgesOverlap && visibility);
4156
4380
  }
4157
- const device = visViewer.getActiveDevice();
4158
- if (!device.isNull()) {
4159
- const canvas = visLib.canvas;
4160
- device.invalidate([0, canvas.width, canvas.height, 0]);
4161
- device.delete();
4162
- }
4381
+ view.delete();
4382
+ device.delete();
4383
+ this.update();
4163
4384
  return this;
4164
4385
  }
4165
- get draggers() {
4166
- return [...draggers.getDraggers().keys()];
4386
+ syncOverlay() {
4387
+ if (!this.visualizeJs)
4388
+ return;
4389
+ const visViewer = this.visViewer();
4390
+ const activeView = visViewer.activeView;
4391
+ let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
4392
+ if (!overlayView) {
4393
+ const markupModel = visViewer.getMarkupModel();
4394
+ const pDevice = visViewer.getActiveDevice();
4395
+ overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
4396
+ overlayView.addModel(markupModel);
4397
+ activeView.addSibling(overlayView);
4398
+ pDevice.addView(overlayView);
4399
+ }
4400
+ overlayView.viewPosition = activeView.viewPosition;
4401
+ overlayView.viewTarget = activeView.viewTarget;
4402
+ overlayView.upVector = activeView.upVector;
4403
+ overlayView.viewFieldWidth = activeView.viewFieldWidth;
4404
+ overlayView.viewFieldHeight = activeView.viewFieldHeight;
4405
+ const viewPort = overlayView.getViewport();
4406
+ overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
4407
+ overlayView.vportRect = activeView.vportRect;
4408
+ this._markup.syncOverlay();
4409
+ this.update();
4167
4410
  }
4168
- get components() {
4169
- return [...components.getComponents().keys()];
4411
+ clearOverlay() {
4412
+ if (!this.visualizeJs)
4413
+ return;
4414
+ this._markup.clearOverlay();
4415
+ this.update();
4416
+ }
4417
+ clearSlices() {
4418
+ if (!this.visualizeJs)
4419
+ return;
4420
+ const visViewer = this.visViewer();
4421
+ const activeView = visViewer.activeView;
4422
+ activeView.removeCuttingPlanes();
4423
+ activeView.delete();
4424
+ this.update();
4425
+ }
4426
+ getSelected() {
4427
+ return this.executeCommand("getSelected");
4428
+ }
4429
+ setSelected(handles) {
4430
+ this.executeCommand("setSelected", handles);
4431
+ }
4432
+ getSelected2() {
4433
+ return this.executeCommand("getSelected2");
4434
+ }
4435
+ setSelected2(handles) {
4436
+ this.executeCommand("setSelected2", handles);
4437
+ }
4438
+ clearSelected() {
4439
+ this.executeCommand("clearSelected");
4440
+ }
4441
+ hideSelected() {
4442
+ this.executeCommand("hideSelected");
4443
+ }
4444
+ isolateSelected() {
4445
+ this.executeCommand("isolateSelected");
4446
+ }
4447
+ showAll() {
4448
+ this.executeCommand("showAll");
4449
+ }
4450
+ explode(index = 0) {
4451
+ this.executeCommand("explode", index);
4452
+ }
4453
+ collect() {
4454
+ this.executeCommand("collect");
4170
4455
  }
4171
4456
  registerDragger(name, dragger) {
4172
4457
  console.warn("Viewer.registerDragger() has been deprecated since 25.12 and will be removed in a future release, use draggers('visualizejs').registerDragger() instead.");
@@ -4213,55 +4498,102 @@ class Viewer extends EventEmitter2 {
4213
4498
  getComponent(name) {
4214
4499
  return this._components.find((component) => component.name === name);
4215
4500
  }
4216
- clearSlices() {
4501
+ drawViewpoint(viewpoint) {
4502
+ var _a, _b;
4217
4503
  if (!this.visualizeJs)
4218
4504
  return;
4219
4505
  const visViewer = this.visViewer();
4220
4506
  const activeView = visViewer.activeView;
4221
- activeView.removeCuttingPlanes();
4222
- activeView.delete();
4223
- this.update();
4224
- }
4225
- clearOverlay() {
4226
- if (!this.visualizeJs)
4227
- return;
4228
- this._markup.clearOverlay();
4507
+ const getPoint3dAsArray = (point3d) => {
4508
+ return [point3d.x, point3d.y, point3d.z];
4509
+ };
4510
+ const setOrthogonalCamera = (orthogonal_camera) => {
4511
+ if (orthogonal_camera) {
4512
+ activeView.setView(getPoint3dAsArray(orthogonal_camera.view_point), getPoint3dAsArray(orthogonal_camera.direction), getPoint3dAsArray(orthogonal_camera.up_vector), orthogonal_camera.field_width, orthogonal_camera.field_height, true);
4513
+ this.syncOverlay();
4514
+ this.emitEvent({ type: "changecameramode", mode: "orthographic" });
4515
+ }
4516
+ };
4517
+ const setPerspectiveCamera = (perspective_camera) => { };
4518
+ const setClippingPlanes = (clipping_planes) => {
4519
+ if (clipping_planes) {
4520
+ for (const clipping_plane of clipping_planes) {
4521
+ const cuttingPlane = new (this.visLib().OdTvPlane)();
4522
+ cuttingPlane.set(getPoint3dAsArray(clipping_plane.location), getPoint3dAsArray(clipping_plane.direction));
4523
+ activeView.addCuttingPlane(cuttingPlane);
4524
+ activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
4525
+ }
4526
+ }
4527
+ };
4528
+ const setSelection = (selection) => {
4529
+ if (selection)
4530
+ this.setSelected(selection.map((component) => component.handle));
4531
+ };
4532
+ const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
4533
+ this.setActiveDragger();
4534
+ this.clearSlices();
4535
+ this.clearOverlay();
4536
+ this.clearSelected();
4537
+ this.showAll();
4538
+ this.explode();
4539
+ setOrthogonalCamera(viewpoint.orthogonal_camera);
4540
+ setPerspectiveCamera(viewpoint.perspective_camera);
4541
+ setClippingPlanes(viewpoint.clipping_planes);
4542
+ setSelection(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.selection2) || viewpoint.selection);
4543
+ this._markup.setViewpoint(viewpoint);
4544
+ this.setActiveDragger(draggerName);
4545
+ this.emitEvent({ type: "drawviewpoint", data: viewpoint });
4229
4546
  this.update();
4230
4547
  }
4231
- syncOverlay() {
4548
+ createViewpoint() {
4232
4549
  if (!this.visualizeJs)
4233
- return;
4550
+ return {};
4234
4551
  const visViewer = this.visViewer();
4235
4552
  const activeView = visViewer.activeView;
4236
- let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
4237
- if (!overlayView) {
4238
- const markupModel = visViewer.getMarkupModel();
4239
- const pDevice = visViewer.getActiveDevice();
4240
- overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
4241
- overlayView.addModel(markupModel);
4242
- activeView.addSibling(overlayView);
4243
- pDevice.addView(overlayView);
4244
- }
4245
- overlayView.viewPosition = activeView.viewPosition;
4246
- overlayView.viewTarget = activeView.viewTarget;
4247
- overlayView.upVector = activeView.upVector;
4248
- overlayView.viewFieldWidth = activeView.viewFieldWidth;
4249
- overlayView.viewFieldHeight = activeView.viewFieldHeight;
4250
- const viewPort = overlayView.getViewport();
4251
- overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
4252
- overlayView.vportRect = activeView.vportRect;
4253
- this._markup.syncOverlay();
4254
- this.update();
4255
- }
4256
- is3D() {
4257
- if (!this.visualizeJs)
4258
- return false;
4259
- const visViewer = this.visViewer();
4260
- const ext = visViewer.getActiveExtents();
4261
- const min = ext.min();
4262
- const max = ext.max();
4263
- const extHeight = max[2] - min[2];
4264
- return extHeight !== 0;
4553
+ const getPoint3dFromArray = (array) => {
4554
+ return { x: array[0], y: array[1], z: array[2] };
4555
+ };
4556
+ const getOrthogonalCamera = () => {
4557
+ return {
4558
+ view_point: getPoint3dFromArray(activeView.viewPosition),
4559
+ direction: getPoint3dFromArray(activeView.viewTarget),
4560
+ up_vector: getPoint3dFromArray(activeView.upVector),
4561
+ field_width: activeView.viewFieldWidth,
4562
+ field_height: activeView.viewFieldHeight,
4563
+ view_to_world_scale: 1,
4564
+ };
4565
+ };
4566
+ const getPerspectiveCamera = () => {
4567
+ return undefined;
4568
+ };
4569
+ const getClippingPlanes = () => {
4570
+ const clipping_planes = [];
4571
+ for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
4572
+ const cuttingPlane = activeView.getCuttingPlane(i);
4573
+ const clipping_plane = {
4574
+ location: getPoint3dFromArray(cuttingPlane.getOrigin()),
4575
+ direction: getPoint3dFromArray(cuttingPlane.normal()),
4576
+ };
4577
+ clipping_planes.push(clipping_plane);
4578
+ }
4579
+ return clipping_planes;
4580
+ };
4581
+ const getSelection = () => {
4582
+ return this.getSelected().map((handle) => ({ handle }));
4583
+ };
4584
+ const getSelection2 = () => {
4585
+ return this.getSelected2().map((handle) => ({ handle }));
4586
+ };
4587
+ const viewpoint = { custom_fields: {} };
4588
+ viewpoint.orthogonal_camera = getOrthogonalCamera();
4589
+ viewpoint.perspective_camera = getPerspectiveCamera();
4590
+ viewpoint.clipping_planes = getClippingPlanes();
4591
+ viewpoint.selection = getSelection();
4592
+ viewpoint.description = new Date().toDateString();
4593
+ this._markup.getViewpoint(viewpoint);
4594
+ viewpoint.custom_fields.selection2 = getSelection2();
4595
+ this.emitEvent({ type: "createviewpoint", data: viewpoint });
4596
+ return viewpoint;
4265
4597
  }
4266
4598
  screenToWorld(position) {
4267
4599
  if (!this.visualizeJs)
@@ -4296,184 +4628,23 @@ class Viewer extends EventEmitter2 {
4296
4628
  result.z = 1 / z;
4297
4629
  return result;
4298
4630
  }
4299
- getSelected() {
4300
- return this.executeCommand("getSelected");
4301
- }
4302
- setSelected(handles) {
4303
- this.executeCommand("setSelected", handles);
4304
- }
4305
- clearSelected() {
4306
- this.executeCommand("clearSelected");
4307
- }
4308
- hideSelected() {
4309
- this.executeCommand("hideSelected");
4310
- }
4311
- isolateSelected() {
4312
- this.executeCommand("isolateSelected");
4313
- }
4314
- showAll() {
4315
- this.executeCommand("showAll");
4316
- }
4317
- explode(index = 0) {
4318
- this.executeCommand("explode", index);
4319
- }
4320
- collect() {
4321
- this.executeCommand("collect");
4322
- }
4323
- async loadReferences(model) {
4324
- var _a;
4325
- if (!this.visualizeJs)
4326
- return this;
4327
- if (!this.client)
4328
- return this;
4329
- if (!model.getReferences)
4330
- return this;
4331
- const abortController = new AbortController();
4332
- (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
4333
- this._abortControllerForReferences = abortController;
4334
- let references = [];
4335
- await model
4336
- .getReferences(abortController.signal)
4337
- .then((data) => (references = data.references))
4338
- .catch((e) => console.error("Cannot load model references.", e));
4339
- for (const file of references) {
4340
- await this.client
4341
- .downloadFile(file.id, undefined, abortController.signal)
4342
- .then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
4343
- .catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
4344
- }
4345
- return this;
4346
- }
4347
- applyModelTransformMatrix(model) {
4348
- this.executeCommand("applyModelTransform", model);
4631
+ executeCommand(id, ...args) {
4632
+ return commands.executeCommand(id, this, ...args);
4349
4633
  }
4350
- applySceneGraphSettings(options = this.options) {
4634
+ addMarkupEntity(entityName) {
4351
4635
  if (!this.visualizeJs)
4352
- return;
4353
- const visLib = this.visLib();
4636
+ return null;
4637
+ this.syncOverlay();
4354
4638
  const visViewer = this.visViewer();
4355
- const device = visViewer.getActiveDevice();
4356
- if (isExist(options.sceneGraph)) {
4357
- device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
4358
- }
4359
- device.delete();
4639
+ const model = visViewer.getMarkupModel();
4640
+ const entityId = model.appendEntity(entityName);
4641
+ const entityPtr = entityId.openObject();
4642
+ const color = this.getMarkupColor();
4643
+ entityPtr.setColor(color.r, color.g, color.b);
4644
+ entityPtr.setLineWeight(2);
4645
+ entityPtr.delete();
4360
4646
  this.update();
4361
- }
4362
- async open(file, params = {}) {
4363
- if (!this.visualizeJs)
4364
- return this;
4365
- this.cancel();
4366
- this.clear();
4367
- this.emitEvent({ type: "open", file });
4368
- let model = file;
4369
- if (model && typeof model.getModels === "function") {
4370
- const models = await model.getModels();
4371
- model = models.find((model) => model.default) || models[0] || file;
4372
- }
4373
- if (!model)
4374
- throw new Error(`Format not supported`);
4375
- let format = params.format;
4376
- if (!format && typeof model.type === "string")
4377
- format = model.type.split(".").pop();
4378
- if (!format && typeof file === "string")
4379
- format = file.split(".").pop();
4380
- if (!format && file instanceof globalThis.File)
4381
- format = file.name.split(".").pop();
4382
- const loader = loaders.createLoader(this, model, format);
4383
- if (!loader)
4384
- throw new Error(`Format not supported`);
4385
- this.loaders.push(loader);
4386
- this.emitEvent({ type: "geometrystart", file, model });
4387
- try {
4388
- await this.loadReferences(model);
4389
- await loader.load(model, format, params);
4390
- }
4391
- catch (error) {
4392
- this.emitEvent({ type: "geometryerror", data: error, file, model });
4393
- throw error;
4394
- }
4395
- this.emitEvent({ type: "geometryend", file, model });
4396
- if (this.visualizeJs) {
4397
- this.applyModelTransformMatrix(model);
4398
- this.applySceneGraphSettings();
4399
- }
4400
- return this;
4401
- }
4402
- openVsfFile(buffer) {
4403
- console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
4404
- if (!this.visualizeJs)
4405
- return this;
4406
- this.cancel();
4407
- this.clear();
4408
- this.emitEvent({ type: "open", file: "", buffer });
4409
- const visViewer = this.visViewer();
4410
- this.emitEvent({ type: "geometrystart", file: "", buffer });
4411
- try {
4412
- const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
4413
- visViewer.parseFile(data);
4414
- this.syncOptions();
4415
- this.syncOverlay();
4416
- this.update(true);
4417
- this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
4418
- this.emitEvent({ type: "databasechunk", data, file: "", buffer });
4419
- }
4420
- catch (error) {
4421
- this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
4422
- throw error;
4423
- }
4424
- this.emitEvent({ type: "geometryend", file: "", buffer });
4425
- return this;
4426
- }
4427
- openVsfxFile(buffer) {
4428
- console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
4429
- if (!this.visualizeJs)
4430
- return this;
4431
- this.cancel();
4432
- this.clear();
4433
- this.emitEvent({ type: "open", file: "", buffer });
4434
- const visViewer = this.visViewer();
4435
- this.emitEvent({ type: "geometrystart", file: "", buffer });
4436
- try {
4437
- const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
4438
- visViewer.parseVsfx(data);
4439
- this.syncOptions();
4440
- this.syncOverlay();
4441
- this.update(true);
4442
- this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
4443
- this.emitEvent({ type: "databasechunk", data, file: "", buffer });
4444
- }
4445
- catch (error) {
4446
- this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
4447
- throw error;
4448
- }
4449
- this.emitEvent({ type: "geometryend", file: "", buffer });
4450
- return this;
4451
- }
4452
- cancel() {
4453
- var _a;
4454
- (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
4455
- this._abortControllerForReferences = undefined;
4456
- this.loaders.forEach((loader) => loader.cancel());
4457
- this.emitEvent({ type: "cancel" });
4458
- return this;
4459
- }
4460
- clear() {
4461
- if (!this.visualizeJs)
4462
- return this;
4463
- const visViewer = this.visViewer();
4464
- this.setActiveDragger();
4465
- this.clearSlices();
4466
- this.clearOverlay();
4467
- this.clearSelected();
4468
- this.loaders.forEach((loader) => loader.dispose());
4469
- this.loaders = [];
4470
- visViewer.clear();
4471
- visViewer.createLocalDatabase();
4472
- this.syncOptions();
4473
- this.syncOverlay();
4474
- this.update(true);
4475
- this.emitEvent({ type: "clear" });
4476
- return this;
4647
+ return entityId;
4477
4648
  }
4478
4649
  getMarkupColor() {
4479
4650
  console.warn("Viewer.getMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.getMarkupColor() instead.");
@@ -4490,113 +4661,43 @@ class Viewer extends EventEmitter2 {
4490
4661
  colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
4491
4662
  this._markup.colorizeSelectedMarkups(r, g, b);
4492
4663
  }
4493
- addMarkupEntity(entityName) {
4494
- if (!this.visualizeJs)
4495
- return null;
4496
- this.syncOverlay();
4497
- const visViewer = this.visViewer();
4498
- const model = visViewer.getMarkupModel();
4499
- const entityId = model.appendEntity(entityName);
4500
- const entityPtr = entityId.openObject();
4501
- const color = this.getMarkupColor();
4502
- entityPtr.setColor(color.r, color.g, color.b);
4503
- entityPtr.setLineWeight(2);
4504
- entityPtr.delete();
4505
- this.update();
4506
- return entityId;
4664
+ scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
4665
+ return new Promise((resolve, reject) => {
4666
+ setTimeout(() => {
4667
+ var _a, _b, _c;
4668
+ try {
4669
+ if (this._enableAutoUpdate) {
4670
+ (_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
4671
+ (_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
4672
+ }
4673
+ this.emitEvent({ type: "update", data: false });
4674
+ resolve();
4675
+ }
4676
+ catch (e) {
4677
+ console.error(e);
4678
+ reject();
4679
+ }
4680
+ }, 0);
4681
+ });
4507
4682
  }
4508
- drawViewpoint(viewpoint) {
4509
- var _a;
4683
+ async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
4510
4684
  if (!this.visualizeJs)
4511
4685
  return;
4512
- const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
4513
- this.setActiveDragger();
4514
- this.clearSlices();
4515
- this.clearOverlay();
4516
- this.clearSelected();
4517
- this.showAll();
4518
- this.explode();
4519
- this.setOrthogonalCameraSettings(viewpoint.orthogonal_camera);
4520
- this.setClippingPlanes(viewpoint.clipping_planes);
4521
- this.setSelection(viewpoint.selection);
4522
- this._markup.setViewpoint(viewpoint);
4523
- this.setActiveDragger(draggerName);
4524
- this.emitEvent({ type: "drawviewpoint", data: viewpoint });
4525
- this.update();
4526
- }
4527
- createViewpoint() {
4528
- if (!this.visualizeJs)
4529
- return {};
4530
- const viewpoint = {};
4531
- viewpoint.orthogonal_camera = this.getOrthogonalCameraSettings();
4532
- viewpoint.clipping_planes = this.getClippingPlanes();
4533
- viewpoint.selection = this.getSelection();
4534
- viewpoint.description = new Date().toDateString();
4535
- this._markup.getViewpoint(viewpoint);
4536
- this.emitEvent({ type: "createviewpoint", data: viewpoint });
4537
- return viewpoint;
4538
- }
4539
- getPoint3dFromArray(array) {
4540
- return { x: array[0], y: array[1], z: array[2] };
4541
- }
4542
- getLogicalPoint3dAsArray(point3d) {
4543
- return [point3d.x, point3d.y, point3d.z];
4544
- }
4545
- getOrthogonalCameraSettings() {
4546
- const visViewer = this.visViewer();
4547
- const activeView = visViewer.activeView;
4548
- return {
4549
- view_point: this.getPoint3dFromArray(activeView.viewPosition),
4550
- direction: this.getPoint3dFromArray(activeView.viewTarget),
4551
- up_vector: this.getPoint3dFromArray(activeView.upVector),
4552
- field_width: activeView.viewFieldWidth,
4553
- field_height: activeView.viewFieldHeight,
4554
- view_to_world_scale: 1,
4555
- };
4556
- }
4557
- setOrthogonalCameraSettings(settings) {
4558
- const visViewer = this.visViewer();
4559
- const activeView = visViewer.activeView;
4560
- if (settings) {
4561
- activeView.setView(this.getLogicalPoint3dAsArray(settings.view_point), this.getLogicalPoint3dAsArray(settings.direction), this.getLogicalPoint3dAsArray(settings.up_vector), settings.field_width, settings.field_height, true);
4562
- this.syncOverlay();
4686
+ this._isRunAsyncUpdate = true;
4687
+ try {
4688
+ const device = this.visViewer().getActiveDevice();
4689
+ for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
4690
+ await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
4691
+ }
4692
+ await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
4563
4693
  }
4564
- }
4565
- getClippingPlanes() {
4566
- const visViewer = this.visViewer();
4567
- const activeView = visViewer.activeView;
4568
- const clipping_planes = [];
4569
- for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
4570
- const cuttingPlane = activeView.getCuttingPlane(i);
4571
- const clipping_plane = {
4572
- location: this.getPoint3dFromArray(cuttingPlane.getOrigin()),
4573
- direction: this.getPoint3dFromArray(cuttingPlane.normal()),
4574
- };
4575
- clipping_planes.push(clipping_plane);
4694
+ catch (e) {
4695
+ console.error(e);
4576
4696
  }
4577
- return clipping_planes;
4578
- }
4579
- setClippingPlanes(clipping_planes) {
4580
- if (clipping_planes) {
4581
- const visViewer = this.visViewer();
4582
- const activeView = visViewer.activeView;
4583
- for (const clipping_plane of clipping_planes) {
4584
- const cuttingPlane = new (this.visLib().OdTvPlane)();
4585
- cuttingPlane.set(this.getLogicalPoint3dAsArray(clipping_plane.location), this.getLogicalPoint3dAsArray(clipping_plane.direction));
4586
- activeView.addCuttingPlane(cuttingPlane);
4587
- activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
4588
- }
4697
+ finally {
4698
+ this._isRunAsyncUpdate = false;
4589
4699
  }
4590
4700
  }
4591
- getSelection() {
4592
- return this.getSelected().map((handle) => ({ handle }));
4593
- }
4594
- setSelection(selection) {
4595
- this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map((component) => component.handle));
4596
- }
4597
- executeCommand(id, ...args) {
4598
- return commands.executeCommand(id, this, ...args);
4599
- }
4600
4701
  deviceAutoRegeneration() {
4601
4702
  const visViewer = this.visViewer();
4602
4703
  const device = visViewer.getActiveDevice();