@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,246 +0,0 @@
1
- import * as THREE from 'three';
2
- import { AbstractRestriction } from '../../AbstractRestriction';
3
- import { Box, sceneTree } from '@shapediver/viewer';
4
- import { DrawingToolsManager } from '../../../../../DrawingToolsManager';
5
- import { IRay } from '@shapediver/viewer.features.interaction';
6
- import { ISnapRestriction, SnapRestrictionProperties } from '../../../../../../interfaces/ISnapRestriction';
7
- import { PlaneRestriction } from '../PlaneRestriction';
8
- import { RestrictionMetaData } from '../../../../../../interfaces/IRestriction';
9
- import { vec3 } from 'gl-matrix';
10
-
11
- // #region Type aliases (1)
12
-
13
- /**
14
- * Properties for the grid restriction
15
- */
16
- export type GridRestrictionProperties = {
17
- /**
18
- * Size of the grid unit
19
- */
20
- gridUnit?: number;
21
-
22
- /**
23
- * If the grid unit is editable for change to the end user.
24
- * If it is not editable, the grid unit cannot be changed from the default value.
25
- */
26
- gridUnitEditable?: boolean;
27
- } & SnapRestrictionProperties;
28
-
29
- // #endregion Type aliases (1)
30
-
31
- // #region Classes (1)
32
-
33
- export class GridRestriction extends AbstractRestriction implements ISnapRestriction {
34
- // #region Properties (10)
35
-
36
- readonly #activationKey: string;
37
- readonly #drawingToolsManager: DrawingToolsManager;
38
- readonly #planeRestriction: PlaneRestriction;
39
-
40
- #active: boolean = false;
41
- #gridHelper?: THREE.GridHelper;
42
- #gridSize: number = 100;
43
- #gridUnit: number;
44
- #gridUnitEditable: boolean = true;
45
- #offsetFromUnit: vec3 = vec3.create();
46
- #priority: number = 0;
47
-
48
- // #endregion Properties (10)
49
-
50
- // #region Constructors (1)
51
-
52
- constructor(drawingToolsManager: DrawingToolsManager, planeRestriction: PlaneRestriction, properties?: GridRestrictionProperties) {
53
- super(drawingToolsManager, 'grid');
54
-
55
- this.#drawingToolsManager = drawingToolsManager;
56
- this.#planeRestriction = planeRestriction;
57
-
58
- this.#activationKey = properties?.activationKey || 'g';
59
- this.enabled = properties?.enabled ?? false;
60
- this._enabledEditable = properties?.enabledEditable ?? true;
61
- this.#gridUnit = properties?.gridUnit || 1;
62
- this.#gridUnitEditable = properties?.gridUnitEditable ?? true;
63
- this.#priority = properties?.priority || 0;
64
-
65
- // create the offset of the grid size to origin
66
- this.createOffsetFromUnit();
67
-
68
- // calculate offset of grid size to origin
69
- this.createGridVisualization();
70
- }
71
-
72
- // #endregion Constructors (1)
73
-
74
- // #region Public Getters And Setters (8)
75
-
76
- public get active(): boolean {
77
- return this.#active;
78
- }
79
-
80
- public set active(value: boolean) {
81
- this.#active = value;
82
-
83
- if (this.#gridHelper) this.#gridHelper.visible = value;
84
- }
85
-
86
- public get enabledEditable(): boolean {
87
- return this._enabledEditable;
88
- }
89
-
90
- public get gridUnit(): number {
91
- return this.#gridUnit;
92
- }
93
-
94
- public set gridUnit(value: number) {
95
- if (this.#gridUnitEditable === false) return;
96
-
97
- this.#gridUnit = value;
98
- this.createOffsetFromUnit();
99
- this.createGridVisualization();
100
- }
101
-
102
- public get gridUnitEditable(): boolean {
103
- return this.#gridUnitEditable;
104
- }
105
-
106
- public get priority(): number {
107
- return this.#priority;
108
- }
109
-
110
- public set priority(value: number) {
111
- this.#priority = value;
112
- }
113
-
114
- // #endregion Public Getters And Setters (8)
115
-
116
- // #region Public Methods (2)
117
-
118
- // public get
119
- public snap(ray: IRay, point: vec3, metaData: RestrictionMetaData): vec3 | undefined {
120
- // if the restriction is not enabled OR the activation key is set and the key is not pressed, return
121
- if (this.enabled === false && this.#drawingToolsManager.keyPressed(this.#activationKey) === false) return;
122
-
123
- /**
124
- * Explanation of the following code:
125
- * 1. Calculate the projection of the origin onto the plane that is created by the point and the normal
126
- * 2. Move the grid helper to the projected origin
127
- */
128
-
129
- // vector from the point to the origin
130
- const v = vec3.sub(vec3.create(), this.#planeRestriction.origin, point);
131
-
132
- // dot product of the vector and the normal
133
- const dot = vec3.dot(v, this.#planeRestriction.normal);
134
-
135
- // projection of the origin onto the plane that is created by the point and the normal
136
- const projectedOrigin = vec3.sub(vec3.create(), this.#planeRestriction.origin, vec3.scale(vec3.create(), this.#planeRestriction.normal, dot));
137
-
138
- // we move the grid helper to the projected origin
139
- if (this.#gridHelper) {
140
- this.#gridHelper.position.copy(new THREE.Vector3(projectedOrigin[0], projectedOrigin[1], projectedOrigin[2]));
141
- this.#gridHelper.visible = false;
142
- }
143
-
144
- /**
145
- * Explanation of the following code:
146
- * 1. Rotate the point so that the normal of the plane is aligned with the Z axis (with previously calculated transformation matrix)
147
- * 2. Snap the point to the grid
148
- * 3. Rotate the point back to the original coordinate system (with previously calculated transformation matrix)
149
- */
150
-
151
- // Apply the transformation to the point
152
- const rotatedPoint = vec3.transformMat4(vec3.create(), point, this.#planeRestriction.transformationToXYPlaneMatrix);
153
-
154
- // Snap the offset to the grid
155
- const snappedOffset = vec3.create();
156
- snappedOffset[0] = Math.round(rotatedPoint[0] / this.#gridUnit) * this.#gridUnit - this.#offsetFromUnit[0];
157
- snappedOffset[1] = Math.round(rotatedPoint[1] / this.#gridUnit) * this.#gridUnit - this.#offsetFromUnit[1];
158
- snappedOffset[2] = rotatedPoint[2];
159
-
160
- // Move the snapped point back to the original coordinate system
161
- const snappedPoint = vec3.transformMat4(vec3.create(), snappedOffset, this.#planeRestriction.transformationFromXYPlaneMatrix);
162
-
163
- return snappedPoint;
164
- }
165
-
166
- public updatePlaneDefinition(): void {
167
- this.createOffsetFromUnit();
168
- this.createGridVisualization();
169
- }
170
-
171
- // #endregion Public Methods (2)
172
-
173
- // #region Protected Methods (1)
174
-
175
- protected visibilityChanged(visible: boolean): void {
176
- if (visible === false) {
177
- if (this.#gridHelper) {
178
- this.#gridHelper.visible = false;
179
- }
180
- }
181
- }
182
-
183
- // #endregion Protected Methods (1)
184
-
185
- // #region Private Methods (2)
186
-
187
- private createGridVisualization(): void {
188
- if (this.#gridHelper) {
189
- this._object3D.remove(this.#gridHelper);
190
- this.#gridHelper.dispose();
191
- }
192
-
193
- const bb = new Box();
194
- for (let i = 0; i < sceneTree.root.children.length; i++) {
195
- if ((sceneTree.root.children[i] as unknown as { sessionNode?: boolean }).sessionNode === true) {
196
- bb.union(sceneTree.root.children[i].boundingBox);
197
- }
198
- }
199
-
200
- const radius = bb.boundingSphere.radius;
201
- this.#gridSize = radius * 2;
202
- if (this.#gridSize === Infinity || this.#gridSize === -Infinity || isNaN(this.#gridSize) || this.#gridSize === 0)
203
- this.#gridSize = 100;
204
-
205
- // if the grid size is not divisible by the grid unit, we need to adjust the grid size
206
- let gridSize = this.#gridUnit * Math.ceil(this.#gridSize / this.#gridUnit);
207
- // if the number of divisions is odd, we need to add one more division
208
- if (gridSize / this.#gridUnit % 2 === 1)
209
- gridSize += this.#gridUnit;
210
-
211
- // todo adjust grid size so that is divisible by grid unit
212
- this.#gridHelper = new THREE.GridHelper(gridSize, gridSize / this.#gridUnit, 0x666666, 0x222222);
213
- const adjustedOrigin = vec3.add(vec3.create(), this.#planeRestriction.origin, this.#offsetFromUnit);
214
- this.#gridHelper.position.copy(new THREE.Vector3(adjustedOrigin[0], adjustedOrigin[1], adjustedOrigin[2]));
215
- this.#gridHelper.visible = false;
216
-
217
- this.#gridHelper.renderOrder = 100;
218
- (this.#gridHelper.material as THREE.LineBasicMaterial).depthTest = false;
219
- (this.#gridHelper.material as THREE.LineBasicMaterial).transparent = true;
220
-
221
- // three.js uses a right-handed coordinate system, so we need to rotate the grid helper
222
- const rotationMatrix = new THREE.Matrix4().fromArray([
223
- this.#planeRestriction.vectorU[0], this.#planeRestriction.vectorU[1], this.#planeRestriction.vectorU[2], 0,
224
- this.#planeRestriction.vectorV[0], this.#planeRestriction.vectorV[1], this.#planeRestriction.vectorV[2], 0,
225
- this.#planeRestriction.normal[0], this.#planeRestriction.normal[1], this.#planeRestriction.normal[2], 0,
226
- 0, 0, 0, 1
227
- ]);
228
-
229
- this.#gridHelper.rotation.setFromRotationMatrix(rotationMatrix);
230
- // three.js grid helper is created in the XY plane, so we need to rotate it by 90 degrees around the X axis
231
- this.#gridHelper.rotateX(Math.PI / 2);
232
-
233
- this._object3D.add(this.#gridHelper);
234
- }
235
-
236
- private createOffsetFromUnit(): void {
237
- // Calculate the offset of the rotated point from the rotated origin
238
- this.#offsetFromUnit[0] = this.#gridUnit * Math.round(this.#planeRestriction.origin[0] / this.#gridUnit) - this.#planeRestriction.origin[0];
239
- this.#offsetFromUnit[1] = this.#gridUnit * Math.round(this.#planeRestriction.origin[1] / this.#gridUnit) - this.#planeRestriction.origin[1];
240
- this.#offsetFromUnit[2] = this.#gridUnit * Math.round(this.#planeRestriction.origin[2] / this.#gridUnit) - this.#planeRestriction.origin[2];
241
- }
242
-
243
- // #endregion Private Methods (2)
244
- }
245
-
246
- // #endregion Classes (1)
@@ -1,5 +0,0 @@
1
-
2
- export const numberCleaner = (value: number): number => {
3
- const roundedThreshold = 100;
4
- return Math.round(value * roundedThreshold) / roundedThreshold;
5
- };
@@ -1,312 +0,0 @@
1
- import { GeometryRestrictionProperties } from '../implementation/managers/interaction/restrictions/geometry/GeometryRestriction';
2
- import { IManager } from './IManager';
3
- import { IMapData, IMaterialBasicLineDataProperties, IMaterialMultiPointDataProperties } from '@shapediver/viewer.shared.types';
4
- import { IRestriction, RestrictionProperties } from './IRestriction';
5
- import { PlaneRestrictionProperties } from '../implementation/managers/interaction/restrictions/plane/PlaneRestriction';
6
- import { vec3 } from 'gl-matrix';
7
-
8
- // #region Type aliases (5)
9
-
10
- /**
11
- * The callbacks of the drawing tool.
12
- *
13
- * Here you can define the callbacks that are used when interacting with the drawing tool.
14
- *
15
- * @typedef Callbacks
16
- */
17
- export type Callbacks = {
18
- /**
19
- * The callback that is called when the drawing tool is cancelled.
20
- */
21
- onCancel(): void;
22
- /**
23
- * The callback that is called when the drawing tool is updated.
24
- *
25
- * @param pointsData The points data of the drawing tool.
26
- */
27
- onUpdate(pointsData: PointsData): void;
28
- };
29
- export type DefaultTextures = { [key: string]: Promise<IMapData> | IMapData }
30
-
31
- /**
32
- * The data of the points.
33
- * The points are defined as an array of arrays, where each array contains the x, y and z coordinates of the point.
34
- *
35
- * @example [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 0]]
36
- * @typedef PointsData
37
- */
38
- export type PointsData = number[][];
39
- /**
40
- * The initial settings of the drawing tool.
41
- * Here you can define the initial settings of the drawing tool.
42
- *
43
- * @typedef Settings
44
- *
45
- */
46
- export type Settings = {
47
- /**
48
- * The geometry settings of the drawing tool.
49
- *
50
- * Here you can define the points, the mode and specific details of the geometry.
51
- */
52
- geometry: {
53
- /**
54
- * The points that are used when starting the drawing tool.
55
- * The points are defined as an array of arrays, where each array contains the x, y and z coordinates of the point.
56
- *
57
- * If the mode is set to 'lines', the points are connected in the order they are defined.
58
- * If the mode is set to 'points', the points are not connected.
59
- *
60
- * @default []
61
- * @example [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 0]]
62
- */
63
- points: PointsData;
64
-
65
- /**
66
- * The mode of the geometry.
67
- *
68
- * If the mode is set to 'lines', the points are connected in the order they are defined.
69
- * If the mode is set to 'points', the points are not connected.
70
- *
71
- * @default 'lines'
72
- */
73
- mode: 'points' | 'lines';
74
-
75
- /**
76
- * The minimum amount of points, if undefined, the geometry is not restricted.
77
- * This value is checked whenever the user tries to update or finish the drawing tool.
78
- *
79
- * @default undefined
80
- */
81
- minPoints?: number;
82
-
83
- /**
84
- * The maximum amount of points, if undefined, the geometry is not restricted.
85
- * This value is checked whenever the user tries to update or finish the drawing tool.
86
- *
87
- * @default undefined
88
- */
89
- maxPoints?: number;
90
-
91
- /**
92
- * If the number of points is strictly checked during the drawing process.
93
- * If this setting is set to true, once the minimum or maximum amount of points is reached, the user cannot add or remove points that would violate the restriction.
94
- * If this setting is set to false, the user can add or remove points even if the minimum or maximum amount of points is exceeded temporarily.
95
- * Once the user tries to update or finish the drawing tool, the amount of points is checked in either case.
96
- *
97
- * @default true
98
- */
99
- strictMinMaxPoints?: boolean;
100
-
101
- /**
102
- * If the mode is set to 'lines', if it is a closed line or not.
103
- * If the mode is set to 'points', this setting is ignored.
104
- *
105
- * A line can be closed by connecting the last point with the first point.
106
- *
107
- * @default true
108
- */
109
- close: boolean;
110
-
111
- /**
112
- * If the mode is set to 'lines', if the line is automatically closed.
113
- * If the mode is set to 'points', this setting is ignored.
114
- *
115
- * The first and last point are always connected if the line is automatically closed.
116
- *
117
- * @default true
118
- */
119
- autoClose: boolean;
120
-
121
- },
122
-
123
- /**
124
- * The restrictions of the drawing tool.
125
- *
126
- * Here you can define the restrictions that are used when interacting with the drawing tool.
127
- * At least one restriction is required, the plane restriction is added by default if no restrictions are defined.
128
- */
129
- restrictions: { [key: string]: RestrictionProperties | PlaneRestrictionProperties | GeometryRestrictionProperties };
130
-
131
- /**
132
- * The visualization settings of the drawing tool.
133
- *
134
- * Here you can define the visualization of the drawing tool.
135
- */
136
- visualization: {
137
- /**
138
- * The multiplication factor of the point size when interactions are performed.
139
- * If the factor is set to 2, the point size is doubled when interacting.
140
- *
141
- * @default 2
142
- */
143
- distanceMultiplicationFactor: number,
144
-
145
- /**
146
- * If the point labels are shown.
147
- * The point labels display the position of the points.
148
- *
149
- * @default false
150
- */
151
- pointLabels: boolean,
152
-
153
- /**
154
- * If the distance labels are shown.
155
- * The distance labels display the distance between the points.
156
- *
157
- * @default true
158
- */
159
- distanceLabels: boolean,
160
-
161
- /**
162
- * The material properties of the points.
163
- */
164
- points: IMaterialMultiPointDataProperties,
165
-
166
- /**
167
- * The material properties of the lines.
168
- */
169
- lines: IMaterialBasicLineDataProperties
170
-
171
- };
172
-
173
- /**
174
- * The control settings of the drawing tool.
175
- *
176
- * Here you can define which keys are used for the different actions of the drawing tool.
177
- */
178
- controls: {
179
- /**
180
- * The key that is used to insert a point.
181
- *
182
- * @default ['Insert','+']
183
- */
184
- insert: string | string[],
185
-
186
- /**
187
- * The key that is used to delete a point.
188
- *
189
- * @default ['Delete','-']
190
- */
191
- delete: string | string[],
192
-
193
- /**
194
- * The key that is used to confirm actions.
195
- *
196
- * @default 'Enter'
197
- */
198
- confirm: string | string[],
199
-
200
- /**
201
- * The key that is used to cancel drawing.
202
- *
203
- * @default 'Escape'
204
- */
205
- cancel: string | string[],
206
-
207
- /**
208
- * The keys that are used to undo the last action.
209
- *
210
- * @default 'Control+Z'
211
- */
212
- undo: string | string[],
213
-
214
- /**
215
- * The keys that are used to redo the last action.
216
- *
217
- * @default 'Control+Y'
218
- */
219
- redo: string | string[]
220
- };
221
-
222
- /**
223
- * The general settings of the drawing tool.
224
- *
225
- * Here you can define general settings of the drawing tool.
226
- */
227
- general: {
228
- /**
229
- * If the drawing tool is started automatically when no points are defined.
230
- *
231
- * @default true
232
- */
233
- autoStart: boolean;
234
-
235
- /**
236
- * If the drawing tool is updated automatically when the drawing is changed.
237
- *
238
- * @default false
239
- */
240
- autoUpdate: boolean;
241
- /**
242
- * If the drawing tool is closed when the drawing is updated.
243
- *
244
- * @default false
245
- */
246
- closeOnUpdate: boolean;
247
-
248
- /**
249
- * The unit that will be displayed in the distance and point labels.
250
- *
251
- * @default ''
252
- */
253
- displayUnit: string;
254
- }
255
-
256
- };
257
- export type SettingsOptional = {
258
- geometry?: Partial<Settings['geometry']>;
259
- restrictions?: Partial<Settings['restrictions']>;
260
- visualization?: Partial<Settings['visualization']>;
261
- controls?: Partial<Settings['controls']>;
262
- general?: Partial<Settings['general']>;
263
- };
264
-
265
- // #endregion Type aliases (5)
266
-
267
- // #region Interfaces (1)
268
-
269
- export interface IDrawingToolsManager extends IManager {
270
- // #region Properties (4)
271
-
272
- readonly closed: boolean;
273
- readonly restrictions: { [key: string]: IRestriction };
274
-
275
- showDistanceLabels: boolean;
276
- showPointLabels: boolean;
277
-
278
- // #endregion Properties (4)
279
-
280
- // #region Public Methods (13)
281
-
282
- addPoint(index: number, position?: vec3, temporary?: boolean): void;
283
- addRestriction(properties: RestrictionProperties, token?: string): string | undefined;
284
- canRedo(): boolean;
285
- canUndo(): boolean;
286
- cancel(): void;
287
- getPointsData(): PointsData;
288
- movePoint(index: number, position: vec3, temporary?: boolean): void;
289
- redo(): void;
290
- removePoint(index: number, temporary?: boolean): void;
291
- removePoints(indices: number[]): void;
292
- removeRestriction(token: string): void;
293
- undo(): void;
294
- update(): PointsData | undefined;
295
-
296
- // #endregion Public Methods (13)
297
- }
298
-
299
- // #endregion Interfaces (1)
300
-
301
- // #region Enums (1)
302
-
303
- export enum MATERIAL_INDEX {
304
- DEFAULT = 0,
305
- HOVERED = 1,
306
- SELECTED = 2,
307
- SELECTED_HOVERED = 3,
308
- INSERTION = 4,
309
- INSERTION_HOVERED = 5
310
- }
311
-
312
- // #endregion Enums (1)
@@ -1,7 +0,0 @@
1
- export interface IManager {
2
- // #region Public Methods (1)
3
-
4
- close(): void;
5
-
6
- // #endregion Public Methods (1)
7
- }
@@ -1,63 +0,0 @@
1
- import { IRay } from '@shapediver/viewer.features.interaction';
2
- import { IRestrictionBase } from './IRestrictionBase';
3
- import { ISnapRestriction } from './ISnapRestriction';
4
- import { vec3 } from 'gl-matrix';
5
-
6
- // #region Type aliases (2)
7
-
8
- export type RestrictionMetaData = {
9
- index?: number;
10
- referencePoint?: vec3;
11
- }
12
-
13
- export type RestrictionProperties = {
14
- /**
15
- * Type of the restriction
16
- */
17
- type: RESTRICTION_TYPE;
18
- };
19
-
20
- // #endregion Type aliases (2)
21
-
22
- // #region Interfaces (1)
23
-
24
- export interface IRestriction extends IRestrictionBase {
25
- // #region Properties (2)
26
-
27
- /**
28
- * Priority of the restriction
29
- */
30
- readonly priority: number;
31
-
32
- /**
33
- * The snap restrictions of the restriction.
34
- */
35
- snapRestrictions: { [key: string]: ISnapRestriction; }
36
-
37
- // #endregion Properties (2)
38
-
39
- // #region Public Methods (1)
40
-
41
- /**
42
- * Ray trace the restriction.
43
- * If the ray does not intersect the restriction, the method returns undefined.
44
- *
45
- * @param ray The ray to trace.
46
- * @param metaData The meta data of the ray.
47
- * @returns The intersection point of the ray with the restriction.
48
- */
49
- rayTrace(ray: IRay, metaData?: RestrictionMetaData): vec3 | undefined;
50
-
51
- // #endregion Public Methods (1)
52
- }
53
-
54
- // #endregion Interfaces (1)
55
-
56
- // #region Enums (1)
57
-
58
- export enum RESTRICTION_TYPE {
59
- PLANE = 'plane',
60
- GEOMETRY = 'geometry',
61
- }
62
-
63
- // #endregion Enums (1)
@@ -1,33 +0,0 @@
1
- // #region Interfaces (1)
2
-
3
- export interface IRestrictionBase {
4
- // #region Properties (3)
5
-
6
- /**
7
- * The unique identifier of the restriction.
8
- */
9
- readonly id: string;
10
-
11
- /**
12
- * Whether the restriction is enabled or not.
13
- */
14
- enabled: boolean;
15
-
16
- /**
17
- * Whether the visualization of the restriction is shown or not (if there is one).
18
- */
19
- showVisualization: boolean;
20
-
21
- // #endregion Properties (3)
22
-
23
- // #region Public Methods (1)
24
-
25
- /**
26
- * Remove the visualization of the restriction.
27
- */
28
- removeVisualization(): void;
29
-
30
- // #endregion Public Methods (1)
31
- }
32
-
33
- // #endregion Interfaces (1)