@inweb/viewer-visualize 25.8.0 → 25.8.2

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.
@@ -12172,6 +12172,29 @@
12172
12172
  }
12173
12173
  }
12174
12174
 
12175
+ class WorldTransform {
12176
+ screenToWorld(position) {
12177
+ return {
12178
+ x: position.x,
12179
+ y: position.y,
12180
+ z: 0
12181
+ };
12182
+ }
12183
+ worldToScreen(position) {
12184
+ return {
12185
+ x: position.x,
12186
+ y: position.y
12187
+ };
12188
+ }
12189
+ getScale() {
12190
+ return {
12191
+ x: 1,
12192
+ y: 1,
12193
+ z: 1
12194
+ };
12195
+ }
12196
+ }
12197
+
12175
12198
  const LineTypeSpecs = new Map([ [ "solid", [] ], [ "dot", [ 30, 30, .001, 30 ] ], [ "dash", [ 30, 30 ] ] ]);
12176
12199
 
12177
12200
  class KonvaLine {
@@ -13082,7 +13105,7 @@
13082
13105
  initialize(container, pointerEvents, viewer, worldTransformer) {
13083
13106
  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>');
13084
13107
  this._viewer = viewer;
13085
- this._worldTransformer = worldTransformer;
13108
+ this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform;
13086
13109
  this._container = container;
13087
13110
  this._pointerEvents = pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : [];
13088
13111
  this._markupContainer = document.createElement("div");
@@ -13221,13 +13244,6 @@
13221
13244
  clearSelected() {
13222
13245
  this._konvaTransformer.nodes([]);
13223
13246
  }
13224
- getPoint3dFromArray(array) {
13225
- return {
13226
- x: array[0],
13227
- y: array[1],
13228
- z: array[2]
13229
- };
13230
- }
13231
13247
  fillViewpointShapes(viewpoint) {
13232
13248
  const markupLines = this.getMarkupLines();
13233
13249
  if (markupLines && markupLines.length > 0) {
@@ -13518,7 +13534,7 @@
13518
13534
  const konvaLine = new KonvaLine(null, line);
13519
13535
  lines.push({
13520
13536
  id: konvaLine.id(),
13521
- points: worldPoints.map((p => this.getPoint3dFromArray(p))),
13537
+ points: worldPoints,
13522
13538
  color: konvaLine.getColor() || "#ff0000",
13523
13539
  type: konvaLine.getLineType() || this.lineType,
13524
13540
  width: konvaLine.getLineWidth() || this.lineWidth
@@ -13532,14 +13548,15 @@
13532
13548
  const textScale = this._worldTransformer.getScale();
13533
13549
  this.konvaLayerFind("Text").forEach((text => {
13534
13550
  if (!text) return;
13535
- const position = this._worldTransformer.screenToWorld({
13551
+ const position = {
13536
13552
  x: text.x(),
13537
13553
  y: text.y()
13538
- });
13554
+ };
13555
+ const worldPoint = this._worldTransformer.screenToWorld(position);
13539
13556
  const shape = new KonvaText(null, text);
13540
13557
  texts.push({
13541
13558
  id: shape.id(),
13542
- position: this.getPoint3dFromArray(position),
13559
+ position: worldPoint,
13543
13560
  text: shape.getText(),
13544
13561
  text_size: textSize * textScale.y,
13545
13562
  angle: shape.getRotation(),
@@ -13557,7 +13574,7 @@
13557
13574
  const shape = new KonvaRectangle(null, rect);
13558
13575
  rectangles.push({
13559
13576
  id: shape.id(),
13560
- position: this.getPoint3dFromArray(worldPoint),
13577
+ position: worldPoint,
13561
13578
  width: shape.getWidth(),
13562
13579
  height: shape.getHeigth(),
13563
13580
  line_width: shape.getLineWidth(),
@@ -13574,7 +13591,7 @@
13574
13591
  const shape = new KonvaEllipse(null, ellipse);
13575
13592
  ellipses.push({
13576
13593
  id: shape.id(),
13577
- position: this.getPoint3dFromArray(worldPoint),
13594
+ position: worldPoint,
13578
13595
  radius: {
13579
13596
  x: ellipse.getRadiusX(),
13580
13597
  y: ellipse.getRadiusY()
@@ -13602,8 +13619,8 @@
13602
13619
  const shape = new KonvaArrow(null, arrow);
13603
13620
  arrows.push({
13604
13621
  id: shape.id(),
13605
- start: this.getPoint3dFromArray(worldStartPoint),
13606
- end: this.getPoint3dFromArray(worldEndPoint),
13622
+ start: worldStartPoint,
13623
+ end: worldEndPoint,
13607
13624
  color: shape.getColor()
13608
13625
  });
13609
13626
  }));
@@ -13617,7 +13634,7 @@
13617
13634
  const shape = new KonvaImage(null, image);
13618
13635
  images.push({
13619
13636
  id: shape.id(),
13620
- position: this.getPoint3dFromArray(worldPoint),
13637
+ position: worldPoint,
13621
13638
  src: shape.getSrc(),
13622
13639
  width: shape.getWidth(),
13623
13640
  height: shape.getHeight()
@@ -13633,7 +13650,7 @@
13633
13650
  const shape = new KonvaCloud(null, cloud);
13634
13651
  clouds.push({
13635
13652
  id: shape.id(),
13636
- position: this.getPoint3dFromArray(worldPoint),
13653
+ position: worldPoint,
13637
13654
  width: shape.getWidth(),
13638
13655
  height: shape.getHeigth(),
13639
13656
  line_width: shape.getLineWidth(),