@shapediver/viewer.features.drawing-tools 3.3.4 → 3.3.6

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 (43) hide show
  1. package/package.json +12 -13
  2. package/src/api/implementation/DrawingToolsApi.ts +0 -130
  3. package/src/api/implementation/restrictions/AbstractRestrictionApi.ts +0 -34
  4. package/src/api/implementation/restrictions/AbstractSnapRestrictionApi.ts +0 -36
  5. package/src/api/implementation/restrictions/geometry/GeometryRestrictionApi.ts +0 -56
  6. package/src/api/implementation/restrictions/plane/PlaneRestrictionApi.ts +0 -70
  7. package/src/api/implementation/restrictions/plane/snap/AngularRestrictionApi.ts +0 -35
  8. package/src/api/implementation/restrictions/plane/snap/AxisRestrictionApi.ts +0 -19
  9. package/src/api/implementation/restrictions/plane/snap/GridRestrictionApi.ts +0 -35
  10. package/src/api/interfaces/IDrawingToolsApi.ts +0 -98
  11. package/src/api/interfaces/IRestrictionApi.ts +0 -15
  12. package/src/api/interfaces/ISnapRestrictionApi.ts +0 -18
  13. package/src/business/implementation/DrawingToolsManager.ts +0 -618
  14. package/src/business/implementation/managers/HistoryManager.ts +0 -101
  15. package/src/business/implementation/managers/TextVisualizationManager.ts +0 -269
  16. package/src/business/implementation/managers/geometry/GeometryManager.ts +0 -95
  17. package/src/business/implementation/managers/geometry/GeometryMathManager.ts +0 -289
  18. package/src/business/implementation/managers/geometry/GeometryState.ts +0 -436
  19. package/src/business/implementation/managers/geometry/helpers/GeometryManagerHelper.ts +0 -170
  20. package/src/business/implementation/managers/interaction/EventManager.ts +0 -80
  21. package/src/business/implementation/managers/interaction/InteractionManager.ts +0 -268
  22. package/src/business/implementation/managers/interaction/RestrictionManager.ts +0 -132
  23. package/src/business/implementation/managers/interaction/handlers/DeletionInteractionHandler.ts +0 -48
  24. package/src/business/implementation/managers/interaction/handlers/InsertionInteractionHandler.ts +0 -149
  25. package/src/business/implementation/managers/interaction/handlers/MidPointInteractionHandler.ts +0 -127
  26. package/src/business/implementation/managers/interaction/helpers/InteractionManagerHelper.ts +0 -411
  27. package/src/business/implementation/managers/interaction/restrictions/AbstractRestriction.ts +0 -99
  28. package/src/business/implementation/managers/interaction/restrictions/geometry/GeometryRestriction.ts +0 -237
  29. package/src/business/implementation/managers/interaction/restrictions/plane/PlaneRestriction.ts +0 -337
  30. package/src/business/implementation/managers/interaction/restrictions/plane/snap/AngularRestriction.ts +0 -394
  31. package/src/business/implementation/managers/interaction/restrictions/plane/snap/AxisRestriction.ts +0 -116
  32. package/src/business/implementation/managers/interaction/restrictions/plane/snap/GridRestriction.ts +0 -246
  33. package/src/business/implementation/utils/numberCleaner.ts +0 -5
  34. package/src/business/interfaces/IDrawingToolsManager.ts +0 -312
  35. package/src/business/interfaces/IManager.ts +0 -7
  36. package/src/business/interfaces/IRestriction.ts +0 -63
  37. package/src/business/interfaces/IRestrictionBase.ts +0 -33
  38. package/src/business/interfaces/ISnapRestriction.ts +0 -70
  39. package/src/business/interfaces/events/EventResponseMapping.ts +0 -19
  40. package/src/business/interfaces/events/IDrawingToolsEvent.ts +0 -16
  41. package/src/index.ts +0 -72
  42. package/src/three/CSS2DRenderer.ts +0 -212
  43. package/tsconfig.json +0 -17
