@inweb/markup 25.8.0 → 25.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/markup",
3
- "version": "25.8.0",
3
+ "version": "25.8.1",
4
4
  "description": "JavaScript 2D markups",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -26,8 +26,8 @@
26
26
  "docs": "typedoc"
27
27
  },
28
28
  "dependencies": {
29
- "@inweb/eventemitter2": "~25.8.0",
30
- "@inweb/viewer-core": "~25.8.0"
29
+ "@inweb/eventemitter2": "~25.8.1",
30
+ "@inweb/viewer-core": "~25.8.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "canvas": "^2.11.2",
@@ -31,6 +31,7 @@ import { IMarkupObject } from "../IMarkupObject";
31
31
  import { IMarkupColorable } from "../IMarkupColorable";
32
32
  import { MarkupLineType } from "../IMarkupLine";
33
33
  import { MarkupColor } from "./MarkupColor";
34
+ import { WorldTransform } from "../WorldTransform";
34
35
  import { KonvaLine } from "./KonvaLine";
35
36
  import { KonvaText } from "./KonvaText";
36
37
  import { KonvaRectangle } from "./KonvaRectangle";
@@ -123,7 +124,7 @@ export class KonvaMarkup implements IMarkup {
123
124
  );
124
125
 
125
126
  this._viewer = viewer;
126
- this._worldTransformer = worldTransformer;
127
+ this._worldTransformer = worldTransformer ?? new WorldTransform();
127
128
  this._container = container;
128
129
  this._pointerEvents = pointerEvents ?? [];
129
130
 
@@ -338,10 +339,6 @@ export class KonvaMarkup implements IMarkup {
338
339
  this._konvaTransformer.nodes([]);
339
340
  }
340
341
 
341
- private getPoint3dFromArray(array) {
342
- return { x: array[0], y: array[1], z: array[2] };
343
- }
344
-
345
342
  private fillViewpointShapes(viewpoint) {
346
343
  const markupLines = this.getMarkupLines();
347
344
  if (markupLines && markupLines.length > 0) {
@@ -662,7 +659,7 @@ export class KonvaMarkup implements IMarkup {
662
659
  const konvaLine = new KonvaLine(null, line);
663
660
  lines.push({
664
661
  id: konvaLine.id(),
665
- points: worldPoints.map((p) => this.getPoint3dFromArray(p)),
662
+ points: worldPoints,
666
663
  color: konvaLine.getColor() || "#ff0000",
667
664
  type: konvaLine.getLineType() || this.lineType,
668
665
  width: konvaLine.getLineWidth() || this.lineWidth,
@@ -681,15 +678,13 @@ export class KonvaMarkup implements IMarkup {
681
678
  this.konvaLayerFind("Text").forEach((text) => {
682
679
  if (!text) return;
683
680
 
684
- const position = this._worldTransformer.screenToWorld({
685
- x: text.x(),
686
- y: text.y(),
687
- });
681
+ const position = { x: text.x(), y: text.y() };
682
+ const worldPoint = this._worldTransformer.screenToWorld(position);
688
683
 
689
684
  const shape = new KonvaText(null, text);
690
685
  texts.push({
691
686
  id: shape.id(),
692
- position: this.getPoint3dFromArray(position),
687
+ position: worldPoint,
693
688
  text: shape.getText(),
694
689
  text_size: textSize * textScale.y,
695
690
  angle: shape.getRotation(),
@@ -710,7 +705,7 @@ export class KonvaMarkup implements IMarkup {
710
705
  const shape = new KonvaRectangle(null, rect);
711
706
  rectangles.push({
712
707
  id: shape.id(),
713
- position: this.getPoint3dFromArray(worldPoint),
708
+ position: worldPoint,
714
709
  width: shape.getWidth(),
715
710
  height: shape.getHeigth(),
716
711
  line_width: shape.getLineWidth(),
@@ -730,7 +725,7 @@ export class KonvaMarkup implements IMarkup {
730
725
  const shape = new KonvaEllipse(null, ellipse);
731
726
  ellipses.push({
732
727
  id: shape.id(),
733
- position: this.getPoint3dFromArray(worldPoint),
728
+ position: worldPoint,
734
729
  radius: { x: ellipse.getRadiusX(), y: ellipse.getRadiusY() },
735
730
  line_width: shape.getLineWidth(),
736
731
  color: shape.getColor(),
@@ -755,8 +750,8 @@ export class KonvaMarkup implements IMarkup {
755
750
  const shape = new KonvaArrow(null, arrow);
756
751
  arrows.push({
757
752
  id: shape.id(),
758
- start: this.getPoint3dFromArray(worldStartPoint),
759
- end: this.getPoint3dFromArray(worldEndPoint),
753
+ start: worldStartPoint,
754
+ end: worldEndPoint,
760
755
  color: shape.getColor(),
761
756
  });
762
757
  });
@@ -773,7 +768,7 @@ export class KonvaMarkup implements IMarkup {
773
768
  const shape = new KonvaImage(null, image);
774
769
  images.push({
775
770
  id: shape.id(),
776
- position: this.getPoint3dFromArray(worldPoint),
771
+ position: worldPoint,
777
772
  src: shape.getSrc(),
778
773
  width: shape.getWidth(),
779
774
  height: shape.getHeight(),
@@ -792,7 +787,7 @@ export class KonvaMarkup implements IMarkup {
792
787
  const shape = new KonvaCloud(null, cloud);
793
788
  clouds.push({
794
789
  id: shape.id(),
795
- position: this.getPoint3dFromArray(worldPoint),
790
+ position: worldPoint,
796
791
  width: shape.getWidth(),
797
792
  height: shape.getHeigth(),
798
793
  line_width: shape.getLineWidth(),
@@ -0,0 +1,36 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ export class WorldTransform {
25
+ screenToWorld(position: { x: number; y: number }): { x: number; y: number; z: number } {
26
+ return { x: position.x, y: position.y, z: 0 };
27
+ }
28
+
29
+ worldToScreen(position: { x: number; y: number; z: number }): { x: number; y: number } {
30
+ return { x: position.x, y: position.y };
31
+ }
32
+
33
+ getScale(): { x: number; y: number; z: number } {
34
+ return { x: 1, y: 1, z: 1 };
35
+ }
36
+ }