@inweb/viewer-visualize 26.10.6 → 26.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/viewer-visualize.js +470 -422
  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 +462 -422
  5. package/dist/viewer-visualize.module.js.map +1 -1
  6. package/lib/Viewer/Commands/GetSelected2.d.ts +2 -0
  7. package/lib/Viewer/Commands/SetSelected.d.ts +1 -1
  8. package/lib/Viewer/Commands/SetSelected2.d.ts +2 -0
  9. package/lib/Viewer/Components/index.d.ts +8 -7
  10. package/lib/Viewer/Loaders/VSFXCloudLoader.d.ts +1 -1
  11. package/lib/Viewer/Loaders/VSFXCloudPartialLoader.d.ts +1 -1
  12. package/lib/Viewer/Loaders/index.d.ts +14 -9
  13. package/lib/Viewer/Models/IModelImpl.d.ts +5 -0
  14. package/lib/Viewer/Models/ModelImpl.d.ts +5 -0
  15. package/lib/Viewer/Viewer.d.ts +129 -136
  16. package/package.json +6 -6
  17. package/src/Viewer/Commands/ClearSelected.ts +3 -1
  18. package/src/Viewer/Commands/GetSelected2.ts +33 -0
  19. package/src/Viewer/Commands/HideSelected.ts +3 -1
  20. package/src/Viewer/Commands/SelectModel.ts +2 -3
  21. package/src/Viewer/Commands/SetSelected.ts +5 -2
  22. package/src/Viewer/Commands/SetSelected2.ts +39 -0
  23. package/src/Viewer/Commands/index.ts +4 -0
  24. package/src/Viewer/Components/index.ts +8 -7
  25. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +3 -2
  26. package/src/Viewer/Draggers/OdJoyStickDragger.ts +2 -2
  27. package/src/Viewer/Loaders/VSFCloudLoader.ts +6 -0
  28. package/src/Viewer/Loaders/VSFFileLoader.ts +7 -1
  29. package/src/Viewer/Loaders/VSFXCloudLoader.ts +7 -1
  30. package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +8 -2
  31. package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +7 -1
  32. package/src/Viewer/Loaders/VSFXFileLoader.ts +7 -1
  33. package/src/Viewer/Loaders/index.ts +14 -9
  34. package/src/Viewer/Models/IModelImpl.ts +29 -0
  35. package/src/Viewer/Models/ModelImpl.ts +32 -0
  36. package/src/Viewer/Viewer.ts +780 -775
@@ -171,6 +171,14 @@
171
171
  cancel() {
172
172
  this.abortController.abort();
173
173
  }
174
+ extractFileName(file) {
175
+ const regex = /[^/\\?#:]+(?=\?|#|$)/;
176
+ if (typeof file === "string")
177
+ return (file.match(regex) || [])[0];
178
+ else if (file instanceof globalThis.File)
179
+ return (file.name.match(regex) || [])[0];
180
+ return undefined;
181
+ }
174
182
  }
175
183
  class Loaders {
176
184
  constructor() {
@@ -707,8 +715,8 @@
707
715
  viewer.select(x, y, x, y);
708
716
  this.subject.update();
709
717
  const selectionSet = viewer.getSelected();
710
- const handles = this.subject.getSelected();
711
- this.onmessage({ type: "select", data: selectionSet, handles });
718
+ this.onmessage({ type: "select", data: selectionSet, handles: this.subject.getSelected() });
719
+ this.onmessage({ type: "select2", data: selectionSet, handles: this.subject.getSelected2() });
712
720
  }
713
721
  }
714
722
  dblclick(ev) {
@@ -1313,7 +1321,7 @@
1313
1321
  callback({
1314
1322
  x: 100 * ((movedX - centerX) / maxMoveStick),
1315
1323
  y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
1316
- global: global,
1324
+ global,
1317
1325
  });
1318
1326
  }
1319
1327
  };
@@ -1328,7 +1336,7 @@
1328
1336
  callback({
1329
1337
  x: 100 * ((movedX - centerX) / maxMoveStick),
1330
1338
  y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
1331
- global: global,
1339
+ global,
1332
1340
  });
1333
1341
  };
1334
1342
  this.drawExternal = () => {
@@ -2819,7 +2827,8 @@
2819
2827
  const visViewer = viewer.visViewer();
2820
2828
  visViewer.unselect();
2821
2829
  viewer.update();
2822
- viewer.emitEvent({ type: "select", data: undefined, handles: [] });
2830
+ viewer.emitEvent({ type: "select", handles: [] });
2831
+ viewer.emitEvent({ type: "select2", handles: [] });
2823
2832
  }
2824
2833
 
2825
2834
  function clearSlices(viewer) {
@@ -2895,6 +2904,13 @@
2895
2904
  return handles;
2896
2905
  }
2897
2906
 
2907
+ function getSelected2(viewer) {
2908
+ const handles = viewer.executeCommand("getSelected");
2909
+ const model = viewer.models[0];
2910
+ const handles2 = handles.map((handle) => `${model.id}:${handle}`);
2911
+ return handles2;
2912
+ }
2913
+
2898
2914
  function hideSelected(viewer) {
2899
2915
  if (!viewer.visualizeJs)
2900
2916
  return;
@@ -2902,7 +2918,8 @@
2902
2918
  visViewer.hideSelectedObjects(false);
2903
2919
  viewer.update();
2904
2920
  viewer.emitEvent({ type: "hide" });
2905
- viewer.emitEvent({ type: "select", data: undefined, handles: [] });
2921
+ viewer.emitEvent({ type: "select", handles: [] });
2922
+ viewer.emitEvent({ type: "select2", handles: [] });
2906
2923
  }
2907
2924
 
2908
2925
  function isolateSelected(viewer) {
@@ -2950,9 +2967,9 @@
2950
2967
  if (modelPtr.getDatabaseHandle() === handle) {
2951
2968
  const selectionSet = activeView.selectCrossing([0, 9999, 9999, 0], modelPtr);
2952
2969
  visViewer.setSelected(selectionSet);
2953
- const handles = viewer.getSelected();
2954
2970
  viewer.update();
2955
- viewer.emitEvent({ type: "select", data: selectionSet, handles });
2971
+ viewer.emitEvent({ type: "select", handles: viewer.getSelected() });
2972
+ viewer.emitEvent({ type: "select2", handles: viewer.getSelected2() });
2956
2973
  selectionSet.delete();
2957
2974
  break;
2958
2975
  }
@@ -2979,13 +2996,14 @@
2979
2996
  viewer.markup.setMarkupColor(r, g, b);
2980
2997
  }
