@inweb/viewer-visualize 26.10.5 → 26.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/viewer-visualize.js +591 -475
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +583 -483
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Commands/GetSelected2.d.ts +2 -0
- package/lib/Viewer/Commands/SetSelected.d.ts +1 -1
- package/lib/Viewer/Commands/SetSelected2.d.ts +2 -0
- package/lib/Viewer/Components/index.d.ts +8 -7
- package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +5 -1
- package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +3 -2
- package/lib/Viewer/Loaders/VSFXCloudLoader.d.ts +1 -1
- package/lib/Viewer/Loaders/VSFXCloudPartialLoader.d.ts +1 -1
- package/lib/Viewer/Loaders/index.d.ts +14 -9
- package/lib/Viewer/Models/IModelImpl.d.ts +5 -0
- package/lib/Viewer/Models/ModelImpl.d.ts +5 -0
- package/lib/Viewer/Viewer.d.ts +129 -136
- package/package.json +5 -5
- package/src/Viewer/Commands/ClearSelected.ts +3 -1
- package/src/Viewer/Commands/GetSelected2.ts +33 -0
- package/src/Viewer/Commands/HideSelected.ts +3 -1
- package/src/Viewer/Commands/SelectModel.ts +2 -3
- package/src/Viewer/Commands/SetSelected.ts +5 -2
- package/src/Viewer/Commands/SetSelected2.ts +39 -0
- package/src/Viewer/Commands/index.ts +4 -0
- package/src/Viewer/Components/index.ts +8 -7
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +3 -2
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +44 -13
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +53 -18
- package/src/Viewer/Draggers/OdJoyStickDragger.ts +2 -2
- package/src/Viewer/Loaders/VSFCloudLoader.ts +6 -0
- package/src/Viewer/Loaders/VSFFileLoader.ts +7 -1
- package/src/Viewer/Loaders/VSFXCloudLoader.ts +7 -1
- package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +8 -2
- package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +7 -1
- package/src/Viewer/Loaders/VSFXFileLoader.ts +7 -1
- package/src/Viewer/Loaders/index.ts +14 -9
- package/src/Viewer/Models/IModelImpl.ts +29 -0
- package/src/Viewer/Models/ModelImpl.ts +32 -0
- package/src/Viewer/Viewer.ts +780 -775
package/dist/viewer-visualize.js
CHANGED
|
@@ -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
|
}
|
|
@@ -707,8 +723,8 @@
|
|
|
707
723
|
viewer.select(x, y, x, y);
|
|
708
724
|
this.subject.update();
|
|
709
725
|
const selectionSet = viewer.getSelected();
|
|
710
|
-
|
|
711
|
-
this.onmessage({ type: "
|
|
726
|
+
this.onmessage({ type: "select", data: selectionSet, handles: this.subject.getSelected() });
|
|
727
|
+
this.onmessage({ type: "select2", data: selectionSet, handles: this.subject.getSelected2() });
|
|
712
728
|
}
|
|
713
729
|
}
|
|
714
730
|
dblclick(ev) {
|
|
@@ -896,8 +912,9 @@
|
|
|
896
912
|
this.htmlElemTitle = null;
|
|
897
913
|
this.startPoint = null;
|
|
898
914
|
this.endPoint = null;
|
|
899
|
-
this.unit = "";
|
|
900
915
|
this.scale = 1.0;
|
|
916
|
+
this.unit = "";
|
|
917
|
+
this.precision = 2;
|
|
901
918
|
this.size = 10.0;
|
|
902
919
|
this.lineThickness = 2;
|
|
903
920
|
this.style = {
|
|
@@ -982,10 +999,9 @@
|
|
|
982
999
|
this.htmlElemLine.style.background = this.style.background;
|
|
983
1000
|
this.htmlElemLine.style.zIndex = "1";
|
|
984
1001
|
this.htmlElemLine.style.height = `${height}px`;
|
|
985
|
-
const distance =
|
|
1002
|
+
const distance = this.getDistance();
|
|
986
1003
|
const pX = p1.x + dx / 2;
|
|
987
1004
|
const pY = p1.y + dy / 2;
|
|
988
|
-
const widthTitle = distance.length * 10;
|
|
989
1005
|
this.htmlElemTitle = createHtmlElementIfNeed(this.htmlElemTitle, this.targetElement, "ruler-value");
|
|
990
1006
|
this.htmlElemTitle.style.display = "block";
|
|
991
1007
|
this.htmlElemTitle.style.cursor = "pointer";
|
|
@@ -993,9 +1009,8 @@
|
|
|
993
1009
|
this.htmlElemTitle.style.color = "white";
|
|
994
1010
|
this.htmlElemTitle.style.position = "Absolute";
|
|
995
1011
|
this.htmlElemTitle.style.top = `${pY}px`;
|
|
996
|
-
this.htmlElemTitle.style.left = `${pX
|
|
997
|
-
this.htmlElemTitle.style.
|
|
998
|
-
this.htmlElemTitle.style.transformOrigin = "0px 0px";
|
|
1012
|
+
this.htmlElemTitle.style.left = `${pX}px`;
|
|
1013
|
+
this.htmlElemTitle.style.transform = "translate(-50%, -50%)";
|
|
999
1014
|
this.htmlElemTitle.style.borderRadius = "5px";
|
|
1000
1015
|
this.htmlElemTitle.style.boxShadow = this.style.boxShadow;
|
|
1001
1016
|
this.htmlElemTitle.style.border = "none";
|
|
@@ -1003,7 +1018,7 @@
|
|
|
1003
1018
|
this.htmlElemTitle.style.zIndex = "3";
|
|
1004
1019
|
this.htmlElemTitle.style.padding = "2px";
|
|
1005
1020
|
this.htmlElemTitle.style.textAlign = "center";
|
|
1006
|
-
this.htmlElemTitle.innerHTML =
|
|
1021
|
+
this.htmlElemTitle.innerHTML = this.formatDistance(distance);
|
|
1007
1022
|
}
|
|
1008
1023
|
else {
|
|
1009
1024
|
this.htmlElemLine.style.display = "none";
|
|
@@ -1013,11 +1028,43 @@
|
|
|
1013
1028
|
}
|
|
1014
1029
|
getDistance() {
|
|
1015
1030
|
let distance = getDistance(this.startPoint, this.endPoint, this.moduleInstance);
|
|
1016
|
-
if (Math.abs(this.scale
|
|
1017
|
-
distance
|
|
1018
|
-
}
|
|
1031
|
+
if (Math.abs(this.scale) > 1e-10)
|
|
1032
|
+
distance /= this.scale;
|
|
1019
1033
|
return distance;
|
|
1020
1034
|
}
|
|
1035
|
+
calculatePrecision(value) {
|
|
1036
|
+
const distance = Math.abs(value);
|
|
1037
|
+
if (distance >= 1000)
|
|
1038
|
+
return 0;
|
|
1039
|
+
if (distance >= 10)
|
|
1040
|
+
return 1;
|
|
1041
|
+
if (distance >= 0.1)
|
|
1042
|
+
return 2;
|
|
1043
|
+
if (distance >= 0.001)
|
|
1044
|
+
return 3;
|
|
1045
|
+
return distance > 0 ? Math.floor(-Math.log10(distance)) + 1 : 2;
|
|
1046
|
+
}
|
|
1047
|
+
formatDistance(distance) {
|
|
1048
|
+
let digits;
|
|
1049
|
+
if (this.precision === "Auto")
|
|
1050
|
+
digits = this.calculatePrecision(distance);
|
|
1051
|
+
else if (Number.isFinite(this.precision))
|
|
1052
|
+
digits = this.precision;
|
|
1053
|
+
else
|
|
1054
|
+
digits = parseFloat(this.precision);
|
|
1055
|
+
if (!Number.isFinite(digits))
|
|
1056
|
+
digits = 2;
|
|
1057
|
+
else if (digits < 0)
|
|
1058
|
+
digits = 0;
|
|
1059
|
+
else if (digits > 10)
|
|
1060
|
+
digits = 10;
|
|
1061
|
+
let result = distance.toFixed(digits);
|
|
1062
|
+
if (this.precision === "Auto")
|
|
1063
|
+
result = result.replace(/\.0+$/, "").replace(/\.$/, "");
|
|
1064
|
+
if (+result !== distance)
|
|
1065
|
+
result = "~ " + result;
|
|
1066
|
+
return `${result} ${this.unit}`;
|
|
1067
|
+
}
|
|
1021
1068
|
setStartPoint(gePoint) {
|
|
1022
1069
|
this.startPoint = gePoint;
|
|
1023
1070
|
this.drawMeasureLine();
|
|
@@ -1050,6 +1097,10 @@
|
|
|
1050
1097
|
this.scale = scale;
|
|
1051
1098
|
this.drawMeasureLine();
|
|
1052
1099
|
}
|
|
1100
|
+
setPrecision(precision) {
|
|
1101
|
+
this.precision = precision;
|
|
1102
|
+
this.drawMeasureLine();
|
|
1103
|
+
}
|
|
1053
1104
|
setStyle(style) {
|
|
1054
1105
|
this.style = style;
|
|
1055
1106
|
this.drawMeasureLine();
|
|
@@ -1072,14 +1123,14 @@
|
|
|
1072
1123
|
}
|
|
1073
1124
|
class MeasureLineDragger extends OdBaseDragger {
|
|
1074
1125
|
constructor(subject) {
|
|
1075
|
-
var _a;
|
|
1126
|
+
var _a, _b;
|
|
1076
1127
|
super(subject);
|
|
1077
1128
|
this.lineThickness = 2;
|
|
1078
1129
|
this.press = false;
|
|
1079
1130
|
this.gripingRadius = 5.0;
|
|
1080
1131
|
this.firstPoint = null;
|
|
1081
1132
|
this.secondPoint = null;
|
|
1082
|
-
this.
|
|
1133
|
+
this.rulerUnitTable = {
|
|
1083
1134
|
Millimeters: "mm",
|
|
1084
1135
|
Centimeters: "cm",
|
|
1085
1136
|
Meters: "m",
|
|
@@ -1089,13 +1140,14 @@
|
|
|
1089
1140
|
Kilometers: "km",
|
|
1090
1141
|
Miles: "mi",
|
|
1091
1142
|
Micrometers: "µm",
|
|
1143
|
+
Mils: "mil",
|
|
1092
1144
|
MicroInches: "µin",
|
|
1093
1145
|
Default: "unit",
|
|
1094
1146
|
};
|
|
1147
|
+
this.rulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
1148
|
+
this.rulerPrecision = (_b = subject.options.rulerPrecision) !== null && _b !== void 0 ? _b : "Default";
|
|
1095
1149
|
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);
|
|
1150
|
+
this.canvasEvents.push("resize", "optionsChange");
|
|
1099
1151
|
}
|
|
1100
1152
|
initialize() {
|
|
1101
1153
|
super.initialize();
|
|
@@ -1190,8 +1242,9 @@
|
|
|
1190
1242
|
const viewer = this.m_module.getViewer();
|
|
1191
1243
|
const item = new MeasureLineItem(this.m_overlayElement, viewer, this.m_module);
|
|
1192
1244
|
item.lineThickness = this.lineThickness || item.lineThickness;
|
|
1193
|
-
const isDefaultUnit =
|
|
1194
|
-
|
|
1245
|
+
const isDefaultUnit = this.rulerUnit === "Default";
|
|
1246
|
+
const isDefaultPrecision = this.rulerPrecision === "Default";
|
|
1247
|
+
item.setUnit(renameUnit(this.rulerUnitTable, isDefaultUnit ? viewer.getUnit() : this.rulerUnit));
|
|
1195
1248
|
if (!isDefaultUnit) {
|
|
1196
1249
|
const fromUnit = this.getKUnitByName(viewer.getUnit());
|
|
1197
1250
|
const toUnit = this.getKUnitByName(this.subject.options.rulerUnit);
|
|
@@ -1202,29 +1255,49 @@
|
|
|
1202
1255
|
else {
|
|
1203
1256
|
item.setConversionFactor(1.0);
|
|
1204
1257
|
}
|
|
1258
|
+
if (!isDefaultPrecision) {
|
|
1259
|
+
item.setPrecision(this.rulerPrecision);
|
|
1260
|
+
}
|
|
1261
|
+
else {
|
|
1262
|
+
item.setPrecision(2);
|
|
1263
|
+
}
|
|
1205
1264
|
this.items.push(item);
|
|
1206
1265
|
return item;
|
|
1207
1266
|
}
|
|
1208
1267
|
optionsChange(event) {
|
|
1209
|
-
var _a;
|
|
1268
|
+
var _a, _b;
|
|
1210
1269
|
const options = event.data;
|
|
1211
1270
|
const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
1212
|
-
|
|
1271
|
+
const toPrecision = (_b = options.rulerPrecision) !== null && _b !== void 0 ? _b : "Default";
|
|
1272
|
+
const unitChanged = this.rulerUnit !== toUnitName;
|
|
1273
|
+
const precisionChanged = this.rulerPrecision !== toPrecision;
|
|
1274
|
+
if (!unitChanged && !precisionChanged)
|
|
1213
1275
|
return;
|
|
1214
|
-
this.
|
|
1276
|
+
this.rulerUnit = toUnitName;
|
|
1277
|
+
this.rulerPrecision = toPrecision;
|
|
1215
1278
|
const drawingUnit = this.m_module.getViewer().getUnit();
|
|
1216
1279
|
const eToUnit = this.getKUnitByName(toUnitName);
|
|
1217
1280
|
const eFromUnit = this.getKUnitByName(drawingUnit);
|
|
1218
1281
|
this.items.forEach((item) => {
|
|
1219
|
-
if (
|
|
1220
|
-
|
|
1221
|
-
|
|
1282
|
+
if (unitChanged) {
|
|
1283
|
+
if (toUnitName === "Default") {
|
|
1284
|
+
item.setUnit(renameUnit(this.rulerUnitTable, drawingUnit));
|
|
1285
|
+
item.setConversionFactor(1.0);
|
|
1286
|
+
}
|
|
1287
|
+
else {
|
|
1288
|
+
item.setUnit(renameUnit(this.rulerUnitTable, toUnitName));
|
|
1289
|
+
const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
|
|
1290
|
+
this.conversionFactor = 1 / multiplier;
|
|
1291
|
+
item.setConversionFactor(this.conversionFactor);
|
|
1292
|
+
}
|
|
1222
1293
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1294
|
+
if (precisionChanged) {
|
|
1295
|
+
if (toPrecision === "Default") {
|
|
1296
|
+
item.setPrecision(2);
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
item.setPrecision(toPrecision);
|
|
1300
|
+
}
|
|
1228
1301
|
}
|
|
1229
1302
|
});
|
|
1230
1303
|
}
|
|
@@ -1258,6 +1331,9 @@
|
|
|
1258
1331
|
case "Micrometers":
|
|
1259
1332
|
eUnit = this.m_module.Units.kMicrometers;
|
|
1260
1333
|
break;
|
|
1334
|
+
case "Mils":
|
|
1335
|
+
eUnit = this.m_module.Units.kMils;
|
|
1336
|
+
break;
|
|
1261
1337
|
case "MicroInches":
|
|
1262
1338
|
eUnit = this.m_module.Units.kMicroInches;
|
|
1263
1339
|
break;
|
|
@@ -1313,7 +1389,7 @@
|
|
|
1313
1389
|
callback({
|
|
1314
1390
|
x: 100 * ((movedX - centerX) / maxMoveStick),
|
|
1315
1391
|
y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
|
|
1316
|
-
global
|
|
1392
|
+
global,
|
|
1317
1393
|
});
|
|
1318
1394
|
}
|
|
1319
1395
|
};
|
|
@@ -1328,7 +1404,7 @@
|
|
|
1328
1404
|
callback({
|
|
1329
1405
|
x: 100 * ((movedX - centerX) / maxMoveStick),
|
|
1330
1406
|
y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
|
|
1331
|
-
global
|
|
1407
|
+
global,
|
|
1332
1408
|
});
|
|
1333
1409
|
};
|
|
1334
1410
|
this.drawExternal = () => {
|
|
@@ -2819,7 +2895,8 @@
|
|
|
2819
2895
|
const visViewer = viewer.visViewer();
|
|
2820
2896
|
visViewer.unselect();
|
|
2821
2897
|
viewer.update();
|
|
2822
|
-
viewer.emitEvent({ type: "select",
|
|
2898
|
+
viewer.emitEvent({ type: "select", handles: [] });
|
|
2899
|
+
viewer.emitEvent({ type: "select2", handles: [] });
|
|
2823
2900
|
}
|
|
2824
2901
|
|
|
2825
2902
|
function clearSlices(viewer) {
|
|
@@ -2895,6 +2972,13 @@
|
|
|
2895
2972
|
return handles;
|
|
2896
2973
|
}
|
|
2897
2974
|
|
|
2975
|
+
function getSelected2(viewer) {
|
|
2976
|
+
const handles = viewer.executeCommand("getSelected");
|
|
2977
|
+
const model = viewer.models[0];
|
|
2978
|
+
const handles2 = handles.map((handle) => `${model.id}:${handle}`);
|
|
2979
|
+
return handles2;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2898
2982
|
function hideSelected(viewer) {
|
|
2899
2983
|
if (!viewer.visualizeJs)
|
|
2900
2984
|
return;
|
|
@@ -2902,7 +2986,8 @@
|
|
|
2902
2986
|
visViewer.hideSelectedObjects(false);
|
|
2903
2987
|
viewer.update();
|
|
2904
2988
|
viewer.emitEvent({ type: "hide" });
|
|
2905
|
-
viewer.emitEvent({ type: "select",
|
|
2989
|
+
viewer.emitEvent({ type: "select", handles: [] });
|
|
2990
|
+
viewer.emitEvent({ type: "select2", handles: [] });
|
|
2906
2991
|
}
|
|
2907
2992
|
|
|
2908
2993
|
function isolateSelected(viewer) {
|
|
@@ -2950,9 +3035,9 @@
|
|
|
2950
3035
|
if (modelPtr.getDatabaseHandle() === handle) {
|
|
2951
3036
|
const selectionSet = activeView.selectCrossing([0, 9999, 9999, 0], modelPtr);
|
|
2952
3037
|
visViewer.setSelected(selectionSet);
|
|
2953
|
-
const handles = viewer.getSelected();
|
|
2954
3038
|
viewer.update();
|
|
2955
|
-
viewer.emitEvent({ type: "select",
|
|
3039
|
+
viewer.emitEvent({ type: "select", handles: viewer.getSelected() });
|
|
3040
|
+
viewer.emitEvent({ type: "select2", handles: viewer.getSelected2() });
|
|
2956
3041
|
selectionSet.delete();
|
|
2957
3042
|
break;
|
|
2958
3043
|
}
|
|
@@ -2979,13 +3064,14 @@
|
|
|
2979
3064
|
viewer.markup.setMarkupColor(r, g, b);
|
|
2980
3065
|
}
|
|
2981
3066
|
|
|
2982
|
-
function setSelected(viewer,
|
|
3067
|
+
function setSelected(viewer, handles2 = []) {
|
|
2983
3068
|
if (!viewer.visualizeJs)
|
|
2984
3069
|
return;
|
|
3070
|
+
const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
|
|
2985
3071
|
const visLib = viewer.visLib();
|
|
2986
3072
|
const visViewer = viewer.visViewer();
|
|
2987
3073
|
const selectionSet = new visLib.OdTvSelectionSet();
|
|
2988
|
-
handles
|
|
3074
|
+
handles.forEach((handle) => {
|
|
2989
3075
|
const entityId = visViewer.getEntityByOriginalHandle(handle + "");
|
|
2990
3076
|
if (!entityId.isNull())
|
|
2991
3077
|
selectionSet.appendEntity(entityId);
|
|
@@ -2993,9 +3079,25 @@
|
|
|
2993
3079
|
visViewer.setSelected(selectionSet);
|
|
2994
3080
|
viewer.update();
|
|
2995
3081
|
viewer.emitEvent({ type: "select", data: selectionSet, handles });
|
|
3082
|
+
viewer.emitEvent({ type: "select2", data: selectionSet, handles: handles2 });
|
|
2996
3083
|
selectionSet.delete();
|
|
2997
3084
|
}
|
|
2998
3085
|
|
|
3086
|
+
function setSelected2(viewer, handles2 = []) {
|
|
3087
|
+
const handles = [];
|
|
3088
|
+
handles2.forEach((handle) => {
|
|
3089
|
+
if (!handle.includes(":")) {
|
|
3090
|
+
handles.push(handle);
|
|
3091
|
+
}
|
|
3092
|
+
else
|
|
3093
|
+
viewer.models.forEach((model) => {
|
|
3094
|
+
if (handle.split(":", 1)[0] === model.id + "")
|
|
3095
|
+
handles.push(handle);
|
|
3096
|
+
});
|
|
3097
|
+
});
|
|
3098
|
+
return viewer.executeCommand("setSelected", handles);
|
|
3099
|
+
}
|
|
3100
|
+
|
|
2999
3101
|
function showAll(viewer) {
|
|
3000
3102
|
if (!viewer.visualizeJs)
|
|
3001
3103
|
return;
|
|
@@ -3118,6 +3220,7 @@
|
|
|
3118
3220
|
commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
3119
3221
|
commands.registerCommand("getModels", getModels);
|
|
3120
3222
|
commands.registerCommand("getSelected", getSelected);
|
|
3223
|
+
commands.registerCommand("getSelected2", getSelected2);
|
|
3121
3224
|
commands.registerCommand("hideSelected", hideSelected);
|
|
3122
3225
|
commands.registerCommand("isolateSelected", isolateSelected);
|
|
3123
3226
|
commands.registerCommand("regenerateAll", regenerateAll);
|
|
@@ -3127,6 +3230,7 @@
|
|
|
3127
3230
|
commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
|
|
3128
3231
|
commands.registerCommand("setMarkupColor", setMarkupColor);
|
|
3129
3232
|
commands.registerCommand("setSelected", setSelected);
|
|
3233
|
+
commands.registerCommand("setSelected2", setSelected2);
|
|
3130
3234
|
commands.registerCommand("showAll", showAll);
|
|
3131
3235
|
commands.registerCommand("zoomToExtents", zoomToExtents);
|
|
3132
3236
|
commands.registerCommand("zoomToObjects", zoomToObjects);
|
|
@@ -3475,6 +3579,10 @@
|
|
|
3475
3579
|
components.registerComponent("GestureManagerComponent", (viewer) => new GestureManagerComponent(viewer));
|
|
3476
3580
|
components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));
|
|
3477
3581
|
|
|
3582
|
+
class ModelImpl {
|
|
3583
|
+
dispose() { }
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3478
3586
|
class FileLoader {
|
|
3479
3587
|
constructor() {
|
|
3480
3588
|
this.requestHeader = {};
|
|
@@ -3558,7 +3666,7 @@
|
|
|
3558
3666
|
return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
3559
3667
|
/vsf$/i.test(format));
|
|
3560
3668
|
}
|
|
3561
|
-
async load(file, format, params) {
|
|
3669
|
+
async load(file, format, params = {}) {
|
|
3562
3670
|
if (!this.viewer.visualizeJs)
|
|
3563
3671
|
return this;
|
|
3564
3672
|
const visViewer = this.viewer.visViewer();
|
|
@@ -3582,6 +3690,9 @@
|
|
|
3582
3690
|
console.error("VSF parse error.", error);
|
|
3583
3691
|
throw error;
|
|
3584
3692
|
}
|
|
3693
|
+
const modelImpl = new ModelImpl();
|
|
3694
|
+
modelImpl.id = params.modelId || this.extractFileName(file);
|
|
3695
|
+
this.viewer.models.push(modelImpl);
|
|
3585
3696
|
this.viewer.syncOptions();
|
|
3586
3697
|
this.viewer.syncOverlay();
|
|
3587
3698
|
this.viewer.update(true);
|
|
@@ -3625,6 +3736,9 @@
|
|
|
3625
3736
|
throw error;
|
|
3626
3737
|
}
|
|
3627
3738
|
if (i === 0) {
|
|
3739
|
+
const modelImpl = new ModelImpl();
|
|
3740
|
+
modelImpl.id = model.file.id;
|
|
3741
|
+
this.viewer.models.push(modelImpl);
|
|
3628
3742
|
this.viewer.syncOptions();
|
|
3629
3743
|
this.viewer.syncOverlay();
|
|
3630
3744
|
this.viewer.update(true);
|
|
@@ -3649,7 +3763,7 @@
|
|
|
3649
3763
|
return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
3650
3764
|
/vsfx$/i.test(format));
|
|
3651
3765
|
}
|
|
3652
|
-
async load(file, format, params) {
|
|
3766
|
+
async load(file, format, params = {}) {
|
|
3653
3767
|
if (!this.viewer.visualizeJs)
|
|
3654
3768
|
return this;
|
|
3655
3769
|
const visViewer = this.viewer.visViewer();
|
|
@@ -3673,6 +3787,9 @@
|
|
|
3673
3787
|
console.error("VSFX parse error.", error);
|
|
3674
3788
|
throw error;
|
|
3675
3789
|
}
|
|
3790
|
+
const modelImpl = new ModelImpl();
|
|
3791
|
+
modelImpl.id = params.modelId || this.extractFileName(file);
|
|
3792
|
+
this.viewer.models.push(modelImpl);
|
|
3676
3793
|
this.viewer.syncOptions();
|
|
3677
3794
|
this.viewer.syncOverlay();
|
|
3678
3795
|
this.viewer.update(true);
|
|
@@ -3693,7 +3810,7 @@
|
|
|
3693
3810
|
/.vsfx$/i.test(file.database) &&
|
|
3694
3811
|
this.viewer.options.enableStreamingMode === false);
|
|
3695
3812
|
}
|
|
3696
|
-
async load(model
|
|
3813
|
+
async load(model) {
|
|
3697
3814
|
if (!this.viewer.visualizeJs)
|
|
3698
3815
|
return Promise.resolve(this);
|
|
3699
3816
|
const visViewer = this.viewer.visViewer();
|
|
@@ -3712,6 +3829,9 @@
|
|
|
3712
3829
|
console.error("VSFX parse error.", error);
|
|
3713
3830
|
throw error;
|
|
3714
3831
|
}
|
|
3832
|
+
const modelImpl = new ModelImpl();
|
|
3833
|
+
modelImpl.id = model.file.id;
|
|
3834
|
+
this.viewer.models.push(modelImpl);
|
|
3715
3835
|
this.viewer.syncOptions();
|
|
3716
3836
|
this.viewer.syncOverlay();
|
|
3717
3837
|
this.viewer.update(true);
|
|
@@ -3790,6 +3910,9 @@
|
|
|
3790
3910
|
isDatabaseChunk = true;
|
|
3791
3911
|
}
|
|
3792
3912
|
if (isDatabaseChunk) {
|
|
3913
|
+
const modelImpl = new ModelImpl();
|
|
3914
|
+
modelImpl.id = model.file.id;
|
|
3915
|
+
this.viewer.models.push(modelImpl);
|
|
3793
3916
|
this.viewer.syncOptions();
|
|
3794
3917
|
this.viewer.syncOverlay();
|
|
3795
3918
|
updateController.update(UpdateType.kForce);
|
|
@@ -3824,7 +3947,7 @@
|
|
|
3824
3947
|
/.vsfx$/i.test(file.database) &&
|
|
3825
3948
|
(this.viewer.options.enablePartialMode === true || /.rcs$/i.test(file.name)));
|
|
3826
3949
|
}
|
|
3827
|
-
async load(model
|
|
3950
|
+
async load(model) {
|
|
3828
3951
|
if (!this.viewer.visualizeJs)
|
|
3829
3952
|
return this;
|
|
3830
3953
|
const visViewer = this.viewer.visViewer();
|
|
@@ -3850,6 +3973,9 @@
|
|
|
3850
3973
|
}
|
|
3851
3974
|
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
3852
3975
|
if (isDatabaseChunk) {
|
|
3976
|
+
const modelImpl = new ModelImpl();
|
|
3977
|
+
modelImpl.id = model.file.id;
|
|
3978
|
+
this.viewer.models.push(modelImpl);
|
|
3853
3979
|
this.viewer.syncOptions();
|
|
3854
3980
|
this.viewer.syncOverlay();
|
|
3855
3981
|
updateController.update(UpdateType.kForce);
|
|
@@ -17811,27 +17937,34 @@ js: import "konva/skia-backend";
|
|
|
17811
17937
|
super();
|
|
17812
17938
|
this._visualizeJsUrl = "";
|
|
17813
17939
|
this.configure(params);
|
|
17814
|
-
this._options = new Options(this);
|
|
17815
17940
|
this.client = client;
|
|
17941
|
+
this.options = new Options(this);
|
|
17816
17942
|
this.loaders = [];
|
|
17943
|
+
this.models = [];
|
|
17944
|
+
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
17945
|
+
this.canvaseventlistener = (event) => this.emit(event);
|
|
17817
17946
|
this._activeDragger = null;
|
|
17818
17947
|
this._components = [];
|
|
17948
|
+
this._renderNeeded = false;
|
|
17819
17949
|
this._renderTime = 0;
|
|
17820
|
-
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
17821
|
-
this.canvaseventlistener = (event) => this.emit(event);
|
|
17822
17950
|
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
17823
|
-
this._renderNeeded = false;
|
|
17824
17951
|
this._isRunAsyncUpdate = false;
|
|
17825
17952
|
this.render = this.render.bind(this);
|
|
17826
17953
|
this.update = this.update.bind(this);
|
|
17827
17954
|
this._markup = MarkupFactory.createMarkup(params.markupType);
|
|
17828
17955
|
}
|
|
17829
|
-
get options() {
|
|
17830
|
-
return this._options;
|
|
17831
|
-
}
|
|
17832
17956
|
get visualizeJsUrl() {
|
|
17833
17957
|
return this._visualizeJsUrl;
|
|
17834
17958
|
}
|
|
17959
|
+
get visualizeJs() {
|
|
17960
|
+
return this._visualizeJs;
|
|
17961
|
+
}
|
|
17962
|
+
visLib() {
|
|
17963
|
+
return this._visualizeJs;
|
|
17964
|
+
}
|
|
17965
|
+
visViewer() {
|
|
17966
|
+
return this._viewer;
|
|
17967
|
+
}
|
|
17835
17968
|
get markup() {
|
|
17836
17969
|
return this._markup;
|
|
17837
17970
|
}
|
|
@@ -17840,13 +17973,20 @@ js: import "konva/skia-backend";
|
|
|
17840
17973
|
this._crossOrigin = params.crossOrigin;
|
|
17841
17974
|
return this;
|
|
17842
17975
|
}
|
|
17976
|
+
get draggers() {
|
|
17977
|
+
return [...draggers.getDraggers().keys()];
|
|
17978
|
+
}
|
|
17979
|
+
get components() {
|
|
17980
|
+
return [...components.getComponents().keys()];
|
|
17981
|
+
}
|
|
17843
17982
|
async initialize(canvas, onProgress) {
|
|
17844
17983
|
this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
|
|
17984
|
+
const pixelRatio = window.devicePixelRatio;
|
|
17845
17985
|
const rect = canvas.parentElement.getBoundingClientRect();
|
|
17846
17986
|
const width = rect.width || 1;
|
|
17847
17987
|
const height = rect.height || 1;
|
|
17848
|
-
canvas.width = Math.round(width *
|
|
17849
|
-
canvas.height = Math.round(height *
|
|
17988
|
+
canvas.width = Math.round(width * pixelRatio);
|
|
17989
|
+
canvas.height = Math.round(height * pixelRatio);
|
|
17850
17990
|
canvas.style.width = width + "px";
|
|
17851
17991
|
canvas.style.height = height + "px";
|
|
17852
17992
|
canvas.parentElement.style.touchAction = "none";
|
|
@@ -17914,6 +18054,26 @@ js: import "konva/skia-backend";
|
|
|
17914
18054
|
this.update(true);
|
|
17915
18055
|
this.emitEvent({ type: "resize", width, height });
|
|
17916
18056
|
}
|
|
18057
|
+
resize() {
|
|
18058
|
+
console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
|
|
18059
|
+
if (!this.visualizeJs)
|
|
18060
|
+
return this;
|
|
18061
|
+
if (!this.canvas.parentElement)
|
|
18062
|
+
return this;
|
|
18063
|
+
const { width, height } = this.canvas.parentElement.getBoundingClientRect();
|
|
18064
|
+
if (!width || !height)
|
|
18065
|
+
return this;
|
|
18066
|
+
this.setSize(width, height);
|
|
18067
|
+
return this;
|
|
18068
|
+
}
|
|
18069
|
+
update(force = false) {
|
|
18070
|
+
if (this._enableAutoUpdate) {
|
|
18071
|
+
this._renderNeeded = true;
|
|
18072
|
+
if (force)
|
|
18073
|
+
this.render();
|
|
18074
|
+
}
|
|
18075
|
+
this.emitEvent({ type: "update", data: force });
|
|
18076
|
+
}
|
|
17917
18077
|
render(time) {
|
|
17918
18078
|
var _a, _b;
|
|
17919
18079
|
if (!this.visualizeJs)
|
|
@@ -17932,119 +18092,210 @@ js: import "konva/skia-backend";
|
|
|
17932
18092
|
(_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
17933
18093
|
this.emitEvent({ type: "render", time, deltaTime });
|
|
17934
18094
|
}
|
|
17935
|
-
|
|
17936
|
-
|
|
18095
|
+
async loadReferences(model) {
|
|
18096
|
+
var _a;
|
|
17937
18097
|
if (!this.visualizeJs)
|
|
17938
18098
|
return this;
|
|
17939
|
-
if (!this.
|
|
18099
|
+
if (!this.client)
|
|
17940
18100
|
return this;
|
|
17941
|
-
|
|
17942
|
-
if (!width || !height)
|
|
18101
|
+
if (!model.getReferences)
|
|
17943
18102
|
return this;
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
18103
|
+
const abortController = new AbortController();
|
|
18104
|
+
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
18105
|
+
this._abortControllerForReferences = abortController;
|
|
18106
|
+
let references = [];
|
|
18107
|
+
await model
|
|
18108
|
+
.getReferences(abortController.signal)
|
|
18109
|
+
.then((data) => (references = data.references))
|
|
18110
|
+
.catch((e) => console.error("Cannot load model references.", e));
|
|
18111
|
+
for (const file of references) {
|
|
18112
|
+
await this.client
|
|
18113
|
+
.downloadFile(file.id, undefined, abortController.signal)
|
|
18114
|
+
.then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
|
|
18115
|
+
.catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
|
|
17952
18116
|
}
|
|
17953
|
-
this
|
|
18117
|
+
return this;
|
|
17954
18118
|
}
|
|
17955
|
-
|
|
17956
|
-
|
|
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
|
-
});
|
|
18119
|
+
applyModelTransformMatrix(model) {
|
|
18120
|
+
this.executeCommand("applyModelTransform", model);
|
|
17973
18121
|
}
|
|
17974
|
-
|
|
18122
|
+
applySceneGraphSettings(options = this.options) {
|
|
17975
18123
|
if (!this.visualizeJs)
|
|
17976
18124
|
return;
|
|
17977
|
-
|
|
18125
|
+
const visLib = this.visLib();
|
|
18126
|
+
const visViewer = this.visViewer();
|
|
18127
|
+
const device = visViewer.getActiveDevice();
|
|
18128
|
+
if (isExist(options.sceneGraph)) {
|
|
18129
|
+
device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
|
|
18130
|
+
}
|
|
18131
|
+
device.delete();
|
|
18132
|
+
this.update();
|
|
18133
|
+
}
|
|
18134
|
+
async open(file, params = {}) {
|
|
18135
|
+
if (!this.visualizeJs)
|
|
18136
|
+
return this;
|
|
18137
|
+
this.cancel();
|
|
18138
|
+
this.clear();
|
|
18139
|
+
this.emitEvent({ type: "open", mode: "file", file });
|
|
18140
|
+
let model = file;
|
|
18141
|
+
if (model && typeof model.getModels === "function") {
|
|
18142
|
+
const models = await model.getModels();
|
|
18143
|
+
model = models.find((model) => model.default) || models[0] || file;
|
|
18144
|
+
}
|
|
18145
|
+
if (model && typeof model.database === "string") {
|
|
18146
|
+
file = model.file;
|
|
18147
|
+
}
|
|
18148
|
+
if (!model)
|
|
18149
|
+
throw new Error(`Format not supported`);
|
|
18150
|
+
let format = params.format;
|
|
18151
|
+
if (!format && typeof file["type"] === "string")
|
|
18152
|
+
format = file["type"].split(".").pop();
|
|
18153
|
+
if (!format && typeof file === "string")
|
|
18154
|
+
format = file.split(".").pop();
|
|
18155
|
+
if (!format && file instanceof globalThis.File)
|
|
18156
|
+
format = file.name.split(".").pop();
|
|
18157
|
+
const loader = loaders.createLoader(this, model, format);
|
|
18158
|
+
if (!loader)
|
|
18159
|
+
throw new Error(`Format not supported`);
|
|
18160
|
+
this.loaders.push(loader);
|
|
18161
|
+
this.emitEvent({ type: "geometrystart", file, model });
|
|
17978
18162
|
try {
|
|
17979
|
-
|
|
17980
|
-
|
|
17981
|
-
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
17982
|
-
}
|
|
17983
|
-
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
18163
|
+
await this.loadReferences(model);
|
|
18164
|
+
await loader.load(model, format, params);
|
|
17984
18165
|
}
|
|
17985
|
-
catch (
|
|
17986
|
-
|
|
18166
|
+
catch (error) {
|
|
18167
|
+
this.emitEvent({ type: "geometryerror", data: error, file, model });
|
|
18168
|
+
throw error;
|
|
17987
18169
|
}
|
|
17988
|
-
|
|
17989
|
-
|
|
18170
|
+
this.emitEvent({ type: "geometryend", file, model });
|
|
18171
|
+
if (this.visualizeJs) {
|
|
18172
|
+
this.applyModelTransformMatrix(model);
|
|
18173
|
+
this.applySceneGraphSettings();
|
|
17990
18174
|
}
|
|
18175
|
+
return this;
|
|
17991
18176
|
}
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
}
|
|
17995
|
-
visLib() {
|
|
17996
|
-
return this._visualizeJs;
|
|
17997
|
-
}
|
|
17998
|
-
visViewer() {
|
|
17999
|
-
return this._viewer;
|
|
18000
|
-
}
|
|
18001
|
-
syncOpenCloudVisualStyle() {
|
|
18177
|
+
openVsfFile(buffer) {
|
|
18178
|
+
console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
18002
18179
|
if (!this.visualizeJs)
|
|
18003
18180
|
return this;
|
|
18004
|
-
|
|
18181
|
+
this.cancel();
|
|
18182
|
+
this.clear();
|
|
18183
|
+
this.emitEvent({ type: "open", mode: "file", file: "", buffer });
|
|
18005
18184
|
const visViewer = this.visViewer();
|
|
18006
|
-
|
|
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;
|
|
18185
|
+
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
18013
18186
|
try {
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18187
|
+
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
18188
|
+
visViewer.parseFile(data);
|
|
18189
|
+
this.syncOptions();
|
|
18190
|
+
this.syncOverlay();
|
|
18191
|
+
this.update(true);
|
|
18192
|
+
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
18193
|
+
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
18018
18194
|
}
|
|
18019
|
-
|
|
18020
|
-
|
|
18021
|
-
|
|
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();
|
|
18195
|
+
catch (error) {
|
|
18196
|
+
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
18197
|
+
throw error;
|
|
18032
18198
|
}
|
|
18033
|
-
|
|
18034
|
-
view.delete();
|
|
18035
|
-
device.delete();
|
|
18199
|
+
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
18036
18200
|
return this;
|
|
18037
18201
|
}
|
|
18038
|
-
|
|
18202
|
+
openVsfxFile(buffer) {
|
|
18203
|
+
console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
18039
18204
|
if (!this.visualizeJs)
|
|
18040
18205
|
return this;
|
|
18041
|
-
this.
|
|
18042
|
-
|
|
18206
|
+
this.cancel();
|
|
18207
|
+
this.clear();
|
|
18208
|
+
this.emitEvent({ type: "open", mode: "file", file: "", buffer });
|
|
18043
18209
|
const visViewer = this.visViewer();
|
|
18044
|
-
|
|
18045
|
-
|
|
18046
|
-
|
|
18047
|
-
|
|
18210
|
+
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
18211
|
+
try {
|
|
18212
|
+
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
18213
|
+
visViewer.parseVsfx(data);
|
|
18214
|
+
this.syncOptions();
|
|
18215
|
+
this.syncOverlay();
|
|
18216
|
+
this.update(true);
|
|
18217
|
+
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
18218
|
+
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
18219
|
+
}
|
|
18220
|
+
catch (error) {
|
|
18221
|
+
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
18222
|
+
throw error;
|
|
18223
|
+
}
|
|
18224
|
+
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
18225
|
+
return this;
|
|
18226
|
+
}
|
|
18227
|
+
cancel() {
|
|
18228
|
+
var _a;
|
|
18229
|
+
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
18230
|
+
this._abortControllerForReferences = undefined;
|
|
18231
|
+
this.loaders.forEach((loader) => loader.cancel());
|
|
18232
|
+
this.emitEvent({ type: "cancel" });
|
|
18233
|
+
return this;
|
|
18234
|
+
}
|
|
18235
|
+
clear() {
|
|
18236
|
+
if (!this.visualizeJs)
|
|
18237
|
+
return this;
|
|
18238
|
+
const visViewer = this.visViewer();
|
|
18239
|
+
this.setActiveDragger();
|
|
18240
|
+
this.clearSlices();
|
|
18241
|
+
this.clearOverlay();
|
|
18242
|
+
this.clearSelected();
|
|
18243
|
+
this.loaders.forEach((loader) => loader.dispose());
|
|
18244
|
+
this.loaders = [];
|
|
18245
|
+
this.models.forEach((model) => model.dispose());
|
|
18246
|
+
this.models = [];
|
|
18247
|
+
visViewer.clear();
|
|
18248
|
+
visViewer.createLocalDatabase();
|
|
18249
|
+
this.syncOptions();
|
|
18250
|
+
this.syncOverlay();
|
|
18251
|
+
this.update(true);
|
|
18252
|
+
this.emitEvent({ type: "clear" });
|
|
18253
|
+
return this;
|
|
18254
|
+
}
|
|
18255
|
+
is3D() {
|
|
18256
|
+
if (!this.visualizeJs)
|
|
18257
|
+
return false;
|
|
18258
|
+
const visViewer = this.visViewer();
|
|
18259
|
+
const ext = visViewer.getActiveExtents();
|
|
18260
|
+
const min = ext.min();
|
|
18261
|
+
const max = ext.max();
|
|
18262
|
+
const extHeight = max[2] - min[2];
|
|
18263
|
+
return extHeight !== 0;
|
|
18264
|
+
}
|
|
18265
|
+
syncOptions(options = this.options) {
|
|
18266
|
+
if (!this.visualizeJs)
|
|
18267
|
+
return this;
|
|
18268
|
+
const visLib = this.visLib();
|
|
18269
|
+
const visViewer = this.visViewer();
|
|
18270
|
+
const device = visViewer.getActiveDevice();
|
|
18271
|
+
if (device.isNull())
|
|
18272
|
+
return this;
|
|
18273
|
+
const view = device.getActiveView();
|
|
18274
|
+
view.enableDefaultLighting(true, visLib.DefaultLightingType.kTwoLights);
|
|
18275
|
+
view.setDefaultLightingIntensity(1.25);
|
|
18276
|
+
let visualStyleId;
|
|
18277
|
+
try {
|
|
18278
|
+
visualStyleId = visViewer.findVisualStyle("OpenCloud");
|
|
18279
|
+
}
|
|
18280
|
+
catch {
|
|
18281
|
+
visualStyleId = undefined;
|
|
18282
|
+
}
|
|
18283
|
+
if (!visualStyleId || visualStyleId.isNull()) {
|
|
18284
|
+
visualStyleId = visViewer.createVisualStyle("OpenCloud");
|
|
18285
|
+
const colorDef = new visLib.OdTvColorDef(66, 66, 66);
|
|
18286
|
+
const shadedVsId = visViewer.findVisualStyle("Realistic");
|
|
18287
|
+
const visualStylePtr = visualStyleId.openObject();
|
|
18288
|
+
visualStylePtr.copyFrom(shadedVsId);
|
|
18289
|
+
visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kFaceModifiers, 0, visLib.VisualStyleOperations.kSet);
|
|
18290
|
+
visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModel, 2, visLib.VisualStyleOperations.kSet);
|
|
18291
|
+
visualStylePtr.setOptionDouble(visLib.VisualStyleOptions.kEdgeCreaseAngle, 60, visLib.VisualStyleOperations.kSet);
|
|
18292
|
+
visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeStyles, 0, visLib.VisualStyleOperations.kSet);
|
|
18293
|
+
visualStylePtr.setOptionInt32(visLib.VisualStyleOptions.kEdgeModifiers, 8, visLib.VisualStyleOperations.kSet);
|
|
18294
|
+
visualStylePtr.setOptionColor(visLib.VisualStyleOptions.kEdgeColorValue, colorDef, visLib.VisualStyleOperations.kSet);
|
|
18295
|
+
visualStylePtr.delete();
|
|
18296
|
+
}
|
|
18297
|
+
view.visualStyle = visualStyleId;
|
|
18298
|
+
if (options.showWCS !== visViewer.getEnableWCS()) {
|
|
18048
18299
|
visViewer.setEnableWCS(options.showWCS);
|
|
18049
18300
|
}
|
|
18050
18301
|
if (options.cameraAnimation !== visViewer.getEnableAnimation()) {
|
|
@@ -18057,8 +18308,6 @@ js: import "konva/skia-backend";
|
|
|
18057
18308
|
}
|
|
18058
18309
|
if (options.shadows !== visViewer.shadows) {
|
|
18059
18310
|
visViewer.shadows = options.shadows;
|
|
18060
|
-
const canvas = visLib.canvas;
|
|
18061
|
-
device.invalidate([0, canvas.width, canvas.height, 0]);
|
|
18062
18311
|
}
|
|
18063
18312
|
if (options.groundShadow !== visViewer.groundShadow) {
|
|
18064
18313
|
visViewer.groundShadow = options.groundShadow;
|
|
@@ -18084,17 +18333,7 @@ js: import "konva/skia-backend";
|
|
|
18084
18333
|
visualStyleId.delete();
|
|
18085
18334
|
activeView.delete();
|
|
18086
18335
|
}
|
|
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
18336
|
const params = options.enableCustomHighlight ? options : Options.defaults();
|
|
18096
|
-
const visLib = this.visLib();
|
|
18097
|
-
const visViewer = this.visViewer();
|
|
18098
18337
|
const { Entry, OdTvRGBColorDef } = visLib;
|
|
18099
18338
|
const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
|
|
18100
18339
|
const highlightStylePtr = highlightStyleId.openObject();
|
|
@@ -18121,19 +18360,80 @@ js: import "konva/skia-backend";
|
|
|
18121
18360
|
const visibility = !isExist(params.edgesVisibility) ? true : params.edgesVisibility;
|
|
18122
18361
|
highlightStylePtr.setEdgesVisibility(Entry.k2DTop.value | Entry.k3DTop.value, params.edgesOverlap && visibility);
|
|
18123
18362
|
}
|
|
18124
|
-
|
|
18125
|
-
|
|
18126
|
-
|
|
18127
|
-
device.invalidate([0, canvas.width, canvas.height, 0]);
|
|
18128
|
-
device.delete();
|
|
18129
|
-
}
|
|
18363
|
+
view.delete();
|
|
18364
|
+
device.delete();
|
|
18365
|
+
this.update();
|
|
18130
18366
|
return this;
|
|
18131
18367
|
}
|
|
18132
|
-
|
|
18133
|
-
|
|
18368
|
+
syncOverlay() {
|
|
18369
|
+
if (!this.visualizeJs)
|
|
18370
|
+
return;
|
|
18371
|
+
const visViewer = this.visViewer();
|
|
18372
|
+
const activeView = visViewer.activeView;
|
|
18373
|
+
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
18374
|
+
if (!overlayView) {
|
|
18375
|
+
const markupModel = visViewer.getMarkupModel();
|
|
18376
|
+
const pDevice = visViewer.getActiveDevice();
|
|
18377
|
+
overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
|
|
18378
|
+
overlayView.addModel(markupModel);
|
|
18379
|
+
activeView.addSibling(overlayView);
|
|
18380
|
+
pDevice.addView(overlayView);
|
|
18381
|
+
}
|
|
18382
|
+
overlayView.viewPosition = activeView.viewPosition;
|
|
18383
|
+
overlayView.viewTarget = activeView.viewTarget;
|
|
18384
|
+
overlayView.upVector = activeView.upVector;
|
|
18385
|
+
overlayView.viewFieldWidth = activeView.viewFieldWidth;
|
|
18386
|
+
overlayView.viewFieldHeight = activeView.viewFieldHeight;
|
|
18387
|
+
const viewPort = overlayView.getViewport();
|
|
18388
|
+
overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
|
|
18389
|
+
overlayView.vportRect = activeView.vportRect;
|
|
18390
|
+
this._markup.syncOverlay();
|
|
18391
|
+
this.update();
|
|
18134
18392
|
}
|
|
18135
|
-
|
|
18136
|
-
|
|
18393
|
+
clearOverlay() {
|
|
18394
|
+
if (!this.visualizeJs)
|
|
18395
|
+
return;
|
|
18396
|
+
this._markup.clearOverlay();
|
|
18397
|
+
this.update();
|
|
18398
|
+
}
|
|
18399
|
+
clearSlices() {
|
|
18400
|
+
if (!this.visualizeJs)
|
|
18401
|
+
return;
|
|
18402
|
+
const visViewer = this.visViewer();
|
|
18403
|
+
const activeView = visViewer.activeView;
|
|
18404
|
+
activeView.removeCuttingPlanes();
|
|
18405
|
+
activeView.delete();
|
|
18406
|
+
this.update();
|
|
18407
|
+
}
|
|
18408
|
+
getSelected() {
|
|
18409
|
+
return this.executeCommand("getSelected");
|
|
18410
|
+
}
|
|
18411
|
+
setSelected(handles) {
|
|
18412
|
+
this.executeCommand("setSelected", handles);
|
|
18413
|
+
}
|
|
18414
|
+
getSelected2() {
|
|
18415
|
+
return this.executeCommand("getSelected2");
|
|
18416
|
+
}
|
|
18417
|
+
setSelected2(handles) {
|
|
18418
|
+
this.executeCommand("setSelected2", handles);
|
|
18419
|
+
}
|
|
18420
|
+
clearSelected() {
|
|
18421
|
+
this.executeCommand("clearSelected");
|
|
18422
|
+
}
|
|
18423
|
+
hideSelected() {
|
|
18424
|
+
this.executeCommand("hideSelected");
|
|
18425
|
+
}
|
|
18426
|
+
isolateSelected() {
|
|
18427
|
+
this.executeCommand("isolateSelected");
|
|
18428
|
+
}
|
|
18429
|
+
showAll() {
|
|
18430
|
+
this.executeCommand("showAll");
|
|
18431
|
+
}
|
|
18432
|
+
explode(index = 0) {
|
|
18433
|
+
this.executeCommand("explode", index);
|
|
18434
|
+
}
|
|
18435
|
+
collect() {
|
|
18436
|
+
this.executeCommand("collect");
|
|
18137
18437
|
}
|
|
18138
18438
|
registerDragger(name, dragger) {
|
|
18139
18439
|
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 +18480,102 @@ js: import "konva/skia-backend";
|
|
|
18180
18480
|
getComponent(name) {
|
|
18181
18481
|
return this._components.find((component) => component.name === name);
|
|
18182
18482
|
}
|
|
18183
|
-
|
|
18483
|
+
drawViewpoint(viewpoint) {
|
|
18484
|
+
var _a, _b;
|
|
18184
18485
|
if (!this.visualizeJs)
|
|
18185
18486
|
return;
|
|
18186
18487
|
const visViewer = this.visViewer();
|
|
18187
18488
|
const activeView = visViewer.activeView;
|
|
18188
|
-
|
|
18189
|
-
|
|
18190
|
-
|
|
18191
|
-
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18489
|
+
const getPoint3dAsArray = (point3d) => {
|
|
18490
|
+
return [point3d.x, point3d.y, point3d.z];
|
|
18491
|
+
};
|
|
18492
|
+
const setOrthogonalCamera = (orthogonal_camera) => {
|
|
18493
|
+
if (orthogonal_camera) {
|
|
18494
|
+
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);
|
|
18495
|
+
this.syncOverlay();
|
|
18496
|
+
this.emitEvent({ type: "changecameramode", mode: "orthographic" });
|
|
18497
|
+
}
|
|
18498
|
+
};
|
|
18499
|
+
const setPerspectiveCamera = (perspective_camera) => { };
|
|
18500
|
+
const setClippingPlanes = (clipping_planes) => {
|
|
18501
|
+
if (clipping_planes) {
|
|
18502
|
+
for (const clipping_plane of clipping_planes) {
|
|
18503
|
+
const cuttingPlane = new (this.visLib().OdTvPlane)();
|
|
18504
|
+
cuttingPlane.set(getPoint3dAsArray(clipping_plane.location), getPoint3dAsArray(clipping_plane.direction));
|
|
18505
|
+
activeView.addCuttingPlane(cuttingPlane);
|
|
18506
|
+
activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
|
|
18507
|
+
}
|
|
18508
|
+
}
|
|
18509
|
+
};
|
|
18510
|
+
const setSelection = (selection) => {
|
|
18511
|
+
if (selection)
|
|
18512
|
+
this.setSelected(selection.map((component) => component.handle));
|
|
18513
|
+
};
|
|
18514
|
+
const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
|
|
18515
|
+
this.setActiveDragger();
|
|
18516
|
+
this.clearSlices();
|
|
18517
|
+
this.clearOverlay();
|
|
18518
|
+
this.clearSelected();
|
|
18519
|
+
this.showAll();
|
|
18520
|
+
this.explode();
|
|
18521
|
+
setOrthogonalCamera(viewpoint.orthogonal_camera);
|
|
18522
|
+
setPerspectiveCamera(viewpoint.perspective_camera);
|
|
18523
|
+
setClippingPlanes(viewpoint.clipping_planes);
|
|
18524
|
+
setSelection(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.selection2) || viewpoint.selection);
|
|
18525
|
+
this._markup.setViewpoint(viewpoint);
|
|
18526
|
+
this.setActiveDragger(draggerName);
|
|
18527
|
+
this.emitEvent({ type: "drawviewpoint", data: viewpoint });
|
|
18196
18528
|
this.update();
|
|
18197
18529
|
}
|
|
18198
|
-
|
|
18530
|
+
createViewpoint() {
|
|
18199
18531
|
if (!this.visualizeJs)
|
|
18200
|
-
return;
|
|
18532
|
+
return {};
|
|
18201
18533
|
const visViewer = this.visViewer();
|
|
18202
18534
|
const activeView = visViewer.activeView;
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18535
|
+
const getPoint3dFromArray = (array) => {
|
|
18536
|
+
return { x: array[0], y: array[1], z: array[2] };
|
|
18537
|
+
};
|
|
18538
|
+
const getOrthogonalCamera = () => {
|
|
18539
|
+
return {
|
|
18540
|
+
view_point: getPoint3dFromArray(activeView.viewPosition),
|
|
18541
|
+
direction: getPoint3dFromArray(activeView.viewTarget),
|
|
18542
|
+
up_vector: getPoint3dFromArray(activeView.upVector),
|
|
18543
|
+
field_width: activeView.viewFieldWidth,
|
|
18544
|
+
field_height: activeView.viewFieldHeight,
|
|
18545
|
+
view_to_world_scale: 1,
|
|
18546
|
+
};
|
|
18547
|
+
};
|
|
18548
|
+
const getPerspectiveCamera = () => {
|
|
18549
|
+
return undefined;
|
|
18550
|
+
};
|
|
18551
|
+
const getClippingPlanes = () => {
|
|
18552
|
+
const clipping_planes = [];
|
|
18553
|
+
for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
|
|
18554
|
+
const cuttingPlane = activeView.getCuttingPlane(i);
|
|
18555
|
+
const clipping_plane = {
|
|
18556
|
+
location: getPoint3dFromArray(cuttingPlane.getOrigin()),
|
|
18557
|
+
direction: getPoint3dFromArray(cuttingPlane.normal()),
|
|
18558
|
+
};
|
|
18559
|
+
clipping_planes.push(clipping_plane);
|
|
18560
|
+
}
|
|
18561
|
+
return clipping_planes;
|
|
18562
|
+
};
|
|
18563
|
+
const getSelection = () => {
|
|
18564
|
+
return this.getSelected().map((handle) => ({ handle }));
|
|
18565
|
+
};
|
|
18566
|
+
const getSelection2 = () => {
|
|
18567
|
+
return this.getSelected2().map((handle) => ({ handle }));
|
|
18568
|
+
};
|
|
18569
|
+
const viewpoint = { custom_fields: {} };
|
|
18570
|
+
viewpoint.orthogonal_camera = getOrthogonalCamera();
|
|
18571
|
+
viewpoint.perspective_camera = getPerspectiveCamera();
|
|
18572
|
+
viewpoint.clipping_planes = getClippingPlanes();
|
|
18573
|
+
viewpoint.selection = getSelection();
|
|
18574
|
+
viewpoint.description = new Date().toDateString();
|
|
18575
|
+
this._markup.getViewpoint(viewpoint);
|
|
18576
|
+
viewpoint.custom_fields.selection2 = getSelection2();
|
|
18577
|
+
this.emitEvent({ type: "createviewpoint", data: viewpoint });
|
|
18578
|
+
return viewpoint;
|
|
18232
18579
|
}
|
|
18233
18580
|
screenToWorld(position) {
|
|
18234
18581
|
if (!this.visualizeJs)
|
|
@@ -18263,184 +18610,23 @@ js: import "konva/skia-backend";
|
|
|
18263
18610
|
result.z = 1 / z;
|
|
18264
18611
|
return result;
|
|
18265
18612
|
}
|
|
18266
|
-
|
|
18267
|
-
return
|
|
18268
|
-
}
|
|
18269
|
-
setSelected(handles) {
|
|
18270
|
-
this.executeCommand("setSelected", handles);
|
|
18271
|
-
}
|
|
18272
|
-
clearSelected() {
|
|
18273
|
-
this.executeCommand("clearSelected");
|
|
18613
|
+
executeCommand(id, ...args) {
|
|
18614
|
+
return commands.executeCommand(id, this, ...args);
|
|
18274
18615
|
}
|
|
18275
|
-
|
|
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);
|
|
18316
|
-
}
|
|
18317
|
-
applySceneGraphSettings(options = this.options) {
|
|
18616
|
+
addMarkupEntity(entityName) {
|
|
18318
18617
|
if (!this.visualizeJs)
|
|
18319
|
-
return;
|
|
18320
|
-
|
|
18618
|
+
return null;
|
|
18619
|
+
this.syncOverlay();
|
|
18321
18620
|
const visViewer = this.visViewer();
|
|
18322
|
-
const
|
|
18323
|
-
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18621
|
+
const model = visViewer.getMarkupModel();
|
|
18622
|
+
const entityId = model.appendEntity(entityName);
|
|
18623
|
+
const entityPtr = entityId.openObject();
|
|
18624
|
+
const color = this.getMarkupColor();
|
|
18625
|
+
entityPtr.setColor(color.r, color.g, color.b);
|
|
18626
|
+
entityPtr.setLineWeight(2);
|
|
18627
|
+
entityPtr.delete();
|
|
18327
18628
|
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;
|
|
18629
|
+
return entityId;
|
|
18444
18630
|
}
|
|
18445
18631
|
getMarkupColor() {
|
|
18446
18632
|
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 +18643,43 @@ js: import "konva/skia-backend";
|
|
|
18457
18643
|
colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
|
|
18458
18644
|
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
18459
18645
|
}
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
|
|
18468
|
-
|
|
18469
|
-
|
|
18470
|
-
|
|
18471
|
-
|
|
18472
|
-
|
|
18473
|
-
|
|
18646
|
+
scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
|
|
18647
|
+
return new Promise((resolve, reject) => {
|
|
18648
|
+
setTimeout(() => {
|
|
18649
|
+
var _a, _b, _c;
|
|
18650
|
+
try {
|
|
18651
|
+
if (this._enableAutoUpdate) {
|
|
18652
|
+
(_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
|
|
18653
|
+
(_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
18654
|
+
}
|
|
18655
|
+
this.emitEvent({ type: "update", data: false });
|
|
18656
|
+
resolve();
|
|
18657
|
+
}
|
|
18658
|
+
catch (e) {
|
|
18659
|
+
console.error(e);
|
|
18660
|
+
reject();
|
|
18661
|
+
}
|
|
18662
|
+
}, 0);
|
|
18663
|
+
});
|
|
18474
18664
|
}
|
|
18475
|
-
|
|
18476
|
-
var _a;
|
|
18665
|
+
async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
|
|
18477
18666
|
if (!this.visualizeJs)
|
|
18478
18667
|
return;
|
|
18479
|
-
|
|
18480
|
-
|
|
18481
|
-
|
|
18482
|
-
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
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();
|
|
18668
|
+
this._isRunAsyncUpdate = true;
|
|
18669
|
+
try {
|
|
18670
|
+
const device = this.visViewer().getActiveDevice();
|
|
18671
|
+
for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
|
|
18672
|
+
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
18673
|
+
}
|
|
18674
|
+
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
18530
18675
|
}
|
|
18531
|
-
|
|
18532
|
-
|
|
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);
|
|
18676
|
+
catch (e) {
|
|
18677
|
+
console.error(e);
|
|
18543
18678
|
}
|
|
18544
|
-
|
|
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
|
-
}
|
|
18679
|
+
finally {
|
|
18680
|
+
this._isRunAsyncUpdate = false;
|
|
18556
18681
|
}
|
|
18557
18682
|
}
|
|
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
18683
|
deviceAutoRegeneration() {
|
|
18568
18684
|
const visViewer = this.visViewer();
|
|
18569
18685
|
const device = visViewer.getActiveDevice();
|