@@ -1,394 +0,0 @@
1
- import { AbstractRestriction } from '../../AbstractRestriction';
2
- import { CSS2DObject } from '../../../../../../../three/CSS2DRenderer';
3
- import { DrawingToolsManager } from '../../../../../DrawingToolsManager';
4
- import { GeometryMathManager } from '../../../../geometry/GeometryMathManager';
5
- import { IRay } from '@shapediver/viewer.features.interaction';
6
- import { ISnapRestriction, SnapRestrictionProperties } from '../../../../../../interfaces/ISnapRestriction';
7
- import { numberCleaner } from '../../../../../utils/numberCleaner';
8
- import { PlaneRestriction } from '../PlaneRestriction';
9
- import { RestrictionMetaData } from '../../../../../../interfaces/IRestriction';
10
- import { sceneTree } from '@shapediver/viewer';
11
- import { Settings } from '../../../../../../interfaces/IDrawingToolsManager';
12
- import { vec3 } from 'gl-matrix';
13
-
14
- // #region Type aliases (1)
15
-
16
- export type AngularRestrictionProperties = {
17
- /**
18
- * Step size for the angles
19
- */
20
- angleStep?: number;
21
-
22
- /**
23
- * If the angle step is editable for change to the end user.
24
- * If it is not editable, the angle step cannot be changed from the default value.
25
- */
26
- angleStepEditable?: boolean;
27
- } & SnapRestrictionProperties;
28
-
29
- // #endregion Type aliases (1)
30
-
31
- // #region Classes (1)
32
-
33
- export class AngularRestriction extends AbstractRestriction implements ISnapRestriction {
34
- // #region Properties (13)
35
-
36
- readonly #activationKey: string;
37
- readonly #drawingToolsManager: DrawingToolsManager;
38
- readonly #geometryMathManager: GeometryMathManager;
39
- readonly #planeRestriction: PlaneRestriction;
40
- readonly #settings: Settings;
41
-
42
- #active: boolean = false;
43
- #activePolarGrids = {
44
- next: false,
45
- previous: false
46
- };
47
- #angleStep: number;
48
- #angleStepEditable: boolean = true;
49
- #angles: number[] = [];
50
- #labelNext?: CSS2DObject;
51
- #labelPrevious?: CSS2DObject;
52
- #priority: number = 0;
53
-
54
- // #endregion Properties (13)
55
-
56
- // #region Constructors (1)
57
-
58
- constructor(drawingToolsManager: DrawingToolsManager, planeRestriction: PlaneRestriction, properties?: AngularRestrictionProperties) {
59
- super(drawingToolsManager, 'angular');
60
-
61
- this.#drawingToolsManager = drawingToolsManager;
62
- this.#geometryMathManager = drawingToolsManager.geometryMathManager;
63
- this.#settings = drawingToolsManager.settings;
64
-
65
- this.#planeRestriction = planeRestriction;
66
-
67
- this.#activationKey = properties?.activationKey || 'a';
68
- this.enabled = properties?.enabled ?? false;
69
- this._enabledEditable = properties?.enabledEditable ?? true;
70
- this.#angleStep = properties?.angleStep || Math.PI / 12;
71
- this.#angleStepEditable = properties?.angleStepEditable ?? true;
72
- this.#priority = properties?.priority || 0;
73
-
74
- // calculate the angles
75
- this.calculateAngles();
76
- }
77
-
78
- // #endregion Constructors (1)
79
-
80
- // #region Public Getters And Setters (8)
81
-
82
- public get active(): boolean {
83
- return this.#active;
84
- }
85
-
86
- public set active(value: boolean) {
87
- this.#active = value;
88
-
89
- if (value === false) {
90
- if (this.#labelNext) this.#labelNext.visible = false;
91
- if (this.#labelPrevious) this.#labelPrevious.visible = false;
92
- } else {
93
- if (this.#labelNext && this.#activePolarGrids.next) this.#labelNext.visible = true;
94
- if (this.#labelPrevious && this.#activePolarGrids.previous) this.#labelPrevious.visible = true;
95
- }
96
- }
97
-
98
- public get angleStep(): number {
99
- return this.#angleStep;
100
- }
101
-
102
- public set angleStep(value: number) {
103
- if (this.#angleStepEditable === false) return;
104
-
105
- this.#angleStep = value;
106
- this.calculateAngles();
107
- }
108
-
109
- public get angleStepEditable(): boolean {
110
- return this.#angleStepEditable;
111
- }
112
-
113
- public get enabledEditable(): boolean {
114
- return this._enabledEditable;
115
- }
116
-
117
- public get priority(): number {
118
- return this.#priority;
119
- }
120
-
121
- public set priority(value: number) {
122
- this.#priority = value;
123
- }
124
-
125
- // #endregion Public Getters And Setters (8)
126
-
127
- // #region Public Methods (2)
128
-
129
- public snap(ray: IRay, point: vec3, metaData?: RestrictionMetaData): vec3 | undefined {
130
- // if the restriction is not enabled OR the activation key is set and the key is not pressed, return
131
- if (this.enabled === false && this.#drawingToolsManager.keyPressed(this.#activationKey) === false) return;
132
-
133
- if (this.#labelNext) this.#labelNext.visible = false;
134
- if (this.#labelPrevious) this.#labelPrevious.visible = false;
135
-
136
- this.#activePolarGrids = {
137
- next: false,
138
- previous: false
139
- };
140
-
141
- const positionArray = this.#drawingToolsManager.positionArray;
142
-
143
- let previousIndex, nextIndex;
144
- if (metaData !== undefined && metaData.index !== undefined) {
145
- previousIndex = this.getPreviousIndex(metaData.index);
146
- nextIndex = this.getNextIndex(metaData.index);
147
- } else {
148
- // if no index was provided, it is a new point
149
- previousIndex = positionArray.length / 3 - 1;
150
- nextIndex = 0;
151
- }
152
-
153
- const previousPreviousIndex = this.getPreviousIndex(previousIndex);
154
- const nextNextIndex = this.getNextIndex(nextIndex);
155
-
156
- if (positionArray.length / 3 < 2) return;
157
-
158
- /**
159
- * Explanation of the algorithm:
160
- * 1. Project the point onto the XY-Plane
161
- * 2. Find the next point and the previous point
162
- * 3. Project the next and previous point onto the XY-Plane
163
- * 4. Calculate the angle between the point and the next and previous point
164
- * 5. Determine which if the angles are in the range to snap to
165
- * a. If both are in the range, snap to the intersection of the two lines
166
- * b. If only one is in the range, snap to the intersection of the line and the plane
167
- * c. If none is in the range, return
168
- * 6. Reverse the projection to the original coordinate system
169
- */
170
-
171
- // get the next and previous point from the position array
172
- const nextPointFromData = vec3.fromValues(positionArray.at((nextIndex * 3))!, positionArray.at((nextIndex * 3) + 1)!, positionArray.at((nextIndex * 3) + 2)!);
173
- const nextNextPointFromData = vec3.fromValues(positionArray.at((nextNextIndex * 3))!, positionArray.at((nextNextIndex * 3) + 1)!, positionArray.at((nextNextIndex * 3) + 2)!);
174
- const previousPointFromData = vec3.fromValues(positionArray.at((previousIndex * 3))!, positionArray.at((previousIndex * 3) + 1)!, positionArray.at((previousIndex * 3) + 2)!);
175
- const previousPreviousPointFromData = vec3.fromValues(positionArray.at((previousPreviousIndex * 3))!, positionArray.at((previousPreviousIndex * 3) + 1)!, positionArray.at((previousPreviousIndex * 3) + 2)!);
176
-
177
- // project them onto the same plane as the point
178
- const nextPointProjected = vec3.sub(vec3.create(), nextPointFromData, vec3.scale(vec3.create(), this.#planeRestriction.normal, vec3.dot(vec3.sub(vec3.create(), nextPointFromData, point), this.#planeRestriction.normal)));
179
- const nextNextPointProjected = vec3.sub(vec3.create(), nextNextPointFromData, vec3.scale(vec3.create(), this.#planeRestriction.normal, vec3.dot(vec3.sub(vec3.create(), nextNextPointFromData, point), this.#planeRestriction.normal)));
180
- const previousPointProjected = vec3.sub(vec3.create(), previousPointFromData, vec3.scale(vec3.create(), this.#planeRestriction.normal, vec3.dot(vec3.sub(vec3.create(), previousPointFromData, point), this.#planeRestriction.normal)));
181
- const previousPreviousPointProjected = vec3.sub(vec3.create(), previousPreviousPointFromData, vec3.scale(vec3.create(), this.#planeRestriction.normal, vec3.dot(vec3.sub(vec3.create(), previousPreviousPointFromData, point), this.#planeRestriction.normal)));
182
-
183
- // project the point onto the XY-Plane
184
- const pointProjected = vec3.transformMat4(vec3.create(), point, this.#planeRestriction.transformationToXYPlaneMatrix);
185
- vec3.transformMat4(nextPointProjected, nextPointProjected, this.#planeRestriction.transformationToXYPlaneMatrix);
186
- vec3.transformMat4(nextNextPointProjected, nextNextPointProjected, this.#planeRestriction.transformationToXYPlaneMatrix);
187
- vec3.transformMat4(previousPointProjected, previousPointProjected, this.#planeRestriction.transformationToXYPlaneMatrix);
188
- vec3.transformMat4(previousPreviousPointProjected, previousPreviousPointProjected, this.#planeRestriction.transformationToXYPlaneMatrix);
189
-
190
- // calculate the angle between the next and previous point and the point to restrict on the axis
191
- const { angularDifference: angularDifferenceNext, crossProduct: crossProductNext, closestAngle: closestAngleNext } = this.getAngularDifference({ start: nextPointProjected, end: nextNextPointProjected }, { start: nextPointProjected, end: pointProjected });
192
- const { angularDifference: angularDifferencePrevious, crossProduct: crossProductPrevious, closestAngle: closestAnglePrevious } = this.getAngularDifference({ start: previousPointProjected, end: previousPreviousPointProjected }, { start: previousPointProjected, end: pointProjected });
193
-
194
- // calculate the distances in screen space so we can check how close it is
195
- const resultPointNextAngle = vec3.rotateZ(vec3.create(), pointProjected, nextPointProjected, crossProductNext[2] < 0 ? -angularDifferenceNext : angularDifferenceNext);
196
- const screenSpaceDistanceCheckNextAngle = this.#geometryMathManager.screenSpaceDistanceCheck(resultPointNextAngle, pointProjected, this.#settings.visualization.points.size_0! * this.#settings.visualization.distanceMultiplicationFactor);
197
- const resultPointPreviousAngle = vec3.rotateZ(vec3.create(), pointProjected, previousPointProjected, crossProductPrevious[2] < 0 ? -angularDifferencePrevious : angularDifferencePrevious);
198
- const screenSpaceDistanceCheckPreviousAngle = this.#geometryMathManager.screenSpaceDistanceCheck(resultPointPreviousAngle, pointProjected, this.#settings.visualization.points.size_0! * this.#settings.visualization.distanceMultiplicationFactor);
199
-
200
- if (screenSpaceDistanceCheckNextAngle.check === false && screenSpaceDistanceCheckPreviousAngle.check === false) return;
201
-
202
- // snap to clear defined point if both distances are smaller than threshold
203
- if (positionArray.length > 6 && screenSpaceDistanceCheckNextAngle.check === true && screenSpaceDistanceCheckPreviousAngle.check === true) {
204
- const rayDirectionNext = vec3.normalize(vec3.create(), vec3.sub(vec3.create(), resultPointNextAngle, nextPointProjected));
205
- const rayDirectionPrevious = vec3.normalize(vec3.create(), vec3.sub(vec3.create(), resultPointPreviousAngle, previousPointProjected));
206
-
207
- const crossProduct = vec3.cross(vec3.create(), rayDirectionNext, rayDirectionPrevious);
208
- const crossProductLength = vec3.length(crossProduct);
209
-
210
- if (crossProductLength < 0.001) {
211
- vec3.transformMat4(resultPointNextAngle, resultPointNextAngle, this.#planeRestriction.transformationFromXYPlaneMatrix);
212
- return resultPointNextAngle;
213
- }
214
-
215
- const t = vec3.sub(vec3.create(), previousPointProjected, nextPointProjected);
216
- const u = vec3.cross(vec3.create(), t, rayDirectionPrevious);
217
- const v = vec3.cross(vec3.create(), t, rayDirectionNext);
218
-
219
- const tValue = vec3.dot(u, crossProduct) / crossProductLength ** 2;
220
- const uValue = vec3.dot(v, crossProduct) / crossProductLength ** 2;
221
-
222
- if (tValue < 0 || uValue < 0) {
223
- vec3.transformMat4(resultPointNextAngle, resultPointNextAngle, this.#planeRestriction.transformationFromXYPlaneMatrix);
224
- return resultPointNextAngle;
225
- }
226
-
227
- const intersection = vec3.add(vec3.create(), nextPointProjected, vec3.scale(vec3.create(), rayDirectionNext, tValue));
228
- this.#labelNext = this.createGrid(this.#labelNext, nextPointFromData, closestAngleNext);
229
- this.#activePolarGrids.next = true;
230
- this.#labelPrevious = this.createGrid(this.#labelPrevious, previousPointFromData, closestAnglePrevious);
231
- this.#activePolarGrids.previous = true;
232
-
233
- // reverse the projection to the original coordinate system
234
- vec3.transformMat4(intersection, intersection, this.#planeRestriction.transformationFromXYPlaneMatrix);
235
- return intersection;
236
- }
237
-
238
- // check which distance to the projection is smaller
239
- if (screenSpaceDistanceCheckNextAngle.distanceSquared < screenSpaceDistanceCheckPreviousAngle.distanceSquared) {
240
- this.#labelNext = this.createGrid(this.#labelNext, nextPointFromData, closestAngleNext);
241
- this.#activePolarGrids.next = true;
242
-
243
- // reverse the projection to the original coordinate system
244
- vec3.transformMat4(resultPointNextAngle, resultPointNextAngle, this.#planeRestriction.transformationFromXYPlaneMatrix);
245
- return resultPointNextAngle;
246
- } else {
247
- this.#labelPrevious = this.createGrid(this.#labelPrevious, previousPointFromData, closestAnglePrevious);
248
- this.#activePolarGrids.previous = true;
249
-
250
- // reverse the projection to the original coordinate system
251
- vec3.transformMat4(resultPointPreviousAngle, resultPointPreviousAngle, this.#planeRestriction.transformationFromXYPlaneMatrix);
252
- return resultPointPreviousAngle;
253
- }
254
- }
255
-
256
- public updatePlaneDefinition(): void { }
257
-
258
- // #endregion Public Methods (2)
259
-
260
- // #region Protected Methods (1)
261
-
262
- protected visibilityChanged(visible: boolean): void {
263
- if (visible === false) {
264
- if (this.#labelNext) this.#labelNext.visible = false;
265
- if (this.#labelPrevious) this.#labelPrevious.visible = false;
266
- }
267
- }
268
-
269
- // #endregion Protected Methods (1)
270
-
271
- // #region Private Methods (5)
272
-
273
- private calculateAngles() {
274
- this.#angles = [];
275
- for (let i = 0; i <= Math.PI + 0.0001; i += this.#angleStep) {
276
- this.#angles.push(i);
277
- }
278
- }
279
-
280
- private createGrid(label: CSS2DObject | undefined, position: vec3, angle: number): CSS2DObject {
281
- if (label)
282
- this._object3D.remove(label);
283
-
284
- let radius = sceneTree.root.boundingBox.boundingSphere.radius / 100;
285
- if (radius === Infinity)
286
- radius = 1;
287
-
288
- const text = document.createElement('div');
289
- text.className = 'label';
290
- label = new CSS2DObject(text);
291
-
292
- // remove the old style, if there is one
293
- document.head.querySelectorAll('style').forEach(style => {
294
- if (style.textContent?.includes(label!.uuid))
295
- document.head.removeChild(style);
296
- });
297
-
298
- const parent = document.createElement('div');
299
- parent.className = `angular-label-parent-${label!.uuid}`;
300
- const child = document.createElement('div');
301
- child.className = `angular-label-${label!.uuid}`;
302
-
303
- const style = document.createElement('style');
304
- style.textContent = `
305
- .angular-label-${label!.uuid} {
306
- display: flex;
307
- justify-content: center;
308
- align-items: center;
309
- width: 32px;
310
- height: 32px;
311
- color: white;
312
- background-color: ${this.#settings.visualization.points.color_1};
313
- border-radius: 50%;
314
- font-size: 16px;
315
- text-align: center;
316
- }
317
-
318
- .angular-label-parent-${label!.uuid} {
319
- display: flex;
320
- justify-content: center;
321
- align-items: center;
322
- width: 40px; /* 32px + 2 * 4px border width */
323
- height: 40px; /* 32px + 2 * 4px border width */
324
- border-radius: 50%;
325
- background: conic-gradient(
326
- ${this.#settings.visualization.points.color_2} 0% ${(angle / Math.PI) * 100}%,
327
- ${this.#settings.visualization.points.color_1} ${(angle / Math.PI) * 100}% 100%
328
- );
329
- }
330
- `;
331
- document.head.appendChild(style);
332
-
333
- parent.appendChild(child);
334
-
335
- child.textContent = `${numberCleaner((angle / Math.PI) * 180)}°`;
336
- text.appendChild(parent);
337
-
338
- label.position.set(position[0], position[1], position[2]);
339
- label.visible = false;
340
- this._object3D.add(label);
341
-
342
- return label;
343
- }
344
-
345
- private getAngularDifference(
346
- line: {
347
- start: vec3, end: vec3
348
- },
349
- referenceLine: {
350
- start: vec3, end: vec3
351
- }
352
- ): {
353
- angularDifference: number,
354
- crossProduct: vec3,
355
- closestAngle: number
356
- } {
357
- const lineDirection = vec3.normalize(vec3.create(), vec3.sub(vec3.create(), line.end, line.start));
358
- const referenceLineDirection = vec3.normalize(vec3.create(), vec3.sub(vec3.create(), referenceLine.end, referenceLine.start));
359
-
360
- // calculate the angle between the lineDirection and the referenceLineDirection
361
- const angleReference = vec3.angle(lineDirection, referenceLineDirection);
362
- const crossProduct = vec3.cross(vec3.create(), lineDirection, referenceLineDirection);
363
-
364
- // find the angle that is closest to the angle of the previous point
365
- let closestAngle = this.#angles[0];
366
- for (let i = 0; i < this.#angles.length; i++) {
367
- const angle = this.#angles[i];
368
-
369
- if (Math.abs(angleReference - angle) < Math.abs(angleReference - closestAngle))
370
- closestAngle = angle;
371
- }
372
-
373
- // move the point to the closest angle
374
- const angularDifference = closestAngle - angleReference;
375
-
376
- return {
377
- angularDifference,
378
- crossProduct,
379
- closestAngle
380
- };
381
- }
382
-
383
- private getNextIndex(index: number): number {
384
- return index + 1 > this.#drawingToolsManager.positionArray.length / 3 - 1 ? 0 : index + 1;
385
- }
386
-
387
- private getPreviousIndex(index: number): number {
388
- return index - 1 < 0 ? this.#drawingToolsManager.positionArray.length / 3 - 1 : index - 1;
389
- }
390
-
391
- // #endregion Private Methods (5)
392
- }
393
-
394
- // #endregion Classes (1)
@@ -1,116 +0,0 @@
1
- import { AbstractRestriction } from '../../AbstractRestriction';
2
- import { DrawingToolsManager } from '../../../../../DrawingToolsManager';
3
- import { GeometryMathManager } from '../../../../geometry/GeometryMathManager';
4
- import { IRay } from '@shapediver/viewer.features.interaction';
5
- import { ISnapRestriction, SnapRestrictionProperties } from '../../../../../../interfaces/ISnapRestriction';
6
- import { PlaneRestriction } from '../PlaneRestriction';
7
- import { RestrictionMetaData } from '../../../../../../interfaces/IRestriction';
8
- import { vec3 } from 'gl-matrix';
9
-
10
- // #region Type aliases (1)
11
-
12
- export type AxisRestrictionProperties = {
13
- activationKeyX?: string;
14
- activationKeyY?: string;
15
- activationKeyZ?: string;
16
- activationKeyPlane?: string;
17
- } & SnapRestrictionProperties;
18
-
19
- // #endregion Type aliases (1)
20
-
21
- // #region Classes (1)
22
-
23
- export class AxisRestriction extends AbstractRestriction implements ISnapRestriction {
24
- // #region Properties (8)
25
-
26
- readonly #activationKeyX: string;
27
- readonly #activationKeyY: string;
28
- readonly #activationKeyZ: string;
29
- readonly #activationKeyPlane: string;
30
- readonly #drawingToolsManager: DrawingToolsManager;
31
- readonly #planeRestriction: PlaneRestriction;
32
-
33
- #active: boolean = false;
34
- #geometryMathManager: GeometryMathManager;
35
- #priority: number = 0;
36
-
37
- // #endregion Properties (8)
38
-
39
- // #region Constructors (1)
40
-
41
- constructor(drawingToolsManager: DrawingToolsManager, planeRestriction: PlaneRestriction, properties?: AxisRestrictionProperties) {
42
- super(drawingToolsManager, 'axis');
43
- this.#drawingToolsManager = drawingToolsManager;
44
- this.#planeRestriction = planeRestriction;
45
- this.#geometryMathManager = drawingToolsManager.geometryMathManager;
46
-
47
- this.#activationKeyX = properties?.activationKeyX || 'x';
48
- this.#activationKeyY = properties?.activationKeyY || 'y';
49
- this.#activationKeyZ = properties?.activationKeyZ || 'z';
50
- this.#activationKeyPlane = properties?.activationKeyPlane || 'p';
51
-
52
- this.#priority = properties?.priority || 1;
53
- }
54
-
55
- // #endregion Constructors (1)
56
-
57
- // #region Public Getters And Setters (5)
58
-
59
- public get active(): boolean {
60
- return this.#active;
61
- }
62
-
63
- public set active(value: boolean) {
64
- this.#active = value;
65
-
66
- // if (this.#gridHelper) this.#gridHelper.visible = value;
67
- }
68
-
69
- public get enabledEditable(): boolean {
70
- return this._enabledEditable;
71
- }
72
-
73
- public get priority(): number {
74
- return this.#priority;
75
- }
76
-
77
- public set priority(value: number) {
78
- this.#priority = value;
79
- }
80
-
81
- // #endregion Public Getters And Setters (5)
82
-
83
- // #region Public Methods (2)
84
-
85
- public snap(ray: IRay, point: vec3, metaData?: RestrictionMetaData): vec3 | undefined {
86
- if (this.enabled === false) return;
87
- if (!metaData || !metaData.referencePoint) return;
88
-
89
- const xPressed = this.#drawingToolsManager.keyPressed(this.#activationKeyX);
90
- const yPressed = this.#drawingToolsManager.keyPressed(this.#activationKeyY);
91
- const zPressed = this.#drawingToolsManager.keyPressed(this.#activationKeyZ);
92
- const pPressed = this.#drawingToolsManager.keyPressed('p');
93
-
94
- if (xPressed) {
95
- return this.#geometryMathManager.closestPoint({ origin: metaData.referencePoint, direction: this.#planeRestriction.vectorU }, point);
96
- } else if (yPressed) {
97
- return this.#geometryMathManager.closestPoint({ origin: metaData.referencePoint, direction: this.#planeRestriction.vectorV }, point);
98
- } else if (zPressed) {
99
- return this.#geometryMathManager.closestPointsRayRay({ origin: metaData.referencePoint, direction: this.#planeRestriction.normal }, ray).closestPointOnRay1;
100
- } else if (pPressed) {
101
- return this.#geometryMathManager.closestPointOnPlane(this.#planeRestriction.origin, this.#planeRestriction.normal, point);
102
- }
103
- }
104
-
105
- public updatePlaneDefinition(): void {}
106
-
107
- // #endregion Public Methods (2)
108
-
109
- // #region Protected Methods (1)
110
-
111
- protected visibilityChanged(): void { }
112
-
113
- // #endregion Protected Methods (1)
114
- }
115
-
116
- // #endregion Classes (1)