2981
2998
 
2982
- function setSelected(viewer, handles = []) {
2999
+ function setSelected(viewer, handles2 = []) {
2983
3000
  if (!viewer.visualizeJs)
2984
3001
  return;
3002
+ const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
2985
3003
  const visLib = viewer.visLib();
2986
3004
  const visViewer = viewer.visViewer();
2987
3005
  const selectionSet = new visLib.OdTvSelectionSet();
2988
- handles === null || handles === void 0 ? void 0 : handles.forEach((handle) => {
3006
+ handles.forEach((handle) => {
2989
3007
  const entityId = visViewer.getEntityByOriginalHandle(handle + "");
2990
3008
  if (!entityId.isNull())
2991
3009
  selectionSet.appendEntity(entityId);
@@ -2993,9 +3011,25 @@
2993
3011
  visViewer.setSelected(selectionSet);
2994
3012
  viewer.update();
2995
3013
  viewer.emitEvent({ type: "select", data: selectionSet, handles });
3014
+ viewer.emitEvent({ type: "select2", data: selectionSet, handles: handles2 });
2996
3015
  selectionSet.delete();
2997
3016
  }
2998
3017
 
3018
+ function setSelected2(viewer, handles2 = []) {
3019
+ const handles = [];
3020
+ handles2.forEach((handle) => {
3021
+ if (!handle.includes(":")) {
3022
+ handles.push(handle);
3023
+ }
3024
+ else
3025
+ viewer.models.forEach((model) => {
3026
+ if (handle.split(":", 1)[0] === model.id + "")
3027
+ handles.push(handle);
3028
+ });
3029
+ });
3030
+ return viewer.executeCommand("setSelected", handles);
3031
+ }
3032
+
2999
3033
  function showAll(viewer) {
3000
3034
  if (!viewer.visualizeJs)
3001
3035
  return;
@@ -3118,6 +3152,7 @@
3118
3152
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
3119
3153
  commands.registerCommand("getModels", getModels);
3120
3154
  commands.registerCommand("getSelected", getSelected);
3155
+ commands.registerCommand("getSelected2", getSelected2);
3121
3156
  commands.registerCommand("hideSelected", hideSelected);
3122
3157
  commands.registerCommand("isolateSelected", isolateSelected);
3123
3158
  commands.registerCommand("regenerateAll", regenerateAll);
@@ -3127,6 +3162,7 @@
3127
3162
  commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
3128
3163
  commands.registerCommand("setMarkupColor", setMarkupColor);
3129
3164
  commands.registerCommand("setSelected", setSelected);
3165
+ commands.registerCommand("setSelected2", setSelected2);
3130
3166
  commands.registerCommand("showAll", showAll);
3131
3167
  commands.registerCommand("zoomToExtents", zoomToExtents);
3132
3168
  commands.registerCommand("zoomToObjects", zoomToObjects);
@@ -3475,6 +3511,10 @@
3475
3511
  components.registerComponent("GestureManagerComponent", (viewer) => new GestureManagerComponent(viewer));
3476
3512
  components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));
3477
3513
 
3514
+ class ModelImpl {
3515
+ dispose() { }
3516
+ }
3517
+
3478
3518
  class FileLoader {
3479
3519
  constructor() {
3480
3520
  this.requestHeader = {};
@@ -3558,7 +3598,7 @@
3558
3598
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
3559
3599
  /vsf$/i.test(format));
3560
3600
  }
3561
- async load(file, format, params) {
3601
+ async load(file, format, params = {}) {
3562
3602
  if (!this.viewer.visualizeJs)
3563
3603
  return this;
3564
3604
  const visViewer = this.viewer.visViewer();
@@ -3582,6 +3622,9 @@
3582
3622
  console.error("VSF parse error.", error);
3583
3623
  throw error;
3584
3624
  }
3625
+ const modelImpl = new ModelImpl();
3626
+ modelImpl.id = params.modelId || this.extractFileName(file);
3627
+ this.viewer.models.push(modelImpl);
3585
3628
  this.viewer.syncOptions();
3586
3629
  this.viewer.syncOverlay();
3587
3630
  this.viewer.update(true);
@@ -3625,6 +3668,9 @@
3625
3668
  throw error;
3626
3669
  }
3627
3670
  if (i === 0) {
3671
+ const modelImpl = new ModelImpl();
3672
+ modelImpl.id = model.file.id;
3673
+ this.viewer.models.push(modelImpl);
3628
3674
  this.viewer.syncOptions();
3629
3675
  this.viewer.syncOverlay();
3630
3676
  this.viewer.update(true);
@@ -3649,7 +3695,7 @@
3649
3695
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
3650
3696
  /vsfx$/i.test(format));
3651
3697
  }
3652
- async load(file, format, params) {
3698
+ async load(file, format, params = {}) {
3653
3699
  if (!this.viewer.visualizeJs)
3654
3700
  return this;
3655
3701
  const visViewer = this.viewer.visViewer();
@@ -3673,6 +3719,9 @@
3673
3719
  console.error("VSFX parse error.", error);
3674
3720
  throw error;
3675
3721
  }
3722
+ const modelImpl = new ModelImpl();
3723
+ modelImpl.id = params.modelId || this.extractFileName(file);
3724
+ this.viewer.models.push(modelImpl);
3676
3725
  this.viewer.syncOptions();
3677
3726
  this.viewer.syncOverlay();
3678
3727
  this.viewer.update(true);
@@ -3693,7 +3742,7 @@
3693
3742
  /.vsfx$/i.test(file.database) &&
3694
3743
  this.viewer.options.enableStreamingMode === false);
3695
3744
  }
3696
- async load(model, format, params = {}) {
3745
+ async load(model) {
3697
3746
  if (!this.viewer.visualizeJs)
3698
3747
  return Promise.resolve(this);
3699
3748
  const visViewer = this.viewer.visViewer();
@@ -3712,6 +3761,9 @@
3712
3761
  console.error("VSFX parse error.", error);
3713
3762
  throw error;
3714
3763
  }
3764
+ const modelImpl = new ModelImpl();
3765
+ modelImpl.id = model.file.id;
3766
+ this.viewer.models.push(modelImpl);
3715
3767
  this.viewer.syncOptions();
3716
3768
  this.viewer.syncOverlay();
3717
3769
  this.viewer.update(true);
@@ -3790,6 +3842,9 @@
3790
3842
  isDatabaseChunk = true;
3791
3843
  }
3792
3844
  if (isDatabaseChunk) {
3845
+ const modelImpl = new ModelImpl();
3846
+ modelImpl.id = model.file.id;
3847
+ this.viewer.models.push(modelImpl);
3793
3848
  this.viewer.syncOptions();
3794
3849
  this.viewer.syncOverlay();
3795
3850
  updateController.update(UpdateType.kForce);
@@ -3824,7 +3879,7 @@
3824
3879
  /.vsfx$/i.test(file.database) &&
3825
3880
  (this.viewer.options.enablePartialMode === true || /.rcs$/i.test(file.name)));
3826
3881
  }
3827
- async load(model, format) {
3882
+ async load(model) {
3828
3883
  if (!this.viewer.visualizeJs)
3829
3884
  return this;
3830
3885
  const visViewer = this.viewer.visViewer();
@@ -3850,6 +3905,9 @@
3850
3905
  }
3851
3906
  this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
3852
3907
  if (isDatabaseChunk) {
3908
+ const modelImpl = new ModelImpl();
3909
+ modelImpl.id = model.file.id;
3910
+ this.viewer.models.push(modelImpl);
3853
3911
  this.viewer.syncOptions();
3854
3912
  this.viewer.syncOverlay();
3855
3913
  updateController.update(UpdateType.kForce);
@@ -17811,42 +17869,56 @@ js: import "konva/skia-backend";
17811
17869
  super();
17812
17870
  this._visualizeJsUrl = "";
17813
17871
  this.configure(params);
17814
- this._options = new Options(this);
17815
17872
  this.client = client;
17873
+ this.options = new Options(this);
17816
17874
  this.loaders = [];
17875
+ this.models = [];
17876
+ this.canvasEvents = CANVAS_EVENTS.slice();
17877
+ this.canvaseventlistener = (event) => this.emit(event);
17817
17878
  this._activeDragger = null;
17818
17879
  this._components = [];
17880
+ this._renderNeeded = false;
17819
17881
  this._renderTime = 0;
17820
- this.canvasEvents = CANVAS_EVENTS.slice();
17821
- this.canvaseventlistener = (event) => this.emit(event);
17822
17882
  this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
17823
- this._renderNeeded = false;
17824
17883
  this._isRunAsyncUpdate = false;
17825
17884
  this.render = this.render.bind(this);
17826
17885
  this.update = this.update.bind(this);
17827
17886
  this._markup = MarkupFactory.createMarkup(params.markupType);
17828
17887
  }
17829
- get options() {
17830
- return this._options;
17831
- }
17832
17888
  get visualizeJsUrl() {
17833
17889
  return this._visualizeJsUrl;
17834
17890
  }
17891
+ get visualizeJs() {
17892
+ return this._visualizeJs;
17893
+ }
17894
+ visLib() {
17895
+ return this._visualizeJs;
17896
+ }
17897
+ visViewer() {
17898
+ return this._viewer;
17899
+ }
17835
17900
  get markup() {
17836
17901
  return this._markup;
17837
17902
  }
17838
17903
  configure(params) {
17839
- this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js";
17904
+ this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/26.11/Visualize.js";
17840
17905
  this._crossOrigin = params.crossOrigin;
17841
17906
  return this;
17842
17907
  }
17908
+ get draggers() {
17909
+ return [...draggers.getDraggers().keys()];
17910
+ }
17911
+ get components() {
17912
+ return [...components.getComponents().keys()];
17913
+ }
17843
17914
  async initialize(canvas, onProgress) {
17844
17915
  this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
17916
+ const pixelRatio = window.devicePixelRatio;
17845
17917
  const rect = canvas.parentElement.getBoundingClientRect();
17846
17918
  const width = rect.width || 1;
17847
17919
  const height = rect.height || 1;
17848
- canvas.width = Math.round(width * window.devicePixelRatio);
17849
- canvas.height = Math.round(height * window.devicePixelRatio);
17920
+ canvas.width = Math.round(width * pixelRatio);
17921
+ canvas.height = Math.round(height * pixelRatio);
17850
17922
  canvas.style.width = width + "px";
17851
17923
  canvas.style.height = height + "px";
17852
17924
  canvas.parentElement.style.touchAction = "none";
@@ -17914,6 +17986,26 @@ js: import "konva/skia-backend";
17914
17986
  this.update(true);
17915
17987
  this.emitEvent({ type: "resize", width, height });
17916
17988
  }
17989
+ resize() {
17990
+ console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
17991
+ if (!this.visualizeJs)
17992
+ return this;
17993
+ if (!this.canvas.parentElement)
17994
+ return this;
17995
+ const { width, height } = this.canvas.parentElement.getBoundingClientRect();
17996
+ if (!width || !height)
17997
+ return this;
17998
+ this.setSize(width, height);
17999
+ return this;
18000
+ }
18001
+ update(force = false) {
18002
+ if (this._enableAutoUpdate) {
18003
+ this._renderNeeded = true;
18004
+ if (force)
18005
+ this.render();
18006
+ }
18007
+ this.emitEvent({ type: "update", data: force });
18008
+ }
17917
18009
  render(time) {
17918
18010
  var _a, _b;
17919
18011
  if (!this.visualizeJs)
@@ -17932,73 +18024,177 @@ js: import "konva/skia-backend";
17932
18024
  (_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
17933
18025
  this.emitEvent({ type: "render", time, deltaTime });
17934
18026
  }
17935
- resize() {
17936
- console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
18027
+ async loadReferences(model) {
18028
+ var _a;
17937
18029
  if (!this.visualizeJs)
17938
18030
  return this;
17939
- if (!this.canvas.parentElement)
18031
+ if (!this.client)
17940
18032
  return this;
17941
- const { width, height } = this.canvas.parentElement.getBoundingClientRect();
17942
- if (!width || !height)
18033
+ if (!model.getReferences)
17943
18034
  return this;
17944
- this.setSize(width, height);
18035
+ const abortController = new AbortController();
18036
+ (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
18037
+ this._abortControllerForReferences = abortController;
18038
+ let references = [];
18039
+ await model
18040
+ .getReferences(abortController.signal)
18041
+ .then((data) => (references = data.references))
18042
+ .catch((e) => console.error("Cannot load model references.", e));
18043
+ for (const file of references) {
18044
+ await this.client
18045
+ .downloadFile(file.id, undefined, abortController.signal)
18046
+ .then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
18047
+ .catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
18048
+ }
17945
18049
  return this;
17946
18050
  }
17947
- update(force = false) {
17948
- if (this._enableAutoUpdate) {
17949
- this._renderNeeded = true;
17950
- if (force)
17951
- this.render();
18051
+ applyModelTransformMatrix(model) {
18052
+ this.executeCommand("applyModelTransform", model);
18053
+ }
18054
+ applySceneGraphSettings(options = this.options) {
18055
+ if (!this.visualizeJs)
18056
+ return;
18057
+ const visLib = this.visLib();
18058
+ const visViewer = this.visViewer();
18059
+ const device = visViewer.getActiveDevice();
18060
+ if (isExist(options.sceneGraph)) {
18061
+ device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
17952
18062
  }
17953
- this.emitEvent({ type: "update", data: force });
18063
+ device.delete();
18064
+ this.update();
17954
18065
  }
17955
- scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
17956
- return new Promise((resolve, reject) => {
17957
- setTimeout(() => {
17958
- var _a, _b, _c;
17959
- try {
17960
- if (this._enableAutoUpdate) {
17961
- (_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
17962
- (_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
17963
- }
17964
- this.emitEvent({ type: "update", data: false });
17965
- resolve();
17966
- }
17967
- catch (e) {
17968
- console.error(e);
17969
- reject();
17970
- }
17971
- }, 0);
17972
- });
18066
+ async open(file, params = {}) {
18067
+ if (!this.visualizeJs)
18068
+ return this;
18069
+ this.cancel();
18070
+ this.clear();
18071
+ this.emitEvent({ type: "open", mode: "file", file });
18072
+ let model = file;
18073
+ if (model && typeof model.getModels === "function") {
18074
+ const models = await model.getModels();
18075
+ model = models.find((model) => model.default) || models[0] || file;
18076
+ }
18077
+ if (model && typeof model.database === "string") {
18078
+ file = model.file;
18079
+ }
18080
+ if (!model)
18081
+ throw new Error(`Format not supported`);
18082
+ let format = params.format;
18083
+ if (!format && typeof file["type"] === "string")
18084
+ format = file["type"].split(".").pop();
18085
+ if (!format && typeof file === "string")
18086
+ format = file.split(".").pop();
18087
+ if (!format && file instanceof globalThis.File)
18088
+ format = file.name.split(".").pop();
18089
+ const loader = loaders.createLoader(this, model, format);
18090
+ if (!loader)
18091
+ throw new Error(`Format not supported`);
18092
+ this.loaders.push(loader);
18093
+ this.emitEvent({ type: "geometrystart", file, model });
18094
+ try {
18095
+ await this.loadReferences(model);
18096
+ await loader.load(model, format, params);
18097
+ }
18098
+ catch (error) {
18099
+ this.emitEvent({ type: "geometryerror", data: error, file, model });
18100
+ throw error;
18101
+ }
18102
+ this.emitEvent({ type: "geometryend", file, model });
18103
+ if (this.visualizeJs) {
18104
+ this.applyModelTransformMatrix(model);
18105
+ this.applySceneGraphSettings();
18106
+ }
18107
+ return this;
17973
18108
  }
17974
- async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
18109
+ openVsfFile(buffer) {
18110
+ console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
17975
18111
  if (!this.visualizeJs)
17976
- return;
17977
- this._isRunAsyncUpdate = true;
18112
+ return this;
18113
+ this.cancel();
18114
+ this.clear();
18115
+ this.emitEvent({ type: "open", mode: "file", file: "", buffer });
18116
+ const visViewer = this.visViewer();
18117
+ this.emitEvent({ type: "geometrystart", file: "", buffer });
17978
18118
  try {
17979
- const device = this.visViewer().getActiveDevice();
17980
- for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
17981
- await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
17982
- }
17983
- await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
18119
+ const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
18120
+ visViewer.parseFile(data);
18121
+ this.syncOptions();
18122
+ this.syncOverlay();
18123
+ this.update(true);
18124
+ this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
18125
+ this.emitEvent({ type: "databasechunk", data, file: "", buffer });
17984
18126
  }
17985
- catch (e) {
17986
- console.error(e);
18127
+ catch (error) {
18128
+ this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
18129
+ throw error;
17987
18130
  }
17988
- finally {
17989
- this._isRunAsyncUpdate = false;
18131
+ this.emitEvent({ type: "geometryend", file: "", buffer });
18132
+ return this;
18133
+ }
18134
+ openVsfxFile(buffer) {
18135
+ console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
18136
+ if (!this.visualizeJs)
18137
+ return this;
18138
+ this.cancel();
18139
+ this.clear();
18140
+ this.emitEvent({ type: "open", mode: "file", file: "", buffer });
18141
+ const visViewer = this.visViewer();
18142
+ this.emitEvent({ type: "geometrystart", file: "", buffer });
18143
+ try {
18144
+ const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
18145
+ visViewer.parseVsfx(data);
18146
+ this.syncOptions();
18147
+ this.syncOverlay();
18148
+ this.update(true);
18149
+ this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
18150
+ this.emitEvent({ type: "databasechunk", data, file: "", buffer });
18151
+ }
18152
+ catch (error) {
18153
+ this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
18154
+ throw error;
17990
18155
  }
18156
+ this.emitEvent({ type: "geometryend", file: "", buffer });
18157
+ return this;
17991
18158
  }
17992
- get visualizeJs() {
17993
- return this._visualizeJs;
18159
+ cancel() {
18160
+ var _a;
18161
+ (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
18162
+ this._abortControllerForReferences = undefined;
18163
+ this.loaders.forEach((loader) => loader.cancel());
18164
+ this.emitEvent({ type: "cancel" });
18165
+ return this;
17994
18166
  }
17995
- visLib() {
17996
- return this._visualizeJs;
18167
+ clear() {
18168
+ if (!this.visualizeJs)
18169
+ return this;
18170
+ const visViewer = this.visViewer();
18171
+ this.setActiveDragger();
18172
+ this.clearSlices();
18173
+ this.clearOverlay();
18174
+ this.clearSelected();
18175
+ this.loaders.forEach((loader) => loader.dispose());
18176
+ this.loaders = [];
18177
+ this.models.forEach((model) => model.dispose());
18178
+ this.models = [];
18179
+ visViewer.clear();
18180
+ visViewer.createLocalDatabase();
18181
+ this.syncOptions();
18182
+ this.syncOverlay();
18183
+ this.update(true);
18184
+ this.emitEvent({ type: "clear" });
18185
+ return this;
17997
18186
  }
17998
- visViewer() {
17999
- return this._viewer;
18187
+ is3D() {
18188
+ if (!this.visualizeJs)
18189
+ return false;
18190
+ const visViewer = this.visViewer();
18191
+ const ext = visViewer.getActiveExtents();
18192
+ const min = ext.min();
18193
+ const max = ext.max();
18194
+ const extHeight = max[2] - min[2];
18195
+ return extHeight !== 0;
18000
18196
  }
18001
- syncOpenCloudVisualStyle() {
18197
+ syncOptions(options = this.options) {
18002
18198
  if (!this.visualizeJs)
18003
18199
  return this;
18004
18200
  const visLib = this.visLib();
@@ -18031,19 +18227,6 @@ js: import "konva/skia-backend";
18031
18227
  visualStylePtr.delete();
18032
18228
  }
18033
18229
  view.visualStyle = visualStyleId;
18034
- view.delete();
18035
- device.delete();
18036
- return this;
18037
- }
18038
- syncOptions(options = this.options) {
18039
- if (!this.visualizeJs)
18040
- return this;
18041
- this.syncOpenCloudVisualStyle();
18042
- const visLib = this.visLib();
18043
- const visViewer = this.visViewer();
18044
- const device = visViewer.getActiveDevice();
18045
- if (device.isNull())
18046
- return this;
18047
18230
  if (options.showWCS !== visViewer.getEnableWCS()) {
18048
18231
  visViewer.setEnableWCS(options.showWCS);
18049
18232
  }
@@ -18057,8 +18240,6 @@ js: import "konva/skia-backend";
18057
18240
  }
18058
18241
  if (options.shadows !== visViewer.shadows) {
18059
18242
  visViewer.shadows = options.shadows;
18060
- const canvas = visLib.canvas;
18061
- device.invalidate([0, canvas.width, canvas.height, 0]);
18062
18243
  }
18063
18244
  if (options.groundShadow !== visViewer.groundShadow) {
18064
18245
  visViewer.groundShadow = options.groundShadow;
@@ -18084,17 +18265,7 @@ js: import "konva/skia-backend";
18084
18265
  visualStyleId.delete();
18085
18266
  activeView.delete();
18086
18267
  }
18087
- device.delete();
18088
- this.syncHighlightingOptions(options);
18089
- this.update();
18090
- return this;
18091
- }
18092
- syncHighlightingOptions(options = this.options) {
18093
- if (!this.visualizeJs)
18094
- return this;
18095
18268
  const params = options.enableCustomHighlight ? options : Options.defaults();
18096
- const visLib = this.visLib();
18097
- const visViewer = this.visViewer();
18098
18269
  const { Entry, OdTvRGBColorDef } = visLib;
18099
18270
  const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
18100
18271
  const highlightStylePtr = highlightStyleId.openObject();
@@ -18121,19 +18292,80 @@ js: import "konva/skia-backend";
18121
18292
  const visibility = !isExist(params.edgesVisibility) ? true : params.edgesVisibility;
18122
18293
  highlightStylePtr.setEdgesVisibility(Entry.k2DTop.value | Entry.k3DTop.value, params.edgesOverlap && visibility);
18123
18294
  }
18124
- const device = visViewer.getActiveDevice();
18125
- if (!device.isNull()) {
18126
- const canvas = visLib.canvas;
18127
- device.invalidate([0, canvas.width, canvas.height, 0]);
18128
- device.delete();
18129
- }
18295
+ view.delete();
18296
+ device.delete();
18297
+ this.update();
18130
18298
  return this;
18131
18299
  }
18132
- get draggers() {
18133
- return [...draggers.getDraggers().keys()];
18300
+ syncOverlay() {
18301
+ if (!this.visualizeJs)
18302
+ return;
18303
+ const visViewer = this.visViewer();
18304
+ const activeView = visViewer.activeView;
18305
+ let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
18306
+ if (!overlayView) {
18307
+ const markupModel = visViewer.getMarkupModel();
18308
+ const pDevice = visViewer.getActiveDevice();
18309
+ overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
18310
+ overlayView.addModel(markupModel);
18311
+ activeView.addSibling(overlayView);
18312
+ pDevice.addView(overlayView);
18313
+ }
18314
+ overlayView.viewPosition = activeView.viewPosition;
18315
+ overlayView.viewTarget = activeView.viewTarget;
18316
+ overlayView.upVector = activeView.upVector;
18317
+ overlayView.viewFieldWidth = activeView.viewFieldWidth;
18318
+ overlayView.viewFieldHeight = activeView.viewFieldHeight;
18319
+ const viewPort = overlayView.getViewport();
18320
+ overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
18321
+ overlayView.vportRect = activeView.vportRect;
18322
+ this._markup.syncOverlay();
18323
+ this.update();
18134
18324
  }
18135
- get components() {
18136
- return [...components.getComponents().keys()];
18325
+ clearOverlay() {
18326
+ if (!this.visualizeJs)
18327
+ return;
18328
+ this._markup.clearOverlay();
18329
+ this.update();
18330
+ }
18331
+ clearSlices() {
18332
+ if (!this.visualizeJs)
18333
+ return;
18334
+ const visViewer = this.visViewer();
18335
+ const activeView = visViewer.activeView;
18336
+ activeView.removeCuttingPlanes();
18337
+ activeView.delete();
18338
+ this.update();
18339
+ }
18340
+ getSelected() {
18341
+ return this.executeCommand("getSelected");
18342
+ }
18343
+ setSelected(handles) {
18344
+ this.executeCommand("setSelected", handles);
18345
+ }
18346
+ getSelected2() {
18347
+ return this.executeCommand("getSelected2");
18348
+ }
18349
+ setSelected2(handles) {
18350
+ this.executeCommand("setSelected2", handles);
18351
+ }
18352
+ clearSelected() {
18353
+ this.executeCommand("clearSelected");
18354
+ }
18355
+ hideSelected() {
18356
+ this.executeCommand("hideSelected");
18357
+ }
18358
+ isolateSelected() {
18359
+ this.executeCommand("isolateSelected");
18360
+ }
18361
+ showAll() {
18362
+ this.executeCommand("showAll");
18363
+ }
18364
+ explode(index = 0) {
18365
+ this.executeCommand("explode", index);
18366
+ }
18367
+ collect() {
18368
+ this.executeCommand("collect");
18137
18369
  }
18138
18370
  registerDragger(name, dragger) {
18139
18371
  console.warn("Viewer.registerDragger() has been deprecated since 25.12 and will be removed in a future release, use draggers('visualizejs').registerDragger() instead.");
@@ -18180,55 +18412,102 @@ js: import "konva/skia-backend";
18180
18412
  getComponent(name) {
18181
18413
  return this._components.find((component) => component.name === name);
18182
18414
  }
18183
- clearSlices() {
18415
+ drawViewpoint(viewpoint) {
18416
+ var _a, _b;
18184
18417
  if (!this.visualizeJs)
18185
18418
  return;
18186
18419
  const visViewer = this.visViewer();
18187
18420
  const activeView = visViewer.activeView;
18188
- activeView.removeCuttingPlanes();
18189
- activeView.delete();
18190
- this.update();
18191
- }
18192
- clearOverlay() {
18193
- if (!this.visualizeJs)
18194
- return;
18195
- this._markup.clearOverlay();
18421
+ const getPoint3dAsArray = (point3d) => {
18422
+ return [point3d.x, point3d.y, point3d.z];
18423
+ };
18424
+ const setOrthogonalCamera = (orthogonal_camera) => {
18425
+ if (orthogonal_camera) {
18426
+ 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);
18427
+ this.syncOverlay();
18428
+ this.emitEvent({ type: "changecameramode", mode: "orthographic" });
18429
+ }
18430
+ };
18431
+ const setPerspectiveCamera = (perspective_camera) => { };
18432
+ const setClippingPlanes = (clipping_planes) => {
18433
+ if (clipping_planes) {
18434
+ for (const clipping_plane of clipping_planes) {
18435
+ const cuttingPlane = new (this.visLib().OdTvPlane)();
18436
+ cuttingPlane.set(getPoint3dAsArray(clipping_plane.location), getPoint3dAsArray(clipping_plane.direction));
18437
+ activeView.addCuttingPlane(cuttingPlane);
18438
+ activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
18439
+ }
18440
+ }
18441
+ };
18442
+ const setSelection = (selection) => {
18443
+ if (selection)
18444
+ this.setSelected(selection.map((component) => component.handle));
18445
+ };
18446
+ const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
18447
+ this.setActiveDragger();
18448
+ this.clearSlices();
18449
+ this.clearOverlay();
18450
+ this.clearSelected();
18451
+ this.showAll();
18452
+ this.explode();
18453
+ setOrthogonalCamera(viewpoint.orthogonal_camera);
18454
+ setPerspectiveCamera(viewpoint.perspective_camera);
18455
+ setClippingPlanes(viewpoint.clipping_planes);
18456
+ setSelection(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.selection2) || viewpoint.selection);
18457
+ this._markup.setViewpoint(viewpoint);
18458
+ this.setActiveDragger(draggerName);
18459
+ this.emitEvent({ type: "drawviewpoint", data: viewpoint });
18196
18460
  this.update();
18197
18461
  }
18198
- syncOverlay() {
18462
+ createViewpoint() {
18199
18463
  if (!this.visualizeJs)
18200
- return;
18464
+ return {};
18201
18465
  const visViewer = this.visViewer();
18202
18466
  const activeView = visViewer.activeView;
18203
- let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
18204
- if (!overlayView) {
18205
- const markupModel = visViewer.getMarkupModel();
18206
- const pDevice = visViewer.getActiveDevice();
18207
- overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
18208
- overlayView.addModel(markupModel);
18209
- activeView.addSibling(overlayView);
18210
- pDevice.addView(overlayView);
18211
- }
18212
- overlayView.viewPosition = activeView.viewPosition;
18213
- overlayView.viewTarget = activeView.viewTarget;
18214
- overlayView.upVector = activeView.upVector;
18215
- overlayView.viewFieldWidth = activeView.viewFieldWidth;
18216
- overlayView.viewFieldHeight = activeView.viewFieldHeight;
18217
- const viewPort = overlayView.getViewport();
18218
- overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
18219
- overlayView.vportRect = activeView.vportRect;
18220
- this._markup.syncOverlay();
18221
- this.update();
18222
- }
18223
- is3D() {
18224
- if (!this.visualizeJs)
18225
- return false;
18226
- const visViewer = this.visViewer();
18227
- const ext = visViewer.getActiveExtents();
18228
- const min = ext.min();
18229
- const max = ext.max();
18230
- const extHeight = max[2] - min[2];
18231
- return extHeight !== 0;
18467
+ const getPoint3dFromArray = (array) => {
18468
+ return { x: array[0], y: array[1], z: array[2] };
18469
+ };
18470
+ const getOrthogonalCamera = () => {
18471
+ return {
18472
+ view_point: getPoint3dFromArray(activeView.viewPosition),
18473
+ direction: getPoint3dFromArray(activeView.viewTarget),
18474
+ up_vector: getPoint3dFromArray(activeView.upVector),
18475
+ field_width: activeView.viewFieldWidth,
18476
+ field_height: activeView.viewFieldHeight,
18477
+ view_to_world_scale: 1,
18478
+ };
18479
+ };
18480
+ const getPerspectiveCamera = () => {
18481
+ return undefined;
18482
+ };
18483
+ const getClippingPlanes = () => {
18484
+ const clipping_planes = [];
18485
+ for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
18486
+ const cuttingPlane = activeView.getCuttingPlane(i);
18487
+ const clipping_plane = {
18488
+ location: getPoint3dFromArray(cuttingPlane.getOrigin()),
18489
+ direction: getPoint3dFromArray(cuttingPlane.normal()),
18490
+ };
18491
+ clipping_planes.push(clipping_plane);
18492
+ }
18493
+ return clipping_planes;
18494
+ };
18495
+ const getSelection = () => {
18496
+ return this.getSelected().map((handle) => ({ handle }));
18497
+ };
18498
+ const getSelection2 = () => {
18499
+ return this.getSelected2().map((handle) => ({ handle }));
18500
+ };
18501
+ const viewpoint = { custom_fields: {} };
18502
+ viewpoint.orthogonal_camera = getOrthogonalCamera();
18503
+ viewpoint.perspective_camera = getPerspectiveCamera();
18504
+ viewpoint.clipping_planes = getClippingPlanes();
18505
+ viewpoint.selection = getSelection();
18506
+ viewpoint.description = new Date().toDateString();
18507
+ this._markup.getViewpoint(viewpoint);
18508
+ viewpoint.custom_fields.selection2 = getSelection2();
18509
+ this.emitEvent({ type: "createviewpoint", data: viewpoint });
18510
+ return viewpoint;
18232
18511
  }
18233
18512
  screenToWorld(position) {
18234
18513
  if (!this.visualizeJs)
@@ -18263,184 +18542,23 @@ js: import "konva/skia-backend";
18263
18542
  result.z = 1 / z;
18264
18543
  return result;
18265
18544
  }
18266
- getSelected() {
18267
- return this.executeCommand("getSelected");
18268
- }
18269
- setSelected(handles) {
18270
- this.executeCommand("setSelected", handles);
18271
- }
18272
- clearSelected() {
18273
- this.executeCommand("clearSelected");
18274
- }
18275
- hideSelected() {
18276
- this.executeCommand("hideSelected");
18277
- }
18278
- isolateSelected() {
18279
- this.executeCommand("isolateSelected");
18280
- }
18281
- showAll() {
18282
- this.executeCommand("showAll");
18283
- }
18284
- explode(index = 0) {
18285
- this.executeCommand("explode", index);
18286
- }
18287
- collect() {
18288
- this.executeCommand("collect");
18289
- }
18290
- async loadReferences(model) {
18291
- var _a;
18292
- if (!this.visualizeJs)
18293
- return this;
18294
- if (!this.client)
18295
- return this;
18296
- if (!model.getReferences)
18297
- return this;
18298
- const abortController = new AbortController();
18299
- (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
18300
- this._abortControllerForReferences = abortController;
18301
- let references = [];
18302
- await model
18303
- .getReferences(abortController.signal)
18304
- .then((data) => (references = data.references))
18305
- .catch((e) => console.error("Cannot load model references.", e));
18306
- for (const file of references) {
18307
- await this.client
18308
- .downloadFile(file.id, undefined, abortController.signal)
18309
- .then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
18310
- .catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
18311
- }
18312
- return this;
18313
- }
18314
- applyModelTransformMatrix(model) {
18315
- this.executeCommand("applyModelTransform", model);
18545
+ executeCommand(id, ...args) {
18546
+ return commands.executeCommand(id, this, ...args);
18316
18547
  }
18317
- applySceneGraphSettings(options = this.options) {
18548
+ addMarkupEntity(entityName) {
18318
18549
  if (!this.visualizeJs)
18319
- return;
18320
- const visLib = this.visLib();
18550
+ return null;
18551
+ this.syncOverlay();
18321
18552
  const visViewer = this.visViewer();
18322
- const device = visViewer.getActiveDevice();
18323
- if (isExist(options.sceneGraph)) {
18324
- device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
18325
- }
18326
- device.delete();
18553
+ const model = visViewer.getMarkupModel();
18554
+ const entityId = model.appendEntity(entityName);
18555
+ const entityPtr = entityId.openObject();
18556
+ const color = this.getMarkupColor();
18557
+ entityPtr.setColor(color.r, color.g, color.b);
18558
+ entityPtr.setLineWeight(2);
18559
+ entityPtr.delete();
18327
18560
  this.update();
18328
- }
18329
- async open(file, params = {}) {
18330
- if (!this.visualizeJs)
18331
- return this;
18332
- this.cancel();
18333
- this.clear();
18334
- this.emitEvent({ type: "open", file });
18335
- let model = file;
18336
- if (model && typeof model.getModels === "function") {
18337
- const models = await model.getModels();
18338
- model = models.find((model) => model.default) || models[0] || file;
18339
- }
18340
- if (!model)
18341
- throw new Error(`Format not supported`);
18342
- let format = params.format;
18343
- if (!format && typeof model.type === "string")
18344
- format = model.type.split(".").pop();
18345
- if (!format && typeof file === "string")
18346
- format = file.split(".").pop();
18347
- if (!format && file instanceof globalThis.File)
18348
- format = file.name.split(".").pop();
18349
- const loader = loaders.createLoader(this, model, format);
18350
- if (!loader)
18351
- throw new Error(`Format not supported`);
18352
- this.loaders.push(loader);
18353
- this.emitEvent({ type: "geometrystart", file, model });
18354
- try {
18355
- await this.loadReferences(model);
18356
- await loader.load(model, format, params);
18357
- }
18358
- catch (error) {
18359
- this.emitEvent({ type: "geometryerror", data: error, file, model });
18360
- throw error;
18361
- }
18362
- this.emitEvent({ type: "geometryend", file, model });
18363
- if (this.visualizeJs) {
18364
- this.applyModelTransformMatrix(model);
18365
- this.applySceneGraphSettings();
18366
- }
18367
- return this;
18368
- }
18369
- openVsfFile(buffer) {
18370
- console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
18371
- if (!this.visualizeJs)
18372
- return this;
18373
- this.cancel();
18374
- this.clear();
18375
- this.emitEvent({ type: "open", file: "", buffer });
18376
- const visViewer = this.visViewer();
18377
- this.emitEvent({ type: "geometrystart", file: "", buffer });
18378
- try {
18379
- const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
18380
- visViewer.parseFile(data);
18381
- this.syncOptions();
18382
- this.syncOverlay();
18383
- this.update(true);
18384
- this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
18385
- this.emitEvent({ type: "databasechunk", data, file: "", buffer });
18386
- }
18387
- catch (error) {
18388
- this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
18389
- throw error;
18390
- }
18391
- this.emitEvent({ type: "geometryend", file: "", buffer });
18392
- return this;
18393
- }
18394
- openVsfxFile(buffer) {
18395
- console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
18396
- if (!this.visualizeJs)
18397
- return this;
18398
- this.cancel();
18399
- this.clear();
18400
- this.emitEvent({ type: "open", file: "", buffer });
18401
- const visViewer = this.visViewer();
18402
- this.emitEvent({ type: "geometrystart", file: "", buffer });
18403
- try {
18404
- const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
18405
- visViewer.parseVsfx(data);
18406
- this.syncOptions();
18407
- this.syncOverlay();
18408
- this.update(true);
18409
- this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
18410
- this.emitEvent({ type: "databasechunk", data, file: "", buffer });
18411
- }
18412
- catch (error) {
18413
- this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
18414
- throw error;
18415
- }
18416
- this.emitEvent({ type: "geometryend", file: "", buffer });
18417
- return this;
18418
- }
18419
- cancel() {
18420
- var _a;
18421
- (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
18422
- this._abortControllerForReferences = undefined;
18423
- this.loaders.forEach((loader) => loader.cancel());
18424
- this.emitEvent({ type: "cancel" });
18425
- return this;
18426
- }
18427
- clear() {
18428
- if (!this.visualizeJs)
18429
- return this;
18430
- const visViewer = this.visViewer();
18431
- this.setActiveDragger();
18432
- this.clearSlices();
18433
- this.clearOverlay();
18434
- this.clearSelected();
18435
- this.loaders.forEach((loader) => loader.dispose());
18436
- this.loaders = [];
18437
- visViewer.clear();
18438
- visViewer.createLocalDatabase();
18439
- this.syncOptions();
18440
- this.syncOverlay();
18441
- this.update(true);
18442
- this.emitEvent({ type: "clear" });
18443
- return this;
18561
+ return entityId;
18444
18562
  }
18445
18563
  getMarkupColor() {
18446
18564
  console.warn("Viewer.getMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.getMarkupColor() instead.");
@@ -18457,113 +18575,43 @@ js: import "konva/skia-backend";
18457
18575
  colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
18458
18576
  this._markup.colorizeSelectedMarkups(r, g, b);
18459
18577
  }
18460
- addMarkupEntity(entityName) {
18461
- if (!this.visualizeJs)
18462
- return null;
18463
- this.syncOverlay();
18464
- const visViewer = this.visViewer();
18465
- const model = visViewer.getMarkupModel();
18466
- const entityId = model.appendEntity(entityName);
18467
- const entityPtr = entityId.openObject();
18468
- const color = this.getMarkupColor();
18469
- entityPtr.setColor(color.r, color.g, color.b);
18470
- entityPtr.setLineWeight(2);
18471
- entityPtr.delete();
18472
- this.update();
18473
- return entityId;
18578
+ scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
18579
+ return new Promise((resolve, reject) => {
18580
+ setTimeout(() => {
18581
+ var _a, _b, _c;
18582
+ try {
18583
+ if (this._enableAutoUpdate) {
18584
+ (_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
18585
+ (_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
18586
+ }
18587
+ this.emitEvent({ type: "update", data: false });
18588
+ resolve();
18589
+ }
18590
+ catch (e) {
18591
+ console.error(e);
18592
+ reject();
18593
+ }
18594
+ }, 0);
18595
+ });
18474
18596
  }
18475
- drawViewpoint(viewpoint) {
18476
- var _a;
18597
+ async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
18477
18598
  if (!this.visualizeJs)
18478
18599
  return;
18479
- const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
18480
- this.setActiveDragger();
18481
- this.clearSlices();
18482
- this.clearOverlay();
18483
- this.clearSelected();
18484
- this.showAll();
18485
- this.explode();
18486
- this.setOrthogonalCameraSettings(viewpoint.orthogonal_camera);
18487
- this.setClippingPlanes(viewpoint.clipping_planes);
18488
- this.setSelection(viewpoint.selection);
18489
- this._markup.setViewpoint(viewpoint);
18490
- this.setActiveDragger(draggerName);
18491
- this.emitEvent({ type: "drawviewpoint", data: viewpoint });
18492
- this.update();
18493
- }
18494
- createViewpoint() {
18495
- if (!this.visualizeJs)
18496
- return {};
18497
- const viewpoint = {};
18498
- viewpoint.orthogonal_camera = this.getOrthogonalCameraSettings();
18499
- viewpoint.clipping_planes = this.getClippingPlanes();
18500
- viewpoint.selection = this.getSelection();
18501
- viewpoint.description = new Date().toDateString();
18502
- this._markup.getViewpoint(viewpoint);
18503
- this.emitEvent({ type: "createviewpoint", data: viewpoint });
18504
- return viewpoint;
18505
- }
18506
- getPoint3dFromArray(array) {
18507
- return { x: array[0], y: array[1], z: array[2] };
18508
- }
18509
- getLogicalPoint3dAsArray(point3d) {
18510
- return [point3d.x, point3d.y, point3d.z];
18511
- }
18512
- getOrthogonalCameraSettings() {
18513
- const visViewer = this.visViewer();
18514
- const activeView = visViewer.activeView;
18515
- return {
18516
- view_point: this.getPoint3dFromArray(activeView.viewPosition),
18517
- direction: this.getPoint3dFromArray(activeView.viewTarget),
18518
- up_vector: this.getPoint3dFromArray(activeView.upVector),
18519
- field_width: activeView.viewFieldWidth,
18520
- field_height: activeView.viewFieldHeight,
18521
- view_to_world_scale: 1,
18522
- };
18523
- }
18524
- setOrthogonalCameraSettings(settings) {
18525
- const visViewer = this.visViewer();
18526
- const activeView = visViewer.activeView;
18527
- if (settings) {
18528
- activeView.setView(this.getLogicalPoint3dAsArray(settings.view_point), this.getLogicalPoint3dAsArray(settings.direction), this.getLogicalPoint3dAsArray(settings.up_vector), settings.field_width, settings.field_height, true);
18529
- this.syncOverlay();
18600
+ this._isRunAsyncUpdate = true;
18601
+ try {
18602
+ const device = this.visViewer().getActiveDevice();
18603
+ for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
18604
+ await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
18605
+ }
18606
+ await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
18530
18607
  }
18531
- }
18532
- getClippingPlanes() {
18533
- const visViewer = this.visViewer();
18534
- const activeView = visViewer.activeView;
18535
- const clipping_planes = [];
18536
- for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
18537
- const cuttingPlane = activeView.getCuttingPlane(i);
18538
- const clipping_plane = {
18539
- location: this.getPoint3dFromArray(cuttingPlane.getOrigin()),
18540
- direction: this.getPoint3dFromArray(cuttingPlane.normal()),
18541
- };
18542
- clipping_planes.push(clipping_plane);
18608
+ catch (e) {
18609
+ console.error(e);
18543
18610
  }
18544
- return clipping_planes;
18545
- }
18546
- setClippingPlanes(clipping_planes) {
18547
- if (clipping_planes) {
18548
- const visViewer = this.visViewer();
18549
- const activeView = visViewer.activeView;
18550
- for (const clipping_plane of clipping_planes) {
18551
- const cuttingPlane = new (this.visLib().OdTvPlane)();
18552
- cuttingPlane.set(this.getLogicalPoint3dAsArray(clipping_plane.location), this.getLogicalPoint3dAsArray(clipping_plane.direction));
18553
- activeView.addCuttingPlane(cuttingPlane);
18554
- activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
18555
- }
18611
+ finally {
18612
+ this._isRunAsyncUpdate = false;
18556
18613
  }
18557
18614
  }
18558
- getSelection() {
18559
- return this.getSelected().map((handle) => ({ handle }));
18560
- }
18561
- setSelection(selection) {
18562
- this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map((component) => component.handle));
18563
- }
18564
- executeCommand(id, ...args) {
18565
- return commands.executeCommand(id, this, ...args);
18566
- }
18567
18615
  deviceAutoRegeneration() {
18568
18616
  const visViewer = this.visViewer();
18569
18617
  const device = visViewer.getActiveDevice();