@inweb/viewer-visualize 27.9.1 → 27.11.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 (89) hide show
  1. package/dist/viewer-visualize.js +573 -236
  2. package/dist/viewer-visualize.js.map +1 -1
  3. package/dist/viewer-visualize.min.js +1 -1
  4. package/dist/viewer-visualize.module.js +458 -236
  5. package/dist/viewer-visualize.module.js.map +1 -1
  6. package/lib/Viewer/Commands/ClearSelected.d.ts +1 -1
  7. package/lib/Viewer/Commands/Deselect.d.ts +2 -0
  8. package/lib/Viewer/Commands/Explode.d.ts +1 -1
  9. package/lib/Viewer/Commands/GetHidden.d.ts +2 -0
  10. package/lib/Viewer/Commands/GetIsolated.d.ts +2 -0
  11. package/lib/Viewer/Commands/GetSelected.d.ts +2 -2
  12. package/lib/Viewer/Commands/GetSelected2.d.ts +1 -1
  13. package/lib/Viewer/Commands/Hide.d.ts +2 -0
  14. package/lib/Viewer/Commands/HideAll.d.ts +2 -0
  15. package/lib/Viewer/Commands/HideSelected.d.ts +1 -1
  16. package/lib/Viewer/Commands/Isolate.d.ts +2 -0
  17. package/lib/Viewer/Commands/IsolateSelected.d.ts +1 -1
  18. package/lib/Viewer/Commands/RegenerateAll.d.ts +1 -1
  19. package/lib/Viewer/Commands/ResetView.d.ts +1 -1
  20. package/lib/Viewer/Commands/Select.d.ts +2 -0
  21. package/lib/Viewer/Commands/SelectModel.d.ts +1 -1
  22. package/lib/Viewer/Commands/SetSelected.d.ts +2 -2
  23. package/lib/Viewer/Commands/SetSelected2.d.ts +2 -2
  24. package/lib/Viewer/Commands/Show.d.ts +2 -0
  25. package/lib/Viewer/Commands/ShowAll.d.ts +1 -1
  26. package/lib/Viewer/Commands/ToHandles.d.ts +2 -0
  27. package/lib/Viewer/Commands/ToHandles2.d.ts +2 -0
  28. package/lib/Viewer/Commands/ToggleSelection.d.ts +2 -0
  29. package/lib/Viewer/Commands/ZoomExtents.d.ts +2 -0
  30. package/lib/Viewer/Commands/ZoomTo.d.ts +2 -0
  31. package/lib/Viewer/Commands/ZoomToSelected.d.ts +1 -1
  32. package/lib/Viewer/Components/index.d.ts +1 -1
  33. package/lib/Viewer/Draggers/index.d.ts +2 -2
  34. package/lib/Viewer/Loaders/VSFCloudLoader.d.ts +2 -2
  35. package/lib/Viewer/Loaders/VSFXCloudLoader.d.ts +2 -2
  36. package/lib/Viewer/Loaders/VSFXCloudPartialLoader.d.ts +2 -2
  37. package/lib/Viewer/Loaders/VSFXCloudStreamingLoader.d.ts +2 -2
  38. package/lib/Viewer/Loaders/index.d.ts +4 -2
  39. package/lib/Viewer/Models/ModelImpl.d.ts +15 -1
  40. package/lib/Viewer/Models/ModelImpl.types.d.ts +10 -0
  41. package/lib/Viewer/Viewer.d.ts +19 -4
  42. package/package.json +6 -6
  43. package/src/Viewer/Commands/ClearSelected.ts +4 -8
  44. package/src/Viewer/Commands/Deselect.ts +35 -0
  45. package/src/Viewer/Commands/Explode.ts +4 -6
  46. package/src/Viewer/Commands/GetHidden.ts +30 -0
  47. package/src/Viewer/Commands/GetIsolated.ts +30 -0
  48. package/src/Viewer/Commands/GetModels.ts +2 -3
  49. package/src/Viewer/Commands/GetSelected.ts +5 -30
  50. package/src/Viewer/Commands/GetSelected2.ts +5 -7
  51. package/src/Viewer/Commands/Hide.ts +35 -0
  52. package/src/Viewer/Commands/HideAll.ts +32 -0
  53. package/src/Viewer/Commands/HideSelected.ts +2 -11
  54. package/src/Viewer/Commands/Isolate.ts +41 -0
  55. package/src/Viewer/Commands/IsolateSelected.ts +2 -8
  56. package/src/Viewer/Commands/RegenerateAll.ts +2 -3
  57. package/src/Viewer/Commands/ResetView.ts +2 -4
  58. package/src/Viewer/Commands/Select.ts +36 -0
  59. package/src/Viewer/Commands/SelectModel.ts +11 -14
  60. package/src/Viewer/Commands/SetSelected.ts +8 -19
  61. package/src/Viewer/Commands/SetSelected2.ts +6 -14
  62. package/src/Viewer/Commands/Show.ts +34 -0
  63. package/src/Viewer/Commands/ShowAll.ts +3 -6
  64. package/src/Viewer/Commands/ToHandles.ts +35 -0
  65. package/src/Viewer/Commands/ToHandles2.ts +36 -0
  66. package/src/Viewer/Commands/ToggleSelection.ts +40 -0
  67. package/src/Viewer/Commands/{ZoomToExtents.ts → ZoomExtents.ts} +2 -8
  68. package/src/Viewer/Commands/{ZoomToObjects.ts → ZoomTo.ts} +8 -13
  69. package/src/Viewer/Commands/ZoomToSelected.ts +3 -11
  70. package/src/Viewer/Commands/index.ts +29 -8
  71. package/src/Viewer/Components/index.ts +1 -1
  72. package/src/Viewer/Draggers/Actions/OrbitAction.ts +21 -14
  73. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +32 -32
  74. package/src/Viewer/Draggers/OdZoomWheelDragger.ts +2 -2
  75. package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +14 -10
  76. package/src/Viewer/Draggers/index.ts +2 -2
  77. package/src/Viewer/Loaders/VSFCloudLoader.ts +5 -4
  78. package/src/Viewer/Loaders/VSFFileLoader.ts +2 -1
  79. package/src/Viewer/Loaders/VSFXCloudLoader.ts +5 -4
  80. package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +5 -4
  81. package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +5 -4
  82. package/src/Viewer/Loaders/VSFXFileLoader.ts +2 -1
  83. package/src/Viewer/Loaders/index.ts +4 -2
  84. package/src/Viewer/Models/ModelImpl.ts +150 -3
  85. package/src/Viewer/Models/{IModelImpl.ts → ModelImpl.types.ts} +9 -1
  86. package/src/Viewer/Viewer.ts +121 -19
  87. package/lib/Viewer/Commands/ZoomToExtents.d.ts +0 -2
  88. package/lib/Viewer/Commands/ZoomToObjects.d.ts +0 -2
  89. package/lib/Viewer/Models/IModelImpl.d.ts +0 -5
@@ -58,7 +58,7 @@
58
58
  }
59
59
  const { handler, thisArg } = command;
60
60
  const result = handler.apply(thisArg, [viewer, ...args]);
61
- viewer === null || viewer === void 0 ? void 0 : viewer.emit({ type: "command", data: id, args });
61
+ viewer === null || viewer === void 0 ? void 0 : viewer.emit({ type: "command", data: id, args, result });
62
62
  return result;
63
63
  }
64
64
  }
@@ -718,6 +718,119 @@
718
718
  };
719
719
  }
720
720
  }
