@inweb/viewer-visualize 26.10.6 → 26.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +6 -4
  2. package/dist/viewer-visualize.js +659 -496
  3. package/dist/viewer-visualize.js.map +1 -1
  4. package/dist/viewer-visualize.min.js +1 -1
  5. package/dist/viewer-visualize.module.js +585 -484
  6. package/dist/viewer-visualize.module.js.map +1 -1
  7. package/lib/Viewer/Commands/GetSelected2.d.ts +2 -0
  8. package/lib/Viewer/Commands/SetSelected.d.ts +1 -1
  9. package/lib/Viewer/Commands/SetSelected2.d.ts +2 -0
  10. package/lib/Viewer/Components/index.d.ts +8 -7
  11. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +5 -1
  12. package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +3 -2
  13. package/lib/Viewer/Loaders/VSFXCloudLoader.d.ts +1 -1
  14. package/lib/Viewer/Loaders/VSFXCloudPartialLoader.d.ts +1 -1
  15. package/lib/Viewer/Loaders/index.d.ts +14 -9
  16. package/lib/Viewer/Models/IModelImpl.d.ts +5 -0
  17. package/lib/Viewer/Models/ModelImpl.d.ts +5 -0
  18. package/lib/Viewer/Viewer.d.ts +130 -136
  19. package/package.json +5 -5
  20. package/src/Viewer/Commands/ClearSelected.ts +3 -1
  21. package/src/Viewer/Commands/GetSelected2.ts +33 -0
  22. package/src/Viewer/Commands/HideSelected.ts +3 -1
  23. package/src/Viewer/Commands/SelectModel.ts +2 -3
  24. package/src/Viewer/Commands/SetSelected.ts +5 -2
  25. package/src/Viewer/Commands/SetSelected2.ts +39 -0
  26. package/src/Viewer/Commands/index.ts +4 -0
  27. package/src/Viewer/Components/index.ts +8 -7
  28. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +3 -2
  29. package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +44 -13
  30. package/src/Viewer/Draggers/MeasureLineDragger/index.ts +53 -18
  31. package/src/Viewer/Draggers/OdJoyStickDragger.ts +2 -2
  32. package/src/Viewer/Loaders/VSFCloudLoader.ts +6 -0
  33. package/src/Viewer/Loaders/VSFFileLoader.ts +7 -1
  34. package/src/Viewer/Loaders/VSFXCloudLoader.ts +7 -1
  35. package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +8 -2
  36. package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +7 -1
  37. package/src/Viewer/Loaders/VSFXFileLoader.ts +7 -1
  38. package/src/Viewer/Loaders/index.ts +14 -9
  39. package/src/Viewer/Models/IModelImpl.ts +29 -0
  40. package/src/Viewer/Models/ModelImpl.ts +32 -0
  41. package/src/Viewer/Viewer.ts +784 -775
@@ -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() {
@@ -236,6 +244,7 @@
236
244
  enableGestures: true,
237
245
  geometryType: "vsfx",
238
246
  rulerUnit: "Default",
247
+ rulerPrecision: 2,
239
248
  cameraMode: "perspective",
240
249
  };
241
250
  }
@@ -492,6 +501,13 @@
492
501
  this._data.rulerUnit = value;
493
502
  this.change();
494
503
  }
504
+ get rulerPrecision() {
505
+ return this._data.rulerPrecision;
506
+ }
507
+ set rulerPrecision(value) {
508
+ this._data.rulerPrecision = value;
509
+ this.change();
510
+ }
495
511
  get cameraMode() {
496
512
  return this._data.cameraMode || "perspective";
497
513
  }
@@ -520,6 +536,51 @@
520
536
  "wheel",
521
537
  ];
522
538
  const CANVAS_EVENTS = CanvasEvents;
539
+ class Info {
540
+ constructor() {
541
+ this.performance = {
542
+ fps: 0,
543
+ frameTime: 0,
544
+ timeToFirstRender: 0,
545
+ loadTime: 0,
546
+ };
547
+ this.render = {
548
+ viewport: { width: 0, height: 0 },
549
+ antialiasing: "",
550
+ drawCalls: 0,
551
+ triangles: 0,
552
+ points: 0,
553
+ lines: 0,
554
+ };
555
+ this.scene = {
556
+ objects: 0,
557
+ triangles: 0,
558
+ points: 0,
559
+ lines: 0,
560
+ edges: 0,
561
+ };
562
+ this.optimizedScene = {
563
+ objects: 0,
564
+ triangles: 0,
565
+ points: 0,
566
+ lines: 0,
567
+ edges: 0,
568
+ };
569
+ this.memory = {
570
+ geometries: 0,
571
+ geometryBytes: 0,
572
+ textures: 0,
573
+ textureBytes: 0,
574
+ materials: 0,
575
+ totalEstimatedGpuBytes: 0,
576
+ usedJSHeapSize: 0,
577
+ };
578
+ this.system = {
579
+ webglRenderer: "",
580
+ webglVendor: "",
581
+ };
582
+ }
583
+ }
523
584
 
524
585
  class OdaGeAction {
525
586
  constructor(module) {
@@ -707,8 +768,8 @@
707
768
  viewer.select(x, y, x, y);
708
769
  this.subject.update();
709
770
  const selectionSet = viewer.getSelected();
710
- const handles = this.subject.getSelected();
711
- this.onmessage({ type: "select", data: selectionSet, handles });
771
+ this.onmessage({ type: "select", data: selectionSet, handles: this.subject.getSelected() });
772
+ this.onmessage({ type: "select2", data: selectionSet, handles: this.subject.getSelected2() });
712
773
  }
713
774
  }
