aurea-eden 1.25.1 → 1.26.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 (93) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +300 -95
  3. package/dist/bpmn-diagram.es.js +37516 -25040
  4. package/dist/bpmn-diagram.umd.js +13 -5790
  5. package/package.json +17 -8
  6. package/.gitattributes +0 -2
  7. package/.github/workflows/static.yml +0 -43
  8. package/CHANGELOG.md +0 -60
  9. package/README_.md +0 -174
  10. package/assets/3diagram_logo.png +0 -0
  11. package/assets/aurea-eden-logo.jpeg +0 -0
  12. package/assets/favicon/about.txt +0 -6
  13. package/assets/favicon/android-chrome-192x192.png +0 -0
  14. package/assets/favicon/android-chrome-512x512.png +0 -0
  15. package/assets/favicon/apple-touch-icon.png +0 -0
  16. package/assets/favicon/favicon-16x16.png +0 -0
  17. package/assets/favicon/favicon-32x32.png +0 -0
  18. package/assets/favicon/favicon.ico +0 -0
  19. package/assets/favicon/site.webmanifest +0 -1
  20. package/assets/threejs_camera.jpg.webp +0 -0
  21. package/assets/threejs_camera3.jpg.webp +0 -0
  22. package/assets/threejs_cameras.webp +0 -0
  23. package/assets/threejs_cameras2.webp +0 -0
  24. package/assets/threejs_objects.webp +0 -0
  25. package/assets/threejs_scene.webp +0 -0
  26. package/assets/threejs_scene_graph.webp +0 -0
  27. package/favicon.ico +0 -0
  28. package/index.html +0 -34
  29. package/index.js +0 -153
  30. package/lib/connectors/Connector.js +0 -47
  31. package/lib/diagrams/Diagram.js +0 -710
  32. package/lib/diagrams/DiagramConstants.js +0 -22
  33. package/lib/elements/Element.js +0 -860
  34. package/lib/materials/BarMaterial.js +0 -17
  35. package/lib/materials/DiagramEditMaterial.js +0 -28
  36. package/lib/notations/BpmnDiagram.js +0 -861
  37. package/lib/shapes/Shape.js +0 -23
  38. package/lib/shapes/bar/ValueBarConstants.js +0 -34
  39. package/lib/shapes/bar/ValueBarShape.js +0 -52
  40. package/lib/shapes/basic/BasicShapeConstants.js +0 -23
  41. package/lib/shapes/basic/BoxShape.js +0 -12
  42. package/lib/shapes/basic/CircleShape.js +0 -55
  43. package/lib/shapes/basic/DiamondShape.js +0 -169
  44. package/lib/shapes/basic/RoundedRectangleShape.js +0 -180
  45. package/lib/shapes/connector/ConnectorConstants.js +0 -7
  46. package/lib/shapes/connector/RoundedCornerOrthogonalConnectorShape.js +0 -229
  47. package/lib/shapes/icon/IconConstants.js +0 -7
  48. package/lib/shapes/icon/IconShape.js +0 -92
  49. package/lib/shapes/icon/bpmn/activities/ad-hoc-marker.svg +0 -50
  50. package/lib/shapes/icon/bpmn/activities/business-rule.svg +0 -92
  51. package/lib/shapes/icon/bpmn/activities/compensation-marker.svg +0 -50
  52. package/lib/shapes/icon/bpmn/activities/loop-marker.svg +0 -50
  53. package/lib/shapes/icon/bpmn/activities/manual.svg +0 -51
  54. package/lib/shapes/icon/bpmn/activities/parallel-mi-marker.svg +0 -70
  55. package/lib/shapes/icon/bpmn/activities/receive.svg +0 -77
  56. package/lib/shapes/icon/bpmn/activities/script.svg +0 -54
  57. package/lib/shapes/icon/bpmn/activities/send.svg +0 -86
  58. package/lib/shapes/icon/bpmn/activities/sequential-mi-marker.svg +0 -70
  59. package/lib/shapes/icon/bpmn/activities/service.svg +0 -58
  60. package/lib/shapes/icon/bpmn/activities/sub-process-marker.svg +0 -51
  61. package/lib/shapes/icon/bpmn/activities/user.svg +0 -50
  62. package/lib/shapes/icon/bpmn/events/compensation.svg +0 -47
  63. package/lib/shapes/icon/bpmn/events/conditional.svg +0 -47
  64. package/lib/shapes/icon/bpmn/events/error.svg +0 -47
  65. package/lib/shapes/icon/bpmn/events/escalation.svg +0 -47
  66. package/lib/shapes/icon/bpmn/events/intermediate-compensation.svg +0 -53
  67. package/lib/shapes/icon/bpmn/events/intermediate-conditional.svg +0 -53
  68. package/lib/shapes/icon/bpmn/events/intermediate-escalation.svg +0 -53
  69. package/lib/shapes/icon/bpmn/events/intermediate-link-catch.svg +0 -53
  70. package/lib/shapes/icon/bpmn/events/intermediate-link-throw.svg +0 -53
  71. package/lib/shapes/icon/bpmn/events/intermediate-receive.svg +0 -53
  72. package/lib/shapes/icon/bpmn/events/intermediate-send.svg +0 -69
  73. package/lib/shapes/icon/bpmn/events/intermediate-signal-catch.svg +0 -53
  74. package/lib/shapes/icon/bpmn/events/intermediate-signal-throw.svg +0 -53
  75. package/lib/shapes/icon/bpmn/events/intermediate-timer.svg +0 -107
  76. package/lib/shapes/icon/bpmn/events/intermediate.svg +0 -49
  77. package/lib/shapes/icon/bpmn/events/message-end.svg +0 -54
  78. package/lib/shapes/icon/bpmn/events/message-start.svg +0 -41
  79. package/lib/shapes/icon/bpmn/events/signal-end.svg +0 -47
  80. package/lib/shapes/icon/bpmn/events/signal-start.svg +0 -47
  81. package/lib/shapes/icon/bpmn/events/terminate.svg +0 -49
  82. package/lib/shapes/icon/bpmn/events/timer.svg +0 -104
  83. package/lib/shapes/icon/bpmn/gateways/complex.svg +0 -61
  84. package/lib/shapes/icon/bpmn/gateways/event-based.svg +0 -68
  85. package/lib/shapes/icon/bpmn/gateways/exclusive.svg +0 -57
  86. package/lib/shapes/icon/bpmn/gateways/inclusive.svg +0 -57
  87. package/lib/shapes/icon/bpmn/gateways/parallel.svg +0 -56
  88. package/lib/shapes/icon/decorators.svg +0 -262
  89. package/lib/shapes/icon/hexagon.svg +0 -5
  90. package/lib/shapes/text/Roboto_Regular.json +0 -5610
  91. package/lib/shapes/text/TextShape.js +0 -29
  92. package/lib/shapes/text/fonts/Roboto.zip +0 -0
  93. package/vite.config.js +0 -15