721
+ class Selector {
722
+ constructor(models) {
723
+ this.models = models;
724
+ this.selected = new Set();
725
+ }
726
+ setSelected(handles) {
727
+ const newSelected = new Set(handles);
728
+ const toUnhighlight = [];
729
+ const toHighlight = [];
730
+ for (const handle of this.selected) {
731
+ if (!newSelected.has(handle))
732
+ toUnhighlight.push(handle);
733
+ }
734
+ for (const handle of newSelected) {
735
+ if (!this.selected.has(handle))
736
+ toHighlight.push(handle);
737
+ }
738
+ this.selected = newSelected;
739
+ if (toUnhighlight.length > 0) {
740
+ this.models.forEach((model) => model.unhighlight(toUnhighlight));
741
+ }
742
+ if (toHighlight.length > 0) {
743
+ this.models.forEach((model) => model.highlight(toHighlight));
744
+ }
745
+ }
746
+ select(handles) {
747
+ const toHighlight = [];
748
+ for (const handle of handles) {
749
+ if (!this.selected.has(handle)) {
750
+ this.selected.add(handle);
751
+ toHighlight.push(handle);
752
+ }
753
+ }
754
+ if (toHighlight.length > 0) {
755
+ this.models.forEach((model) => model.highlight(toHighlight));
756
+ }
757
+ }
758
+ deselect(handles) {
759
+ const toUnhighlight = [];
760
+ for (const handle of handles) {
761
+ if (this.selected.delete(handle))
762
+ toUnhighlight.push(handle);
763
+ }
764
+ if (toUnhighlight.length > 0) {
765
+ this.models.forEach((model) => model.unhighlight(toUnhighlight));
766
+ }
767
+ }
768
+ clearSelected() {
769
+ if (this.selected.size === 0)
770
+ return;
771
+ const toUnhighlight = Array.from(this.selected);
772
+ this.selected.clear();
773
+ this.models.forEach((model) => model.unhighlight(toUnhighlight));
774
+ }
775
+ }
776
+ class VisibilityManager {
777
+ constructor(models) {
778
+ this.models = models;
779
+ this.defaultVisible = true;
780
+ this.exceptions = new Set();
781
+ }
782
+ get hidden() {
783
+ if (this.defaultVisible)
784
+ return this.exceptions;
785
+ else if (this.exceptions.size > 0)
786
+ return new Set();
787
+ else
788
+ return new Set(["$all"]);
789
+ }
790
+ get isolated() {
791
+ if (!this.defaultVisible)
792
+ return this.exceptions;
793
+ else
794
+ return new Set();
795
+ }
796
+ hide(handles) {
797
+ for (const handle of handles) {
798
+ if (this.defaultVisible)
799
+ this.exceptions.add(handle);
800
+ else
801
+ this.exceptions.delete(handle);
802
+ }
803
+ if (handles.length > 0) {
804
+ this.models.forEach((model) => model.hide(handles));
805
+ }
806
+ }
807
+ hideAll() {
808
+ this.defaultVisible = false;
809
+ this.exceptions.clear();
810
+ this.models.forEach((model) => model.hideAll());
811
+ }
812
+ isolate(handles) {
813
+ this.defaultVisible = false;
814
+ this.exceptions = new Set(handles);
815
+ this.models.forEach((model) => model.isolate(handles));
816
+ }
817
+ show(handles) {
818
+ for (const handle of handles) {
819
+ if (this.defaultVisible)
820
+ this.exceptions.delete(handle);
821
+ else
822
+ this.exceptions.add(handle);
823
+ }
824
+ if (handles.length > 0) {
825
+ this.models.forEach((model) => model.show(handles));
826
+ }
827
+ }
828
+ showAll() {
829
+ this.defaultVisible = true;
830
+ this.exceptions.clear();
831
+ this.models.forEach((model) => model.showAll());
832
+ }
833
+ }
721
834
 
722
835
  class OdaGeAction {
723
836
  constructor(module) {
@@ -848,21 +961,21 @@
848
961
  this.pointermove = this.pointermove.bind(this);
849
962
  this.click = this.click.bind(this);
850
963
  this.dblclick = this.dblclick.bind(this);
851
- this.subject.addEventListener("pointerdown", this.pointerdown);
852
- this.subject.addEventListener("pointerup", this.pointerup);
853
- this.subject.addEventListener("pointercancel", this.pointercancel);
854
- this.subject.addEventListener("pointermove", this.pointermove);
855
- this.subject.addEventListener("click", this.click);
856
- this.subject.addEventListener("dblclick", this.dblclick);
964
+ this.subject.canvas.addEventListener("pointerdown", this.pointerdown);
965
+ this.subject.canvas.addEventListener("pointerup", this.pointerup);
966
+ this.subject.canvas.addEventListener("pointercancel", this.pointercancel);
967
+ this.subject.canvas.addEventListener("pointermove", this.pointermove);
968
+ this.subject.canvas.addEventListener("click", this.click);
969
+ this.subject.canvas.addEventListener("dblclick", this.dblclick);
857
970
  this.getViewer().setEnableAutoSelect(false);
858
971
  }
859
972
  dispose() {
860
- this.subject.removeEventListener("pointerdown", this.pointerdown);
861
- this.subject.removeEventListener("pointerup", this.pointerup);
862
- this.subject.removeEventListener("pointercancel", this.pointercancel);
863
- this.subject.removeEventListener("pointermove", this.pointermove);
864
- this.subject.removeEventListener("click", this.click);
865
- this.subject.removeEventListener("dblclick", this.dblclick);
973
+ this.subject.canvas.removeEventListener("pointerdown", this.pointerdown);
974
+ this.subject.canvas.removeEventListener("pointerup", this.pointerup);
975
+ this.subject.canvas.removeEventListener("pointercancel", this.pointercancel);
976
+ this.subject.canvas.removeEventListener("pointermove", this.pointermove);
977
+ this.subject.canvas.removeEventListener("click", this.click);
978
+ this.subject.canvas.removeEventListener("dblclick", this.dblclick);
866
979
  }
867
980
  relativeCoords(event) {
868
981
  return { x: event.offsetX * window.devicePixelRatio, y: event.offsetY * window.devicePixelRatio };
@@ -908,25 +1021,37 @@
908
1021
  }
909
1022
  }
910
1023
  click(ev) {
911
- const viewer = this.getViewer();
912
1024
  const relCoord = this.relativeCoords(ev);
913
1025
  const x = relCoord.x;
914
1026
  const y = relCoord.y;
915
1027
  const isNotDragging = Math.abs(x - this.mouseDownPosition.x) < CLICK_DELTA && Math.abs(y - this.mouseDownPosition.y) < CLICK_DELTA;
916
1028
  if (this.autoSelect && isNotDragging) {
917
- viewer.unselect();
918
- viewer.select(x, y, x, y);
919
- this.subject.update();
920
- const selectionSet = viewer.getSelected();
921
- this.subject.emitEvent({ type: "select", data: selectionSet, handles: this.subject.getSelected() });
922
- this.subject.emitEvent({ type: "select2", data: selectionSet, handles: this.subject.getSelected2() });
1029
+ const viewer = this.getViewer();
1030
+ const view = viewer.activeView;
1031
+ const model = viewer.getActiveModel();
1032
+ const opt = new this.m_module.OdTvSelectionOptions();
1033
+ opt.setMode(this.m_module.SelectionMode.kPoint);
1034
+ const selectionSet = view.select([x, y], opt, model);
1035
+ const handles = this.subject.models[0].getHandlesBySelectionSet(selectionSet);
1036
+ selectionSet.delete();
1037
+ opt.delete();
1038
+ if (handles.length > 0) {
1039
+ if (!ev.shiftKey)
1040
+ this.subject.setSelected(handles);
1041
+ else
1042
+ this.subject.toggleSelection(handles);
1043
+ }
1044
+ else {
1045
+ if (!ev.shiftKey)
1046
+ this.subject.clearSelected();
1047
+ }
923
1048
  }
924
1049
  }