714
775
  dblclick(ev) {
@@ -896,8 +957,9 @@
896
957
  this.htmlElemTitle = null;
897
958
  this.startPoint = null;
898
959
  this.endPoint = null;
899
- this.unit = "";
900
960
  this.scale = 1.0;
961
+ this.unit = "";
962
+ this.precision = 2;
901
963
  this.size = 10.0;
902
964
  this.lineThickness = 2;
903
965
  this.style = {
@@ -982,10 +1044,9 @@
982
1044
  this.htmlElemLine.style.background = this.style.background;
983
1045
  this.htmlElemLine.style.zIndex = "1";
984
1046
  this.htmlElemLine.style.height = `${height}px`;
985
- const distance = `${this.getDistance()} ${this.unit}`;
1047
+ const distance = this.getDistance();
986
1048
  const pX = p1.x + dx / 2;
987
1049
  const pY = p1.y + dy / 2;
988
- const widthTitle = distance.length * 10;
989
1050
  this.htmlElemTitle = createHtmlElementIfNeed(this.htmlElemTitle, this.targetElement, "ruler-value");
990
1051
  this.htmlElemTitle.style.display = "block";
991
1052
  this.htmlElemTitle.style.cursor = "pointer";
@@ -993,9 +1054,8 @@
993
1054
  this.htmlElemTitle.style.color = "white";
994
1055
  this.htmlElemTitle.style.position = "Absolute";
995
1056
  this.htmlElemTitle.style.top = `${pY}px`;
996
- this.htmlElemTitle.style.left = `${pX - widthTitle / 2}px`;
997
- this.htmlElemTitle.style.width = `${widthTitle}px`;
998
- this.htmlElemTitle.style.transformOrigin = "0px 0px";
1057
+ this.htmlElemTitle.style.left = `${pX}px`;
1058
+ this.htmlElemTitle.style.transform = "translate(-50%, -50%)";
999
1059
  this.htmlElemTitle.style.borderRadius = "5px";
1000
1060
  this.htmlElemTitle.style.boxShadow = this.style.boxShadow;
1001
1061
  this.htmlElemTitle.style.border = "none";
@@ -1003,7 +1063,7 @@
1003
1063
  this.htmlElemTitle.style.zIndex = "3";
1004
1064
  this.htmlElemTitle.style.padding = "2px";
1005
1065
  this.htmlElemTitle.style.textAlign = "center";
1006
- this.htmlElemTitle.innerHTML = `${distance}`;
1066
+ this.htmlElemTitle.innerHTML = this.formatDistance(distance);
1007
1067
  }
1008
1068
  else {
1009
1069
  this.htmlElemLine.style.display = "none";
@@ -1013,11 +1073,43 @@
1013
1073
  }
1014
1074
  getDistance() {
1015
1075
  let distance = getDistance(this.startPoint, this.endPoint, this.moduleInstance);
1016
- if (Math.abs(this.scale - 1.0) > 10e-5) {
1017
- distance = (distance / this.scale).toFixed(2);
1018
- }
1076
+ if (Math.abs(this.scale) > 1e-10)
1077
+ distance /= this.scale;
1019
1078
  return distance;
1020
1079
  }
1080
+ calculatePrecision(value) {
1081
+ const distance = Math.abs(value);
1082
+ if (distance >= 1000)
1083
+ return 0;
1084
+ if (distance >= 10)
1085
+ return 1;
1086
+ if (distance >= 0.1)
1087
+ return 2;
1088
+ if (distance >= 0.001)
1089
+ return 3;
1090
+ return distance > 0 ? Math.floor(-Math.log10(distance)) + 1 : 2;
1091
+ }
1092
+ formatDistance(distance) {
1093
+ let digits;
1094
+ if (this.precision === "Auto")
1095
+ digits = this.calculatePrecision(distance);
1096
+ else if (Number.isFinite(this.precision))
1097
+ digits = this.precision;
1098
+ else
1099
+ digits = parseFloat(this.precision);
1100
+ if (!Number.isFinite(digits))
1101
+ digits = 2;
1102
+ else if (digits < 0)
1103
+ digits = 0;
1104
+ else if (digits > 10)
1105
+ digits = 10;
1106
+ let result = distance.toFixed(digits);
1107
+ if (this.precision === "Auto")
1108
+ result = result.replace(/\.0+$/, "").replace(/\.$/, "");
1109
+ if (+result !== distance)
1110
+ result = "~ " + result;
1111
+ return `${result} ${this.unit}`;
1112
+ }
1021
1113
  setStartPoint(gePoint) {
1022
1114
  this.startPoint = gePoint;
1023
1115
  this.drawMeasureLine();
@@ -1050,6 +1142,10 @@
1050
1142
  this.scale = scale;
1051
1143
  this.drawMeasureLine();
1052
1144
  }
1145
+ setPrecision(precision) {
1146
+ this.precision = precision;
1147
+ this.drawMeasureLine();
1148
+ }
1053
1149
  setStyle(style) {
1054
1150
  this.style = style;
1055
1151
  this.drawMeasureLine();
@@ -1072,14 +1168,14 @@
1072
1168
  }
1073
1169
  class MeasureLineDragger extends OdBaseDragger {
1074
1170
  constructor(subject) {
1075
- var _a;
1171
+ var _a, _b;
1076
1172
  super(subject);
1077
1173
  this.lineThickness = 2;
1078
1174
  this.press = false;
1079
1175
  this.gripingRadius = 5.0;
1080
1176
  this.firstPoint = null;
1081
1177
  this.secondPoint = null;
1082
- this.renameUnitTable = {
1178
+ this.rulerUnitTable = {
1083
1179
  Millimeters: "mm",
1084
1180
  Centimeters: "cm",
1085
1181
  Meters: "m",
@@ -1089,13 +1185,14 @@
1089
1185
  Kilometers: "km",
1090
1186
  Miles: "mi",
1091
1187
  Micrometers: "µm",
1188
+ Mils: "mil",
1092
1189
  MicroInches: "µin",
1093
1190
  Default: "unit",
1094
1191
  };
1192
+ this.rulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
1193
+ this.rulerPrecision = (_b = subject.options.rulerPrecision) !== null && _b !== void 0 ? _b : "Default";
1095
1194
  this.items = [];
1096
- this.canvasEvents.push("resize");
1097
- this.oldRulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
1098
- this.optionsChange = this.optionsChange.bind(this);
1195
+ this.canvasEvents.push("resize", "optionsChange");
1099
1196
  }
1100
1197
  initialize() {
1101
1198
  super.initialize();
@@ -1190,8 +1287,9 @@
1190
1287
  const viewer = this.m_module.getViewer();
1191
1288
  const item = new MeasureLineItem(this.m_overlayElement, viewer, this.m_module);
1192
1289
  item.lineThickness = this.lineThickness || item.lineThickness;
1193
- const isDefaultUnit = !this.subject.options.rulerUnit || this.subject.options.rulerUnit === "Default";
1194
- item.setUnit(renameUnit(this.renameUnitTable, isDefaultUnit ? viewer.getUnit() : this.subject.options.rulerUnit));
1290
+ const isDefaultUnit = this.rulerUnit === "Default";
1291
+ const isDefaultPrecision = this.rulerPrecision === "Default";
1292
+ item.setUnit(renameUnit(this.rulerUnitTable, isDefaultUnit ? viewer.getUnit() : this.rulerUnit));
1195
1293
  if (!isDefaultUnit) {
1196
1294
  const fromUnit = this.getKUnitByName(viewer.getUnit());
1197
1295
  const toUnit = this.getKUnitByName(this.subject.options.rulerUnit);
@@ -1202,29 +1300,49 @@
1202
1300
  else {
1203
1301
  item.setConversionFactor(1.0);
1204
1302
  }
1303
+ if (!isDefaultPrecision) {
1304
+ item.setPrecision(this.rulerPrecision);
1305
+ }
1306
+ else {
1307
+ item.setPrecision(2);
1308
+ }
1205
1309
  this.items.push(item);
1206
1310
  return item;
1207
1311
  }
1208
1312
  optionsChange(event) {
1209
- var _a;
1313
+ var _a, _b;
1210
1314
  const options = event.data;
1211
1315
  const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
1212
- if (this.oldRulerUnit === toUnitName)
1316
+ const toPrecision = (_b = options.rulerPrecision) !== null && _b !== void 0 ? _b : "Default";
1317
+ const unitChanged = this.rulerUnit !== toUnitName;
1318
+ const precisionChanged = this.rulerPrecision !== toPrecision;
1319
+ if (!unitChanged && !precisionChanged)
1213
1320
  return;
1214
- this.oldRulerUnit = toUnitName;
1321
+ this.rulerUnit = toUnitName;
1322
+ this.rulerPrecision = toPrecision;
1215
1323
  const drawingUnit = this.m_module.getViewer().getUnit();
1216
1324
  const eToUnit = this.getKUnitByName(toUnitName);
1217
1325
  const eFromUnit = this.getKUnitByName(drawingUnit);
1218
1326
  this.items.forEach((item) => {
1219
- if (toUnitName === "Default") {
1220
- item.setUnit(renameUnit(this.renameUnitTable, drawingUnit));
1221
- item.setConversionFactor(1.0);
1327
+ if (unitChanged) {
1328
+ if (toUnitName === "Default") {
1329
+ item.setUnit(renameUnit(this.rulerUnitTable, drawingUnit));
1330
+ item.setConversionFactor(1.0);
1331
+ }
1332
+ else {
1333
+ item.setUnit(renameUnit(this.rulerUnitTable, toUnitName));
1334
+ const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
1335
+ this.conversionFactor = 1 / multiplier;
1336
+ item.setConversionFactor(this.conversionFactor);
1337
+ }
1222
1338
  }
1223
- else {
1224
- item.setUnit(renameUnit(this.renameUnitTable, toUnitName));
1225
- const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
1226
- this.conversionFactor = 1 / multiplier;
1227
- item.setConversionFactor(this.conversionFactor);
1339
+ if (precisionChanged) {
1340
+ if (toPrecision === "Default") {
1341
+ item.setPrecision(2);
1342
+ }
1343
+ else {
1344
+ item.setPrecision(toPrecision);
1345
+ }
1228
1346
  }
1229
1347
  });
1230
1348
  }
@@ -1258,6 +1376,9 @@
1258
1376
  case "Micrometers":
1259
1377
  eUnit = this.m_module.Units.kMicrometers;
1260
1378
  break;
1379
+ case "Mils":
1380
+ eUnit = this.m_module.Units.kMils;
1381
+ break;
1261
1382
  case "MicroInches":
1262
1383
  eUnit = this.m_module.Units.kMicroInches;
1263
1384
  break;
@@ -1313,7 +1434,7 @@
1313
1434
  callback({
1314
1435
  x: 100 * ((movedX - centerX) / maxMoveStick),
1315
1436
  y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
1316
- global: global,
1437
+ global,
1317
1438
  });
1318
1439
  }
1319
1440
  };
@@ -1328,7 +1449,7 @@
1328
1449
  callback({
1329
1450
  x: 100 * ((movedX - centerX) / maxMoveStick),
1330
1451
  y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
1331
- global: global,
1452
+ global,
1332
1453
  });
1333
1454
  };
1334
1455
  this.drawExternal = () => {
@@ -2819,7 +2940,8 @@
2819
2940
  const visViewer = viewer.visViewer();
2820
2941
  visViewer.unselect();
2821
2942
  viewer.update();
2822
- viewer.emitEvent({ type: "select", data: undefined, handles: [] });
2943
+ viewer.emitEvent({ type: "select", handles: [] });
2944
+ viewer.emitEvent({ type: "select2", handles: [] });
2823
2945
  }
2824
2946
 
2825
2947
  function clearSlices(viewer) {
@@ -2895,6 +3017,13 @@
2895
3017
  return handles;
2896
3018
  }
2897
3019
 
3020
+ function getSelected2(viewer) {
3021
+ const handles = viewer.executeCommand("getSelected");
3022
+ const model = viewer.models[0];
3023
+ const handles2 = handles.map((handle) => `${model.id}:${handle}`);
3024
+ return handles2;
3025
+ }
3026
+
2898
3027
  function hideSelected(viewer) {
2899
3028
  if (!viewer.visualizeJs)
2900
3029
  return;
@@ -2902,7 +3031,8 @@
2902
3031
  visViewer.hideSelectedObjects(false);
2903
3032
  viewer.update();
2904
3033
  viewer.emitEvent({ type: "hide" });
2905
- viewer.emitEvent({ type: "select", data: undefined, handles: [] });
3034
+ viewer.emitEvent({ type: "select", handles: [] });
3035
+ viewer.emitEvent({ type: "select2", handles: [] });
2906
3036
  }
2907
3037
 
2908
3038
  function isolateSelected(viewer) {
@@ -2950,9 +3080,9 @@
2950
3080
  if (modelPtr.getDatabaseHandle() === handle) {
2951
3081
  const selectionSet = activeView.selectCrossing([0, 9999, 9999, 0], modelPtr);
2952
3082
  visViewer.setSelected(selectionSet);
2953
- const handles = viewer.getSelected();
2954
3083
  viewer.update();
2955
- viewer.emitEvent({ type: "select", data: selectionSet, handles });
3084
+ viewer.emitEvent({ type: "select", handles: viewer.getSelected() });
3085
+ viewer.emitEvent({ type: "select2", handles: viewer.getSelected2() });
2956
3086
  selectionSet.delete();
2957
3087
  break;
2958
3088
  }
@@ -2979,13 +3109,14 @@
2979
3109
  viewer.markup.setMarkupColor(r, g, b);
2980
3110
  }
2981
3111
 
2982
- function setSelected(viewer, handles = []) {
3112
+ function setSelected(viewer, handles2 = []) {
2983
3113
  if (!viewer.visualizeJs)
2984
3114
  return;
3115
+ const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
2985
3116
  const visLib = viewer.visLib();
2986
3117
  const visViewer = viewer.visViewer();
2987
3118
  const selectionSet = new visLib.OdTvSelectionSet();
2988
- handles === null || handles === void 0 ? void 0 : handles.forEach((handle) => {
3119
+ handles.forEach((handle) => {
2989
3120
  const entityId = visViewer.getEntityByOriginalHandle(handle + "");
2990
3121
  if (!entityId.isNull())
2991
3122
  selectionSet.appendEntity(entityId);
@@ -2993,9 +3124,25 @@
2993
3124
  visViewer.setSelected(selectionSet);
2994
3125
  viewer.update();
2995
3126
  viewer.emitEvent({ type: "select", data: selectionSet, handles });
3127
+ viewer.emitEvent({ type: "select2", data: selectionSet, handles: handles2 });
2996
3128
  selectionSet.delete();
2997
3129
  }
2998
3130
 
3131
+ function setSelected2(viewer, handles2 = []) {
3132
+ const handles = [];
3133
+ handles2.forEach((handle) => {
3134
+ if (!handle.includes(":")) {
3135
+ handles.push(handle);
3136
+ }
3137
+ else
3138
+ viewer.models.forEach((model) => {
3139
+ if (handle.split(":", 1)[0] === model.id + "")
3140
+ handles.push(handle);
3141
+ });
3142
+ });
3143
+ return viewer.executeCommand("setSelected", handles);
3144
+ }
3145
+
2999
3146
  function showAll(viewer) {
3000
3147
  if (!viewer.visualizeJs)
3001
3148
  return;
@@ -3118,6 +3265,7 @@
3118
3265
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
3119
3266
  commands.registerCommand("getModels", getModels);
3120
3267
  commands.registerCommand("getSelected", getSelected);
3268
+ commands.registerCommand("getSelected2", getSelected2);
3121
3269
  commands.registerCommand("hideSelected", hideSelected);
3122
3270
  commands.registerCommand("isolateSelected", isolateSelected);
3123
3271
  commands.registerCommand("regenerateAll", regenerateAll);
@@ -3127,6 +3275,7 @@
3127
3275
  commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
3128
3276
  commands.registerCommand("setMarkupColor", setMarkupColor);
3129
3277
  commands.registerCommand("setSelected", setSelected);
3278
+ commands.registerCommand("setSelected2", setSelected2);
3130
3279
  commands.registerCommand("showAll", showAll);
3131
3280
  commands.registerCommand("zoomToExtents", zoomToExtents);
3132
3281
  commands.registerCommand("zoomToObjects", zoomToObjects);
@@ -3475,6 +3624,10 @@
3475
3624
  components.registerComponent("GestureManagerComponent", (viewer) => new GestureManagerComponent(viewer));
3476
3625
  components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));
3477
3626
 
3627
+ class ModelImpl {
3628
+ dispose() { }
3629
+ }
3630
+
3478
3631
  class FileLoader {
3479
3632
  constructor() {
3480
3633
  this.requestHeader = {};
@@ -3558,7 +3711,7 @@
3558
3711
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
3559
3712
  /vsf$/i.test(format));
3560
3713
  }
3561
- async load(file, format, params) {
3714
+ async load(file, format, params = {}) {
3562
3715
  if (!this.viewer.visualizeJs)
3563
3716
  return this;
3564
3717
  const visViewer = this.viewer.visViewer();
@@ -3582,6 +3735,9 @@
3582
3735
  console.error("VSF parse error.", error);
3583
3736
  throw error;
3584
3737
  }
3738
+ const modelImpl = new ModelImpl();
3739
+ modelImpl.id = params.modelId || this.extractFileName(file);
3740
+ this.viewer.models.push(modelImpl);
3585
3741
  this.viewer.syncOptions();
3586
3742
  this.viewer.syncOverlay();
3587
3743
  this.viewer.update(true);
@@ -3625,6 +3781,9 @@
3625
3781
  throw error;
3626
3782
  }
3627
3783
  if (i === 0) {
3784
+ const modelImpl = new ModelImpl();
3785
+ modelImpl.id = model.file.id;
3786
+ this.viewer.models.push(modelImpl);
3628
3787
  this.viewer.syncOptions();
3629
3788
  this.viewer.syncOverlay();
3630
3789
  this.viewer.update(true);
@@ -3649,7 +3808,7 @@
3649
3808
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
3650
3809
  /vsfx$/i.test(format));
3651
3810
  }
3652
- async load(file, format, params) {
3811
+ async load(file, format, params = {}) {
3653
3812
  if (!this.viewer.visualizeJs)
3654
3813
  return this;
3655
3814
  const visViewer = this.viewer.visViewer();
@@ -3673,6 +3832,9 @@
3673
3832
  console.error("VSFX parse error.", error);
3674
3833
  throw error;
3675
3834
  }
3835
+ const modelImpl = new ModelImpl();
3836
+ modelImpl.id = params.modelId || this.extractFileName(file);
3837
+ this.viewer.models.push(modelImpl);
3676
3838
  this.viewer.syncOptions();
3677
3839
  this.viewer.syncOverlay();
3678
3840
  this.viewer.update(true);
@@ -3693,7 +3855,7 @@
3693
3855
  /.vsfx$/i.test(file.database) &&
3694
3856
  this.viewer.options.enableStreamingMode === false);
3695
3857
  }
3696
- async load(model, format, params = {}) {
3858
+ async load(model) {
3697
3859
  if (!this.viewer.visualizeJs)
3698
3860
  return Promise.resolve(this);
3699
3861
  const visViewer = this.viewer.visViewer();
@@ -3712,6 +3874,9 @@
3712
3874
  console.error("VSFX parse error.", error);
3713
3875
  throw error;
3714
3876
  }
3877
+ const modelImpl = new ModelImpl();
3878
+ modelImpl.id = model.file.id;
3879
+ this.viewer.models.push(modelImpl);
3715
3880
  this.viewer.syncOptions();
3716
3881
  this.viewer.syncOverlay();
3717
3882
  this.viewer.update(true);
@@ -3790,6 +3955,9 @@
3790
3955
  isDatabaseChunk = true;
3791
3956
  }
3792
3957
  if (isDatabaseChunk) {
3958
+ const modelImpl = new ModelImpl();
3959
+ modelImpl.id = model.file.id;
3960
+ this.viewer.models.push(modelImpl);
3793
3961
  this.viewer.syncOptions();
3794
3962
  this.viewer.syncOverlay();
3795
3963
  updateController.update(UpdateType.kForce);
@@ -3824,7 +3992,7 @@
3824
3992
  /.vsfx$/i.test(file.database) &&
3825
3993
  (this.viewer.options.enablePartialMode === true || /.rcs$/i.test(file.name)));
3826
3994
  }
3827
- async load(model, format) {
3995
+ async load(model) {
3828
3996
  if (!this.viewer.visualizeJs)
3829
3997
  return this;
3830
3998
  const visViewer = this.viewer.visViewer();
@@ -3850,6 +4018,9 @@
3850
4018
  }
3851
4019
  this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
3852
4020
  if (isDatabaseChunk) {
4021
+ const modelImpl = new ModelImpl();
4022
+ modelImpl.id = model.file.id;
4023
+ this.viewer.models.push(modelImpl);
3853
4024
  this.viewer.syncOptions();
3854
4025
  this.viewer.syncOverlay();
3855
4026
  updateController.update(UpdateType.kForce);
@@ -17811,27 +17982,35 @@ js: import "konva/skia-backend";
17811
17982
  super();
17812
17983
  this._visualizeJsUrl = "";
17813
17984
  this.configure(params);
17814
- this._options = new Options(this);
17815
17985
  this.client = client;
17986
+ this.options = new Options(this);
17816
17987
  this.loaders = [];
17988
+ this.models = [];
17989
+ this.info = new Info();
17990
+ this.canvasEvents = CANVAS_EVENTS.slice();
17991
+ this.canvaseventlistener = (event) => this.emit(event);
17817
17992
  this._activeDragger = null;
17818
17993
  this._components = [];
17994
+ this._renderNeeded = false;
17819
17995
  this._renderTime = 0;
17820
- this.canvasEvents = CANVAS_EVENTS.slice();
17821
- this.canvaseventlistener = (event) => this.emit(event);
17822
17996
  this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
17823
- this._renderNeeded = false;
17824
17997
  this._isRunAsyncUpdate = false;
17825
17998
  this.render = this.render.bind(this);
17826
17999
  this.update = this.update.bind(this);
17827
18000
  this._markup = MarkupFactory.createMarkup(params.markupType);
17828
18001
  }
17829
- get options() {
17830
- return this._options;
17831
- }
17832
18002
  get visualizeJsUrl() {
17833
18003
  return this._visualizeJsUrl;
17834
18004
  }
18005
+ get visualizeJs() {
18006
+ return this._visualizeJs;
18007
+ }
18008
+ visLib() {
18009
+ return this._visualizeJs;
18010
+ }
18011
+ visViewer() {
18012
+ return this._viewer;
18013
+ }
17835
18014
  get markup() {
17836
18015
  return this._markup;
17837
18016
  }
@@ -17840,13 +18019,20 @@ js: import "konva/skia-backend";
17840
18019
  this._crossOrigin = params.crossOrigin;
17841
18020
  return this;
17842
18021
  }
18022
+ get draggers() {
18023
+ return [...draggers.getDraggers().keys()];
18024
+ }
18025
+ get components() {
18026
+ return [...components.getComponents().keys()];
18027
+ }
17843
18028
  async initialize(canvas, onProgress) {
17844
18029
  this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
18030
+ const pixelRatio = window.devicePixelRatio;
17845
18031
  const rect = canvas.parentElement.getBoundingClientRect();
17846
18032
  const width = rect.width || 1;
17847
18033
  const height = rect.height || 1;
17848
- canvas.width = Math.round(width * window.devicePixelRatio);
17849
- canvas.height = Math.round(height * window.devicePixelRatio);
18034
+ canvas.width = Math.round(width * pixelRatio);
18035
+ canvas.height = Math.round(height * pixelRatio);
17850
18036
  canvas.style.width = width + "px";
17851
18037
  canvas.style.height = height + "px";
17852
18038
  canvas.parentElement.style.touchAction = "none";
@@ -17914,6 +18100,26 @@ js: import "konva/skia-backend";
17914
18100
  this.update(true);
17915
18101
  this.emitEvent({ type: "resize", width, height });
17916
18102
  }
18103
+ resize() {
18104
+ console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
18105
+ if (!this.visualizeJs)
18106
+ return this;
18107
+ if (!this.canvas.parentElement)
18108
+ return this;
18109
+ const { width, height } = this.canvas.parentElement.getBoundingClientRect();
18110
+ if (!width || !height)
18111
+ return this;
18112
+ this.setSize(width, height);
18113
+ return this;
18114
+ }
18115
+ update(force = false) {
18116
+ if (this._enableAutoUpdate) {
18117
+ this._renderNeeded = true;
18118
+ if (force)
18119
+ this.render();
18120
+ }
18121
+ this.emitEvent({ type: "update", data: force });
18122
+ }
17917
18123
  render(time) {
17918
18124
  var _a, _b;
17919
18125
  if (!this.visualizeJs)
@@ -17932,139 +18138,228 @@ js: import "konva/skia-backend";
17932
18138
  (_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
17933
18139
  this.emitEvent({ type: "render", time, deltaTime });
17934
18140
  }
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.");
18141
+ async loadReferences(model) {
18142
+ var _a;
17937
18143
  if (!this.visualizeJs)
17938
18144
  return this;
17939
- if (!this.canvas.parentElement)
18145
+ if (!this.client)
17940
18146
  return this;
17941
- const { width, height } = this.canvas.parentElement.getBoundingClientRect();
17942
- if (!width || !height)
18147
+ if (!model.getReferences)
17943
18148
  return this;
17944
- this.setSize(width, height);
17945
- return this;
17946
- }
17947
- update(force = false) {
17948
- if (this._enableAutoUpdate) {
17949
- this._renderNeeded = true;
17950
- if (force)
17951
- this.render();
18149
+ const abortController = new AbortController();
18150
+ (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
18151
+ this._abortControllerForReferences = abortController;
18152
+ let references = [];
18153
+ await model
18154
+ .getReferences(abortController.signal)
18155
+ .then((data) => (references = data.references))
18156
+ .catch((e) => console.error("Cannot load model references.", e));
18157
+ for (const file of references) {
18158
+ await this.client
18159
+ .downloadFile(file.id, undefined, abortController.signal)
18160
+ .then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
18161
+ .catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
17952
18162
  }
17953
- this.emitEvent({ type: "update", data: force });
18163
+ return this;
17954
18164
  }
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
- });
18165
+ applyModelTransformMatrix(model) {
18166
+ this.executeCommand("applyModelTransform", model);
17973
18167
  }
17974
- async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
18168
+ applySceneGraphSettings(options = this.options) {
17975
18169
  if (!this.visualizeJs)
17976
18170
  return;
17977
- this._isRunAsyncUpdate = true;
17978
- 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);
17984
- }
17985
- catch (e) {
17986
- console.error(e);
17987
- }
17988
- finally {
17989
- this._isRunAsyncUpdate = false;
17990
- }
17991
- }
17992
- get visualizeJs() {
17993
- return this._visualizeJs;
17994
- }
17995
- visLib() {
17996
- return this._visualizeJs;
17997
- }
17998
- visViewer() {
17999
- return this._viewer;
18000
- }
18001
- syncOpenCloudVisualStyle() {
18002
- if (!this.visualizeJs)
18003
- return this;
18004
18171
  const visLib = this.visLib();
18005
18172
  const visViewer = this.visViewer();
18006
18173
  const device = visViewer.getActiveDevice();
18007
- if (device.isNull())
18008
- return this;
18009
- const view = device.getActiveView();
18010
- view.enableDefaultLighting(true, visLib.DefaultLightingType.kTwoLights);
18011
- view.setDefaultLightingIntensity(1.25);
18012
- let visualStyleId;
18013
- try {
18014
- visualStyleId = visViewer.findVisualStyle("OpenCloud");
18015
- }
18016
- catch {
18017
- visualStyleId = undefined;
18018
- }
18019
- if (!visualStyleId || visualStyleId.isNull()) {
18020
- visualStyleId = visViewer.createVisualStyle("OpenCloud");
18021
- const colorDef = new visLib.OdTvColorDef(66, 66, 66);
18022
- const shadedVsId = visViewer.findVisualStyle("Realistic");
18023
- const visualStylePtr = visualStyleId.openObject();
18024
- visualStylePtr.copyFrom(shadedVsId);
18025
- visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kFaceModifiers, 0, visLib.VisualStyleOperations.kSet);
18026
- visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModel, 2, visLib.VisualStyleOperations.kSet);
18027
- visualStylePtr.setOptionDouble(visLib.VisualStyleOptions.kEdgeCreaseAngle, 60, visLib.VisualStyleOperations.kSet);
18028
- visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeStyles, 0, visLib.VisualStyleOperations.kSet);
18029
- visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModifiers, 8, visLib.VisualStyleOperations.kSet);
18030
- visualStylePtr.setOptionColor(visLib.VisualStyleOptions.kEdgeColorValue, colorDef, visLib.VisualStyleOperations.kSet);
18031
- visualStylePtr.delete();
18174
+ if (isExist(options.sceneGraph)) {
18175
+ device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
18032
18176
  }
18033
- view.visualStyle = visualStyleId;
18034
- view.delete();
18035
18177
  device.delete();
18036
- return this;
18178
+ this.update();
18037
18179
  }
