@shapediver/viewer.features.drawing-tools 3.1.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.
Files changed (209) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +161 -0
  3. package/dist/api/implementation/DrawingToolsApi.d.ts +31 -0
  4. package/dist/api/implementation/DrawingToolsApi.d.ts.map +1 -0
  5. package/dist/api/implementation/DrawingToolsApi.js +111 -0
  6. package/dist/api/implementation/DrawingToolsApi.js.map +1 -0
  7. package/dist/api/implementation/restrictions/AbstractRestrictionApi.d.ts +10 -0
  8. package/dist/api/implementation/restrictions/AbstractRestrictionApi.d.ts.map +1 -0
  9. package/dist/api/implementation/restrictions/AbstractRestrictionApi.js +38 -0
  10. package/dist/api/implementation/restrictions/AbstractRestrictionApi.js.map +1 -0
  11. package/dist/api/implementation/restrictions/AbstractSnapRestrictionApi.d.ts +11 -0
  12. package/dist/api/implementation/restrictions/AbstractSnapRestrictionApi.d.ts.map +1 -0
  13. package/dist/api/implementation/restrictions/AbstractSnapRestrictionApi.js +40 -0
  14. package/dist/api/implementation/restrictions/AbstractSnapRestrictionApi.js.map +1 -0
  15. package/dist/api/implementation/restrictions/axis/AxisRestrictionApi.d.ts +7 -0
  16. package/dist/api/implementation/restrictions/axis/AxisRestrictionApi.d.ts.map +1 -0
  17. package/dist/api/implementation/restrictions/axis/AxisRestrictionApi.js +24 -0
  18. package/dist/api/implementation/restrictions/axis/AxisRestrictionApi.js.map +1 -0
  19. package/dist/api/implementation/restrictions/geometry/GeometryRestrictionApi.d.ts +15 -0
  20. package/dist/api/implementation/restrictions/geometry/GeometryRestrictionApi.d.ts.map +1 -0
  21. package/dist/api/implementation/restrictions/geometry/GeometryRestrictionApi.js +54 -0
  22. package/dist/api/implementation/restrictions/geometry/GeometryRestrictionApi.js.map +1 -0
  23. package/dist/api/implementation/restrictions/plane/PlaneRestrictionApi.d.ts +18 -0
  24. package/dist/api/implementation/restrictions/plane/PlaneRestrictionApi.d.ts.map +1 -0
  25. package/dist/api/implementation/restrictions/plane/PlaneRestrictionApi.js +61 -0
  26. package/dist/api/implementation/restrictions/plane/PlaneRestrictionApi.js.map +1 -0
  27. package/dist/api/implementation/restrictions/plane/snap/AngularRestrictionApi.d.ts +10 -0
  28. package/dist/api/implementation/restrictions/plane/snap/AngularRestrictionApi.d.ts.map +1 -0
  29. package/dist/api/implementation/restrictions/plane/snap/AngularRestrictionApi.js +40 -0
  30. package/dist/api/implementation/restrictions/plane/snap/AngularRestrictionApi.js.map +1 -0
  31. package/dist/api/implementation/restrictions/plane/snap/GridRestrictionApi.d.ts +10 -0
  32. package/dist/api/implementation/restrictions/plane/snap/GridRestrictionApi.d.ts.map +1 -0
  33. package/dist/api/implementation/restrictions/plane/snap/GridRestrictionApi.js +40 -0
  34. package/dist/api/implementation/restrictions/plane/snap/GridRestrictionApi.js.map +1 -0
  35. package/dist/api/interfaces/IDrawingToolsApi.d.ts +89 -0
  36. package/dist/api/interfaces/IDrawingToolsApi.d.ts.map +1 -0
  37. package/dist/api/interfaces/IDrawingToolsApi.js +3 -0
  38. package/dist/api/interfaces/IDrawingToolsApi.js.map +1 -0
  39. package/dist/api/interfaces/IRestrictionApi.d.ts +11 -0
  40. package/dist/api/interfaces/IRestrictionApi.d.ts.map +1 -0
  41. package/dist/api/interfaces/IRestrictionApi.js +3 -0
  42. package/dist/api/interfaces/IRestrictionApi.js.map +1 -0
  43. package/dist/api/interfaces/ISnapRestrictionApi.d.ts +13 -0
  44. package/dist/api/interfaces/ISnapRestrictionApi.d.ts.map +1 -0
  45. package/dist/api/interfaces/ISnapRestrictionApi.js +3 -0
  46. package/dist/api/interfaces/ISnapRestrictionApi.js.map +1 -0
  47. package/dist/business/implementation/DrawingToolsManager.d.ts +95 -0
  48. package/dist/business/implementation/DrawingToolsManager.d.ts.map +1 -0
  49. package/dist/business/implementation/DrawingToolsManager.js +544 -0
  50. package/dist/business/implementation/DrawingToolsManager.js.map +1 -0
  51. package/dist/business/implementation/managers/HistoryManager.d.ts +19 -0
  52. package/dist/business/implementation/managers/HistoryManager.d.ts.map +1 -0
  53. package/dist/business/implementation/managers/HistoryManager.js +89 -0
  54. package/dist/business/implementation/managers/HistoryManager.js.map +1 -0
  55. package/dist/business/implementation/managers/TextVisualizationManager.d.ts +14 -0
  56. package/dist/business/implementation/managers/TextVisualizationManager.d.ts.map +1 -0
  57. package/dist/business/implementation/managers/TextVisualizationManager.js +228 -0
  58. package/dist/business/implementation/managers/TextVisualizationManager.js.map +1 -0
  59. package/dist/business/implementation/managers/geometry/GeometryManager.d.ts +23 -0
  60. package/dist/business/implementation/managers/geometry/GeometryManager.d.ts.map +1 -0
  61. package/dist/business/implementation/managers/geometry/GeometryManager.js +82 -0
  62. package/dist/business/implementation/managers/geometry/GeometryManager.js.map +1 -0
  63. package/dist/business/implementation/managers/geometry/GeometryMathManager.d.ts +73 -0
  64. package/dist/business/implementation/managers/geometry/GeometryMathManager.d.ts.map +1 -0
  65. package/dist/business/implementation/managers/geometry/GeometryMathManager.js +230 -0
  66. package/dist/business/implementation/managers/geometry/GeometryMathManager.js.map +1 -0
  67. package/dist/business/implementation/managers/geometry/GeometryState.d.ts +46 -0
  68. package/dist/business/implementation/managers/geometry/GeometryState.d.ts.map +1 -0
  69. package/dist/business/implementation/managers/geometry/GeometryState.js +323 -0
  70. package/dist/business/implementation/managers/geometry/GeometryState.js.map +1 -0
  71. package/dist/business/implementation/managers/geometry/helpers/GeometryManagerHelper.d.ts +16 -0
  72. package/dist/business/implementation/managers/geometry/helpers/GeometryManagerHelper.d.ts.map +1 -0
  73. package/dist/business/implementation/managers/geometry/helpers/GeometryManagerHelper.js +157 -0
  74. package/dist/business/implementation/managers/geometry/helpers/GeometryManagerHelper.js.map +1 -0
  75. package/dist/business/implementation/managers/interaction/EventManager.d.ts +26 -0
  76. package/dist/business/implementation/managers/interaction/EventManager.d.ts.map +1 -0
  77. package/dist/business/implementation/managers/interaction/EventManager.js +63 -0
  78. package/dist/business/implementation/managers/interaction/EventManager.js.map +1 -0
  79. package/dist/business/implementation/managers/interaction/InteractionManager.d.ts +39 -0
  80. package/dist/business/implementation/managers/interaction/InteractionManager.d.ts.map +1 -0
  81. package/dist/business/implementation/managers/interaction/InteractionManager.js +237 -0
  82. package/dist/business/implementation/managers/interaction/InteractionManager.js.map +1 -0
  83. package/dist/business/implementation/managers/interaction/RestrictionManager.d.ts +19 -0
  84. package/dist/business/implementation/managers/interaction/RestrictionManager.d.ts.map +1 -0
  85. package/dist/business/implementation/managers/interaction/RestrictionManager.js +117 -0
  86. package/dist/business/implementation/managers/interaction/RestrictionManager.js.map +1 -0
  87. package/dist/business/implementation/managers/interaction/handlers/DeletionInteractionHandler.d.ts +10 -0
  88. package/dist/business/implementation/managers/interaction/handlers/DeletionInteractionHandler.d.ts.map +1 -0
  89. package/dist/business/implementation/managers/interaction/handlers/DeletionInteractionHandler.js +52 -0
  90. package/dist/business/implementation/managers/interaction/handlers/DeletionInteractionHandler.js.map +1 -0
  91. package/dist/business/implementation/managers/interaction/handlers/InsertionInteractionHandler.d.ts +14 -0
  92. package/dist/business/implementation/managers/interaction/handlers/InsertionInteractionHandler.d.ts.map +1 -0
  93. package/dist/business/implementation/managers/interaction/handlers/InsertionInteractionHandler.js +135 -0
  94. package/dist/business/implementation/managers/interaction/handlers/InsertionInteractionHandler.js.map +1 -0
  95. package/dist/business/implementation/managers/interaction/handlers/MidPointInteractionHandler.d.ts +16 -0
  96. package/dist/business/implementation/managers/interaction/handlers/MidPointInteractionHandler.d.ts.map +1 -0
  97. package/dist/business/implementation/managers/interaction/handlers/MidPointInteractionHandler.js +113 -0
  98. package/dist/business/implementation/managers/interaction/handlers/MidPointInteractionHandler.js.map +1 -0
  99. package/dist/business/implementation/managers/interaction/helpers/InteractionManagerHelper.d.ts +58 -0
  100. package/dist/business/implementation/managers/interaction/helpers/InteractionManagerHelper.d.ts.map +1 -0
  101. package/dist/business/implementation/managers/interaction/helpers/InteractionManagerHelper.js +377 -0
  102. package/dist/business/implementation/managers/interaction/helpers/InteractionManagerHelper.js.map +1 -0
  103. package/dist/business/implementation/managers/interaction/restrictions/AbstractRestriction.d.ts +19 -0
  104. package/dist/business/implementation/managers/interaction/restrictions/AbstractRestriction.d.ts.map +1 -0
  105. package/dist/business/implementation/managers/interaction/restrictions/AbstractRestriction.js +105 -0
  106. package/dist/business/implementation/managers/interaction/restrictions/AbstractRestriction.js.map +1 -0
  107. package/dist/business/implementation/managers/interaction/restrictions/axis/AxisRestriction.d.ts +22 -0
  108. package/dist/business/implementation/managers/interaction/restrictions/axis/AxisRestriction.d.ts.map +1 -0
  109. package/dist/business/implementation/managers/interaction/restrictions/axis/AxisRestriction.js +96 -0
  110. package/dist/business/implementation/managers/interaction/restrictions/axis/AxisRestriction.js.map +1 -0
  111. package/dist/business/implementation/managers/interaction/restrictions/geometry/GeometryRestriction.d.ts +39 -0
  112. package/dist/business/implementation/managers/interaction/restrictions/geometry/GeometryRestriction.d.ts.map +1 -0
  113. package/dist/business/implementation/managers/interaction/restrictions/geometry/GeometryRestriction.js +215 -0
  114. package/dist/business/implementation/managers/interaction/restrictions/geometry/GeometryRestriction.js.map +1 -0
  115. package/dist/business/implementation/managers/interaction/restrictions/plane/PlaneRestriction.d.ts +58 -0
  116. package/dist/business/implementation/managers/interaction/restrictions/plane/PlaneRestriction.d.ts.map +1 -0
  117. package/dist/business/implementation/managers/interaction/restrictions/plane/PlaneRestriction.js +180 -0
  118. package/dist/business/implementation/managers/interaction/restrictions/plane/PlaneRestriction.js.map +1 -0
  119. package/dist/business/implementation/managers/interaction/restrictions/plane/snap/AngularRestriction.d.ts +38 -0
  120. package/dist/business/implementation/managers/interaction/restrictions/plane/snap/AngularRestriction.d.ts.map +1 -0
  121. package/dist/business/implementation/managers/interaction/restrictions/plane/snap/AngularRestriction.js +308 -0
  122. package/dist/business/implementation/managers/interaction/restrictions/plane/snap/AngularRestriction.js.map +1 -0
  123. package/dist/business/implementation/managers/interaction/restrictions/plane/snap/GridRestriction.d.ts +37 -0
  124. package/dist/business/implementation/managers/interaction/restrictions/plane/snap/GridRestriction.d.ts.map +1 -0
  125. package/dist/business/implementation/managers/interaction/restrictions/plane/snap/GridRestriction.js +228 -0
  126. package/dist/business/implementation/managers/interaction/restrictions/plane/snap/GridRestriction.js.map +1 -0
  127. package/dist/business/implementation/utils/numberCleaner.d.ts +2 -0
  128. package/dist/business/implementation/utils/numberCleaner.d.ts.map +1 -0
  129. package/dist/business/implementation/utils/numberCleaner.js +9 -0
  130. package/dist/business/implementation/utils/numberCleaner.js.map +1 -0
  131. package/dist/business/interfaces/IDrawingToolsManager.d.ts +270 -0
  132. package/dist/business/interfaces/IDrawingToolsManager.d.ts.map +1 -0
  133. package/dist/business/interfaces/IDrawingToolsManager.js +16 -0
  134. package/dist/business/interfaces/IDrawingToolsManager.js.map +1 -0
  135. package/dist/business/interfaces/IManager.d.ts +4 -0
  136. package/dist/business/interfaces/IManager.d.ts.map +1 -0
  137. package/dist/business/interfaces/IManager.js +3 -0
  138. package/dist/business/interfaces/IManager.js.map +1 -0
  139. package/dist/business/interfaces/IRestriction.d.ts +41 -0
  140. package/dist/business/interfaces/IRestriction.d.ts.map +1 -0
  141. package/dist/business/interfaces/IRestriction.js +13 -0
  142. package/dist/business/interfaces/IRestriction.js.map +1 -0
  143. package/dist/business/interfaces/IRestrictionBase.d.ts +19 -0
  144. package/dist/business/interfaces/IRestrictionBase.d.ts.map +1 -0
  145. package/dist/business/interfaces/IRestrictionBase.js +5 -0
  146. package/dist/business/interfaces/IRestrictionBase.js.map +1 -0
  147. package/dist/business/interfaces/ISnapRestriction.d.ts +50 -0
  148. package/dist/business/interfaces/ISnapRestriction.d.ts.map +1 -0
  149. package/dist/business/interfaces/ISnapRestriction.js +4 -0
  150. package/dist/business/interfaces/ISnapRestriction.js.map +1 -0
  151. package/dist/business/interfaces/events/EventResponseMapping.d.ts +19 -0
  152. package/dist/business/interfaces/events/EventResponseMapping.d.ts.map +1 -0
  153. package/dist/business/interfaces/events/EventResponseMapping.js +4 -0
  154. package/dist/business/interfaces/events/EventResponseMapping.js.map +1 -0
  155. package/dist/business/interfaces/events/IDrawingToolsEvent.d.ts +12 -0
  156. package/dist/business/interfaces/events/IDrawingToolsEvent.d.ts.map +1 -0
  157. package/dist/business/interfaces/events/IDrawingToolsEvent.js +3 -0
  158. package/dist/business/interfaces/events/IDrawingToolsEvent.js.map +1 -0
  159. package/dist/index.d.ts +32 -0
  160. package/dist/index.d.ts.map +1 -0
  161. package/dist/index.js +45 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/three/CSS2DRenderer.d.ts +32 -0
  164. package/dist/three/CSS2DRenderer.d.ts.map +1 -0
  165. package/dist/three/CSS2DRenderer.js +137 -0
  166. package/dist/three/CSS2DRenderer.js.map +1 -0
  167. package/package.json +55 -0
  168. package/src/api/implementation/DrawingToolsApi.ts +135 -0
  169. package/src/api/implementation/restrictions/AbstractRestrictionApi.ts +34 -0
  170. package/src/api/implementation/restrictions/AbstractSnapRestrictionApi.ts +36 -0
  171. package/src/api/implementation/restrictions/axis/AxisRestrictionApi.ts +19 -0
  172. package/src/api/implementation/restrictions/geometry/GeometryRestrictionApi.ts +56 -0
  173. package/src/api/implementation/restrictions/plane/PlaneRestrictionApi.ts +63 -0
  174. package/src/api/implementation/restrictions/plane/snap/AngularRestrictionApi.ts +35 -0
  175. package/src/api/implementation/restrictions/plane/snap/GridRestrictionApi.ts +35 -0
  176. package/src/api/interfaces/IDrawingToolsApi.ts +99 -0
  177. package/src/api/interfaces/IRestrictionApi.ts +15 -0
  178. package/src/api/interfaces/ISnapRestrictionApi.ts +18 -0
  179. package/src/business/implementation/DrawingToolsManager.ts +619 -0
  180. package/src/business/implementation/managers/HistoryManager.ts +101 -0
  181. package/src/business/implementation/managers/TextVisualizationManager.ts +245 -0
  182. package/src/business/implementation/managers/geometry/GeometryManager.ts +95 -0
  183. package/src/business/implementation/managers/geometry/GeometryMathManager.ts +273 -0
  184. package/src/business/implementation/managers/geometry/GeometryState.ts +436 -0
  185. package/src/business/implementation/managers/geometry/helpers/GeometryManagerHelper.ts +170 -0
  186. package/src/business/implementation/managers/interaction/EventManager.ts +80 -0
  187. package/src/business/implementation/managers/interaction/InteractionManager.ts +268 -0
  188. package/src/business/implementation/managers/interaction/RestrictionManager.ts +135 -0
  189. package/src/business/implementation/managers/interaction/handlers/DeletionInteractionHandler.ts +48 -0
  190. package/src/business/implementation/managers/interaction/handlers/InsertionInteractionHandler.ts +149 -0
  191. package/src/business/implementation/managers/interaction/handlers/MidPointInteractionHandler.ts +127 -0
  192. package/src/business/implementation/managers/interaction/helpers/InteractionManagerHelper.ts +411 -0
  193. package/src/business/implementation/managers/interaction/restrictions/AbstractRestriction.ts +99 -0
  194. package/src/business/implementation/managers/interaction/restrictions/axis/AxisRestriction.ts +107 -0
  195. package/src/business/implementation/managers/interaction/restrictions/geometry/GeometryRestriction.ts +237 -0
  196. package/src/business/implementation/managers/interaction/restrictions/plane/PlaneRestriction.ts +257 -0
  197. package/src/business/implementation/managers/interaction/restrictions/plane/snap/AngularRestriction.ts +384 -0
  198. package/src/business/implementation/managers/interaction/restrictions/plane/snap/GridRestriction.ts +262 -0
  199. package/src/business/implementation/utils/numberCleaner.ts +5 -0
  200. package/src/business/interfaces/IDrawingToolsManager.ts +313 -0
  201. package/src/business/interfaces/IManager.ts +7 -0
  202. package/src/business/interfaces/IRestriction.ts +64 -0
  203. package/src/business/interfaces/IRestrictionBase.ts +33 -0
  204. package/src/business/interfaces/ISnapRestriction.ts +70 -0
  205. package/src/business/interfaces/events/EventResponseMapping.ts +19 -0
  206. package/src/business/interfaces/events/IDrawingToolsEvent.ts +16 -0
  207. package/src/index.ts +72 -0
  208. package/src/three/CSS2DRenderer.ts +212 -0
  209. package/tsconfig.json +17 -0
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _GeometryMathManager_drawingToolsManager, _GeometryMathManager_settings, _GeometryMathManager_viewport;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.GeometryMathManager = void 0;
16
+ const gl_matrix_1 = require("gl-matrix");
17
+ class GeometryMathManager {
18
+ // #endregion Properties (3)
19
+ // #region Constructors (1)
20
+ constructor(drawingToolsManager) {
21
+ // #region Properties (3)
22
+ _GeometryMathManager_drawingToolsManager.set(this, void 0);
23
+ _GeometryMathManager_settings.set(this, void 0);
24
+ _GeometryMathManager_viewport.set(this, void 0);
25
+ __classPrivateFieldSet(this, _GeometryMathManager_drawingToolsManager, drawingToolsManager, "f");
26
+ __classPrivateFieldSet(this, _GeometryMathManager_viewport, drawingToolsManager.viewport, "f");
27
+ __classPrivateFieldSet(this, _GeometryMathManager_settings, drawingToolsManager.settings, "f");
28
+ }
29
+ // #endregion Constructors (1)
30
+ // #region Public Methods (7)
31
+ /**
32
+ * Check which distances of lines to ray
33
+ *
34
+ * @param ray
35
+ * @returns
36
+ */
37
+ checkLineDistances(ray) {
38
+ const positionArray = __classPrivateFieldGet(this, _GeometryMathManager_drawingToolsManager, "f").positionArray;
39
+ const indicesArrayLines = __classPrivateFieldGet(this, _GeometryMathManager_drawingToolsManager, "f").indicesArrayLines;
40
+ // if there are no line array indices, return
41
+ if (!indicesArrayLines)
42
+ return;
43
+ /**
44
+ * Calculate line distances to ray
45
+ */
46
+ const distances = [];
47
+ for (let i = 0; i < indicesArrayLines.length; i += 2) {
48
+ const firstIndex = indicesArrayLines.at(i);
49
+ const secondIndex = indicesArrayLines.at(i + 1);
50
+ const lineStart = gl_matrix_1.vec3.fromValues(positionArray.at(firstIndex * 3), positionArray.at(firstIndex * 3 + 1), positionArray.at(firstIndex * 3 + 2));
51
+ const lineEnd = gl_matrix_1.vec3.fromValues(positionArray.at(secondIndex * 3), positionArray.at(secondIndex * 3 + 1), positionArray.at(secondIndex * 3 + 2));
52
+ const { closestPointOnRay, closestPointOnLine } = this.closestPointsRayLine(ray, lineStart, lineEnd);
53
+ if (this.screenSpaceDistanceCheck(closestPointOnRay, closestPointOnLine, __classPrivateFieldGet(this, _GeometryMathManager_settings, "f").visualization.points.size_0 * __classPrivateFieldGet(this, _GeometryMathManager_settings, "f").visualization.distanceMultiplicationFactor).check === false)
54
+ continue;
55
+ distances.push({ index: [firstIndex, secondIndex], distance: gl_matrix_1.vec3.distance(closestPointOnRay, closestPointOnLine) });
56
+ }
57
+ // if there are no distances, return
58
+ if (distances.length === 0)
59
+ return;
60
+ return distances.sort((a, b) => a.distance - b.distance);
61
+ }
62
+ /**
63
+ * Check which distances of points to ray
64
+ *
65
+ * @param ray
66
+ * @returns
67
+ */
68
+ checkPointDistances(ray) {
69
+ const positionArray = __classPrivateFieldGet(this, _GeometryMathManager_drawingToolsManager, "f").positionArray;
70
+ /**
71
+ * Calculate point distances to ray
72
+ */
73
+ const distances = [];
74
+ for (let i = 0; i < positionArray.length; i += 3) {
75
+ const point = gl_matrix_1.vec3.fromValues(positionArray.at(i), positionArray.at(i + 1), positionArray.at(i + 2));
76
+ // distance from point to ray
77
+ const closestPoint = this.closestPoint(ray, point);
78
+ if (this.screenSpaceDistanceCheck(point, closestPoint, __classPrivateFieldGet(this, _GeometryMathManager_settings, "f").visualization.points.size_0 * __classPrivateFieldGet(this, _GeometryMathManager_settings, "f").visualization.distanceMultiplicationFactor).check === false)
79
+ continue;
80
+ distances.push({ index: i / 3, distance: gl_matrix_1.vec3.distance(point, closestPoint) });
81
+ }
82
+ // if there are no distances, return
83
+ if (distances.length === 0)
84
+ return;
85
+ // sort distances
86
+ return distances.sort((a, b) => a.distance - b.distance);
87
+ }
88
+ close() { }
89
+ /**
90
+ * Calculate the closest point on a line to a point
91
+ *
92
+ * @param start
93
+ * @param end
94
+ * @param point
95
+ */
96
+ closestPointOnLine(start, end, point) {
97
+ const lineDir = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), end, start);
98
+ // Vector from linePoint to point
99
+ const v = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), point, start);
100
+ // Line direction dot product with itself
101
+ const dirDotDir = gl_matrix_1.vec3.dot(lineDir, lineDir);
102
+ // If the direction vector is a zero vector, return the line point as closest point
103
+ if (dirDotDir === 0)
104
+ return start;
105
+ // Projection factor t
106
+ const t = gl_matrix_1.vec3.dot(v, lineDir) / dirDotDir;
107
+ // Closest point on the line
108
+ const closestPoint = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), start, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), lineDir, t));
109
+ return closestPoint;
110
+ }
111
+ /**
112
+ * Calculate the distance between a ray and a line segment
113
+ *
114
+ * @param ray
115
+ * @param lineStart
116
+ * @param lineEnd
117
+ * @returns
118
+ */
119
+ closestPointsRayLine(ray, lineStart, lineEnd) {
120
+ // direction of line
121
+ const lineDirection = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), lineEnd, lineStart));
122
+ // cross product of ray direction and line direction
123
+ const crossProduct = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), ray.direction, lineDirection);
124
+ // length of cross product
125
+ const crossProductLength = gl_matrix_1.vec3.length(crossProduct);
126
+ if (crossProductLength < 0.0001) {
127
+ // ray and line are parallel, calculate the distance differently
128
+ const closestPointOnRay = ray.origin;
129
+ const closestPointOnLine = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), lineStart, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), lineDirection, gl_matrix_1.vec3.dot(gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), ray.origin, lineStart), lineDirection)));
130
+ return {
131
+ closestPointOnRay, closestPointOnLine
132
+ };
133
+ }
134
+ const t = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), lineStart, ray.origin);
135
+ const u = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), t, lineDirection);
136
+ const v = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), t, ray.direction);
137
+ const tValue = gl_matrix_1.vec3.dot(u, crossProduct) / Math.pow(crossProductLength, 2);
138
+ const uValue = gl_matrix_1.vec3.dot(v, crossProduct) / Math.pow(crossProductLength, 2);
139
+ const closestPointOnRay = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), ray.origin, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), ray.direction, tValue));
140
+ // restrict the closest point on line to the line segment
141
+ let closestPointOnLine;
142
+ if (uValue < 0) {
143
+ closestPointOnLine = lineStart;
144
+ }
145
+ else if (uValue > gl_matrix_1.vec3.distance(lineStart, lineEnd)) {
146
+ closestPointOnLine = lineEnd;
147
+ }
148
+ else {
149
+ closestPointOnLine = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), lineStart, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), lineDirection, uValue));
150
+ }
151
+ return {
152
+ closestPointOnRay, closestPointOnLine
153
+ };
154
+ }
155
+ /**
156
+ * Calculate the distance between two rays
157
+ *
158
+ * @param ray1
159
+ * @param ray2
160
+ * @returns
161
+ */
162
+ closestPointsRayRay(ray1, ray2) {
163
+ // cross product of ray1 direction and ray2 direction
164
+ const crossProduct = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), ray1.direction, ray2.direction);
165
+ // length of cross product
166
+ const crossProductLength = gl_matrix_1.vec3.length(crossProduct);
167
+ if (crossProductLength < 0.0001) {
168
+ // ray1 and ray2 are parallel, calculate the distance differently
169
+ const closestPointOnRay1 = ray1.origin;
170
+ const closestPointOnRay2 = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), ray2.origin, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), ray2.direction, gl_matrix_1.vec3.dot(gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), ray1.origin, ray2.origin), ray2.direction)));
171
+ return {
172
+ closestPointOnRay1, closestPointOnRay2
173
+ };
174
+ }
175
+ const t = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), ray2.origin, ray1.origin);
176
+ const u = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), t, ray2.direction);
177
+ const v = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), t, ray1.direction);
178
+ const tValue = gl_matrix_1.vec3.dot(u, crossProduct) / Math.pow(crossProductLength, 2);
179
+ const uValue = gl_matrix_1.vec3.dot(v, crossProduct) / Math.pow(crossProductLength, 2);
180
+ const closestPointOnRay1 = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), ray1.origin, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), ray1.direction, tValue));
181
+ const closestPointOnRay2 = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), ray2.origin, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), ray2.direction, uValue));
182
+ return {
183
+ closestPointOnRay1, closestPointOnRay2
184
+ };
185
+ }
186
+ screenSpaceDistanceCheck(point1, point2, threshold) {
187
+ const camera = __classPrivateFieldGet(this, _GeometryMathManager_viewport, "f").camera;
188
+ // Project points to NDC
189
+ const screenPos1 = camera.project(gl_matrix_1.vec3.clone(point1));
190
+ const screenPos2 = camera.project(gl_matrix_1.vec3.clone(point2));
191
+ const width = __classPrivateFieldGet(this, _GeometryMathManager_viewport, "f").canvas.width;
192
+ const height = __classPrivateFieldGet(this, _GeometryMathManager_viewport, "f").canvas.height;
193
+ const x1 = ((screenPos1[0] * (width / 2)) + (width / 2));
194
+ const y1 = -((screenPos1[1] * (height / 2)) + (height / 2));
195
+ const x2 = ((screenPos2[0] * (width / 2)) + (width / 2));
196
+ const y2 = -((screenPos2[1] * (height / 2)) + (height / 2));
197
+ const distanceSquared = Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2);
198
+ /**
199
+ * Logic: The actual calculation would be
200
+ * distance * 2 < threshold
201
+ * the multiplication by 2 is to account for the fact that the distance is from the center of the point
202
+ *
203
+ * However, we work with the squared distance to avoid the sqrt operation
204
+ * Therefore we square all values:
205
+ * distanceSquared * 4 < threshold ** 2
206
+ */
207
+ return {
208
+ distanceSquared: distanceSquared,
209
+ check: distanceSquared * 4 < Math.pow(threshold, 2)
210
+ };
211
+ }
212
+ // #endregion Public Methods (7)
213
+ // #region Private Methods (1)
214
+ /**
215
+ * Calculate the closest point on a ray to a point
216
+ *
217
+ * @param ray
218
+ * @param point
219
+ * @returns
220
+ */
221
+ closestPoint(ray, point) {
222
+ // distance from point to ray
223
+ const dot = gl_matrix_1.vec3.dot(ray.direction, gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), point, ray.origin));
224
+ // closest point on ray to point
225
+ return gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), ray.origin, gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), ray.direction, gl_matrix_1.vec3.fromValues(dot, dot, dot)));
226
+ }
227
+ }
228
+ exports.GeometryMathManager = GeometryMathManager;
229
+ _GeometryMathManager_drawingToolsManager = new WeakMap(), _GeometryMathManager_settings = new WeakMap(), _GeometryMathManager_viewport = new WeakMap();
230
+ //# sourceMappingURL=GeometryMathManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeometryMathManager.js","sourceRoot":"","sources":["../../../../../src/business/implementation/managers/geometry/GeometryMathManager.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,gBAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,gBAAI,CAAC,GAAG,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAChF,gCAAgC;QAChC,OAAO,gBAAI,CAAC,GAAG,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAI,CAAC,QAAQ,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,SAAS,EAAE,gBAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5H,CAAC;CAGJ;AA1QD,kDA0QC"}
@@ -0,0 +1,46 @@
1
+ import { IGeometryData } from '@shapediver/viewer.shared.types';
2
+ import { PointsData } from '../../../interfaces/IDrawingToolsManager';
3
+ import { DrawingToolsManager } from '../../DrawingToolsManager';
4
+ import { GeometryManager } from './GeometryManager';
5
+ import { vec3 } from 'gl-matrix';
6
+ export declare class GeometryState {
7
+ #private;
8
+ constructor(drawingToolsManager: DrawingToolsManager, geometryManager: GeometryManager);
9
+ get closeLoop(): boolean;
10
+ set closeLoop(value: boolean);
11
+ get geometryData(): IGeometryData;
12
+ get geometryDataLines(): IGeometryData | undefined;
13
+ get geometryDataPoints(): IGeometryData;
14
+ get indicesArrayLines(): Uint8Array | null | undefined;
15
+ get materialIndexArray(): number[];
16
+ get pointsLength(): number;
17
+ get positionArray(): Float32Array;
18
+ get positionIndexArray(): Float32Array;
19
+ get wasWithinMinimumMaximumPointsRange(): boolean;
20
+ set wasWithinMinimumMaximumPointsRange(value: boolean);
21
+ canAddPoint(number?: number): boolean;
22
+ canRemovePoint(number?: number): boolean;
23
+ checkMaximumNumberOfPoints(number?: number): boolean;
24
+ checkMinimumNumberOfPoints(number?: number): boolean;
25
+ checkNumberOfPoints(number?: number): boolean;
26
+ close(): void;
27
+ convertToFloat32Array(points: PointsData): Float32Array;
28
+ /**
29
+ * Creates the indices array for the lines
30
+ * Each line segment consists of two indices, start and end point
31
+ *
32
+ * optionally connect the last point with the first point
33
+ */
34
+ createLineIndices(loop: boolean): Uint8Array | undefined;
35
+ getPointCount(): number;
36
+ getPointsData(): PointsData;
37
+ getPosition(index: number): vec3;
38
+ init(): void;
39
+ makePointPersistent(index: number, recordHistory?: boolean): void;
40
+ updateData(positionArray: Float32Array, temporary?: boolean, fromHistory?: boolean): void;
41
+ updateDataFromHistory(points: PointsData): void;
42
+ updateMaterialIndexArray(materialIndexArray: number[]): void;
43
+ updateParentNode(): void;
44
+ private createAndSetPositionIndexArray;
45
+ }
46
+ //# sourceMappingURL=GeometryState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeometryState.d.ts","sourceRoot":"","sources":["../../../../../src/business/implementation/managers/geometry/GeometryState.ts"],"names":[],"mappings":"AAOA,OAAO,EAGH,aAAa,EAQhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAmB,UAAU,EAAY,MAAM,0CAA0C,CAAC;AAEjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,qBAAa,aAAa;;gBAwBV,mBAAmB,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe;IAkCtF,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,IAAW,SAAS,CAAC,KAAK,EAAE,OAAO,EAGlC;IAED,IAAW,YAAY,IAAI,aAAa,CAEvC;IAED,IAAW,iBAAiB,IAAI,aAAa,GAAG,SAAS,CAExD;IAED,IAAW,kBAAkB,IAAI,aAAa,CAE7C;IAED,IAAW,iBAAiB,IAAI,UAAU,GAAG,IAAI,GAAG,SAAS,CAE5D;IAED,IAAW,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED,IAAW,aAAa,IAAI,YAAY,CAEvC;IAED,IAAW,kBAAkB,IAAI,YAAY,CAE5C;IAED,IAAW,kCAAkC,IAAI,OAAO,CAEvD;IAED,IAAW,kCAAkC,CAAC,KAAK,EAAE,OAAO,EAE3D;IAMM,WAAW,CAAC,MAAM,GAAE,MAAU,GAAG,OAAO;IAOxC,cAAc,CAAC,MAAM,GAAE,MAAU,GAAG,OAAO;IAO3C,0BAA0B,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpD,0BAA0B,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpD,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAI7C,KAAK;IAOL,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY;IAQ9D;;;;;OAKG;IACI,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS;IAwBxD,aAAa,IAAI,MAAM;IAIvB,aAAa,IAAI,UAAU;IAQ3B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQhC,IAAI;IAoFJ,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,UAAO,GAAG,IAAI;IAc9D,UAAU,CACb,aAAa,EAAE,YAAY,EAC3B,SAAS,GAAE,OAAe,EAC1B,WAAW,GAAE,OAAe,GAC7B,IAAI;IA4DA,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAK/C,wBAAwB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI;IAa5D,gBAAgB,IAAI,IAAI;IAS/B,OAAO,CAAC,8BAA8B;CAczC"}
@@ -0,0 +1,323 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _GeometryState_eventEngine, _GeometryState_geometryManager, _GeometryState_parentNode, _GeometryState_settings, _GeometryState_viewport, _GeometryState_closeLoop, _GeometryState_defaultTextures, _GeometryState_geometryDataLines, _GeometryState_geometryDataPoints, _GeometryState_indicesArrayLines, _GeometryState_materialIndexArray, _GeometryState_positionArray, _GeometryState_positionIndexArray, _GeometryState_temporaryIndices, _GeometryState_wasWithinMinimumMaximumPointsRange;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.GeometryState = void 0;
16
+ const viewer_1 = require("@shapediver/viewer");
17
+ const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
18
+ const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
19
+ const gl_matrix_1 = require("gl-matrix");
20
+ class GeometryState {
21
+ // #endregion Properties (15)
22
+ // #region Constructors (1)
23
+ constructor(drawingToolsManager, geometryManager) {
24
+ // #region Properties (15)
25
+ _GeometryState_eventEngine.set(this, viewer_shared_services_1.EventEngine.instance);
26
+ _GeometryState_geometryManager.set(this, void 0);
27
+ _GeometryState_parentNode.set(this, void 0);
28
+ _GeometryState_settings.set(this, void 0);
29
+ _GeometryState_viewport.set(this, void 0);
30
+ _GeometryState_closeLoop.set(this, false);
31
+ _GeometryState_defaultTextures.set(this, void 0);
32
+ _GeometryState_geometryDataLines.set(this, void 0);
33
+ _GeometryState_geometryDataPoints.set(this, void 0);
34
+ _GeometryState_indicesArrayLines.set(this, void 0);
35
+ _GeometryState_materialIndexArray.set(this, []);
36
+ _GeometryState_positionArray.set(this, void 0);
37
+ _GeometryState_positionIndexArray.set(this, void 0);
38
+ _GeometryState_temporaryIndices.set(this, []);
39
+ _GeometryState_wasWithinMinimumMaximumPointsRange.set(this, false);
40
+ __classPrivateFieldSet(this, _GeometryState_geometryManager, geometryManager, "f");
41
+ __classPrivateFieldSet(this, _GeometryState_settings, drawingToolsManager.settings, "f");
42
+ __classPrivateFieldSet(this, _GeometryState_viewport, drawingToolsManager.viewport, "f");
43
+ __classPrivateFieldSet(this, _GeometryState_parentNode, geometryManager.parentNode, "f");
44
+ __classPrivateFieldSet(this, _GeometryState_defaultTextures, drawingToolsManager.defaultTextures, "f");
45
+ (0, viewer_1.addListener)(viewer_1.EVENTTYPE_DRAWING_TOOLS.ADDED, (e) => {
46
+ const event = e;
47
+ if (event.temporary === false && event.index !== undefined) {
48
+ // shift the temporary indices
49
+ __classPrivateFieldSet(this, _GeometryState_temporaryIndices, __classPrivateFieldGet(this, _GeometryState_temporaryIndices, "f").map(i => i > event.index ? i + 1 : i), "f");
50
+ }
51
+ else if (event.temporary === true && event.index !== undefined) {
52
+ __classPrivateFieldGet(this, _GeometryState_temporaryIndices, "f").push(event.index);
53
+ }
54
+ });
55
+ (0, viewer_1.addListener)(viewer_1.EVENTTYPE_DRAWING_TOOLS.REMOVED, (e) => {
56
+ const event = e;
57
+ if (event.temporary === false && event.index !== undefined) {
58
+ // shift the temporary indices
59
+ __classPrivateFieldSet(this, _GeometryState_temporaryIndices, __classPrivateFieldGet(this, _GeometryState_temporaryIndices, "f").map(i => i > event.index ? i - 1 : i), "f");
60
+ }
61
+ else if (event.temporary === true && event.index !== undefined) {
62
+ __classPrivateFieldSet(this, _GeometryState_temporaryIndices, __classPrivateFieldGet(this, _GeometryState_temporaryIndices, "f").filter(i => i !== event.index), "f");
63
+ }
64
+ });
65
+ }
66
+ // #endregion Constructors (1)
67
+ // #region Public Getters And Setters (12)
68
+ get closeLoop() {
69
+ return __classPrivateFieldGet(this, _GeometryState_closeLoop, "f");
70
+ }
71
+ set closeLoop(value) {
72
+ __classPrivateFieldSet(this, _GeometryState_closeLoop, value, "f");
73
+ this.updateData(__classPrivateFieldGet(this, _GeometryState_positionArray, "f"), true);
74
+ }
75
+ get geometryData() {
76
+ return __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f");
77
+ }
78
+ get geometryDataLines() {
79
+ return __classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f");
80
+ }
81
+ get geometryDataPoints() {
82
+ return __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f");
83
+ }
84
+ get indicesArrayLines() {
85
+ return __classPrivateFieldGet(this, _GeometryState_indicesArrayLines, "f");
86
+ }
87
+ get materialIndexArray() {
88
+ return __classPrivateFieldGet(this, _GeometryState_materialIndexArray, "f");
89
+ }
90
+ get pointsLength() {
91
+ return __classPrivateFieldGet(this, _GeometryState_positionArray, "f").length / 3;
92
+ }
93
+ get positionArray() {
94
+ return __classPrivateFieldGet(this, _GeometryState_positionArray, "f");
95
+ }
96
+ get positionIndexArray() {
97
+ return __classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f");
98
+ }
99
+ get wasWithinMinimumMaximumPointsRange() {
100
+ return __classPrivateFieldGet(this, _GeometryState_wasWithinMinimumMaximumPointsRange, "f");
101
+ }
102
+ set wasWithinMinimumMaximumPointsRange(value) {
103
+ __classPrivateFieldSet(this, _GeometryState_wasWithinMinimumMaximumPointsRange, value, "f");
104
+ }
105
+ // #endregion Public Getters And Setters (12)
106
+ // #region Public Methods (17)
107
+ canAddPoint(number = 1) {
108
+ if (this.wasWithinMinimumMaximumPointsRange === true && __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.strictMinMaxPoints === true) {
109
+ return __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.maxPoints !== undefined && this.pointsLength + number <= __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.maxPoints;
110
+ }
111
+ return true;
112
+ }
113
+ canRemovePoint(number = 1) {
114
+ if (this.wasWithinMinimumMaximumPointsRange === true && __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.strictMinMaxPoints === true) {
115
+ return __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.minPoints !== undefined && this.pointsLength - number >= __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.minPoints;
116
+ }
117
+ return true;
118
+ }
119
+ checkMaximumNumberOfPoints(number) {
120
+ if (number === undefined)
121
+ number = __classPrivateFieldGet(this, _GeometryState_positionArray, "f").length / 3;
122
+ if (__classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.maxPoints === undefined)
123
+ return true;
124
+ return number <= __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.maxPoints;
125
+ }
126
+ checkMinimumNumberOfPoints(number) {
127
+ if (number === undefined)
128
+ number = __classPrivateFieldGet(this, _GeometryState_positionArray, "f").length / 3;
129
+ if (__classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.minPoints === undefined)
130
+ return true;
131
+ return number >= __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.minPoints;
132
+ }
133
+ checkNumberOfPoints(number) {
134
+ return this.checkMinimumNumberOfPoints(number) && this.checkMaximumNumberOfPoints(number);
135
+ }
136
+ close() {
137
+ __classPrivateFieldGet(this, _GeometryState_parentNode, "f").removeData(__classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f"));
138
+ if (__classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f"))
139
+ __classPrivateFieldGet(this, _GeometryState_parentNode, "f").removeData(__classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f"));
140
+ }
141
+ convertToFloat32Array(points) {
142
+ const positionArray = new Float32Array(points.length * 3);
143
+ for (let i = 0; i < points.length; i++) {
144
+ positionArray.set(points[i], i * 3);
145
+ }
146
+ return positionArray;
147
+ }
148
+ /**
149
+ * Creates the indices array for the lines
150
+ * Each line segment consists of two indices, start and end point
151
+ *
152
+ * optionally connect the last point with the first point
153
+ */
154
+ createLineIndices(loop) {
155
+ if (!__classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f"))
156
+ return;
157
+ const positionArrayLength = __classPrivateFieldGet(this, _GeometryState_positionArray, "f").length / 3;
158
+ if (positionArrayLength < 1)
159
+ return;
160
+ let indicesArrayLines = new Uint8Array((positionArrayLength - 1) * 2);
161
+ // create indices array
162
+ for (let i = 0; i < positionArrayLength - 1; i++) {
163
+ indicesArrayLines.set([i, i + 1], i * 2);
164
+ }
165
+ if (loop) {
166
+ // connect the last point with the first point
167
+ const tempIndicesArray = new Uint8Array(indicesArrayLines.length + 2);
168
+ tempIndicesArray.set([...indicesArrayLines, positionArrayLength - 1, 0]);
169
+ indicesArrayLines = tempIndicesArray;
170
+ }
171
+ return indicesArrayLines;
172
+ }
173
+ getPointCount() {
174
+ return this.pointsLength;
175
+ }
176
+ getPointsData() {
177
+ const points = [];
178
+ for (let i = 0; i < __classPrivateFieldGet(this, _GeometryState_positionArray, "f").length; i += 3) {
179
+ points.push([__classPrivateFieldGet(this, _GeometryState_positionArray, "f")[i], __classPrivateFieldGet(this, _GeometryState_positionArray, "f")[i + 1], __classPrivateFieldGet(this, _GeometryState_positionArray, "f")[i + 2]]);
180
+ }
181
+ return points;
182
+ }
183
+ getPosition(index) {
184
+ return gl_matrix_1.vec3.fromValues(__classPrivateFieldGet(this, _GeometryState_positionArray, "f")[(index * 3)], __classPrivateFieldGet(this, _GeometryState_positionArray, "f")[(index * 3) + 1], __classPrivateFieldGet(this, _GeometryState_positionArray, "f")[(index * 3) + 2]);
185
+ }
186
+ init() {
187
+ const geometryProperties = __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry;
188
+ if (geometryProperties.points.length > 0) {
189
+ __classPrivateFieldSet(this, _GeometryState_positionArray, new Float32Array(geometryProperties.points.length * 3), "f");
190
+ __classPrivateFieldGet(this, _GeometryState_positionArray, "f").set([].concat(...geometryProperties.points));
191
+ }
192
+ else {
193
+ __classPrivateFieldSet(this, _GeometryState_positionArray, new Float32Array(), "f");
194
+ }
195
+ __classPrivateFieldSet(this, _GeometryState_geometryDataPoints, new viewer_shared_types_1.GeometryData(new viewer_shared_types_1.PrimitiveData({
196
+ 'POSITION': new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_positionArray, "f"), 3, 12, 0, 4, false, __classPrivateFieldGet(this, _GeometryState_positionArray, "f").length)
197
+ }), viewer_shared_types_1.PRIMITIVE_MODE.POINTS), "f");
198
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").renderOrder = 1000;
199
+ __classPrivateFieldGet(this, _GeometryState_parentNode, "f").addData(__classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f"));
200
+ if (geometryProperties.mode !== 'points') {
201
+ __classPrivateFieldSet(this, _GeometryState_indicesArrayLines, new Uint8Array(), "f");
202
+ __classPrivateFieldSet(this, _GeometryState_geometryDataLines, new viewer_shared_types_1.GeometryData(new viewer_shared_types_1.PrimitiveData({
203
+ 'POSITION': new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_positionArray, "f"), 3, 12, 0, 4, false, __classPrivateFieldGet(this, _GeometryState_positionArray, "f").length)
204
+ }, new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_indicesArrayLines, "f"), 1, 2, 0, 2, false, 0)), viewer_shared_types_1.PRIMITIVE_MODE.LINES), "f");
205
+ __classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f").renderOrder = 999;
206
+ __classPrivateFieldGet(this, _GeometryState_parentNode, "f").addData(__classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f"));
207
+ __classPrivateFieldSet(this, _GeometryState_indicesArrayLines, this.createLineIndices(__classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.close && __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.autoClose), "f");
208
+ }
209
+ // create material index array
210
+ __classPrivateFieldSet(this, _GeometryState_materialIndexArray, new Array(1024).fill(0), "f");
211
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").material = new viewer_shared_types_1.MaterialMultiPointData(Object.assign({
212
+ materialIndexDataMap: new viewer_shared_types_1.MapData(new Image(), { asData: true, data: __classPrivateFieldGet(this, _GeometryState_materialIndexArray, "f") }),
213
+ materialIndexDataMapSize: 1024,
214
+ alphaMode: viewer_shared_types_1.MATERIAL_ALPHA.BLEND,
215
+ depthTest: false,
216
+ depthWrite: false,
217
+ transparent: true
218
+ }, __classPrivateFieldGet(this, _GeometryState_settings, "f").visualization.points));
219
+ const updateMaterialVariation = (variations, map) => {
220
+ for (const v of variations) {
221
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").material[v] = map;
222
+ }
223
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").material.updateVersion();
224
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").updateVersion();
225
+ this.updateParentNode();
226
+ };
227
+ const variation_0 = ['map_0', 'map_1', 'map_2', 'map_3', 'map_4', 'map_5', 'map_6', 'map_7'];
228
+ if (__classPrivateFieldGet(this, _GeometryState_defaultTextures, "f").variation_0 instanceof viewer_shared_types_1.MapData) {
229
+ updateMaterialVariation(variation_0, __classPrivateFieldGet(this, _GeometryState_defaultTextures, "f").variation_0);
230
+ }
231
+ else {
232
+ __classPrivateFieldGet(this, _GeometryState_defaultTextures, "f").variation_0.then((map) => {
233
+ updateMaterialVariation(variation_0, map);
234
+ });
235
+ }
236
+ if (__classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f")) {
237
+ __classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f").material = new viewer_shared_types_1.MaterialBasicLineData(Object.assign({
238
+ alphaMode: viewer_shared_types_1.MATERIAL_ALPHA.BLEND,
239
+ depthTest: false,
240
+ depthWrite: false,
241
+ transparent: true
242
+ }, __classPrivateFieldGet(this, _GeometryState_settings, "f").visualization.lines));
243
+ }
244
+ this.updateData(__classPrivateFieldGet(this, _GeometryState_positionArray, "f"));
245
+ }
246
+ makePointPersistent(index, recordHistory = true) {
247
+ // check if the number of points is within the minimum and maximum range
248
+ this.wasWithinMinimumMaximumPointsRange = this.checkNumberOfPoints();
249
+ // remove from the temporary indices
250
+ __classPrivateFieldSet(this, _GeometryState_temporaryIndices, __classPrivateFieldGet(this, _GeometryState_temporaryIndices, "f").filter(i => i !== index), "f");
251
+ __classPrivateFieldGet(this, _GeometryState_eventEngine, "f").emitEvent(viewer_1.EVENTTYPE_DRAWING_TOOLS.GEOMETRY_CHANGED, {
252
+ points: this.getPointsData(),
253
+ temporary: false,
254
+ recordHistory
255
+ });
256
+ }
257
+ updateData(positionArray, temporary = false, fromHistory = false) {
258
+ __classPrivateFieldSet(this, _GeometryState_positionArray, positionArray, "f");
259
+ __classPrivateFieldSet(this, _GeometryState_positionIndexArray, this.createAndSetPositionIndexArray(), "f");
260
+ this.geometryDataPoints.primitive.attributes['POSITION'] =
261
+ new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_positionArray, "f"), this.geometryDataPoints.primitive.attributes['POSITION'].itemSize, this.geometryDataPoints.primitive.attributes['POSITION'].itemBytes, this.geometryDataPoints.primitive.attributes['POSITION'].byteOffset, this.geometryDataPoints.primitive.attributes['POSITION'].elementBytes, this.geometryDataPoints.primitive.attributes['POSITION'].normalized, this.geometryDataPoints.primitive.attributes['POSITION'].count - 1);
262
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").primitive.attributes['POSITION_INDEX'] = new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f"), 1, 1, 0, 1, true, __classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f").length, [0], [__classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f").length]);
263
+ this.geometryDataPoints.updateVersion();
264
+ this.geometryDataPoints.primitive.updateVersion();
265
+ if (this.geometryDataLines) {
266
+ __classPrivateFieldSet(this, _GeometryState_indicesArrayLines, this.createLineIndices(__classPrivateFieldGet(this, _GeometryState_closeLoop, "f") || (__classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.close && __classPrivateFieldGet(this, _GeometryState_settings, "f").geometry.autoClose)), "f");
267
+ if (__classPrivateFieldGet(this, _GeometryState_indicesArrayLines, "f")) {
268
+ this.geometryDataLines.primitive.indices =
269
+ new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_indicesArrayLines, "f"), this.geometryDataLines.primitive.indices.itemSize, this.geometryDataLines.primitive.indices.itemBytes, this.geometryDataLines.primitive.indices.byteOffset, this.geometryDataLines.primitive.indices.elementBytes, this.geometryDataLines.primitive.indices.normalized, __classPrivateFieldGet(this, _GeometryState_indicesArrayLines, "f").length);
270
+ }
271
+ this.geometryDataLines.primitive.attributes['POSITION'] =
272
+ new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_positionArray, "f"), this.geometryDataLines.primitive.attributes['POSITION'].itemSize, this.geometryDataLines.primitive.attributes['POSITION'].itemBytes, this.geometryDataLines.primitive.attributes['POSITION'].byteOffset, this.geometryDataLines.primitive.attributes['POSITION'].elementBytes, this.geometryDataLines.primitive.attributes['POSITION'].normalized, this.geometryDataLines.primitive.attributes['POSITION'].count - 1);
273
+ this.geometryDataLines.primitive.attributes['POSITION_INDEX'] = new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f"), 1, 1, 0, 1, true, __classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f").length, [0], [__classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f").length]);
274
+ this.geometryDataLines.updateVersion();
275
+ this.geometryDataLines.primitive.updateVersion();
276
+ }
277
+ this.updateParentNode();
278
+ if (temporary === false) {
279
+ // check if the number of points is within the minimum and maximum range
280
+ this.wasWithinMinimumMaximumPointsRange = this.checkNumberOfPoints();
281
+ }
282
+ __classPrivateFieldGet(this, _GeometryState_eventEngine, "f").emitEvent(viewer_1.EVENTTYPE_DRAWING_TOOLS.GEOMETRY_CHANGED, {
283
+ points: this.getPointsData(),
284
+ temporary,
285
+ fromHistory
286
+ });
287
+ }
288
+ updateDataFromHistory(points) {
289
+ const positionArray = this.convertToFloat32Array(points);
290
+ this.updateData(positionArray, false, true);
291
+ }
292
+ updateMaterialIndexArray(materialIndexArray) {
293
+ __classPrivateFieldSet(this, _GeometryState_materialIndexArray, materialIndexArray, "f");
294
+ const threeJsPointsGeometry = __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").convertedObject[__classPrivateFieldGet(this, _GeometryState_viewport, "f").id];
295
+ for (let i = 0; i < __classPrivateFieldGet(this, _GeometryState_materialIndexArray, "f").length; i++)
296
+ threeJsPointsGeometry.material.materialIndexDataTexture.image.data[i] = __classPrivateFieldGet(this, _GeometryState_materialIndexArray, "f")[i];
297
+ threeJsPointsGeometry.material.materialIndexDataTexture.needsUpdate = true;
298
+ threeJsPointsGeometry.material.needsUpdate = true;
299
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").material.materialIndexDataMap = new viewer_shared_types_1.MapData(new Image(), { asData: true, data: __classPrivateFieldGet(this, _GeometryState_materialIndexArray, "f") }),
300
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").material.updateVersion();
301
+ }
302
+ updateParentNode() {
303
+ __classPrivateFieldGet(this, _GeometryState_parentNode, "f").updateVersion(false, true);
304
+ __classPrivateFieldGet(this, _GeometryState_viewport, "f").updateNode(__classPrivateFieldGet(this, _GeometryState_parentNode, "f"));
305
+ }
306
+ // #endregion Public Methods (17)
307
+ // #region Private Methods (1)
308
+ createAndSetPositionIndexArray() {
309
+ const positionIndexArray = new Float32Array((__classPrivateFieldGet(this, _GeometryState_positionArray, "f").length / 3));
310
+ // fill position index array with indices
311
+ for (let i = 0; i < positionIndexArray.length; i++) {
312
+ positionIndexArray.set([i], i);
313
+ }
314
+ __classPrivateFieldSet(this, _GeometryState_positionIndexArray, positionIndexArray, "f");
315
+ __classPrivateFieldGet(this, _GeometryState_geometryDataPoints, "f").primitive.attributes['POSITION_INDEX'] = new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f"), 1, 1, 0, 1, true, __classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f").length, [0], [__classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f").length]);
316
+ if (__classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f"))
317
+ __classPrivateFieldGet(this, _GeometryState_geometryDataLines, "f").primitive.attributes['POSITION_INDEX'] = new viewer_shared_types_1.AttributeData(__classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f"), 1, 1, 0, 1, true, __classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f").length, [0], [__classPrivateFieldGet(this, _GeometryState_positionIndexArray, "f").length]);
318
+ return positionIndexArray;
319
+ }
320
+ }
321
+ exports.GeometryState = GeometryState;
322
+ _GeometryState_eventEngine = new WeakMap(), _GeometryState_geometryManager = new WeakMap(), _GeometryState_parentNode = new WeakMap(), _GeometryState_settings = new WeakMap(), _GeometryState_viewport = new WeakMap(), _GeometryState_closeLoop = new WeakMap(), _GeometryState_defaultTextures = new WeakMap(), _GeometryState_geometryDataLines = new WeakMap(), _GeometryState_geometryDataPoints = new WeakMap(), _GeometryState_indicesArrayLines = new WeakMap(), _GeometryState_materialIndexArray = new WeakMap(), _GeometryState_positionArray = new WeakMap(), _GeometryState_positionIndexArray = new WeakMap(), _GeometryState_temporaryIndices = new WeakMap(), _GeometryState_wasWithinMinimumMaximumPointsRange = new WeakMap();
323
+ //# sourceMappingURL=GeometryState.js.map