925
1050
  dblclick(ev) {
926
- const viewer = this.getViewer();
927
1051
  const relCoord = this.relativeCoords(ev);
928
1052
  const x = relCoord.x;
929
1053
  const y = relCoord.y;
1054
+ const viewer = this.getViewer();
930
1055
  const device = viewer.getActiveDevice();
931
1056
  const clickView = device.viewAt([x, y]);
932
1057
  if (clickView && !clickView.active) {
@@ -935,15 +1060,7 @@
935
1060
  this.subject.update();
936
1061
  }
937
1062
  else if (this.autoSelect) {
938
- const pSelected = viewer.getSelected();
939
- if (!pSelected.isNull() && pSelected.numItems() !== 0) {
940
- const itr = pSelected.getIterator();
941
- const entity = itr.getEntity();
942
- viewer.zoomToEntity(entity);
943
- this.subject.emitEvent({ type: "zoomtoentity", data: entity });
944
- this.subject.update();
945
- this.deleteAll([itr, entity]);
946
- }
1063
+ this.subject.zoomToSelected();
947
1064
  }
948
1065
  device.delete();
949
1066
  }
@@ -2557,27 +2674,29 @@
2557
2674
  }
2558
2675
  }
2559
2676
  getCenter() {
2677
+ const handles = this._subject.getSelected();
2678
+ const selectionSet = this._subject.models[0].getSelectionSetByHandles(handles);
2560
2679
  const viewer = this.getViewer();
2561
2680
  let center;
2562
- const pSet = viewer.getSelected();
2563
- if (!pSet.isNull() && pSet.numItems() !== 0) {
2564
- const itr = pSet.getIterator();
2565
- let ext, entId, extSelected;
2566
- for (; !itr.done(); itr.step()) {
2567
- entId = itr.getEntity();
2568
- ext = entId.getWCSExtents();
2681
+ if (selectionSet.numItems() > 0) {
2682
+ let extSelected;
2683
+ const itemItr = selectionSet.getIterator();
2684
+ while (!itemItr.done()) {
2685
+ const entityId = itemItr.getEntity();
2686
+ const entityExt = entityId.getWCSExtents();
2569
2687
  if (extSelected)
2570
- extSelected.addExt(ext);
2688
+ extSelected.addExt(entityExt);
2571
2689
  else
2572
- extSelected = ext;
2690
+ extSelected = entityExt;
2691
+ itemItr.step();
2573
2692
  }
2693
+ itemItr.delete();
2574
2694
  center = extSelected.center();
2575
- extSelected.delete();
2576
- itr.delete();
2577
2695
  }
2578
2696
  else {
2579
2697
  center = viewer.getActiveExtents().center();
2580
2698
  }
2699
+ selectionSet.delete();
2581
2700
  return center;
2582
2701
  }
2583
2702
  getViewer() {
@@ -2756,14 +2875,14 @@
2756
2875
  constructor(subject) {
2757
2876
  super(subject);
2758
2877
  this.wheel = this.wheel.bind(this);
2759
- this.subject.addEventListener("wheel", this.wheel);
2878
+ this.subject.canvas.addEventListener("wheel", this.wheel);
2760
2879
  this._zoomAction = new ZoomAction(this.m_module, this.subject);
2761
2880
  this._endInteractivityTimeOutId = undefined;
2762
2881
  this._isEnableInteractivityMode = false;
2763
2882
  }
2764
2883
  dispose() {
2765
2884
  super.dispose();
2766
- this.subject.removeEventListener("wheel", this.wheel);
2885
+ this.subject.canvas.removeEventListener("wheel", this.wheel);
2767
2886
  if (this._endInteractivityTimeOutId) {
2768
2887
  clearTimeout(this._endInteractivityTimeOutId);
2769
2888
  this.endInteractivity();
@@ -2994,28 +3113,31 @@
2994
3113
  this.endInteractivity();
2995
3114
  }
2996
3115
  getCenter() {
3116
+ const handles = this.subject.getSelected();
3117
+ const selectionSet = this.subject.models[0].getSelectionSetByHandles(handles);
2997
3118
  const viewer = this.getViewer();
2998
3119
  let ext = viewer.getActiveExtents();
2999
- const pSet = viewer.getSelected();
3000
- if (!pSet.isNull() && pSet.numItems() !== 0) {
3001
- const itr = pSet.getIterator();
3002
- const entId = itr.getEntity();
3003
- if (entId.getType() === 1) {
3004
- const obj = entId.openObject();
3120
+ if (selectionSet.numItems() > 0) {
3121
+ const itemItr = selectionSet.getIterator();
3122
+ const entityId = itemItr.getEntity();
3123
+ const type = entityId.getType();
3124
+ if (type === this.m_module.OdTvEntityType.kEntity.value) {
3125
+ const obj = entityId.openObject();
3005
3126
  ext.delete();
3006
3127
  ext = obj.getExtents();
3007
3128
  obj.delete();
3008
3129
  }
3009
- else if (entId.getType() === 2) {
3010
- const obj = entId.openObjectAsInsert();
3130
+ else if (type === this.m_module.OdTvEntityType.kInsert.value) {
3131
+ const obj = entityId.openObjectAsInsert();
3011
3132
  const extTuple = obj.getExtents();
3012
3133
  ext.delete();
3013
3134
  ext = extTuple.ext;
3014
3135
  extTuple.delete();
3015
3136
  obj.delete();
3016
3137
  }
3017
- itr.delete();
3138
+ itemItr.delete();
3018
3139
  }
3140
+ selectionSet.delete();
3019
3141
  const center = ext.center();
3020
3142
  ext.delete();
3021
3143
  return center;
@@ -3198,38 +3320,40 @@
3198
3320
  }
3199
3321
 
3200
3322
  function clearSelected(viewer) {
3201
- if (!viewer.visualizeJs)
3202
- return;
3203
- const visViewer = viewer.visViewer();
3204
- visViewer.unselect();
3323
+ viewer.selector.clearSelected();
3324
+ viewer.emitEvent({ type: "select" });
3325
+ viewer.emitEvent({ type: "select2" });
3205
3326
  viewer.update();
3206
- viewer.emitEvent({ type: "select", handles: [] });
3207
- viewer.emitEvent({ type: "select2", handles: [] });
3208
3327
  }
3209
3328
 
3210
3329
  function clearSlices(viewer) {
3211
3330
  viewer.clearSlices();
3212
3331
  }
3213
3332
 
3214
- function getSnapshot(viewer, type, quality) {
3215
- var _a, _b, _c;
3216
- if (!viewer.visualizeJs)
3217
- return "";
3218
- const mimeType = (_a = type !== null && type !== void 0 ? type : viewer.options.snapshotMimeType) !== null && _a !== void 0 ? _a : "image/jpeg";
3219
- const imageQuality = (_b = quality !== null && quality !== void 0 ? quality : viewer.options.snapshotQuality) !== null && _b !== void 0 ? _b : 0.25;
3220
- if (viewer.markup) {
3221
- return viewer.markup.getSnapshot(mimeType, imageQuality);
3222
- }
3223
- return ((_c = viewer.canvas) === null || _c === void 0 ? void 0 : _c.toDataURL(mimeType, imageQuality)) || "";
3333
+ function toHandles(viewer, handles2) {
3334
+ if (!Array.isArray(handles2))
3335
+ handles2 = [handles2];
3336
+ if (handles2.length === 0)
3337
+ return handles2;
3338
+ if (!handles2[0].includes(":"))
3339
+ return handles2;
3340
+ const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
3341
+ return handles;
3224
3342
  }
3225
3343
 
3226
- function explode(viewer, index = 0) {
3227
- if (!viewer.visualizeJs)
3228
- return;
3229
- const visViewer = viewer.visViewer();
3230
- visViewer.explode(index);
3344
+ function deselect(viewer, handles = []) {
3345
+ handles = toHandles(viewer, handles);
3346
+ viewer.selector.deselect(handles);
3347
+ viewer.emitEvent({ type: "select" });
3348
+ viewer.emitEvent({ type: "select2" });
3349
+ viewer.update();
3350
+ }
3351
+
3352
+ function explode(viewer, scale = 0) {
3353
+ viewer.models.forEach((model) => model.explode(scale));
3354
+ viewer.explodeScale = scale;
3231
3355
  viewer.update();
3232
- viewer.emitEvent({ type: "explode", data: index });
3356
+ viewer.emitEvent({ type: "explode", data: scale });
3233
3357
  }
3234
3358
  function collect(viewer) {
3235
3359
  explode(viewer, 0);
@@ -3243,78 +3367,102 @@
3243
3367
  return Object.keys(defViewPos).filter((x) => x !== "values");
3244
3368
  }
3245
3369
 
3370
+ function toHandles2(viewer, handles) {
3371
+ if (!Array.isArray(handles))
3372
+ handles = [handles];
3373
+ if (handles.length === 0)
3374
+ return handles;
3375
+ if (handles[0].includes(":"))
3376
+ return handles;
3377
+ const model = viewer.models[0];
3378
+ const handles2 = handles.map((handle) => `${model.id}:${handle}`);
3379
+ return handles2;
3380
+ }
3381
+
3382
+ function getHidden(viewer, multimodel = false) {
3383
+ const handles = Array.from(viewer.visibilityManager.hidden);
3384
+ return multimodel ? toHandles2(viewer, handles) : handles;
3385
+ }
3386
+
3387
+ function getIsolated(viewer, multimodel = false) {
3388
+ const handles = Array.from(viewer.visibilityManager.isolated);
3389
+ return multimodel ? toHandles2(viewer, handles) : handles;
3390
+ }
3391
+
3246
3392
  function getModels(viewer) {
3247
- if (!viewer.visualizeJs)
3248
- return [];
3249
3393
  const visViewer = viewer.visViewer();
3250
3394
  const handles = [];
3251
3395
  const modelItr = visViewer.getModelIterator();
3252
- for (; !modelItr.done(); modelItr.step()) {
3396
+ while (!modelItr.done()) {
3253
3397
  const modelPtr = modelItr.getModel();
3254
3398
  if (modelPtr.getName()[0] !== "$")
3255
3399
  handles.push(modelPtr.getDatabaseHandle());
3400
+ modelItr.step();
3256
3401
  }
3257
3402
  modelItr.delete();
3258
3403
  return handles;
3259
3404
  }
3260
3405
 
3261
- function getSelected(viewer) {
3262
- if (!viewer.visualizeJs)
3263
- return [];
3264
- const visViewer = viewer.visViewer();
3265
- const handles = [];
3266
- const selectionSet = visViewer.getSelected();
3267
- if (!selectionSet.isNull() && selectionSet.numItems() !== 0) {
3268
- const itr = selectionSet.getIterator();
3269
- for (; !itr.done(); itr.step()) {
3270
- const entityId = itr.getEntity();
3271
- const entityPtr = entityId.getType() === 1
3272
- ? entityId.openObject()
3273
- : entityId.getType() === 2
3274
- ? entityId.openObjectAsInsert()
3275
- : null;
3276
- if (entityPtr) {
3277
- const handle = entityPtr.getNativeDatabaseHandle();
3278
- if (handle !== "-1")
3279
- handles.push(handle);
3280
- entityPtr.delete();
3281
- }
3282
- }
3283
- itr.delete();
3284
- }
3285
- return handles;
3406
+ function getSelected(viewer, multimodel = false) {
3407
+ const handles = Array.from(viewer.selector.selected);
3408
+ return multimodel ? toHandles2(viewer, handles) : handles;
3286
3409
  }
3287
3410
 
3288
3411
  function getSelected2(viewer) {
3289
- const handles = viewer.executeCommand("getSelected");
3290
- const model = viewer.models[0];
3291
- const handles2 = handles.map((handle) => `${model.id}:${handle}`);
3292
- return handles2;
3412
+ console.warn("getSelected2 command has been deprecated since 27.11 and will be removed in a future release, use getSelected instead");
3413
+ return viewer.executeCommand("getSelected", true);
3293
3414
  }
3294
3415
 
3295
- function hideSelected(viewer) {
3416
+ function getSnapshot(viewer, type, quality) {
3417
+ var _a, _b, _c;
3296
3418
  if (!viewer.visualizeJs)
3297
- return;
3298
- const visViewer = viewer.visViewer();
3299
- visViewer.hideSelectedObjects(false);
3300
- viewer.update();
3419
+ return "";
3420
+ const mimeType = (_a = type !== null && type !== void 0 ? type : viewer.options.snapshotMimeType) !== null && _a !== void 0 ? _a : "image/jpeg";
3421
+ const imageQuality = (_b = quality !== null && quality !== void 0 ? quality : viewer.options.snapshotQuality) !== null && _b !== void 0 ? _b : 0.25;
3422
+ if (viewer.markup) {
3423
+ return viewer.markup.getSnapshot(mimeType, imageQuality);
3424
+ }
3425
+ return ((_c = viewer.canvas) === null || _c === void 0 ? void 0 : _c.toDataURL(mimeType, imageQuality)) || "";
3426
+ }
3427
+
3428
+ function hide(viewer, handles) {
3429
+ handles = toHandles(viewer, handles);
3430
+ viewer.deselect(handles);
3431
+ viewer.visibilityManager.hide(handles);
3301
3432
  viewer.emitEvent({ type: "hide" });
3302
- viewer.emitEvent({ type: "select", handles: [] });
3303
- viewer.emitEvent({ type: "select2", handles: [] });
3433
+ viewer.update();
3304
3434
  }
3305
3435
 
3306
- function isolateSelected(viewer) {
3307
- if (!viewer.visualizeJs)
3308
- return;
3309
- const visViewer = viewer.visViewer();
3310
- visViewer.isolateSelectedObjects(false);
3436
+ function hideAll(viewer) {
3437
+ viewer.clearSelected();
3438
+ viewer.visibilityManager.hideAll();
3439
+ viewer.emitEvent({ type: "hideall" });
3311
3440
  viewer.update();
3441
+ }
3442
+
3443
+ function hideSelected(viewer) {
3444
+ viewer.hide(viewer.getSelected(false));
3445
+ }
3446
+
3447
+ function isolate(viewer, handles) {
3448
+ handles = toHandles(viewer, handles);
3449
+ const handlesSet = new Set(handles);
3450
+ const toDeselect = [];
3451
+ for (const handle of viewer.selector.selected) {
3452
+ if (!handlesSet.has(handle))
3453
+ toDeselect.push(handle);
3454
+ }
3455
+ viewer.deselect(toDeselect);
3456
+ viewer.visibilityManager.isolate(handles);
3312
3457
  viewer.emitEvent({ type: "isolate" });
3458
+ viewer.update();
3459
+ }
3460
+
3461
+ function isolateSelected(viewer) {
3462
+ viewer.isolate(viewer.getSelected(false));
3313
3463
  }
3314
3464
 
3315
3465
  function regenerateAll(viewer) {
3316
- if (!viewer.visualizeJs)
3317
- return;
3318
3466
  const visViewer = viewer.visViewer();
3319
3467
  visViewer.regenAll();
3320
3468
  viewer.update();
@@ -3322,8 +3470,6 @@
3322
3470
  }
3323
3471
 
3324
3472
  function resetView(viewer) {
3325
- if (!viewer.visualizeJs)
3326
- return;
3327
3473
  viewer.executeCommand("setActiveDragger");
3328
3474
  viewer.executeCommand("clearSlices");
3329
3475
  viewer.executeCommand("clearOverlay");
@@ -3331,29 +3477,35 @@
3331
3477
  viewer.executeCommand("clearSelected");
3332
3478
  viewer.executeCommand("showAll");
3333
3479
  viewer.executeCommand("explode", 0);
3334
- viewer.executeCommand("zoomToExtents", true);
3480
+ viewer.executeCommand("zoomExtents");
3335
3481
  viewer.emit({ type: "resetview" });
3336
3482
  }
3337
3483
 
3484
+ function select(viewer, handles = []) {
3485
+ handles = toHandles(viewer, handles);
3486
+ viewer.show(handles);
3487
+ viewer.selector.select(handles);
3488
+ viewer.emitEvent({ type: "select" });
3489
+ viewer.emitEvent({ type: "select2" });
3490
+ viewer.update();
3491
+ }
3492
+
3338
3493
  function selectModel(viewer, handle) {
3339
- if (!viewer.visualizeJs)
3340
- return;
3494
+ let handles = [];
3341
3495
  const visViewer = viewer.visViewer();
3342
- const activeView = visViewer.activeView;
3343
3496
  const modelItr = visViewer.getModelIterator();
3344
- for (; !modelItr.done(); modelItr.step()) {
3345
- const modelPtr = modelItr.getModel();
3346
- if (modelPtr.getDatabaseHandle() === handle) {
3347
- const selectionSet = activeView.selectCrossing([0, 9999, 9999, 0], modelPtr);
3348
- visViewer.setSelected(selectionSet);
3349
- viewer.update();
3350
- viewer.emitEvent({ type: "select", handles: viewer.getSelected() });
3351
- viewer.emitEvent({ type: "select2", handles: viewer.getSelected2() });
3352
- selectionSet.delete();
3497
+ while (!modelItr.done()) {
3498
+ const model = modelItr.getModel();
3499
+ if (model.getDatabaseHandle() === handle) {
3500
+ const entityItr = model.getEntitiesIterator();
3501
+ handles = viewer.models[0].getHandlesByEntityIterator(entityItr);
3502
+ entityItr.delete();
3353
3503
  break;
3354
3504
  }
3505
+ modelItr.step();
3355
3506
  }
3356
3507
  modelItr.delete();
3508
+ viewer.setSelected(handles);
3357
3509
  }
3358
3510
 
3359
3511
  function setActiveDragger(viewer, dragger = "") {
@@ -3375,94 +3527,74 @@
3375
3527
  viewer.markup.setMarkupColor(r, g, b);
3376
3528
  }
3377
3529
 
3378
- function setSelected(viewer, handles2 = []) {
3379
- if (!viewer.visualizeJs)
3380
- return;
3381
- const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
3382
- const visLib = viewer.visLib();
3383
- const visViewer = viewer.visViewer();
3384
- const selectionSet = new visLib.OdTvSelectionSet();
3385
- handles.forEach((handle) => {
3386
- const entityId = visViewer.getEntityByOriginalHandle(handle + "");
3387
- if (!entityId.isNull())
3388
- selectionSet.appendEntity(entityId);
3389
- });
3390
- visViewer.setSelected(selectionSet);
3530
+ function setSelected(viewer, handles = []) {
3531
+ handles = toHandles(viewer, handles);
3532
+ viewer.show(handles);
3533
+ viewer.selector.setSelected(handles);
3534
+ viewer.emitEvent({ type: "select" });
3535
+ viewer.emitEvent({ type: "select2" });
3391
3536
  viewer.update();
3392
- viewer.emitEvent({ type: "select", data: selectionSet, handles });
3393
- viewer.emitEvent({ type: "select2", data: selectionSet, handles: handles2 });
3394
- selectionSet.delete();
3395
3537
  }
3396
3538
 
3397
3539
  function setSelected2(viewer, handles2 = []) {
3398
- const handles = [];
3399
- handles2.forEach((handle) => {
3400
- if (!handle.includes(":")) {
3401
- handles.push(handle);
3402
- }
3403
- else
3404
- viewer.models.forEach((model) => {
3405
- if (handle.split(":", 1)[0] === model.id + "")
3406
- handles.push(handle);
3407
- });
3408
- });
3409
- return viewer.executeCommand("setSelected", handles);
3540
+ console.warn("setSelected2 command has been deprecated since 27.11 and will be removed in a future release, use setSelected instead");
3541
+ return viewer.executeCommand("setSelected", handles2);
3410
3542
  }
3411
3543
 
3412
- function showAll(viewer) {
3413
- if (!viewer.visualizeJs)
3414
- return;
3415
- const visViewer = viewer.visViewer();
3416
- visViewer.unisolateSelectedObjects(false);
3544
+ function show(viewer, handles) {
3545
+ handles = toHandles(viewer, handles);
3546
+ viewer.visibilityManager.show(handles);
3547
+ viewer.emitEvent({ type: "show" });
3417
3548
  viewer.update();
3549
+ }
3550
+
3551
+ function showAll(viewer) {
3552
+ viewer.visibilityManager.showAll();
3418
3553
  viewer.emitEvent({ type: "showall" });
3554
+ viewer.update();
3419
3555
  }
3420
3556
 
3421
- function zoomToExtents(viewer, force = false, animate = viewer.options.cameraAnimation) {
3422
- if (!viewer.visualizeJs)
3423
- return;
3424
- const visViewer = viewer.visViewer();
3425
- const saveEnableAmination = visViewer.getEnableAnimation();
3426
- visViewer.setEnableAnimation(animate);
3427
- visViewer.zoomExtents(force);
3428
- visViewer.update();
3429
- visViewer.setEnableAnimation(saveEnableAmination);
3430
- viewer.deviceAutoRegeneration();
3557
+ function toggleSelection(viewer, handles = []) {
3558
+ handles = toHandles(viewer, handles);
3559
+ if (viewer.selector.selected.has(handles[0])) {
3560
+ viewer.selector.deselect(handles);
3561
+ }
3562
+ else {
3563
+ viewer.show(handles);
3564
+ viewer.selector.select(handles);
3565
+ }
3566
+ viewer.emitEvent({ type: "select" });
3567
+ viewer.emitEvent({ type: "select2" });
3431
3568
  viewer.update();
3432
- viewer.emitEvent({ type: "zoom" });
3433
3569
  }
3434
3570
 
3435
- function zoomToObjects(viewer, handles = []) {
3436
- var _a;
3437
- if (!viewer.visualizeJs)
3438
- return;
3439
- const visLib = viewer.visLib();
3571
+ function zoomExtents(viewer) {
3440
3572
  const visViewer = viewer.visViewer();
3441
- const selectionSet = new visLib.OdTvSelectionSet();
3442
- handles.forEach((handle) => {
3443
- const entityId = visViewer.getEntityByOriginalHandle(handle + "");
3444
- if (!entityId.isNull())
3445
- selectionSet.appendEntity(entityId);
3446
- });
3447
- (_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
3573
+ visViewer.zoomExtents(true);
3448
3574
  viewer.deviceAutoRegeneration();
3449
3575
  viewer.update();
3450
3576
  viewer.emitEvent({ type: "zoom" });
3451
- selectionSet.delete();
3452
3577
  }
3453
3578
 
3454
- function zoomToSelected(viewer) {
3579
+ function zoomTo(viewer, handles = []) {
3455
3580
  var _a;
3456
- if (!viewer.visualizeJs)
3457
- return;
3581
+ handles = toHandles(viewer, handles);
3458
3582
  const visViewer = viewer.visViewer();
3459
- const selectionSet = visViewer.getSelected();
3460
- (_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
3583
+ const selectionSet = viewer.models[0].getSelectionSetByHandles(handles);
3584
+ if (selectionSet.numItems() > 0)
3585
+ (_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
3586
+ else
3587
+ visViewer.zoomExtents(false);
3588
+ selectionSet.delete();
3461
3589
  viewer.deviceAutoRegeneration();
3462
3590
  viewer.update();
3463
3591
  viewer.emitEvent({ type: "zoom" });
3464
3592
  }
3465
3593
 
3594
+ function zoomToSelected(viewer) {
3595
+ zoomTo(viewer, viewer.getSelected(false));
3596
+ }
3597
+
3466
3598
  function isTemplateModel(modelPtr) {
3467
3599
  return modelPtr.getName()[0] === "$";
3468
3600
  }
@@ -3525,26 +3657,35 @@
3525
3657
  commands.registerCommand("clearMarkup", clearMarkup);
3526
3658
  commands.registerCommand("clearSelected", clearSelected);
3527
3659
  commands.registerCommand("clearSlices", clearSlices);
3528
- commands.registerCommand("getSnapshot", getSnapshot);
3529
- commands.registerCommand("explode", explode);
3530
3660
  commands.registerCommand("collect", collect);
3661
+ commands.registerCommand("deselect", deselect);
3662
+ commands.registerCommand("explode", explode);
3663
+ commands.registerCommand("getSnapshot", getSnapshot);
3531
3664
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
3665
+ commands.registerCommand("getHidden", getHidden);
3666
+ commands.registerCommand("getIsolated", getIsolated);
3532
3667
  commands.registerCommand("getModels", getModels);
3533
3668
  commands.registerCommand("getSelected", getSelected);
3534
3669
  commands.registerCommand("getSelected2", getSelected2);
3670
+ commands.registerCommand("hide", hide);
3671
+ commands.registerCommand("hideAll", hideAll);
3535
3672
  commands.registerCommand("hideSelected", hideSelected);
3673
+ commands.registerCommand("isolate", isolate);
3536
3674
  commands.registerCommand("isolateSelected", isolateSelected);
3537
3675
  commands.registerCommand("regenerateAll", regenerateAll);
3538
3676
  commands.registerCommand("resetView", resetView);
3677
+ commands.registerCommand("select", select);
3539
3678
  commands.registerCommand("selectModel", selectModel);
3540
3679
  commands.registerCommand("setActiveDragger", setActiveDragger);
3541
3680
  commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
3542
3681
  commands.registerCommand("setMarkupColor", setMarkupColor);
3543
3682
  commands.registerCommand("setSelected", setSelected);
3544
3683
  commands.registerCommand("setSelected2", setSelected2);
3684
+ commands.registerCommand("show", show);
3545
3685
  commands.registerCommand("showAll", showAll);
3546
- commands.registerCommand("zoomToExtents", zoomToExtents);
3547
- commands.registerCommand("zoomToObjects", zoomToObjects);
3686
+ commands.registerCommand("toggleSelection", toggleSelection);
3687
+ commands.registerCommand("zoomExtents", zoomExtents);
3688
+ commands.registerCommand("zoomTo", zoomTo);
3548
3689
  commands.registerCommand("zoomToSelected", zoomToSelected);
3549
3690
  commands.registerCommand("autoTransformAllModelsToCentralPoint", autoTransformAllModelsToCentralPoint);
3550
3691
  commands.registerCommand("top", (viewer) => setDefaultViewPosition(viewer, "k3DViewTop"));
@@ -3560,7 +3701,8 @@
3560
3701
  commands.registerCommandAlias("clearMarkup", "clearOverlay");
3561
3702
  commands.registerCommandAlias("clearSelected", "unselect");
3562
3703
  commands.registerCommandAlias("getSnapshot", "createPreview");
3563
- commands.registerCommandAlias("zoomToExtents", "zoomExtents");
3704
+ commands.registerCommandAlias("zoomExtents", "zoomToExtents");
3705
+ commands.registerCommandAlias("zoomTo", "zoomToObjects");
3564
3706
  commands.registerCommandAlias("top", "k3DViewTop");
3565
3707
  commands.registerCommandAlias("bottom", "k3DViewBottom");
3566
3708
  commands.registerCommandAlias("left", "k3DViewLeft");
@@ -4024,10 +4166,120 @@
4024
4166
  components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));
4025
4167
 
4026
4168
  class ModelImpl {
4027
- constructor() {
4169
+ constructor(visualizeJs) {
4028
4170
  this.id = "";
4171
+ this.id = "";
4172
+ this.visualizeJs = visualizeJs;
4029
4173
  }
4030
4174
  dispose() { }
4175
+ initialize() {
4176
+ }
4177
+ getHandlesByEntityIterator(iterator) {
4178
+ const handles2 = [];
4179
+ while (!iterator.done()) {
4180
+ const entityId = iterator.getEntity();
4181
+ const entityType = entityId.getType();
4182
+ let entityPtr = null;
4183
+ if (entityType === this.visualizeJs.OdTvEntityType.kEntity.value)
4184
+ entityPtr = entityId.openObject();
4185
+ if (entityType === this.visualizeJs.OdTvEntityType.kInsert.value)
4186
+ entityPtr = entityId.openObjectAsInsert();
4187
+ if (entityPtr) {
4188
+ const handle = entityPtr.getNativeDatabaseHandle();
4189
+ if (handle !== "-1")
4190
+ handles2.push(handle);
4191
+ entityPtr.delete();
4192
+ }
4193
+ iterator.step();
4194
+ }
4195
+ return handles2;
4196
+ }
4197
+ getHandlesBySelectionSet(selectionSet) {
4198
+ const iterator = selectionSet.getIterator();
4199
+ const handles = this.getHandlesByEntityIterator(iterator);
4200
+ iterator.delete();
4201
+ return handles;
4202
+ }
4203
+ getSelectionSetByHandles(handles) {
4204
+ const viewer = this.visualizeJs.getViewer();
4205
+ const selectionSet = viewer.getEntitySetByOriginalHandles(handles);
4206
+ return selectionSet;
4207
+ }
4208
+ hide(handles) {
4209
+ const viewer = this.visualizeJs.getViewer();
4210
+ const model = viewer.getActiveModel();
4211
+ const selectionSet = this.getSelectionSetByHandles(handles);
4212
+ model.hideBySelectionSet(selectionSet, false);
4213
+ selectionSet.delete();
4214
+ return this;
4215
+ }
4216
+ hideAll() {
4217
+ const viewer = this.visualizeJs.getViewer();
4218
+ const model = viewer.getActiveModel();
4219
+ const selectionSet = new this.visualizeJs.OdTvSelectionSet();
4220
+ const entityItr = model.getEntitiesIterator();
4221
+ while (!entityItr.done()) {
4222
+ const entityId = entityItr.getEntity();
4223
+ const entityType = entityId.getType();
4224
+ const isEntity = entityType === this.visualizeJs.OdTvEntityType.kEntity.value;
4225
+ const isInsert = entityType === this.visualizeJs.OdTvEntityType.kInsert.value;
4226
+ if (isEntity || isInsert)
4227
+ selectionSet.appendEntity(entityId);
4228
+ entityItr.step();
4229
+ }
4230
+ entityItr.delete();
4231
+ model.hideBySelectionSet(selectionSet, false);
4232
+ selectionSet.delete();
4233
+ return this;
4234
+ }
4235
+ isolate(handles) {
4236
+ if (handles.length > 0) {
4237
+ const viewer = this.visualizeJs.getViewer();
4238
+ const model = viewer.getActiveModel();
4239
+ const selectionSet = this.getSelectionSetByHandles(handles);
4240
+ model.isolateBySelectionSet(selectionSet, false);
4241
+ selectionSet.delete();
4242
+ }
4243
+ else {
4244
+ this.hideAll();
4245
+ }
4246
+ return this;
4247
+ }
4248
+ show(handles) {
4249
+ const viewer = this.visualizeJs.getViewer();
4250
+ const model = viewer.getActiveModel();
4251
+ const selectionSet = this.getSelectionSetByHandles(handles);
4252
+ model.unHideBySelectionSet(selectionSet, true, false);
4253
+ selectionSet.delete();
4254
+ return this;
4255
+ }
4256
+ showAll() {
4257
+ const viewer = this.visualizeJs.getViewer();
4258
+ const model = viewer.getActiveModel();
4259
+ model.unIsolate(false);
4260
+ return this;
4261
+ }
4262
+ highlight(handles) {
4263
+ const viewer = this.visualizeJs.getViewer();
4264
+ const view = viewer.activeView;
4265
+ const selectionSet = this.getSelectionSetByHandles(handles);
4266
+ view.highlightAll(selectionSet, true);
4267
+ selectionSet.delete();
4268
+ return this;
4269
+ }
4270
+ unhighlight(handles) {
4271
+ const viewer = this.visualizeJs.getViewer();
4272
+ const view = viewer.activeView;
4273
+ const selectionSet = this.getSelectionSetByHandles(handles);
4274
+ view.highlightAll(selectionSet, false);
4275
+ selectionSet.delete();
4276
+ return this;
4277
+ }
4278
+ explode(scale, coeff = 4) {
4279
+ const viewer = this.visualizeJs.getViewer();
4280
+ viewer.explode(scale);
4281
+ return this;
4282
+ }
4031
4283
  }
4032
4284
 
4033
4285
  class FileLoader {
@@ -4139,8 +4391,9 @@
4139
4391
  console.error("VSF parse error.", error);
4140
4392
  throw error;
4141
4393
  }
4142
- const modelImpl = new ModelImpl();
4394
+ const modelImpl = new ModelImpl(this.viewer.visualizeJs);
4143
4395
  modelImpl.id = params.modelId || this.extractFileName(file);
4396
+ modelImpl.initialize();
4144
4397
  this.viewer.models.push(modelImpl);
4145
4398
  this.viewer.syncOptions();
4146
4399
  this.viewer.syncOverlay();
@@ -4161,7 +4414,7 @@
4161
4414
  typeof file.downloadResource === "function" &&
4162
4415
  /.data$/i.test(file.database));
4163
4416
  }
4164
- async load(model, format) {
4417
+ async load(model, format, params = {}) {
4165
4418
  if (!this.viewer.visualizeJs)
4166
4419
  return this;
4167
4420
  const visViewer = this.viewer.visViewer();
@@ -4184,8 +4437,9 @@
4184
4437
  throw error;
4185
4438
  }
4186
4439
  if (i === 0) {
4187
- const modelImpl = new ModelImpl();
4188
- modelImpl.id = model.file.id;
4440
+ const modelImpl = new ModelImpl(this.viewer.visualizeJs);
4441
+ modelImpl.id = params.modelId || model.file.id;
4442
+ modelImpl.initialize();
4189
4443
  this.viewer.models.push(modelImpl);
4190
4444
  this.viewer.syncOptions();
4191
4445
  this.viewer.syncOverlay();
@@ -4234,8 +4488,9 @@
4234
4488
  console.error("VSFX parse error.", error);
4235
4489
  throw error;
4236
4490
  }
4237
- const modelImpl = new ModelImpl();
4491
+ const modelImpl = new ModelImpl(this.viewer.visualizeJs);
4238
4492
  modelImpl.id = params.modelId || this.extractFileName(file);
4493
+ modelImpl.initialize();
4239
4494
  this.viewer.models.push(modelImpl);
4240
4495
  this.viewer.syncOptions();
4241
4496
  this.viewer.syncOverlay();
@@ -4257,7 +4512,7 @@
4257
4512
  /.vsfx$/i.test(file.database) &&
4258
4513
  this.viewer.options.enableStreamingMode === false);
4259
4514
  }
4260
- async load(model) {
4515
+ async load(model, format, params = {}) {
4261
4516
  if (!this.viewer.visualizeJs)
4262
4517
  return Promise.resolve(this);
4263
4518
  const visViewer = this.viewer.visViewer();
@@ -4275,8 +4530,9 @@
4275
4530
  console.error("VSFX parse error.", error);
4276
4531
  throw error;
4277
4532
  }
4278
- const modelImpl = new ModelImpl();
4279
- modelImpl.id = model.file.id;
4533
+ const modelImpl = new ModelImpl(this.viewer.visualizeJs);
4534
+ modelImpl.id = params.modelId || model.file.id;
4535
+ modelImpl.initialize();
4280
4536
  this.viewer.models.push(modelImpl);
4281
4537
  this.viewer.syncOptions();
4282
4538
  this.viewer.syncOverlay();
@@ -4300,7 +4556,7 @@
4300
4556
  this.viewer.options.enablePartialMode === false &&
4301
4557
  !/.rcs$/i.test(file.type));
4302
4558
  }
4303
- async load(model) {
4559
+ async load(model, format, params = {}) {
4304
4560
  if (!this.viewer.visualizeJs)
4305
4561
  return this;
4306
4562
  const visLib = this.viewer.visLib();
@@ -4325,8 +4581,9 @@
4325
4581
  isDatabaseChunk = true;
4326
4582
  }
4327
4583
  if (isDatabaseChunk) {
4328
- const modelImpl = new ModelImpl();
4329
- modelImpl.id = model.file.id;
4584
+ const modelImpl = new ModelImpl(this.viewer.visualizeJs);
4585
+ modelImpl.id = params.modelId || model.file.id;
4586
+ modelImpl.initialize();
4330
4587
  this.viewer.models.push(modelImpl);
4331
4588
  this.viewer.syncOptions();
4332
4589
  this.viewer.syncOverlay();
@@ -4359,7 +4616,7 @@
4359
4616
  /.vsfx$/i.test(file.database) &&
4360
4617
  (this.viewer.options.enablePartialMode === true || /.rcs$/i.test(file.type)));
4361
4618
  }
4362
- async load(model) {
4619
+ async load(model, format, params = {}) {
4363
4620
  if (!this.viewer.visualizeJs)
4364
4621
  return this;
4365
4622
  const visViewer = this.viewer.visViewer();
@@ -4383,8 +4640,9 @@
4383
4640
  }
4384
4641
  this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
4385
4642
  if (isDatabaseChunk) {
4386
- const modelImpl = new ModelImpl();
4387
- modelImpl.id = model.file.id;
4643
+ const modelImpl = new ModelImpl(this.viewer.visualizeJs);
4644
+ modelImpl.id = params.modelId || model.file.id;
4645
+ modelImpl.initialize();
4388
4646
  this.viewer.models.push(modelImpl);
4389
4647
  this.viewer.syncOptions();
4390
4648
  this.viewer.syncOverlay();
@@ -18486,9 +18744,12 @@ js: import "konva/skia-backend";
18486
18744
  this.info = new Info();
18487
18745
  this.canvasEvents = CANVAS_EVENTS.slice();
18488
18746
  this.canvaseventlistener = (event) => this.emit(event);
18747
+ this.selector = new Selector(this.models);
18748
+ this.visibilityManager = new VisibilityManager(this.models);
18749
+ this.explodeScale = 0;
18489
18750
  this._visualizeTimestamp = 0;
18490
18751
  this._activeDragger = null;
18491
- this._components = [];
18752
+ this._components = new Map();
18492
18753
  this._renderNeeded = false;
18493
18754
  this._renderTime = 0;
18494
18755
  this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
@@ -18513,7 +18774,7 @@ js: import "konva/skia-backend";
18513
18774
  return this._markup;
18514
18775
  }
18515
18776
  configure(params) {
18516
- this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/27.9/Visualize.js";
18777
+ this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js";
18517
18778
  this._crossOrigin = params.crossOrigin;
18518
18779
  return this;
18519
18780
  }
@@ -18555,7 +18816,7 @@ js: import "konva/skia-backend";
18555
18816
  for (const name of components.getComponents().keys()) {
18556
18817
  const component = components.createComponent(name, this);
18557
18818
  if (component)
18558
- this._components.push(component);
18819
+ this._components.set(name, component);
18559
18820
  }
18560
18821
  this.syncOptions();
18561
18822
  this.syncOverlay();
@@ -18571,7 +18832,7 @@ js: import "konva/skia-backend";
18571
18832
  this.removeAllListeners();
18572
18833
  this.setActiveDragger();
18573
18834
  this._components.forEach((component) => component.dispose());
18574
- this._components.length = 0;
18835
+ this._components.clear();
18575
18836
  this._markup.dispose();
18576
18837
  if (this.canvas) {
18577
18838
  this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
@@ -18602,8 +18863,8 @@ js: import "konva/skia-backend";
18602
18863
  }
18603
18864
  update(force = false) {
18604
18865
  const time = performance.now();
18605
- if (typeof force === "number" && time - this._renderTime >= force)
18606
- force = true;
18866
+ if (typeof force === "number")
18867
+ force = time - this._renderTime >= force;
18607
18868
  if (this._enableAutoUpdate) {
18608
18869
  this._renderNeeded = true;
18609
18870
  if (force)
@@ -18892,30 +19153,66 @@ js: import "konva/skia-backend";
18892
19153
  this.emitEvent({ type: "clearslices" });
18893
19154
  this.update();
18894
19155
  }
18895
- getSelected() {
18896
- return this.executeCommand("getSelected");
18897
- }
18898
- setSelected(handles) {
18899
- this.executeCommand("setSelected", handles);
19156
+ getSelected(multimodel) {
19157
+ return this.executeCommand("getSelected", multimodel);
18900
19158
  }
18901
19159
  getSelected2() {
18902
19160
  return this.executeCommand("getSelected2");
18903
19161
  }
19162
+ setSelected(handles) {
19163
+ this.executeCommand("setSelected", handles);
19164
+ }
18904
19165
  setSelected2(handles) {
18905
19166
  this.executeCommand("setSelected2", handles);
18906
19167
  }
19168
+ select(handles) {
19169
+ this.executeCommand("select", handles);
19170
+ }
19171
+ deselect(handles) {
19172
+ this.executeCommand("deselect", handles);
19173
+ }
19174
+ toggleSelection(handles) {
19175
+ this.executeCommand("toggleSelection", handles);
19176
+ }
18907
19177
  clearSelected() {
18908
19178
  this.executeCommand("clearSelected");
18909
19179
  }
19180
+ getHidden(multimodel) {
19181
+ return this.executeCommand("getHidden", multimodel);
19182
+ }
19183
+ getIsolated(multimodel) {
19184
+ return this.executeCommand("getIsolated", multimodel);
19185
+ }
19186
+ hide(handle) {
19187
+ this.executeCommand("hide", handle);
19188
+ }
19189
+ hideAll() {
19190
+ this.executeCommand("hideAll");
19191
+ }
18910
19192
  hideSelected() {
18911
19193
  this.executeCommand("hideSelected");
18912
19194
  }
19195
+ isolate(handle) {
19196
+ this.executeCommand("isolate", handle);
19197
+ }
18913
19198
  isolateSelected() {
18914
19199
  this.executeCommand("isolateSelected");
18915
19200
  }
19201
+ show(handle) {
19202
+ this.executeCommand("show", handle);
19203
+ }
18916
19204
  showAll() {
18917
19205
  this.executeCommand("showAll");
18918
19206
  }
19207
+ zoomExtents() {
19208
+ this.executeCommand("zoomExtents");
19209
+ }
19210
+ zoomTo(handles) {
19211
+ this.executeCommand("zoomTo", handles);
19212
+ }
19213
+ zoomToSelected() {
19214
+ this.executeCommand("zoomToSelected");
19215
+ }
18919
19216
  explode(index = 0) {
18920
19217
  this.executeCommand("explode", index);
18921
19218
  }
@@ -18957,10 +19254,10 @@ js: import "konva/skia-backend";
18957
19254
  }
18958
19255
  }
18959
19256
  getComponent(name) {
18960
- return this._components.find((component) => component.name === name) || null;
19257
+ return this._components.get(name) || null;
18961
19258
  }
18962
19259
  drawViewpoint(viewpoint) {
18963
- var _a, _b;
19260
+ var _a, _b, _c, _d;
18964
19261
  if (!this.visualizeJs)
18965
19262
  return;
18966
19263
  const visViewer = this.visViewer();
@@ -19004,8 +19301,22 @@ js: import "konva/skia-backend";
19004
19301
  }
19005
19302
  };
19006
19303
  const setSelection = (selection) => {
19007
- if (selection)
19008
- this.setSelected(selection.map((component) => component.handle));
19304
+ if (selection) {
19305
+ this.setSelected(selection.map(({ handle }) => handle));
19306
+ }
19307
+ };
19308
+ const setVisibility = (visibility) => {
19309
+ if (visibility && visibility.exceptions)
19310
+ if (visibility.default_visibility) {
19311
+ this.hide(visibility.exceptions.map(({ handle }) => handle));
19312
+ }
19313
+ else {
19314
+ this.isolate(visibility.exceptions.map(({ handle }) => handle));
19315
+ }
19316
+ };
19317
+ const setExplodeScale = (scale) => {
19318
+ if (scale > 0)
19319
+ this.explode(scale);
19009
19320
  };
19010
19321
  const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
19011
19322
  this.setActiveDragger();
@@ -19017,7 +19328,9 @@ js: import "konva/skia-backend";
19017
19328
  setOrthogonalCamera(viewpoint.orthogonal_camera);
19018
19329
  setPerspectiveCamera(viewpoint.perspective_camera);
19019
19330
  setClippingPlanes(viewpoint.clipping_planes);
19020
- setSelection(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.selection2) || viewpoint.selection);
19331
+ setVisibility(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.visibility2) || viewpoint.visibility);
19332
+ setSelection(((_c = viewpoint.custom_fields) === null || _c === void 0 ? void 0 : _c.selection2) || viewpoint.selection);
19333
+ setExplodeScale((_d = viewpoint.custom_fields) === null || _d === void 0 ? void 0 : _d.explodeScale);
19021
19334
  this._markup.setViewpoint(viewpoint);
19022
19335
  this.syncOverlay();
19023
19336
  this.setActiveDragger(draggerName);
@@ -19078,20 +19391,42 @@ js: import "konva/skia-backend";
19078
19391
  return clipping_planes;
19079
19392
  };
19080
19393
  const getSelection = () => {
19081
- return this.getSelected().map((handle) => ({ handle }));
19394
+ const selected = Array.from(this.selector.selected);
19395
+ return selected.map((handle) => ({ handle }));
19082
19396
  };
19083
19397
  const getSelection2 = () => {
19084
- return this.getSelected2().map((handle) => ({ handle }));
19398
+ const selected = Array.from(this.selector.selected);
19399
+ const selected2 = toHandles2(this, selected);
19400
+ return selected2.map((handle) => ({ handle }));
19401
+ };
19402
+ const getVisibility = () => {
19403
+ const exceptions = Array.from(this.visibilityManager.exceptions);
19404
+ return {
19405
+ default_visibility: this.visibilityManager.defaultVisible,
19406
+ exceptions: exceptions.map((handle) => ({ handle })),
19407
+ };
19408
+ };
19409
+ const getVisibility2 = () => {
19410
+ const exceptions = Array.from(this.visibilityManager.exceptions);
19411
+ const exceptions2 = toHandles2(this, exceptions);
19412
+ return {
19413
+ default_visibility: this.visibilityManager.defaultVisible,
19414
+ exceptions: exceptions2.map((handle) => ({ handle })),
19415
+ };
19085
19416
  };
19086
19417
  const viewpoint = { custom_fields: {} };
19087
19418
  viewpoint.orthogonal_camera = getOrthogonalCamera();
19088
19419
  viewpoint.perspective_camera = getPerspectiveCamera();
19089
19420
  viewpoint.clipping_planes = getClippingPlanes();
19090
19421
  viewpoint.selection = getSelection();
19422
+ viewpoint.visibility = getVisibility();
19091
19423
  viewpoint.description = new Date().toDateString();
19092
19424
  viewpoint.snapshot = { data: this.getSnapshot() };
19093
- this._markup.getViewpoint(viewpoint);
19094
19425
  viewpoint.custom_fields.selection2 = getSelection2();
19426
+ viewpoint.custom_fields.visibility2 = getVisibility2();
19427
+ viewpoint.custom_fields.explodeScale = this.explodeScale;
19428
+ viewpoint.custom_fields.files = this.models.map((model) => model.id);
19429
+ this._markup.getViewpoint(viewpoint);
19095
19430
  this.emitEvent({ type: "createviewpoint", data: viewpoint });
19096
19431
  return viewpoint;
19097
19432
  }
@@ -19202,7 +19537,9 @@ js: import "konva/skia-backend";
19202
19537
  exports.Markup = KonvaMarkup;
19203
19538
  exports.OdBaseDragger = OdBaseDragger;
19204
19539
  exports.Options = Options;
19540
+ exports.Selector = Selector;
19205
19541
  exports.Viewer = Viewer;
19542
+ exports.VisibilityManager = VisibilityManager;
19206
19543
  exports.commands = commands;
19207
19544
  exports.commandsRegistry = commandsRegistry;
19208
19545
  exports.components = components;