@inweb/viewer-visualize 26.11.0 → 26.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,12 +4,10 @@
4
4
 
5
5
  Core capabilities:
6
6
 
7
- - Rendering CAD/BIM files from [Open Cloud Server](https://cloud.opendesign.com/docs/index.html#/opencloud_server), web, or local files
8
- - Interactive scene navigation (Orbit, Pan, Zoom, Walk, Fly modes)
9
- - Model selection and highlighting
10
- - Cutting planes and slicing
11
- - Markups and measurements
12
- - Viewpoint management
7
+ - Visualize files stored on the [Open Cloud Server](https://cloud.opendesign.com/docs/index.html#/opencloud_server), on the web, or on your local computer.
8
+ - Add user interaction with scenes.
9
+ - Create markups.
10
+ - Save and load viewpoints.
13
11
 
14
12
  This library is a part of [CDE SDK](https://www.opendesign.com/products/cde) by [Open Design Alliance](https://opendesign.com).
15
13
 
@@ -244,7 +244,6 @@
244
244
  enableGestures: true,
245
245
  geometryType: "vsfx",
246
246
  rulerUnit: "Default",
247
- rulerPrecision: 2,
248
247
  cameraMode: "perspective",
249
248
  };
250
249
  }
@@ -501,13 +500,6 @@
501
500
  this._data.rulerUnit = value;
502
501
  this.change();
503
502
  }
504
- get rulerPrecision() {
505
- return this._data.rulerPrecision;
506
- }
507
- set rulerPrecision(value) {
508
- this._data.rulerPrecision = value;
509
- this.change();
510
- }
511
503
  get cameraMode() {
512
504
  return this._data.cameraMode || "perspective";
513
505
  }
@@ -912,9 +904,8 @@
912
904
  this.htmlElemTitle = null;
913
905
  this.startPoint = null;
914
906
  this.endPoint = null;
915
- this.scale = 1.0;
916
907
  this.unit = "";
917
- this.precision = 2;
908
+ this.scale = 1.0;
918
909
  this.size = 10.0;
919
910
  this.lineThickness = 2;
920
911
  this.style = {
@@ -999,9 +990,10 @@
999
990
  this.htmlElemLine.style.background = this.style.background;
1000
991
  this.htmlElemLine.style.zIndex = "1";
1001
992
  this.htmlElemLine.style.height = `${height}px`;
1002
- const distance = this.getDistance();
993
+ const distance = `${this.getDistance()} ${this.unit}`;
1003
994
  const pX = p1.x + dx / 2;
1004
995
  const pY = p1.y + dy / 2;
996
+ const widthTitle = distance.length * 10;
1005
997
  this.htmlElemTitle = createHtmlElementIfNeed(this.htmlElemTitle, this.targetElement, "ruler-value");
1006
998
  this.htmlElemTitle.style.display = "block";
1007
999
  this.htmlElemTitle.style.cursor = "pointer";
@@ -1009,8 +1001,9 @@
1009
1001
  this.htmlElemTitle.style.color = "white";
1010
1002
  this.htmlElemTitle.style.position = "Absolute";
1011
1003
  this.htmlElemTitle.style.top = `${pY}px`;
1012
- this.htmlElemTitle.style.left = `${pX}px`;
1013
- this.htmlElemTitle.style.transform = "translate(-50%, -50%)";
1004
+ this.htmlElemTitle.style.left = `${pX - widthTitle / 2}px`;
1005
+ this.htmlElemTitle.style.width = `${widthTitle}px`;
1006
+ this.htmlElemTitle.style.transformOrigin = "0px 0px";
1014
1007
  this.htmlElemTitle.style.borderRadius = "5px";
1015
1008
  this.htmlElemTitle.style.boxShadow = this.style.boxShadow;
1016
1009
  this.htmlElemTitle.style.border = "none";
@@ -1018,7 +1011,7 @@
1018
1011
  this.htmlElemTitle.style.zIndex = "3";
1019
1012
  this.htmlElemTitle.style.padding = "2px";
1020
1013
  this.htmlElemTitle.style.textAlign = "center";
1021
- this.htmlElemTitle.innerHTML = this.formatDistance(distance);
1014
+ this.htmlElemTitle.innerHTML = `${distance}`;
1022
1015
  }
1023
1016
  else {
1024
1017
  this.htmlElemLine.style.display = "none";
@@ -1028,43 +1021,11 @@
1028
1021
  }
1029
1022
  getDistance() {
1030
1023
  let distance = getDistance(this.startPoint, this.endPoint, this.moduleInstance);
1031
- if (Math.abs(this.scale) > 1e-10)
1032
- distance /= this.scale;
1024
+ if (Math.abs(this.scale - 1.0) > 10e-5) {
1025
+ distance = (distance / this.scale).toFixed(2);
1026
+ }
1033
1027
  return distance;
1034
1028
  }
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
- }
1068
1029
  setStartPoint(gePoint) {
1069
1030
  this.startPoint = gePoint;
1070
1031
  this.drawMeasureLine();
@@ -1097,10 +1058,6 @@
1097
1058
  this.scale = scale;
1098
1059
  this.drawMeasureLine();
1099
1060
  }