@@ -1,860 +0,0 @@
1
- import * as THREE from 'three';
2
- import { BoxShape } from '../shapes/basic/BoxShape.js';
3
- import { TextShape } from '../shapes/text/TextShape.js';
4
- import { IconShape } from '../shapes/icon/IconShape.js';
5
- import { ValueBarShape } from '../shapes/bar/ValueBarShape.js';
6
- import { DiagramDimensions } from '../diagrams/DiagramConstants.js';
7
- import { IconDimensions } from '../shapes/icon/IconConstants.js';
8
- import { Connector } from '../connectors/Connector.js';
9
- import { RoundedCornerOrthogonalConnectorShape } from '../shapes/connector/RoundedCornerOrthogonalConnectorShape.js';
10
-
11
- /**
12
- * Represents a diagram element that can be positioned, connected, and decorated with text, icons, and bars.
13
- * @extends THREE.Mesh
14
- */
15
- class Element extends THREE.Mesh {
16
- /**
17
- * Creates a new diagram element.
18
- * @param {string} elementId - Unique identifier for the element
19
- * @param {Shape} [shape=new BoxShape()] - Shape of the element
20
- * @param {Object} [positionXY={ x: 0, y: 0 }] - Initial position of the element
21
- * @param {number} positionXY.x - X coordinate
22
- * @param {number} positionXY.y - Y coordinate
23
- */
24
- constructor(elementId,
25
- shape = new BoxShape(), // Default shape is BoxShape. Type is Shape (lib/shapes/Shape.js)
26
- positionXY = { x: 0, y: 0 } ) { // Position of the center of the Element
27
- super(shape.geometry, shape.material);
28
- this.elementId = elementId;
29
- this.type = shape.constructor.name; // Derive type from shape's constructor name
30
- this.parameters = {}; // Parameters of the element
31
- this.shape = shape;
32
- this.position.set(positionXY.x, positionXY.y, 0); // Use set method to update position
33
- this.width = this.getSize().x;
34
- this.height = this.getSize().y;
35
- this.texts = [];
36
- this.icons = [];
37
- this.valueBars = [];
38
- }
39
-
40
- /**
41
- * Sets the diagram context for this element.
42
- * @param {Diagram} diagram - The diagram this element belongs to
43
- */
44
- setDiagram(diagram) {
45
- this.diagram = diagram;
46
- }
47
-
48
- // ================================================================
49
- // Element placement methods
50
- // ================================================================
51
-
52
- /**
53
- * Gets the size of the element's bounding box.
54
- * @returns {THREE.Vector3} The size vector containing width, height, and depth
55
- */
56
- getSize() {
57
- const size = new THREE.Vector3();
58
- this.shape.geometry.computeBoundingBox();
59
- this.shape.geometry.boundingBox.getSize(size);
60
- // console.log(`size: ${size.x}, ${size.y}, ${size.z}`);
61
- return size;
62
- }
63
-
64
- /**
65
- * Positions the element and its decorations at the specified coordinates.
66
- * @param {Object} position - The position coordinates
67
- * @param {number} position.x - X coordinate
68
- * @param {number} position.y - Y coordinate
69
- * @param {number} [position.z] - Optional Z coordinate
70
- * @returns {Element} This element for method chaining
71
- */
72
- positionAt(position) {
73
- if (position.z !== undefined) {
74
- this.position.set(position.x, position.y, position.z);
75
- } else {
76
- this.position.set(position.x, position.y, 0);
77
- }
78
-
79
- // Set the position of the element's texts, icons, and bars
80
- this.texts.forEach(text => {
81
- const offset = text.positionOffset;
82
- if (position.z !== undefined) {
83
- text.element.position.set(position.x + offset.x, position.y + offset.y, position.z + offset.z);
84
- } else {
85
- text.element.position.set(position.x + offset.x, position.y + offset.y, offset.z);
86
- }
87
- });
88
- this.icons.forEach(icon => {
89
- const offset = icon.positionOffset;
90
- if (position.z !== undefined) {
91
- icon.element.position.set(position.x + offset.x, position.y + offset.y, position.z + offset.z);
92
- } else {
93
- icon.element.position.set(position.x + offset.x, position.y + offset.y, offset.z);
94
- }
95
- });
96
- this.valueBars.forEach(bar => {
97
- const offset = bar.positionOffset;
98
- if (position.z !== undefined) {
99
- bar.element.position.set(position.x + offset.x, position.y + offset.y, position.z + offset.z);
100
- } else {
101
- bar.element.position.set(position.x + offset.x, position.y + offset.y, offset.z);
102
- }
103
- });
104
-
105
- return this;
106
- }
107
-
108
- /**
109
- * Sets the position of the element using individual coordinates.
110
- * @param {number} x - X coordinate
111
- * @param {number} y - Y coordinate
112
- * @param {number} z - Z coordinate
113
- * @returns {Element} This element for method chaining
114
- */
115
- setPosition(x, y, z) {
116
- const pos = new THREE.Vector3(x, y, z);
117
- this.positionAt(pos);
118
- return this;
119
- }
120
-
121
- /**
122
- * Gets the current position of the element.
123
- * @returns {THREE.Vector3} The position vector
124
- */
125
- getPosition() {
126
- return this.position;
127
- // return new THREE.Vector3(this.position.x, this.position.y);
128
- }
129
-
130
- /**
131
- * Positions this element to the right of another element.
132
- * @param {string} elementId - ID of the reference element
133
- * @returns {Element} This element for method chaining
134
- */
135
- positionRightOf(elementId) {
136
- const element = this.diagram.getElementById(elementId);
137
- const elementWidth = element.getSize().x;
138
- const thisWidth = this.getSize().x;
139
- // console.log(`positionRightOf(${element.elementId}), element.getSize().x: ${element.getSize().x}`);
140
- this.setPosition(element.position.x + elementWidth / 2
141
- + DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
142
- + thisWidth / 2, // x
143
- element.position.y, // y
144
- 0 ); // z
145
- return this;
146
- }
147
-
148
- /**
149
- * Positions this element to the left of another element.
150
- * @param {string} elementId - ID of the reference element
151
- * @returns {Element} This element for method chaining
152
- */
153
- positionLeftOf(elementId) {
154
- const element = this.diagram.getElementById(elementId);
155
- const elementWidth = element.getSize().x;
156
- const thisWidth = this.getSize().x;
157
- this.setPosition(element.position.x - elementWidth / 2
158
- - DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
159
- - thisWidth / 2, // x
160
- element.position.y, // y
161
- 0 ); // z
162
- return this;
163
- }
164
-
165
- /**
166
- * Positions this element above another element.
167
- * @param {string} elementId - ID of the reference element
168
- * @returns {Element} This element for method chaining
169
- */
170
- positionUpOf(elementId) {
171
- const element = this.diagram.getElementById(elementId);
172
- const elementHeight = element.getSize().y;
173
- const thisHeight = this.getSize().y;
174
- this.setPosition(element.position.x, // x
175
- element.position.y + elementHeight / 2
176
- + DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
177
- + thisHeight / 2, // y
178
- 0 ); // z
179
- return this;
180
- }
181
-
182
- /**
183
- * Positions this element below another element.
184
- * @param {string} elementId - ID of the reference element
185
- * @returns {Element} This element for method chaining
186
- */
187
- positionDownOf(elementId) {
188
- const element = this.diagram.getElementById(elementId);
189
- const elementHeight = element.getSize().y;
190
- const thisHeight = this.getSize().y;
191
- this.setPosition(element.position.x, // x
192
- element.position.y - elementHeight / 2
193
- - DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
194
- - thisHeight / 2, // y
195
- 0 ); // z
196
-
197
- return this;
198
- }
199
-
200
- /**
201
- * Positions this element above and to the left of another element.
202
- * @param {string} elementId - ID of the reference element
203
- * @returns {Element} This element for method chaining
204
- */
205
- positionUpLeftOf(elementId) {
206
- const element = this.diagram.getElementById(elementId);
207
- const elementWidth = element.getSize().x;
208
- const elementHeight = element.getSize().y;
209
- const thisWidth = this.getSize().x;
210
- const thisHeight = this.getSize().y;
211
- this.setPosition(element.position.x - elementWidth / 2
212
- - DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
213
- - thisWidth / 2, // x
214
- element.position.y + elementHeight / 2
215
- + DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
216
- + thisHeight / 2, // y
217
- 0 ); // z
218
- return this;
219
- }
220
-
221
- /**
222
- * Positions this element below and to the left of another element.
223
- * @param {string} elementId - ID of the reference element
224
- * @returns {Element} This element for method chaining
225
- */
226
- positionDownLeftOf(elementId) {
227
- const element = this.diagram.getElementById(elementId);
228
- const elementWidth = element.getSize().x;
229
- const elementHeight = element.getSize().y;
230
- const thisWidth = this.getSize().x;
231
- const thisHeight = this.getSize().y;
232
- this.setPosition(element.position.x - elementWidth / 2
233
- - DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
234
- - thisWidth / 2, // x
235
- element.position.y - elementHeight / 2
236
- - DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
237
- - thisHeight / 2, // y
238
- 0 ); // z
239
- return this;
240
- }
241
-
242
- /**
243
- * Positions this element above and to the right of another element.
244
- * @param {string} elementId - ID of the reference element
245
- * @returns {Element} This element for method chaining
246
- */
247
- positionUpRightOf(elementId) {
248
- const element = this.diagram.getElementById(elementId);
249
- const elementWidth = element.getSize().x;
250
- const elementHeight = element.getSize().y;
251
- const thisWidth = this.getSize().x;
252
- const thisHeight = this.getSize().y;
253
- this.setPosition(element.position.x + elementWidth / 2
254
- + DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
255
- + thisWidth / 2, // x
256
- element.position.y + elementHeight / 2
257
- + DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
258
- + thisHeight / 2, // y
259
- 0 ); // z
260
- return this;
261
- }
262
-
263
- /**
264
- * Positions this element below and to the right of another element.
265
- * @param {string} elementId - ID of the reference element
266
- * @returns {Element} This element for method chaining
267
- */
268
- positionDownRightOf(elementId) {
269
- const element = this.diagram.getElementById(elementId);
270
- const elementWidth = element.getSize().x;
271
- const elementHeight = element.getSize().y;
272
- const thisWidth = this.getSize().x;
273
- const thisHeight = this.getSize().y;
274
- this.setPosition(element.position.x + elementWidth / 2
275
- + DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
276
- + thisWidth / 2, // x
277
- element.position.y - elementHeight / 2
278
- - DiagramDimensions.DISTANCE_BETWEEN_ELEMENTS
279
- - thisHeight / 2, // y
280
- 0 ); // z
281
- return this;
282
- }
283
-
284
-
285
- // =================================================================
286
- // Determine connecting points positions in geographical manner
287
- // (N, S, E, W, NNE, NNW, NEE, NWW, SEE, SWW, SSE, SSW)
288
- // for connectors to connect to
289
- // ================================================================
290
-
291
- /**
292
- * Gets the north connection point of the element.
293
- * The point is positioned at the middle of the element's top edge.
294
- * @returns {THREE.Vector2} A 2D vector representing the north point coordinates
295
- * where x is the element's center x-coordinate
296
- * and y is the element's top edge y-coordinate
297
- */
298
- getNorthPoint() {
299
- return new THREE.Vector2( this.position.x,
300
- this.position.y + this.getSize().y / 2 );
301
- }
302
-
303
- /**
304
- * Gets the south connection point of the element.
305
- * The point is positioned at the middle of the element's bottom edge.
306
- * @returns {THREE.Vector2} A 2D vector representing the south point coordinates
307
- * where x is the element's center x-coordinate
308
- * and y is the element's bottom edge y-coordinate
309
- */
310
- getSouthPoint() {
311
- return new THREE.Vector2( this.position.x,
312
- this.position.y - this.getSize().y / 2 );
313
- }
314
-
315
- /**
316
- * Gets the east connection point of the element.
317
- * The point is positioned at the middle of the element's right edge.
318
- * @returns {THREE.Vector2} A 2D vector representing the east point coordinates
319
- * where x is the element's right edge x-coordinate
320
- * and y is the element's center y-coordinate
321
- */
322
- getEastPoint() {
323
- return new THREE.Vector2( this.position.x + this.getSize().x / 2,
324
- this.position.y );
325
- }
326
-
327
- /**
328
- * Gets the west connection point of the element.
329
- * The point is positioned at the middle of the element's left edge.
330
- * @returns {THREE.Vector2} A 2D vector representing the west point coordinates
331
- * where x is the element's left edge x-coordinate
332
- * and y is the element's center y-coordinate
333
- */
334
- getWestPoint() {
335
- return new THREE.Vector2( this.position.x - this.getSize().x / 2,
336
- this.position.y );
337
- }
338
-
339
- /**
340
- * Gets the north-east connection point of the element.
341
- * The point is positioned at the top-right corner of the element.
342
- * @returns {THREE.Vector2} A 2D vector representing the north-east point coordinates
343
- * where x is the element's right edge x-coordinate
344
- * and y is the element's top edge y-coordinate
345
- */
346
- getNorthEastPoint() {
347
- return new THREE.Vector2( this.position.x + this.getSize().x / 2,
348
- this.position.y + this.getSize().y / 2 );
349
- }
350
-
351
- /**
352
- * Gets the north-west connection point of the element.
353
- * The point is positioned at the top-left corner of the element.
354
- * @returns {THREE.Vector2} A 2D vector representing the north-west point coordinates
355
- * where x is the element's left edge x-coordinate
356
- * and y is the element's top edge y-coordinate
357
- */
358
- getNorthWestPoint() {
359
- return new THREE.Vector2( this.position.x - this.getSize().x / 2,
360
- this.position.y + this.getSize().y / 2 );
361
- }
362
-
363
- /**
364
- * Gets the south-east connection point of the element.
365
- * The point is positioned at the bottom-right corner of the element.
366
- * @returns {THREE.Vector2} A 2D vector representing the south-east point coordinates
367
- * where x is the element's right edge x-coordinate
368
- * and y is the element's bottom edge y-coordinate
369
- */
370
- getSouthEastPoint() {
371
- return new THREE.Vector2( this.position.x + this.getSize().x / 2,
372
- this.position.y - this.getSize().y / 2 );
373
- }
374
-
375
- /**
376
- * Gets the south-west connection point of the element.
377
- * The point is positioned at the bottom-left corner of the element.
378
- * @returns {THREE.Vector2} A 2D vector representing the south-west point coordinates
379
- * where x is the element's left edge x-coordinate
380
- * and y is the element's bottom edge y-coordinate
381
- */
382
- getSouthWestPoint() {
383
- return new THREE.Vector2( this.position.x - this.getSize().x / 2,
384
- this.position.y - this.getSize().y / 2 );
385
- }
386
-
387
- /**
388
- * Gets the north-north-east connection point of the element.
389
- * The point is positioned on the top edge, one-quarter of the width from the center towards the right.
390
- * @returns {THREE.Vector2} A 2D vector representing the north-north-east point coordinates
391
- * where x is the element's center x-coordinate plus one-quarter of the width
392
- * and y is the element's top edge y-coordinate
393
- */
394
- getNorthNorthEastPoint() {
395
- return new THREE.Vector2( this.position.x + this.getSize().x / 4,
396
- this.position.y + this.getSize().y / 2 );
397
- }
398
-
399
- /**
400
- * Gets the north-north-west connection point of the element.
401
- * The point is positioned on the top edge, one-quarter of the width from the center towards the left.
402
- * @returns {THREE.Vector2} A 2D vector representing the north-north-west point coordinates
403
- * where x is the element's center x-coordinate minus one-quarter of the width
404
- * and y is the element's top edge y-coordinate
405
- */
406
- getNorthNorthWestPoint() {
407
- return new THREE.Vector2( this.position.x - this.getSize().x / 4,
408
- this.position.y + this.getSize().y / 2 );
409
- }
410
-
411
- /**
412
- * Gets the north-east-east connection point of the element.
413
- * The point is positioned on the right edge, one-quarter of the height from the top.
414
- * @returns {THREE.Vector2} A 2D vector representing the north-east-east point coordinates
415
- * where x is the element's right edge x-coordinate
416
- * and y is the element's top edge y-coordinate plus one-quarter of the height
417
- */
418
- getNorthEastEastPoint() {
419
- return new THREE.Vector2( this.position.x + this.getSize().x / 2,
420
- this.position.y + this.getSize().y / 4 );
421
- }
422
-
423
- /**
424
- * Gets the north-west-west connection point of the element.
425
- * The point is positioned on the left edge, one-quarter of the height from the top.
426
- * @returns {THREE.Vector2} A 2D vector representing the north-west-west point coordinates
427
- * where x is the element's left edge x-coordinate
428
- * and y is the element's top edge y-coordinate plus one-quarter of the height
429
- */
430
- getNorthWestWestPoint() {
431
- return new THREE.Vector2( this.position.x - this.getSize().x / 2,
432
- this.position.y + this.getSize().y / 4 );
433
- }
434
-
435
- /**
436
- * Gets the south-south-east connection point of the element.
437
- * The point is positioned on the bottom edge, one-quarter of the width from the center towards the right.
438
- * @returns {THREE.Vector2} A 2D vector representing the south-south-east point coordinates
439
- * where x is the element's center x-coordinate plus one-quarter of the width
440
- * and y is the element's bottom edge y-coordinate
441
- */
442
- getSouthSouthEastPoint() {
443
- return new THREE.Vector2( this.position.x + this.getSize().x / 4,
444
- this.position.y - this.getSize().y / 2 );
445
- }
446
-
447
- /**
448
- * Gets the south-south-west connection point of the element.
449
- * The point is positioned on the bottom edge, one-quarter of the width from the center towards the left.
450
- * @returns {THREE.Vector2} A 2D vector representing the south-south-west point coordinates
451
- * where x is the element's center x-coordinate minus one-quarter of the width
452
- * and y is the element's bottom edge y-coordinate
453
- */
454
- getSouthSouthWestPoint() {
455
- return new THREE.Vector2( this.position.x - this.getSize().x / 4,
456
- this.position.y - this.getSize().y / 2 );
457
- }
458
-
459
- /**
460
- * Gets the south-east-east connection point of the element.
461
- * The point is positioned on the right edge, one-quarter of the height from the bottom.
462
- * @returns {THREE.Vector2} A 2D vector representing the south-east-east point coordinates
463
- * where x is the element's right edge x-coordinate
464
- * and y is the element's bottom edge y-coordinate plus one-quarter of the height
465
- */
466
- getSouthEastEastPoint() {
467
- return new THREE.Vector2( this.position.x + this.getSize().x / 2,
468
- this.position.y - this.getSize().y / 4 );
469
- }
470
-
471
- /**
472
- * Gets the south-west-west connection point of the element.
473
- * The point is positioned on the left edge, one-quarter of the height from the bottom.
474
- * @returns {THREE.Vector2} A 2D vector representing the south-west-west point coordinates
475
- * where x is the element's left edge x-coordinate
476
- * and y is the element's bottom edge y-coordinate plus one-quarter of the height
477
- */
478
- getSouthWestWestPoint() {
479
- return new THREE.Vector2( this.position.x - this.getSize().x / 2,
480
- this.position.y - this.getSize().y / 4 );
481
- }
482
-
483
- /**
484
- * Gets the position of a connection point on the element.
485
- * @param {string} position - Position identifier (N, S, E, W, NE, NW, etc.)
486
- * @returns {THREE.Vector2} The connection point coordinates
487
- * @throws {Error} If the position identifier is invalid
488
- */
489
- getPointPosition(position) {
490
- switch (position) {
491
- case 'N':
492
- case 'north':
493
- return this.getNorthPoint();
494
- case 'S':
495
- case 'south':
496
- return this.getSouthPoint();
497
- case 'E':
498
- case 'east':
499
- return this.getEastPoint();
500
- case 'W':
501
- case 'west':
502
- return this.getWestPoint();
503
- case 'NE':
504
- case 'northeast':
505
- return this.getNorthEastPoint();
506
- case 'NW':
507
- case 'northwest':
508
- return this.getNorthWestPoint();
509
- case 'SE':
510
- case 'southeast':
511
- return this.getSouthEastPoint();
512
- case 'SW':
513
- case 'southwest':
514
- return this.getSouthWestPoint();
515
- case 'NNE':
516
- case 'northnortheast':
517
- return this.getNorthNorthEastPoint();
518
- case 'NNW':
519
- case 'northnorthwest':
520
- return this.getNorthNorthWestPoint();
521
- case 'NEE':
522
- case 'northeast':
523
- return this.getNorthEastEastPoint();
524
- case 'NWW':
525
- case 'northwest':
526
- return this.getNorthWestWestPoint();
527
- case 'SSE':
528
- case 'southsoutheast':
529
- return this.getSouthSouthEastPoint();
530
- case 'SSW':
531
- case 'southsouthwest':
532
- return this.getSouthSouthWestPoint();
533
- case 'SEE':
534
- case 'southeast':
535
- return this.getSouthEastEastPoint();
536
- case 'SWW':
537
- case 'southwest':
538
- return this.getSouthWestWestPoint();
539
- default:
540
- throw new Error(`Unknown position: ${position}`);
541
- }
542
- }
543
-
544
-
545
- // ================================================================
546
- // Add Text methods
547
- // ================================================================
548
-
549
- /**
550
- * Adds text to the element.
551
- * @param {string} text - The text to add
552
- * @returns {Element} This element for method chaining
553
- */
554
- addText(text) {
555
- const textElement = new Element(this.elementId + '_text', new TextShape(text));
556
- this.diagram.addElement(textElement).positionAt(this.position);
557
- this.texts.push({ element: textElement, positionOffset: new THREE.Vector3(0, 0, 0) });
558
- return this;
559
- }
560
-
561
- /**
562
- * Adds wrapped text that fits within the element's bounds.
563
- * @param {string} text - The text to add and wrap
564
- * @returns {Element} This element for method chaining
565
- */
566
- addWrappedText(text) {
567
- // If text is null or undefined, log a warning and return
568
- if (!text) {
569
- console.warn('addWrappedText: text is null or undefined');
570
- return this;
571
- }
572
- // If text is not null, add wrapped text
573
- let wrappedText = text.replace(/\s+/g, '\n');
574
-
575
- let wrappedTextElement = new Element( this.elementId + '_text', new TextShape(wrappedText));
576
- let candidateTextElement;
577
-
578
- while (true) {
579
- let words = wrappedText.split('\n');
580
- let minLength = Infinity;
581
- let minIndex = -1;
582
-
583
- for (let i = 0; i < words.length - 1; i++) {
584
- let combinedLength = words[i].length + words[i + 1].length;
585
- if (combinedLength < minLength) {
586
- minLength = combinedLength;
587
- minIndex = i;
588
- }
589
- }
590
-
591
- // console.log('minIndex:', minIndex);
592
- if (minIndex === -1) break;
593
-
594
- words[minIndex] = words[minIndex] + ' ' + words[minIndex + 1];
595
- words.splice(minIndex + 1, 1);
596
- wrappedText = words.join('\n');
597
-
598
- candidateTextElement = new Element( this.elementId + '_text', new TextShape(wrappedText));
599
-
600
- if (candidateTextElement.getSize().x <= this.getSize().x * .9) {
601
- // console.log('FITS INSIDE !');
602
- wrappedTextElement = candidateTextElement;
603
- } else {
604
- break;
605
- }
606
- }
607
-
608
- this.diagram.addElement(wrappedTextElement)
609
- .positionAt({ x: this.position.x, y: this.position.y, z: 3 }); //TODO: Use lib/shapes/bpmn/BpmnConstants.js BpmnDimensions.ACTIVITY_TEXT_SIZE and ACTIVITY_TEXT_ELEVATION
610
- // .positionAt(this.position);
611
- this.texts.push({ element: wrappedTextElement, positionOffset: new THREE.Vector3(0, 0, 3) });
612
- return this;
613
- }
614
-
615
- // ================================================================
616
- // Add icons methods
617
- // ================================================================
618
-
619
- /**
620
- * Gets the placeholder position for an icon at the top of the element.
621
- * The position is calculated by taking the element's top edge and offsetting it inward
622
- * by half the icon size plus padding.
623
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
624
- * where x is the element's center x-coordinate
625
- * and y is the element's top edge y-coordinate minus (icon size/2 + padding)
626
- */
627
- getTopIconPlaceholder() {
628
- return new THREE.Vector2(
629
- this.position.x,
630
- this.position.y + this.getSize().y / 2 - IconDimensions.ICON_SIZE_SMALL / 2 - IconDimensions.ICON_PADDING);
631
- }
632
-
633
- /**
634
- * Gets the placeholder position for an icon at the bottom of the element.
635
- * The position is calculated by taking the element's bottom edge and offsetting it inward
636
- * by half the icon size plus padding.
637
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
638
- * where x is the element's center x-coordinate
639
- * and y is the element's bottom edge y-coordinate plus (icon size/2 + padding)
640
- */
641
- getBottomIconPlaceholder() {
642
- return new THREE.Vector2(
643
- this.position.x,
644
- this.position.y - this.getSize().y / 2 + IconDimensions.ICON_SIZE_SMALL / 2 + IconDimensions.ICON_PADDING);
645
- }
646
-
647
- /**
648
- * Gets the placeholder position for an icon at the left of the element.
649
- * The position is calculated by taking the element's left edge and offsetting it inward
650
- * by half the icon size plus padding.
651
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
652
- * where x is the element's left edge x-coordinate plus (icon size/2 + padding)
653
- * and y is the element's center y-coordinate
654
- */
655
- getLeftIconPlaceholder() {
656
- return new THREE.Vector2(
657
- this.position.x - this.getSize().x / 2 + IconDimensions.ICON_SIZE_SMALL / 2 + IconDimensions.ICON_PADDING, this.position.y);
658
- }
659
-
660
- /**
661
- * Gets the placeholder position for an icon at the right of the element.
662
- * The position is calculated by taking the element's right edge and offsetting it inward
663
- * by half the icon size plus padding.
664
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
665
- * where x is the element's right edge x-coordinate minus (icon size/2 + padding)
666
- * and y is the element's center y-coordinate
667
- */
668
- getRightIconPlaceholder() {
669
- return new THREE.Vector2(
670
- this.position.x + this.getSize().x / 2 - IconDimensions.ICON_SIZE_SMALL / 2 - IconDimensions.ICON_PADDING,
671
- this.position.y);
672
- }
673
-
674
- /**
675
- * Gets the placeholder position for an icon at the top-left corner of the element.
676
- * The position is calculated by taking the element's top-left corner and offsetting it inward
677
- * by half the icon size plus padding along both axes.
678
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
679
- * where x is the element's left edge x-coordinate plus (icon size/2 + padding)
680
- * and y is the element's top edge y-coordinate minus (icon size/2 + padding)
681
- */
682
- getTopLeftIconPlaceholder() {
683
- return new THREE.Vector2(
684
- this.position.x - this.getSize().x / 2 + IconDimensions.ICON_SIZE_SMALL / 2 + IconDimensions.ICON_PADDING,
685
- this.position.y + this.getSize().y / 2 - IconDimensions.ICON_SIZE_SMALL / 2 - IconDimensions.ICON_PADDING
686
- );
687
- }
688
-
689
- /**
690
- * Gets the placeholder position for an icon at the top-right corner of the element.
691
- * The position is calculated by taking the element's top-right corner and offsetting it inward
692
- * by half the icon size plus padding along both axes.
693
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
694
- * where x is the element's right edge x-coordinate minus (icon size/2 + padding)
695
- * and y is the element's top edge y-coordinate minus (icon size/2 + padding)
696
- */
697
- getTopRightIconPlaceholder() {
698
- return new THREE.Vector2(
699
- this.position.x + this.getSize().x / 2 - IconDimensions.ICON_SIZE_SMALL / 2 - IconDimensions.ICON_PADDING,
700
- this.position.y + this.getSize().y / 2 - IconDimensions.ICON_SIZE_SMALL / 2 - IconDimensions.ICON_PADDING);
701
- }
702
-
703
- /**
704
- * Gets the placeholder position for an icon at the bottom-left corner of the element.
705
- * The position is calculated by taking the element's bottom-left corner and offsetting it inward
706
- * by half the icon size plus padding along both axes.
707
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
708
- * where x is the element's left edge x-coordinate plus (icon size/2 + padding)
709
- * and y is the element's bottom edge y-coordinate plus (icon size/2 + padding)
710
- */
711
- getBottomLeftIconPlaceholder() {
712
- return new THREE.Vector2(
713
- this.position.x - this.getSize().x / 2 + IconDimensions.ICON_SIZE_SMALL / 2 + IconDimensions.ICON_PADDING,
714
- this.position.y - this.getSize().y / 2 + IconDimensions.ICON_SIZE_SMALL / 2 + IconDimensions.ICON_PADDING);
715
- }
716
-
717
- /**
718
- * Gets the placeholder position for an icon at the bottom-right corner of the element.
719
- * The position is calculated by taking the element's bottom-right corner and offsetting it inward
720
- * by half the icon size plus padding along both axes.
721
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
722
- * where x is the element's right edge x-coordinate minus (icon size/2 + padding)
723
- * and y is the element's bottom edge y-coordinate plus (icon size/2 + padding)
724
- */
725
- getBottomRightIconPlaceholder() {
726
- return new THREE.Vector2(
727
- this.position.x + this.getSize().x / 2 - IconDimensions.ICON_SIZE_SMALL / 2 - IconDimensions.ICON_PADDING,
728
- this.position.y - this.getSize().y / 2 + IconDimensions.ICON_SIZE_SMALL / 2 + IconDimensions.ICON_PADDING);
729
- }
730
-
731
- /**
732
- * Gets the placeholder position for an icon at the center of the element.
733
- * The position is at the element's center.
734
- * @returns {THREE.Vector2} A 2D vector representing the placeholder coordinates
735
- * where x is the element's center x-coordinate
736
- * and y is the element's center y-coordinate
737
- */
738
- getCenterIconPlaceholder() {
739
- return new THREE.Vector2(this.position.x, this.position.y);
740
- }
741
-
742
- /**
743
- * Gets the position for an icon placeholder.
744
- * @param {string} position - Position identifier (top, bottom, left, right, etc.)
745
- * @returns {THREE.Vector2} The placeholder position
746
- * @throws {Error} If the position identifier is invalid
747
- */
748
- getIconPlaceholder(position) {
749
- switch (position) {
750
- case 'top':
751
- return this.getTopIconPlaceholder();
752
- case 'bottom':
753
- return this.getBottomIconPlaceholder();
754
- case 'left':
755
- return this.getLeftIconPlaceholder();
756
- case 'right':
757
- return this.getRightIconPlaceholder();
758
- case 'top-left':
759
- return this.getTopLeftIconPlaceholder();
760
- case 'top-right':
761
- return this.getTopRightIconPlaceholder();
762
- case 'bottom-left':
763
- return this.getBottomLeftIconPlaceholder();
764
- case 'bottom-right':
765
- return this.getBottomRightIconPlaceholder();
766
- case 'center':
767
- return this.getCenterIconPlaceholder();
768
- default:
769
- throw new Error(`Unknown icon position: ${position}`);
770
- }
771
- }
772
-
773
- /**
774
- * Adds an icon to the element.
775
- * @param {string} icon - The icon identifier
776
- * @param {string} [placeholder='center'] - Position of the icon
777
- * @param {number} [size=IconDimensions.ICON_SIZE_MEDIUM] - Size of the icon
778
- * @returns {Element} This element for method chaining
779
- */
780
- addIcon(icon, placeholder = 'center', size = IconDimensions.ICON_SIZE_MEDIUM) {
781
- let position;
782
- if (typeof placeholder === 'string') {
783
- position = this.getIconPlaceholder(placeholder);
784
- }
785
- const iconElement = new Element(this.elementId + '_icon_placeholder', new IconShape(icon, size));
786
- this.diagram.addElement(iconElement).positionAt(position);
787
- this.icons.push({ element: iconElement, positionOffset: new THREE.Vector3(position.x - this.position.x, position.y - this.position.y, 0) });
788
- return this;
789
- }
790
-
791
-
792
- // ================================================================
793
- // Add Analysis methods
794
- // ================================================================
795
-
796
- /**
797
- * Adds a value bar for analysis mode.
798
- * @param {number} value - The value to represent (must be positive)
799
- * @returns {Element} This element for method chaining
800
- */
801
- addValueBar(value) {
802
- // Ensure the value is positive
803
- if (value < 0) {
804
- console.warn('valueBar: Value must be positive');
805
- return this;
806
- }
807
- // Add values to the element parameters
808
- this.parameters['value'] = value;
809
- console.log('valueBar added:', this);
810
- // Draw bars if mode is ANALYZE
811
- if (this.diagram.mode !== 'ANALYZE') {
812
- console.warn('valueBar: Diagram mode is not ANALYZE');
813
- return this;
814
- }
815
- const barElement = new Element(this.elementId + '_bar', new ValueBarShape(this.shape.getOuterShape(), value));
816
- this.diagram.addElement(barElement).positionAt(this.position);
817
- this.valueBars.push({ element: barElement, positionOffset: new THREE.Vector3(0, 0, 0) });
818
- return this;
819
- }
820
-
821
- // ================================================================
822
- // Add connecting methods
823
- // ================================================================
824
-
825
- /**
826
- * Creates a connector from another element to this element.
827
- * @param {string} sourceElementId - ID of the source element
828
- * @param {string} sourcePosition - Connection point on the source element
829
- * @param {string} targetPosition - Connection point on this element
830
- * @returns {Element} This element for method chaining
831
- * @throws {Error} If the diagram is not set or source element is not found
832
- */
833
- connectFrom(sourceElementId, sourcePosition, targetPosition) {
834
- if (!this.diagram) {
835
- throw new Error("Diagram is not set for this element.");
836
- }
837
-
838
- const targetElement = this;
839
- const sourceElement = this.diagram.getElementById(sourceElementId);
840
-
841
- if (!sourceElement) {
842
- throw new Error(`Element with ID ${sourceElementId} not found.`);
843
- }
844
-
845
- const sourcePoint = sourceElement.getPointPosition(sourcePosition);
846
- const targetPoint = targetElement.getPointPosition(targetPosition);
847
-
848
- const points = Connector.determinePoints(sourcePoint, targetPoint, sourcePosition, targetPosition);
849
-
850
- this.diagram.addConnector(new Connector(`connector-${sourceElement.elementId}-${targetElement.elementId}`,
851
- new RoundedCornerOrthogonalConnectorShape(points))); //TODO: Zrobić bardziej ogólnie - nie wiadomo jaki connector wybrać (może flowFrom?)
852
-
853
- return this;
854
- }
855
-
856
- }
857
-
858
- export {
859
- Element
860
- };