18038
- syncOptions(options = this.options) {
18180
+ async open(file, params = {}) {
18039
18181
  if (!this.visualizeJs)
18040
18182
  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
- if (options.showWCS !== visViewer.getEnableWCS()) {
18048
- visViewer.setEnableWCS(options.showWCS);
18183
+ this.cancel();
18184
+ this.clear();
18185
+ this.emitEvent({ type: "open", mode: "file", file });
18186
+ let model = file;
18187
+ if (model && typeof model.getModels === "function") {
18188
+ const models = await model.getModels();
18189
+ model = models.find((model) => model.default) || models[0] || file;
18049
18190
  }
18050
- if (options.cameraAnimation !== visViewer.getEnableAnimation()) {
18051
- visViewer.setEnableAnimation(options.cameraAnimation);
18191
+ if (model && typeof model.database === "string") {
18192
+ file = model.file;
18052
18193
  }
18053
- const antialiasing = options.antialiasing === true || options.antialiasing === "fxaa";
18054
- if (antialiasing !== visViewer.fxaaAntiAliasing3d) {
18055
- visViewer.fxaaAntiAliasing3d = antialiasing;
18056
- visViewer.fxaaQuality = 5;
18194
+ if (!model)
18195
+ throw new Error(`Format not supported`);
18196
+ let format = params.format;
18197
+ if (!format && typeof file["type"] === "string")
18198
+ format = file["type"].split(".").pop();
18199
+ if (!format && typeof file === "string")
18200
+ format = file.split(".").pop();
18201
+ if (!format && file instanceof globalThis.File)
18202
+ format = file.name.split(".").pop();
18203
+ const loader = loaders.createLoader(this, model, format);
18204
+ if (!loader)
18205
+ throw new Error(`Format not supported`);
18206
+ this.loaders.push(loader);
18207
+ this.emitEvent({ type: "geometrystart", file, model });
18208
+ try {
18209
+ await this.loadReferences(model);
18210
+ await loader.load(model, format, params);
18057
18211
  }
18058
- if (options.shadows !== visViewer.shadows) {
18059
- visViewer.shadows = options.shadows;
18060
- const canvas = visLib.canvas;
18061
- device.invalidate([0, canvas.width, canvas.height, 0]);
18212
+ catch (error) {
18213
+ this.emitEvent({ type: "geometryerror", data: error, file, model });
18214
+ throw error;
18062
18215
  }
18063
- if (options.groundShadow !== visViewer.groundShadow) {
18064
- visViewer.groundShadow = options.groundShadow;
18216
+ this.emitEvent({ type: "geometryend", file, model });
18217
+ if (this.visualizeJs) {
18218
+ this.applyModelTransformMatrix(model);
18219
+ this.applySceneGraphSettings();
18065
18220
  }
18066
- if (options.ambientOcclusion !== device.getOptionBool(visLib.DeviceOptions.kSSAOEnable)) {
18067
- device.setOptionBool(visLib.DeviceOptions.kSSAOEnable, options.ambientOcclusion);
18221
+ return this;
18222
+ }
18223
+ openVsfFile(buffer) {
18224
+ console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
18225
+ if (!this.visualizeJs)
18226
+ return this;
18227
+ this.cancel();
18228
+ this.clear();
18229
+ this.emitEvent({ type: "open", mode: "file", file: "", buffer });
18230
+ const visViewer = this.visViewer();
18231
+ this.emitEvent({ type: "geometrystart", file: "", buffer });
18232
+ try {
18233
+ const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
18234
+ visViewer.parseFile(data);
18235
+ this.syncOptions();
18236
+ this.syncOverlay();
18237
+ this.update(true);
18238
+ this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
18239
+ this.emitEvent({ type: "databasechunk", data, file: "", buffer });
18240
+ }
18241
+ catch (error) {
18242
+ this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
18243
+ throw error;
18244
+ }
18245
+ this.emitEvent({ type: "geometryend", file: "", buffer });
18246
+ return this;
18247
+ }
18248
+ openVsfxFile(buffer) {
18249
+ console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
18250
+ if (!this.visualizeJs)
18251
+ return this;
18252
+ this.cancel();
18253
+ this.clear();
18254
+ this.emitEvent({ type: "open", mode: "file", file: "", buffer });
18255
+ const visViewer = this.visViewer();
18256
+ this.emitEvent({ type: "geometrystart", file: "", buffer });
18257
+ try {
18258
+ const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
18259
+ visViewer.parseVsfx(data);
18260
+ this.syncOptions();
18261
+ this.syncOverlay();
18262
+ this.update(true);
18263
+ this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
18264
+ this.emitEvent({ type: "databasechunk", data, file: "", buffer });
18265
+ }
18266
+ catch (error) {
18267
+ this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
18268
+ throw error;
18269
+ }
18270
+ this.emitEvent({ type: "geometryend", file: "", buffer });
18271
+ return this;
18272
+ }
18273
+ cancel() {
18274
+ var _a;
18275
+ (_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
18276
+ this._abortControllerForReferences = undefined;
18277
+ this.loaders.forEach((loader) => loader.cancel());
18278
+ this.emitEvent({ type: "cancel" });
18279
+ return this;
18280
+ }
18281
+ clear() {
18282
+ if (!this.visualizeJs)
18283
+ return this;
18284
+ const visViewer = this.visViewer();
18285
+ this.setActiveDragger();
18286
+ this.clearSlices();
18287
+ this.clearOverlay();
18288
+ this.clearSelected();
18289
+ this.loaders.forEach((loader) => loader.dispose());
18290
+ this.loaders = [];
18291
+ this.models.forEach((model) => model.dispose());
18292
+ this.models = [];
18293
+ visViewer.clear();
18294
+ visViewer.createLocalDatabase();
18295
+ this.syncOptions();
18296
+ this.syncOverlay();
18297
+ this.update(true);
18298
+ this.emitEvent({ type: "clear" });
18299
+ return this;
18300
+ }
18301
+ is3D() {
18302
+ if (!this.visualizeJs)
18303
+ return false;
18304
+ const visViewer = this.visViewer();
18305
+ const ext = visViewer.getActiveExtents();
18306
+ const min = ext.min();
18307
+ const max = ext.max();
18308
+ const extHeight = max[2] - min[2];
18309
+ return extHeight !== 0;
18310
+ }
18311
+ syncOptions(options = this.options) {
18312
+ if (!this.visualizeJs)
18313
+ return this;
18314
+ const visLib = this.visLib();
18315
+ const visViewer = this.visViewer();
18316
+ const device = visViewer.getActiveDevice();
18317
+ if (device.isNull())
18318
+ return this;
18319
+ const view = device.getActiveView();
18320
+ view.enableDefaultLighting(true, visLib.DefaultLightingType.kTwoLights);
18321
+ view.setDefaultLightingIntensity(1.25);
18322
+ let visualStyleId;
18323
+ try {
18324
+ visualStyleId = visViewer.findVisualStyle("OpenCloud");
18325
+ }
18326
+ catch {
18327
+ visualStyleId = undefined;
18328
+ }
18329
+ if (!visualStyleId || visualStyleId.isNull()) {
18330
+ visualStyleId = visViewer.createVisualStyle("OpenCloud");
18331
+ const colorDef = new visLib.OdTvColorDef(66, 66, 66);
18332
+ const shadedVsId = visViewer.findVisualStyle("Realistic");
18333
+ const visualStylePtr = visualStyleId.openObject();
18334
+ visualStylePtr.copyFrom(shadedVsId);
18335
+ visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kFaceModifiers, 0, visLib.VisualStyleOperations.kSet);
18336
+ visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModel, 2, visLib.VisualStyleOperations.kSet);
18337
+ visualStylePtr.setOptionDouble(visLib.VisualStyleOptions.kEdgeCreaseAngle, 60, visLib.VisualStyleOperations.kSet);
18338
+ visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeStyles, 0, visLib.VisualStyleOperations.kSet);
18339
+ visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModifiers, 8, visLib.VisualStyleOperations.kSet);
18340
+ visualStylePtr.setOptionColor(visLib.VisualStyleOptions.kEdgeColorValue, colorDef, visLib.VisualStyleOperations.kSet);
18341
+ visualStylePtr.delete();
18342
+ }
18343
+ view.visualStyle = visualStyleId;
18344
+ if (options.showWCS !== visViewer.getEnableWCS()) {
18345
+ visViewer.setEnableWCS(options.showWCS);
18346
+ }
18347
+ if (options.cameraAnimation !== visViewer.getEnableAnimation()) {
18348
+ visViewer.setEnableAnimation(options.cameraAnimation);
18349
+ }
18350
+ const antialiasing = options.antialiasing === true || options.antialiasing === "fxaa";
18351
+ if (antialiasing !== visViewer.fxaaAntiAliasing3d) {
18352
+ visViewer.fxaaAntiAliasing3d = antialiasing;
18353
+ visViewer.fxaaQuality = 5;
18354
+ }
18355
+ if (options.shadows !== visViewer.shadows) {
18356
+ visViewer.shadows = options.shadows;
18357
+ }
18358
+ if (options.groundShadow !== visViewer.groundShadow) {
18359
+ visViewer.groundShadow = options.groundShadow;
18360
+ }
18361
+ if (options.ambientOcclusion !== device.getOptionBool(visLib.DeviceOptions.kSSAOEnable)) {
18362
+ device.setOptionBool(visLib.DeviceOptions.kSSAOEnable, options.ambientOcclusion);
18068
18363
  device.setOptionBool(visLib.DeviceOptions.kSSAODynamicRadius, true);
18069
18364
  device.setOptionDouble(visLib.DeviceOptions.kSSAORadius, 1);
18070
18365
  device.setOptionInt32(visLib.DeviceOptions.kSSAOLoops, 32);
@@ -18084,17 +18379,7 @@ js: import "konva/skia-backend";
18084
18379
  visualStyleId.delete();
18085
18380
  activeView.delete();
18086
18381
  }
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
18382
  const params = options.enableCustomHighlight ? options : Options.defaults();
18096
- const visLib = this.visLib();
18097
- const visViewer = this.visViewer();
18098
18383
  const { Entry, OdTvRGBColorDef } = visLib;
18099
18384
  const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
18100
18385
  const highlightStylePtr = highlightStyleId.openObject();
@@ -18121,19 +18406,80 @@ js: import "konva/skia-backend";
18121
18406
  const visibility = !isExist(params.edgesVisibility) ? true : params.edgesVisibility;
18122
18407
  highlightStylePtr.setEdgesVisibility(Entry.k2DTop.value | Entry.k3DTop.value, params.edgesOverlap && visibility);
18123
18408
  }
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
- }
18409
+ view.delete();
18410
+ device.delete();
18411
+ this.update();
18130
18412
  return this;
18131
18413
  }
18132
- get draggers() {
18133
- return [...draggers.getDraggers().keys()];
18414
+ syncOverlay() {
18415
+ if (!this.visualizeJs)
18416
+ return;
18417
+ const visViewer = this.visViewer();
18418
+ const activeView = visViewer.activeView;
18419
+ let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
18420
+ if (!overlayView) {
18421
+ const markupModel = visViewer.getMarkupModel();
18422
+ const pDevice = visViewer.getActiveDevice();
18423
+ overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
18424
+ overlayView.addModel(markupModel);
18425
+ activeView.addSibling(overlayView);
18426
+ pDevice.addView(overlayView);
18427
+ }
18428
+ overlayView.viewPosition = activeView.viewPosition;
18429
+ overlayView.viewTarget = activeView.viewTarget;
18430
+ overlayView.upVector = activeView.upVector;
18431
+ overlayView.viewFieldWidth = activeView.viewFieldWidth;
18432
+ overlayView.viewFieldHeight = activeView.viewFieldHeight;
18433
+ const viewPort = overlayView.getViewport();
18434
+ overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
18435
+ overlayView.vportRect = activeView.vportRect;
18436
+ this._markup.syncOverlay();
18437
+ this.update();
18134
18438
  }
18135
- get components() {
18136
- return [...components.getComponents().keys()];
18439
+ clearOverlay() {
18440
+ if (!this.visualizeJs)
18441
+ return;
18442
+ this._markup.clearOverlay();
18443
+ this.update();
18444
+ }
18445
+ clearSlices() {
18446
+ if (!this.visualizeJs)
18447
+ return;
18448
+ const visViewer = this.visViewer();
18449
+ const activeView = visViewer.activeView;
18450
+ activeView.removeCuttingPlanes();
18451
+ activeView.delete();
18452
+ this.update();
18453
+ }
18454
+ getSelected() {
18455
+ return this.executeCommand("getSelected");
18456
+ }
18457
+ setSelected(handles) {
18458
+ this.executeCommand("setSelected", handles);
18459
+ }
18460
+ getSelected2() {
18461
+ return this.executeCommand("getSelected2");
18462
+ }
18463
+ setSelected2(handles) {
18464
+ this.executeCommand("setSelected2", handles);
18465
+ }
18466
+ clearSelected() {
18467
+ this.executeCommand("clearSelected");
18468
+ }
18469
+ hideSelected() {
18470
+ this.executeCommand("hideSelected");
18471
+ }
18472
+ isolateSelected() {
18473
+ this.executeCommand("isolateSelected");
18474
+ }
18475
+ showAll() {
18476
+ this.executeCommand("showAll");
18477
+ }
18478
+ explode(index = 0) {
18479
+ this.executeCommand("explode", index);
18480
+ }
18481
+ collect() {
18482
+ this.executeCommand("collect");
18137
18483
  }
18138
18484
  registerDragger(name, dragger) {
18139
18485
  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 +18526,102 @@ js: import "konva/skia-backend";
18180
18526
  getComponent(name) {
18181
18527
  return this._components.find((component) => component.name === name);
18182
18528
  }
18183
- clearSlices() {
18529
+ drawViewpoint(viewpoint) {
18530
+ var _a, _b;
18184
18531
  if (!this.visualizeJs)
18185
18532
  return;
18186
18533
  const visViewer = this.visViewer();
18187
18534
  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();
18535
+ const getPoint3dAsArray = (point3d) => {
18536
+ return [point3d.x, point3d.y, point3d.z];
18537
+ };
18538
+ const setOrthogonalCamera = (orthogonal_camera) => {
18539
+ if (orthogonal_camera) {
18540
+ 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);
18541
+ this.syncOverlay();
18542
+ this.emitEvent({ type: "changecameramode", mode: "orthographic" });
18543
+ }
18544
+ };
18545
+ const setPerspectiveCamera = (perspective_camera) => { };
18546
+ const setClippingPlanes = (clipping_planes) => {
18547
+ if (clipping_planes) {
18548
+ for (const clipping_plane of clipping_planes) {
18549
+ const cuttingPlane = new (this.visLib().OdTvPlane)();
18550
+ cuttingPlane.set(getPoint3dAsArray(clipping_plane.location), getPoint3dAsArray(clipping_plane.direction));
18551
+ activeView.addCuttingPlane(cuttingPlane);
18552
+ activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
18553
+ }
18554
+ }
18555
+ };
18556
+ const setSelection = (selection) => {
18557
+ if (selection)
18558
+ this.setSelected(selection.map((component) => component.handle));
18559
+ };
18560
+ const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
18561
+ this.setActiveDragger();
18562
+ this.clearSlices();
18563
+ this.clearOverlay();
18564
+ this.clearSelected();
18565
+ this.showAll();
18566
+ this.explode();
18567
+ setOrthogonalCamera(viewpoint.orthogonal_camera);
18568
+ setPerspectiveCamera(viewpoint.perspective_camera);
18569
+ setClippingPlanes(viewpoint.clipping_planes);
18570
+ setSelection(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.selection2) || viewpoint.selection);
18571
+ this._markup.setViewpoint(viewpoint);
18572
+ this.setActiveDragger(draggerName);
18573
+ this.emitEvent({ type: "drawviewpoint", data: viewpoint });
18196
18574
  this.update();
18197
18575
  }
18198
- syncOverlay() {
18576
+ createViewpoint() {
18199
18577
  if (!this.visualizeJs)
18200
- return;
18578
+ return {};
18201
18579
  const visViewer = this.visViewer();
18202
18580
  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;
18581
+ const getPoint3dFromArray = (array) => {
18582
+ return { x: array[0], y: array[1], z: array[2] };
18583
+ };
18584
+ const getOrthogonalCamera = () => {
18585
+ return {
18586
+ view_point: getPoint3dFromArray(activeView.viewPosition),
18587
+ direction: getPoint3dFromArray(activeView.viewTarget),
18588
+ up_vector: getPoint3dFromArray(activeView.upVector),
18589
+ field_width: activeView.viewFieldWidth,
18590
+ field_height: activeView.viewFieldHeight,
18591
+ view_to_world_scale: 1,
18592
+ };
18593
+ };
18594
+ const getPerspectiveCamera = () => {
18595
+ return undefined;
18596
+ };
18597
+ const getClippingPlanes = () => {
18598
+ const clipping_planes = [];
18599
+ for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
18600
+ const cuttingPlane = activeView.getCuttingPlane(i);
18601
+ const clipping_plane = {
18602
+ location: getPoint3dFromArray(cuttingPlane.getOrigin()),
18603
+ direction: getPoint3dFromArray(cuttingPlane.normal()),
18604
+ };
18605
+ clipping_planes.push(clipping_plane);
18606
+ }
18607
+ return clipping_planes;
18608
+ };
18609
+ const getSelection = () => {
18610
+ return this.getSelected().map((handle) => ({ handle }));
18611
+ };
18612
+ const getSelection2 = () => {
18613
+ return this.getSelected2().map((handle) => ({ handle }));
18614
+ };
18615
+ const viewpoint = { custom_fields: {} };
18616
+ viewpoint.orthogonal_camera = getOrthogonalCamera();
18617
+ viewpoint.perspective_camera = getPerspectiveCamera();
18618
+ viewpoint.clipping_planes = getClippingPlanes();
18619
+ viewpoint.selection = getSelection();
18620
+ viewpoint.description = new Date().toDateString();
18621
+ this._markup.getViewpoint(viewpoint);
18622
+ viewpoint.custom_fields.selection2 = getSelection2();
18623
+ this.emitEvent({ type: "createviewpoint", data: viewpoint });
18624
+ return viewpoint;
18232
18625
  }
18233
18626
  screenToWorld(position) {
18234
18627
  if (!this.visualizeJs)
@@ -18263,184 +18656,23 @@ js: import "konva/skia-backend";
18263
18656
  result.z = 1 / z;
18264
18657
  return result;
18265
18658
  }
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);
18659
+ executeCommand(id, ...args) {
18660
+ return commands.executeCommand(id, this, ...args);
18316
18661
  }
18317
- applySceneGraphSettings(options = this.options) {
18662
+ addMarkupEntity(entityName) {
18318
18663
  if (!this.visualizeJs)
18319
- return;
18320
- const visLib = this.visLib();
18664
+ return null;
18665
+ this.syncOverlay();
18321
18666
  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();
18667
+ const model = visViewer.getMarkupModel();
18668
+ const entityId = model.appendEntity(entityName);
18669
+ const entityPtr = entityId.openObject();
18670
+ const color = this.getMarkupColor();
18671
+ entityPtr.setColor(color.r, color.g, color.b);
18672
+ entityPtr.setLineWeight(2);
18673
+ entityPtr.delete();
18327
18674
  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;
18675
+ return entityId;
18444
18676
  }
18445
18677
  getMarkupColor() {
18446
18678
  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 +18689,43 @@ js: import "konva/skia-backend";
18457
18689
  colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
18458
18690
  this._markup.colorizeSelectedMarkups(r, g, b);
18459
18691
  }
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;
18692
+ scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
18693
+ return new Promise((resolve, reject) => {
18694
+ setTimeout(() => {
18695
+ var _a, _b, _c;
18696
+ try {
18697
+ if (this._enableAutoUpdate) {
18698
+ (_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
18699
+ (_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
18700
+ }
18701
+ this.emitEvent({ type: "update", data: false });
18702
+ resolve();
18703
+ }
18704
+ catch (e) {
18705
+ console.error(e);
18706
+ reject();
18707
+ }
18708
+ }, 0);
18709
+ });
18474
18710
  }
18475
- drawViewpoint(viewpoint) {
18476
- var _a;
18711
+ async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
18477
18712
  if (!this.visualizeJs)
18478
18713
  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();
18714
+ this._isRunAsyncUpdate = true;
18715
+ try {
18716
+ const device = this.visViewer().getActiveDevice();
18717
+ for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
18718
+ await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
18719
+ }
18720
+ await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
18530
18721
  }
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);
18722
+ catch (e) {
18723
+ console.error(e);
18543
18724
  }
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
- }
18725
+ finally {
18726
+ this._isRunAsyncUpdate = false;
18556
18727
  }
18557
18728
  }
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
18729
  deviceAutoRegeneration() {
18568
18730
  const visViewer = this.visViewer();
18569
18731
  const device = visViewer.getActiveDevice();
@@ -18580,6 +18742,7 @@ js: import "konva/skia-backend";
18580
18742
  exports.Component = Component;
18581
18743
  exports.Dragger = Dragger;
18582
18744
  exports.FileLoader = FileLoader;
18745
+ exports.Info = Info;
18583
18746
  exports.Loader = Loader;
18584
18747
  exports.Markup = KonvaMarkup;
18585
18748
  exports.OdBaseDragger = OdBaseDragger;