@inweb/viewer-visualize 25.7.11 → 25.7.13

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.
@@ -734,6 +734,29 @@ class MarkupColor {
734
734
  }
735
735
  }
736
736
 
737
+ class WorldTransform {
738
+ screenToWorld(position) {
739
+ return {
740
+ x: position.x,
741
+ y: position.y,
742
+ z: 0
743
+ };
744
+ }
745
+ worldToScreen(position) {
746
+ return {
747
+ x: position.x,
748
+ y: position.y
749
+ };
750
+ }
751
+ getScale() {
752
+ return {
753
+ x: 1,
754
+ y: 1,
755
+ z: 1
756
+ };
757
+ }
758
+ }
759
+
737
760
  const LineTypeSpecs = new Map([ [ "solid", [] ], [ "dot", [ 30, 30, .001, 30 ] ], [ "dash", [ 30, 30 ] ] ]);
738
761
 
739
762
  class KonvaLine {
@@ -1638,7 +1661,7 @@ class KonvaMarkup {
1638
1661
  initialize(container, pointerEvents, viewer, worldTransformer) {
1639
1662
  if (!Konva) throw new Error('Markup: Error during initialization. Konva is not initialized. Update node_modules or add to your page <script src="https://unpkg.com/konva@9/konva.min.js"><\/script>');
1640
1663
  this._viewer = viewer;
1641
- this._worldTransformer = worldTransformer;
1664
+ this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform;
1642
1665
  this._container = container;
1643
1666
  this._pointerEvents = pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : [];
1644
1667
  this._markupContainer = document.createElement("div");
@@ -1862,13 +1885,6 @@ class KonvaMarkup {
1862
1885
  clearSelected() {
1863
1886
  this._konvaTransformer.nodes([]);
1864
1887
  }
1865
- getPoint3dFromArray(array) {
1866
- return {
1867
- x: array[0],
1868
- y: array[1],
1869
- z: array[2]
1870
- };
1871
- }
1872
1888
  fillViewpointShapes(viewpoint) {
1873
1889
  const markupLines = this.getMarkupLines();
1874
1890
  if (markupLines && markupLines.length > 0) {
@@ -2159,7 +2175,7 @@ class KonvaMarkup {
2159
2175
  const konvaLine = new KonvaLine(null, line);
2160
2176
  lines.push({
2161
2177
  id: konvaLine.id(),
2162
- points: worldPoints.map((p => this.getPoint3dFromArray(p))),
2178
+ points: worldPoints,
2163
2179
  color: konvaLine.getColor() || "#ff0000",
2164
2180
  type: konvaLine.getLineType() || this.lineType,
2165
2181
  width: konvaLine.getLineWidth() || this.lineWidth
@@ -2173,14 +2189,15 @@ class KonvaMarkup {
2173
2189
  const textScale = this._worldTransformer.getScale();
2174
2190
  this.konvaLayerFind("Text").forEach((text => {
2175
2191
  if (!text) return;
2176
- const position = this._worldTransformer.screenToWorld({
2192
+ const position = {
2177
2193
  x: text.x(),
2178
2194
  y: text.y()
2179
- });
2195
+ };
2196
+ const worldPoint = this._worldTransformer.screenToWorld(position);
2180
2197
  const shape = new KonvaText(null, text);
2181
2198
  texts.push({
2182
2199
  id: shape.id(),
2183
- position: this.getPoint3dFromArray(position),
2200
+ position: worldPoint,
2184
2201
  text: shape.getText(),
2185
2202
  text_size: textSize * textScale.y,
2186
2203
  angle: shape.getRotation(),
@@ -2198,7 +2215,7 @@ class KonvaMarkup {
2198
2215
  const shape = new KonvaRectangle(null, rect);
2199
2216
  rectangles.push({
2200
2217
  id: shape.id(),
2201
- position: this.getPoint3dFromArray(worldPoint),
2218
+ position: worldPoint,
2202
2219
  width: shape.getWidth(),
2203
2220
  height: shape.getHeigth(),
2204
2221
  line_width: shape.getLineWidth(),
@@ -2215,7 +2232,7 @@ class KonvaMarkup {
2215
2232
  const shape = new KonvaEllipse(null, ellipse);
2216
2233
  ellipses.push({
2217
2234
  id: shape.id(),
2218
- position: this.getPoint3dFromArray(worldPoint),
2235
+ position: worldPoint,
2219
2236
  radius: {
2220
2237
  x: ellipse.getRadiusX(),
2221
2238
  y: ellipse.getRadiusY()
@@ -2243,8 +2260,8 @@ class KonvaMarkup {
2243
2260
  const shape = new KonvaArrow(null, arrow);
2244
2261
  arrows.push({
2245
2262
  id: shape.id(),
2246
- start: this.getPoint3dFromArray(worldStartPoint),
2247
- end: this.getPoint3dFromArray(worldEndPoint),
2263
+ start: worldStartPoint,
2264
+ end: worldEndPoint,
2248
2265
  color: shape.getColor()
2249
2266
  });
2250
2267
  }));
@@ -2258,7 +2275,7 @@ class KonvaMarkup {
2258
2275
  const shape = new KonvaImage(null, image);
2259
2276
  images.push({
2260
2277
  id: shape.id(),
2261
- position: this.getPoint3dFromArray(worldPoint),
2278
+ position: worldPoint,
2262
2279
  src: shape.getSrc(),
2263
2280
  width: shape.getWidth(),
2264
2281
  height: shape.getHeight()
@@ -2274,7 +2291,7 @@ class KonvaMarkup {
2274
2291
  const shape = new KonvaCloud(null, cloud);
2275
2292
  clouds.push({
2276
2293
  id: shape.id(),
2277
- position: this.getPoint3dFromArray(worldPoint),
2294
+ position: worldPoint,
2278
2295
  width: shape.getWidth(),
2279
2296
  height: shape.getHeigth(),
2280
2297
  line_width: shape.getLineWidth(),
@@ -4954,8 +4971,6 @@ class OdaTextDragger extends OdBaseDragger {
4954
4971
  }
4955
4972
  }
4956
4973
 
4957
- const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
4958
-
4959
4974
  class VisualizeMarkup {
4960
4975
  constructor() {
4961
4976
  this._markupColor = {
@@ -4972,30 +4987,7 @@ class VisualizeMarkup {
4972
4987
  this._viewer.registerDragger("Text", OdaTextDragger);
4973
4988
  }
4974
4989
  dispose() {}
4975
- syncOverlay() {
4976
- if (!this._viewer.visualizeJs) return;
4977
- const visViewer = this._viewer.visViewer();
4978
- const activeView = visViewer.activeView;
4979
- let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
4980
- if (!overlayView) {
4981
- const overlayModel = visViewer.getMarkupModel();
4982
- const pDevice = visViewer.getActiveDevice();
4983
- overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
4984
- overlayView.addModel(overlayModel);
4985
- activeView.addSibling(overlayView);
4986
- pDevice.addView(overlayView);
4987
- }
4988
- overlayView.viewPosition = activeView.viewPosition;
4989
- overlayView.viewTarget = activeView.viewTarget;
4990
- overlayView.upVector = activeView.upVector;
4991
- overlayView.viewFieldWidth = activeView.viewFieldWidth;
4992
- overlayView.viewFieldHeight = activeView.viewFieldHeight;
4993
- const viewPort = overlayView.getViewport();
4994
- overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
4995
- overlayView.vportRect = activeView.vportRect;
4996
- this._viewer.update();
4997
- return overlayView;
4998
- }
4990
+ syncOverlay() {}
4999
4991
  clearOverlay() {
5000
4992
  if (!this._viewer.visualizeJs) return;
5001
4993
  const visViewer = this._viewer.visViewer();
@@ -5148,23 +5140,19 @@ class VisualizeMarkup {
5148
5140
  return viewpoint;
5149
5141
  }
5150
5142
  enableEditMode(mode) {
5151
- throw new Error("Not implemented yet");
5143
+ return this;
5152
5144
  }
5153
5145
  createObject(type, params) {
5154
- throw new Error("Not implemented yet");
5146
+ return undefined;
5155
5147
  }
5156
5148
  getObjects() {
5157
- throw new Error("Not implemented yet");
5149
+ return [];
5158
5150
  }
5159
5151
  getSelectedObjects() {
5160
- throw new Error("Not implemented yet");
5161
- }
5162
- selectObjects(objects) {
5163
- throw new Error("Not implemented yet");
5164
- }
5165
- clearSelected() {
5166
- throw new Error("Not implemented yet");
5152
+ return [];
5167
5153
  }
5154
+ selectObjects(objects) {}
5155
+ clearSelected() {}
5168
5156
  }
5169
5157
 
5170
5158
  var MarkupType;
@@ -5194,6 +5182,8 @@ class MarkupFactory {
5194
5182
  }
5195
5183
  }
5196
5184
 
5185
+ const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
5186
+
5197
5187
  const isExist = value => value !== undefined && value !== null;
5198
5188
 
5199
5189
  class Viewer extends EventEmitter2 {
@@ -5239,7 +5229,7 @@ class Viewer extends EventEmitter2 {
5239
5229
  return this._markup;
5240
5230
  }
5241
5231
  configure(params) {
5242
- this._visualizeJsUrl = params.visualizeJsUrl || "https://opencloud.azureedge.net/libs/visualizejs/25.7/Visualize.js";
5232
+ this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/25.7/Visualize.js";
5243
5233
  return this;
5244
5234
  }
5245
5235
  async initialize(canvas, onProgress) {
@@ -5573,10 +5563,33 @@ class Viewer extends EventEmitter2 {
5573
5563
  this.update();
5574
5564
  }
5575
5565
  clearOverlay() {
5566
+ if (!this.visualizeJs) return;
5576
5567
  this._markup.clearOverlay();
5568
+ this.update();
5577
5569
  }
5578
5570
  syncOverlay() {
5579
- return this._markup.syncOverlay();
5571
+ if (!this.visualizeJs) return;
5572
+ const visViewer = this.visViewer();
5573
+ const activeView = visViewer.activeView;
5574
+ let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
5575
+ if (!overlayView) {
5576
+ const markupModel = visViewer.getMarkupModel();
5577
+ const pDevice = visViewer.getActiveDevice();
5578
+ overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
5579
+ overlayView.addModel(markupModel);
5580
+ activeView.addSibling(overlayView);
5581
+ pDevice.addView(overlayView);
5582
+ }
5583
+ overlayView.viewPosition = activeView.viewPosition;
5584
+ overlayView.viewTarget = activeView.viewTarget;
5585
+ overlayView.upVector = activeView.upVector;
5586
+ overlayView.viewFieldWidth = activeView.viewFieldWidth;
5587
+ overlayView.viewFieldHeight = activeView.viewFieldHeight;
5588
+ const viewPort = overlayView.getViewport();
5589
+ overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
5590
+ overlayView.vportRect = activeView.vportRect;
5591
+ this._markup.syncOverlay();
5592
+ this.update();
5580
5593
  }
5581
5594
  is3D() {
5582
5595
  if (!this.visualizeJs) return false;
@@ -5588,7 +5601,18 @@ class Viewer extends EventEmitter2 {
5588
5601
  return extHeight !== 0;
5589
5602
  }
5590
5603
  screenToWorld(position) {
5591
- return this.visViewer().screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
5604
+ if (!this.visualizeJs) return {
5605
+ x: position.x,
5606
+ y: position.y,
5607
+ z: 0
5608
+ };
5609
+ const worldPoint = this.visViewer().screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
5610
+ const result = {
5611
+ x: worldPoint[0],
5612
+ y: worldPoint[1],
5613
+ z: worldPoint[2]
5614
+ };
5615
+ return result;
5592
5616
  }
5593
5617
  worldToScreen(position) {
5594
5618
  if (!this.visualizeJs) return position;
@@ -5614,12 +5638,12 @@ class Viewer extends EventEmitter2 {
5614
5638
  };
5615
5639
  const projMatrix = this.visViewer().activeView.projectionMatrix;
5616
5640
  const tolerance = 1e-6;
5617
- const x = projMatrix.get(1, 1);
5618
- if (x > tolerance || x < -tolerance) result.x = 1 / result.x;
5641
+ const x = projMatrix.get(0, 0);
5642
+ if (x > tolerance || x < -tolerance) result.x = 1 / x;
5619
5643
  const y = projMatrix.get(1, 1);
5620
- if (y > tolerance || y < -tolerance) result.y = 1 / result.y;
5644
+ if (y > tolerance || y < -tolerance) result.y = 1 / y;
5621
5645
  const z = projMatrix.get(2, 2);
5622
- if (z > tolerance || z < -tolerance) result.z = 1 / result.z;
5646
+ if (z > tolerance || z < -tolerance) result.z = 1 / z;
5623
5647
  return result;
5624
5648
  }
5625
5649
  getSelected() {