1100
- setPrecision(precision) {
1101
- this.precision = precision;
1102
- this.drawMeasureLine();
1103
- }
1104
1061
  setStyle(style) {
1105
1062
  this.style = style;
1106
1063
  this.drawMeasureLine();
@@ -1123,14 +1080,14 @@
1123
1080
  }
1124
1081
  class MeasureLineDragger extends OdBaseDragger {
1125
1082
  constructor(subject) {
1126
- var _a, _b;
1083
+ var _a;
1127
1084
  super(subject);
1128
1085
  this.lineThickness = 2;
1129
1086
  this.press = false;
1130
1087
  this.gripingRadius = 5.0;
1131
1088
  this.firstPoint = null;
1132
1089
  this.secondPoint = null;
1133
- this.rulerUnitTable = {
1090
+ this.renameUnitTable = {
1134
1091
  Millimeters: "mm",
1135
1092
  Centimeters: "cm",
1136
1093
  Meters: "m",
@@ -1140,14 +1097,13 @@
1140
1097
  Kilometers: "km",
1141
1098
  Miles: "mi",
1142
1099
  Micrometers: "µm",
1143
- Mils: "mil",
1144
1100
  MicroInches: "µin",
1145
1101
  Default: "unit",
1146
1102
  };
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";
1149
1103
  this.items = [];
1150
- this.canvasEvents.push("resize", "optionsChange");
1104
+ this.canvasEvents.push("resize");
1105
+ this.oldRulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
1106
+ this.optionsChange = this.optionsChange.bind(this);
1151
1107
  }
1152
1108
  initialize() {
1153
1109
  super.initialize();
@@ -1242,9 +1198,8 @@
1242
1198
  const viewer = this.m_module.getViewer();
1243
1199
  const item = new MeasureLineItem(this.m_overlayElement, viewer, this.m_module);
1244
1200
  item.lineThickness = this.lineThickness || item.lineThickness;
1245
- const isDefaultUnit = this.rulerUnit === "Default";
1246
- const isDefaultPrecision = this.rulerPrecision === "Default";
1247
- item.setUnit(renameUnit(this.rulerUnitTable, isDefaultUnit ? viewer.getUnit() : this.rulerUnit));
1201
+ const isDefaultUnit = !this.subject.options.rulerUnit || this.subject.options.rulerUnit === "Default";
1202
+ item.setUnit(renameUnit(this.renameUnitTable, isDefaultUnit ? viewer.getUnit() : this.subject.options.rulerUnit));
1248
1203
  if (!isDefaultUnit) {
1249
1204
  const fromUnit = this.getKUnitByName(viewer.getUnit());
1250
1205
  const toUnit = this.getKUnitByName(this.subject.options.rulerUnit);
@@ -1255,49 +1210,29 @@
1255
1210
  else {
1256
1211
  item.setConversionFactor(1.0);
1257
1212
  }
1258
- if (!isDefaultPrecision) {
1259
- item.setPrecision(this.rulerPrecision);
1260
- }
1261
- else {
1262
- item.setPrecision(2);
1263
- }
1264
1213
  this.items.push(item);
1265
1214
  return item;
1266
1215
  }
1267
1216
  optionsChange(event) {
1268
- var _a, _b;
1217
+ var _a;
1269
1218
  const options = event.data;
1270
1219
  const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
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)
1220
+ if (this.oldRulerUnit === toUnitName)
1275
1221
  return;
1276
- this.rulerUnit = toUnitName;
1277
- this.rulerPrecision = toPrecision;
1222
+ this.oldRulerUnit = toUnitName;
1278
1223
  const drawingUnit = this.m_module.getViewer().getUnit();
1279
1224
  const eToUnit = this.getKUnitByName(toUnitName);
1280
1225
  const eFromUnit = this.getKUnitByName(drawingUnit);
1281
1226
  this.items.forEach((item) => {
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
- }
1227
+ if (toUnitName === "Default") {
1228
+ item.setUnit(renameUnit(this.renameUnitTable, drawingUnit));
1229
+ item.setConversionFactor(1.0);
1293
1230
  }
1294
- if (precisionChanged) {
1295
- if (toPrecision === "Default") {
1296
- item.setPrecision(2);
1297
- }
1298
- else {
1299
- item.setPrecision(toPrecision);
1300
- }
1231
+ else {
1232
+ item.setUnit(renameUnit(this.renameUnitTable, toUnitName));
1233
+ const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
1234
+ this.conversionFactor = 1 / multiplier;
1235
+ item.setConversionFactor(this.conversionFactor);
1301
1236
  }
1302
1237
  });
1303
1238
  }
@@ -1331,9 +1266,6 @@
1331
1266
  case "Micrometers":
1332
1267
  eUnit = this.m_module.Units.kMicrometers;
1333
1268
  break;
1334
- case "Mils":
1335
- eUnit = this.m_module.Units.kMils;
1336
- break;
1337
1269
  case "MicroInches":
1338
1270
  eUnit = this.m_module.Units.kMicroInches;
1339
1271
  break;
@@ -17969,7 +17901,7 @@ js: import "konva/skia-backend";
17969
17901
  return this._markup;
17970
17902
  }
17971
17903
  configure(params) {
17972
- this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js";
17904
+ this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/26.11/Visualize.js";
17973
17905
  this._crossOrigin = params.crossOrigin;
17974
17906
  return this;
17975
17907
  }