@shapediver/viewer.features.drawing-tools 3.3.4 → 3.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/business/implementation/managers/geometry/GeometryState.d.ts.map +1 -1
- package/dist/business/implementation/managers/geometry/GeometryState.js +4 -1
- package/dist/business/implementation/managers/geometry/GeometryState.js.map +1 -1
- package/package.json +12 -13
- package/src/api/implementation/DrawingToolsApi.ts +0 -130
- package/src/api/implementation/restrictions/AbstractRestrictionApi.ts +0 -34
- package/src/api/implementation/restrictions/AbstractSnapRestrictionApi.ts +0 -36
- package/src/api/implementation/restrictions/geometry/GeometryRestrictionApi.ts +0 -56
- package/src/api/implementation/restrictions/plane/PlaneRestrictionApi.ts +0 -70
- package/src/api/implementation/restrictions/plane/snap/AngularRestrictionApi.ts +0 -35
- package/src/api/implementation/restrictions/plane/snap/AxisRestrictionApi.ts +0 -19
- package/src/api/implementation/restrictions/plane/snap/GridRestrictionApi.ts +0 -35
- package/src/api/interfaces/IDrawingToolsApi.ts +0 -98
- package/src/api/interfaces/IRestrictionApi.ts +0 -15
- package/src/api/interfaces/ISnapRestrictionApi.ts +0 -18
- package/src/business/implementation/DrawingToolsManager.ts +0 -618
- package/src/business/implementation/managers/HistoryManager.ts +0 -101
- package/src/business/implementation/managers/TextVisualizationManager.ts +0 -269
- package/src/business/implementation/managers/geometry/GeometryManager.ts +0 -95
- package/src/business/implementation/managers/geometry/GeometryMathManager.ts +0 -289
- package/src/business/implementation/managers/geometry/GeometryState.ts +0 -436
- package/src/business/implementation/managers/geometry/helpers/GeometryManagerHelper.ts +0 -170
- package/src/business/implementation/managers/interaction/EventManager.ts +0 -80
- package/src/business/implementation/managers/interaction/InteractionManager.ts +0 -268
- package/src/business/implementation/managers/interaction/RestrictionManager.ts +0 -132
- package/src/business/implementation/managers/interaction/handlers/DeletionInteractionHandler.ts +0 -48
- package/src/business/implementation/managers/interaction/handlers/InsertionInteractionHandler.ts +0 -149
- package/src/business/implementation/managers/interaction/handlers/MidPointInteractionHandler.ts +0 -127
- package/src/business/implementation/managers/interaction/helpers/InteractionManagerHelper.ts +0 -411
- package/src/business/implementation/managers/interaction/restrictions/AbstractRestriction.ts +0 -99
- package/src/business/implementation/managers/interaction/restrictions/geometry/GeometryRestriction.ts +0 -237
- package/src/business/implementation/managers/interaction/restrictions/plane/PlaneRestriction.ts +0 -337
- package/src/business/implementation/managers/interaction/restrictions/plane/snap/AngularRestriction.ts +0 -394
- package/src/business/implementation/managers/interaction/restrictions/plane/snap/AxisRestriction.ts +0 -116
- package/src/business/implementation/managers/interaction/restrictions/plane/snap/GridRestriction.ts +0 -246
- package/src/business/implementation/utils/numberCleaner.ts +0 -5
- package/src/business/interfaces/IDrawingToolsManager.ts +0 -312
- package/src/business/interfaces/IManager.ts +0 -7
- package/src/business/interfaces/IRestriction.ts +0 -63
- package/src/business/interfaces/IRestrictionBase.ts +0 -33
- package/src/business/interfaces/ISnapRestriction.ts +0 -70
- package/src/business/interfaces/events/EventResponseMapping.ts +0 -19
- package/src/business/interfaces/events/IDrawingToolsEvent.ts +0 -16
- package/src/index.ts +0 -72
- package/src/three/CSS2DRenderer.ts +0 -212
- package/tsconfig.json +0 -17
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { addListener, EVENTTYPE_DRAWING_TOOLS, IEvent } from '@shapediver/viewer';
|
|
2
|
-
import { DrawingToolsEventResponseMapping } from '../../interfaces/events/EventResponseMapping';
|
|
3
|
-
import { DrawingToolsManager } from '../DrawingToolsManager';
|
|
4
|
-
import { IManager } from '../../interfaces/IManager';
|
|
5
|
-
import { PointsData } from '../../interfaces/IDrawingToolsManager';
|
|
6
|
-
|
|
7
|
-
// #region Type aliases (1)
|
|
8
|
-
|
|
9
|
-
export type HistoryState = {
|
|
10
|
-
points: PointsData;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// #endregion Type aliases (1)
|
|
14
|
-
|
|
15
|
-
// #region Classes (1)
|
|
16
|
-
|
|
17
|
-
export class HistoryManager implements IManager {
|
|
18
|
-
// #region Properties (3)
|
|
19
|
-
|
|
20
|
-
#currentStateIndex: number = -1;
|
|
21
|
-
#drawingToolsManager: DrawingToolsManager;
|
|
22
|
-
#history: HistoryState[] = [];
|
|
23
|
-
|
|
24
|
-
// #endregion Properties (3)
|
|
25
|
-
|
|
26
|
-
// #region Constructors (1)
|
|
27
|
-
|
|
28
|
-
constructor(drawingToolsManager: DrawingToolsManager) {
|
|
29
|
-
this.#drawingToolsManager = drawingToolsManager;
|
|
30
|
-
|
|
31
|
-
addListener(EVENTTYPE_DRAWING_TOOLS.GEOMETRY_CHANGED, (e: IEvent) => {
|
|
32
|
-
const event = e as DrawingToolsEventResponseMapping[EVENTTYPE_DRAWING_TOOLS.GEOMETRY_CHANGED];
|
|
33
|
-
if (event.temporary === false && event.points !== undefined && event.fromHistory !== true && event.recordHistory !== false) {
|
|
34
|
-
/**
|
|
35
|
-
* DO SOME CHECKS TO ENSURE THAT THE STATE IS CORRECT
|
|
36
|
-
*/
|
|
37
|
-
// 1. within number of points
|
|
38
|
-
if (this.#drawingToolsManager.geometryState.checkNumberOfPoints(event.points.length) === false) return;
|
|
39
|
-
// 2. closed loop if it should be closed
|
|
40
|
-
if (this.#drawingToolsManager.settings.geometry.close === true && this.#drawingToolsManager.geometryState.closeLoop === false && this.#drawingToolsManager.settings.geometry.autoClose === false) return;
|
|
41
|
-
|
|
42
|
-
this.recordState({
|
|
43
|
-
points: event.points
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// #endregion Constructors (1)
|
|
50
|
-
|
|
51
|
-
// #region Public Methods (8)
|
|
52
|
-
|
|
53
|
-
public applyState(state: HistoryState): void {
|
|
54
|
-
this.#drawingToolsManager.geometryState.updateDataFromHistory(state.points);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public canRedo(): boolean {
|
|
58
|
-
return this.#currentStateIndex < this.#history.length - 1;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public canUndo(): boolean {
|
|
62
|
-
return this.#currentStateIndex > 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public close(): void {
|
|
66
|
-
this.#currentStateIndex = -1;
|
|
67
|
-
this.#history = [];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public getState(): HistoryState {
|
|
71
|
-
return this.#history[this.#currentStateIndex];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public recordState(state: HistoryState): void {
|
|
75
|
-
this.#history = this.#history.slice(0, this.#currentStateIndex + 1);
|
|
76
|
-
this.#history.push(state);
|
|
77
|
-
this.#currentStateIndex = this.#history.length - 1;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public redo(): void {
|
|
81
|
-
if (!this.canRedo()) return;
|
|
82
|
-
|
|
83
|
-
if (this.#currentStateIndex < this.#history.length - 1)
|
|
84
|
-
this.#currentStateIndex++;
|
|
85
|
-
|
|
86
|
-
this.applyState(this.#history[this.#currentStateIndex]);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public undo(): void {
|
|
90
|
-
if (!this.canUndo()) return;
|
|
91
|
-
|
|
92
|
-
if (this.#currentStateIndex > 0)
|
|
93
|
-
this.#currentStateIndex--;
|
|
94
|
-
|
|
95
|
-
this.applyState(this.#history[this.#currentStateIndex]);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// #endregion Public Methods (8)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// #endregion Classes (1)
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
3
|
-
addListener,
|
|
4
|
-
EVENTTYPE_DRAWING_TOOLS,
|
|
5
|
-
ITreeNode,
|
|
6
|
-
IViewportApi,
|
|
7
|
-
ThreejsData,
|
|
8
|
-
TreeNode
|
|
9
|
-
} from '@shapediver/viewer';
|
|
10
|
-
import { CSS2DObject, CSS2DRenderer } from '../../../three/CSS2DRenderer';
|
|
11
|
-
import { DrawingToolsManager } from '../DrawingToolsManager';
|
|
12
|
-
import { IManager } from '../../interfaces/IManager';
|
|
13
|
-
import { numberCleaner } from '../utils/numberCleaner';
|
|
14
|
-
import { Settings } from '../../interfaces/IDrawingToolsManager';
|
|
15
|
-
import { vec3 } from 'gl-matrix';
|
|
16
|
-
|
|
17
|
-
export class TextVisualizationManager implements IManager {
|
|
18
|
-
// #region Properties (11)
|
|
19
|
-
|
|
20
|
-
readonly #drawingToolsManager: DrawingToolsManager;
|
|
21
|
-
readonly #labelRenderer: CSS2DRenderer;
|
|
22
|
-
readonly #parentNode: ITreeNode;
|
|
23
|
-
readonly #settings: Settings;
|
|
24
|
-
readonly #viewport: IViewportApi;
|
|
25
|
-
readonly #visualizationNode: TreeNode = new TreeNode('TextVisualizationNode');
|
|
26
|
-
|
|
27
|
-
#distanceObject3D: THREE.Object3D;
|
|
28
|
-
#object3D: THREE.Object3D;
|
|
29
|
-
#positionObject3D: THREE.Object3D;
|
|
30
|
-
#showDistanceLabels: boolean = true;
|
|
31
|
-
#showPointLabels: boolean = true;
|
|
32
|
-
|
|
33
|
-
#prevWidth: number = 0;
|
|
34
|
-
#prevHeight: number = 0;
|
|
35
|
-
|
|
36
|
-
// #endregion Properties (11)
|
|
37
|
-
|
|
38
|
-
// #region Constructors (1)
|
|
39
|
-
|
|
40
|
-
constructor(drawingToolsManager: DrawingToolsManager) {
|
|
41
|
-
this.#drawingToolsManager = drawingToolsManager;
|
|
42
|
-
this.#viewport = drawingToolsManager.viewport;
|
|
43
|
-
this.#settings = drawingToolsManager.settings;
|
|
44
|
-
this.#parentNode = drawingToolsManager.parentNode;
|
|
45
|
-
|
|
46
|
-
this.#labelRenderer = new CSS2DRenderer();
|
|
47
|
-
this.#labelRenderer.setSize(this.#viewport.canvas.clientWidth, this.#viewport.canvas.clientHeight);
|
|
48
|
-
this.#labelRenderer.domElement.style.userSelect = 'none';
|
|
49
|
-
this.#labelRenderer.domElement.style.cursor = 'default';
|
|
50
|
-
this.#labelRenderer.domElement.style.pointerEvents = 'none';
|
|
51
|
-
this.#labelRenderer.domElement.style.overflow = 'hidden';
|
|
52
|
-
this.#labelRenderer.domElement.style.position = 'absolute';
|
|
53
|
-
this.#labelRenderer.domElement.style.width = '100%';
|
|
54
|
-
this.#labelRenderer.domElement.style.height = '100%';
|
|
55
|
-
this.#labelRenderer.domElement.style.left = '0%';
|
|
56
|
-
this.#labelRenderer.domElement.style.top = '0%';
|
|
57
|
-
this.#viewport.canvas.parentElement!.appendChild(this.#labelRenderer.domElement);
|
|
58
|
-
|
|
59
|
-
this.#viewport.postRenderingCallback = (renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => {
|
|
60
|
-
if(this.#prevWidth !== renderer.domElement.clientWidth || this.#prevHeight !== renderer.domElement.clientHeight) {
|
|
61
|
-
this.#prevWidth = renderer.domElement.clientWidth;
|
|
62
|
-
this.#prevHeight = renderer.domElement.clientHeight;
|
|
63
|
-
this.#labelRenderer.setSize(renderer.domElement.clientWidth, renderer.domElement.clientHeight);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (this.#labelRenderer.domElement.clientWidth !== renderer.domElement.clientWidth || this.#labelRenderer.domElement.clientHeight !== renderer.domElement.clientHeight) {
|
|
67
|
-
this.#labelRenderer.setSize(renderer.domElement.clientWidth, renderer.domElement.clientHeight);
|
|
68
|
-
}
|
|
69
|
-
this.#labelRenderer.render(scene, camera);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
this.#object3D = new THREE.Object3D();
|
|
73
|
-
this.#positionObject3D = new THREE.Object3D();
|
|
74
|
-
this.#positionObject3D.visible = this.#settings.visualization.pointLabels;
|
|
75
|
-
this.#distanceObject3D = new THREE.Object3D();
|
|
76
|
-
this.#distanceObject3D.visible = this.#settings.visualization.distanceLabels;
|
|
77
|
-
|
|
78
|
-
this.#object3D.add(this.#positionObject3D);
|
|
79
|
-
this.#object3D.add(this.#distanceObject3D);
|
|
80
|
-
|
|
81
|
-
this.#showPointLabels = this.#settings.visualization.pointLabels;
|
|
82
|
-
this.#showDistanceLabels = this.#settings.visualization.distanceLabels;
|
|
83
|
-
|
|
84
|
-
const node = new TreeNode('ThreeJsDataNode');
|
|
85
|
-
|
|
86
|
-
const data = new ThreejsData(this.#object3D);
|
|
87
|
-
node.addData(data);
|
|
88
|
-
|
|
89
|
-
this.#visualizationNode.addChild(node);
|
|
90
|
-
this.#visualizationNode.updateVersion();
|
|
91
|
-
this.#parentNode.addChild(this.#visualizationNode);
|
|
92
|
-
this.#parentNode.updateVersion(false, false);
|
|
93
|
-
this.#viewport.updateNode(this.#parentNode);
|
|
94
|
-
|
|
95
|
-
this.createPointLabels();
|
|
96
|
-
this.createDistanceLabels();
|
|
97
|
-
|
|
98
|
-
addListener(EVENTTYPE_DRAWING_TOOLS.GEOMETRY_CHANGED, () => {
|
|
99
|
-
this.createPointLabels();
|
|
100
|
-
this.createDistanceLabels();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
addListener(EVENTTYPE_DRAWING_TOOLS.MOVED, () => {
|
|
104
|
-
this.createPointLabels();
|
|
105
|
-
this.createDistanceLabels();
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// #endregion Constructors (1)
|
|
110
|
-
|
|
111
|
-
// #region Public Getters And Setters (4)
|
|
112
|
-
|
|
113
|
-
public get showDistanceLabels(): boolean {
|
|
114
|
-
return this.#distanceObject3D.visible;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public set showDistanceLabels(value: boolean) {
|
|
118
|
-
this.#showDistanceLabels = value;
|
|
119
|
-
if (this.#showDistanceLabels) {
|
|
120
|
-
this.createDistanceLabels();
|
|
121
|
-
} else {
|
|
122
|
-
this.#distanceObject3D.remove(...this.#distanceObject3D.children);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public get showPointLabels(): boolean {
|
|
127
|
-
return this.#showPointLabels;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public set showPointLabels(value: boolean) {
|
|
131
|
-
this.#showPointLabels = value;
|
|
132
|
-
if (this.#showPointLabels) {
|
|
133
|
-
this.createPointLabels();
|
|
134
|
-
} else {
|
|
135
|
-
this.#positionObject3D.remove(...this.#positionObject3D.children);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// #endregion Public Getters And Setters (4)
|
|
140
|
-
|
|
141
|
-
// #region Public Methods (3)
|
|
142
|
-
|
|
143
|
-
public close(): void {
|
|
144
|
-
this.#positionObject3D.remove(...this.#positionObject3D.children);
|
|
145
|
-
this.#distanceObject3D.remove(...this.#distanceObject3D.children);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public createDistanceLabels(): void {
|
|
149
|
-
if (!this.#showDistanceLabels) return;
|
|
150
|
-
this.#distanceObject3D.remove(...this.#distanceObject3D.children);
|
|
151
|
-
|
|
152
|
-
const positionArray = this.#drawingToolsManager.positionArray;
|
|
153
|
-
const indicesArrayLines = this.#drawingToolsManager.indicesArrayLines;
|
|
154
|
-
|
|
155
|
-
if (!indicesArrayLines || positionArray.length <= 3) return;
|
|
156
|
-
|
|
157
|
-
for (let i = 0; i < indicesArrayLines.length; i += 2) {
|
|
158
|
-
// calculate the midpoint of the line
|
|
159
|
-
const firstIndex = indicesArrayLines[i];
|
|
160
|
-
const secondIndex = indicesArrayLines[i + 1];
|
|
161
|
-
const firstPoint = vec3.fromValues(
|
|
162
|
-
positionArray.at(firstIndex * 3)!,
|
|
163
|
-
positionArray.at(firstIndex * 3 + 1)!,
|
|
164
|
-
positionArray.at(firstIndex * 3 + 2)!
|
|
165
|
-
);
|
|
166
|
-
const secondPoint = vec3.fromValues(
|
|
167
|
-
positionArray.at(secondIndex * 3)!,
|
|
168
|
-
positionArray.at(secondIndex * 3 + 1)!,
|
|
169
|
-
positionArray.at(secondIndex * 3 + 2)!
|
|
170
|
-
);
|
|
171
|
-
const midPoint = vec3.add(vec3.create(), firstPoint, secondPoint);
|
|
172
|
-
vec3.scale(midPoint, midPoint, 0.5);
|
|
173
|
-
|
|
174
|
-
const text = document.createElement('div');
|
|
175
|
-
text.className = 'label';
|
|
176
|
-
text.style.marginTop = '1em';
|
|
177
|
-
|
|
178
|
-
const child = document.createElement('div');
|
|
179
|
-
child.className = 'distance-label';
|
|
180
|
-
|
|
181
|
-
// check if there is already a style tag in the head that defined the style for the point label
|
|
182
|
-
// if not, create one
|
|
183
|
-
let styleExists = false;
|
|
184
|
-
document.head.querySelectorAll('style').forEach(style => {
|
|
185
|
-
if (style.textContent?.includes('.distance-label')) {
|
|
186
|
-
styleExists = true;
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
if(!styleExists) {
|
|
192
|
-
const style = document.createElement('style');
|
|
193
|
-
style.textContent = `
|
|
194
|
-
.distance-label {
|
|
195
|
-
display: flex;
|
|
196
|
-
justify-content: center;
|
|
197
|
-
align-items: center;
|
|
198
|
-
color: white;
|
|
199
|
-
background-color: ${this.#settings.visualization.points.color_1}80;
|
|
200
|
-
border-radius: 5px;
|
|
201
|
-
font-size: 16px;
|
|
202
|
-
text-align: center;
|
|
203
|
-
padding: 0px 2px;
|
|
204
|
-
}
|
|
205
|
-
`;
|
|
206
|
-
document.head.appendChild(style);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
child.textContent = `${numberCleaner(vec3.distance(firstPoint, secondPoint))}${this.#settings.general.displayUnit}`;
|
|
210
|
-
text.appendChild(child);
|
|
211
|
-
|
|
212
|
-
const label = new CSS2DObject(text);
|
|
213
|
-
label.position.set(midPoint[0], midPoint[1], midPoint[2]);
|
|
214
|
-
this.#distanceObject3D.add(label);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
public createPointLabels(): void {
|
|
219
|
-
if (!this.#showPointLabels) return;
|
|
220
|
-
this.#positionObject3D.remove(...this.#positionObject3D.children);
|
|
221
|
-
|
|
222
|
-
const positionArray = this.#drawingToolsManager.positionArray;
|
|
223
|
-
for (let i = 0; i < positionArray.length; i += 3) {
|
|
224
|
-
const text = document.createElement('div');
|
|
225
|
-
text.className = 'label';
|
|
226
|
-
text.style.marginTop = '1em';
|
|
227
|
-
|
|
228
|
-
const child = document.createElement('div');
|
|
229
|
-
child.className = 'point-label';
|
|
230
|
-
|
|
231
|
-
// check if there is already a style tag in the head that defined the style for the point label
|
|
232
|
-
// if not, create one
|
|
233
|
-
let styleExists = false;
|
|
234
|
-
document.head.querySelectorAll('style').forEach(style => {
|
|
235
|
-
if (style.textContent?.includes('.point-label')) {
|
|
236
|
-
styleExists = true;
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
if(!styleExists) {
|
|
242
|
-
const style = document.createElement('style');
|
|
243
|
-
style.textContent = `
|
|
244
|
-
.point-label {
|
|
245
|
-
display: flex;
|
|
246
|
-
justify-content: center;
|
|
247
|
-
align-items: center;
|
|
248
|
-
color: white;
|
|
249
|
-
background-color: ${this.#settings.visualization.points.color_1}80;
|
|
250
|
-
border-radius: 5px;
|
|
251
|
-
font-size: 16px;
|
|
252
|
-
text-align: center;
|
|
253
|
-
padding: 0px 2px;
|
|
254
|
-
}
|
|
255
|
-
`;
|
|
256
|
-
document.head.appendChild(style);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
child.textContent = `[${numberCleaner(positionArray[i])}${this.#settings.general.displayUnit}, ${numberCleaner(positionArray[i + 1])}${this.#settings.general.displayUnit}, ${numberCleaner(positionArray[i + 2])}${this.#settings.general.displayUnit}]`;
|
|
260
|
-
text.appendChild(child);
|
|
261
|
-
|
|
262
|
-
const label = new CSS2DObject(text);
|
|
263
|
-
label.position.set(positionArray[i], positionArray[i + 1], positionArray[i + 2]);
|
|
264
|
-
this.#positionObject3D.add(label);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// #endregion Public Methods (3)
|
|
269
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { DrawingToolsManager } from '../../DrawingToolsManager';
|
|
2
|
-
import { GeometryManagerHelper } from './helpers/GeometryManagerHelper';
|
|
3
|
-
import { GeometryState } from './GeometryState';
|
|
4
|
-
import { IManager } from '../../../interfaces/IManager';
|
|
5
|
-
import { ITreeNode, TreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
6
|
-
import { MATERIAL_INDEX } from '../../../interfaces/IDrawingToolsManager';
|
|
7
|
-
import { vec3 } from 'gl-matrix';
|
|
8
|
-
|
|
9
|
-
export class GeometryManager implements IManager {
|
|
10
|
-
// #region Properties (4)
|
|
11
|
-
|
|
12
|
-
readonly #geometryState: GeometryState;
|
|
13
|
-
readonly #originalParentNode: ITreeNode;
|
|
14
|
-
readonly #parentNode: ITreeNode;
|
|
15
|
-
|
|
16
|
-
#geometryManagerHelper: GeometryManagerHelper;
|
|
17
|
-
|
|
18
|
-
// #endregion Properties (4)
|
|
19
|
-
|
|
20
|
-
// #region Constructors (1)
|
|
21
|
-
|
|
22
|
-
constructor(drawingToolsManager: DrawingToolsManager) {
|
|
23
|
-
this.#originalParentNode = drawingToolsManager.parentNode;
|
|
24
|
-
|
|
25
|
-
// create a new node with the geometry data
|
|
26
|
-
const parentNode = new TreeNode('DrawingToolsGeometry');
|
|
27
|
-
this.#originalParentNode.addChild(parentNode);
|
|
28
|
-
|
|
29
|
-
this.#parentNode = parentNode;
|
|
30
|
-
|
|
31
|
-
this.#geometryState = new GeometryState(drawingToolsManager, this);
|
|
32
|
-
this.#geometryManagerHelper = new GeometryManagerHelper(drawingToolsManager, this, this.#geometryState);
|
|
33
|
-
this.#geometryState.init();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// #endregion Constructors (1)
|
|
37
|
-
|
|
38
|
-
// #region Public Getters And Setters (2)
|
|
39
|
-
|
|
40
|
-
public get geometryState(): GeometryState {
|
|
41
|
-
return this.#geometryState;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public get parentNode(): ITreeNode {
|
|
45
|
-
return this.#parentNode;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// #endregion Public Getters And Setters (2)
|
|
49
|
-
|
|
50
|
-
// #region Public Methods (10)
|
|
51
|
-
|
|
52
|
-
public addPoint(index: number, position?: vec3, temporary = false): void {
|
|
53
|
-
this.#geometryManagerHelper.addPoint(index, position, temporary);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public canAddPoint(): boolean {
|
|
57
|
-
return this.#geometryState.canAddPoint();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public canRemovePoint(): boolean {
|
|
61
|
-
return this.#geometryState.canRemovePoint();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public close(): void {
|
|
65
|
-
this.#geometryState.close();
|
|
66
|
-
this.#originalParentNode.removeChild(this.#parentNode);
|
|
67
|
-
this.#originalParentNode.updateVersion();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public createLineIndices(loop: boolean): void {
|
|
71
|
-
this.#geometryState.createLineIndices(loop);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public movePoint(index: number, position: vec3, temporary = false): void {
|
|
75
|
-
this.#geometryManagerHelper.movePoint(index, position, temporary);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public removePoint(removalIndex: number, temporary = false): void {
|
|
79
|
-
this.#geometryManagerHelper.removePoint(removalIndex, temporary);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public removePoints(removalIndices: number[]): void {
|
|
83
|
-
this.#geometryManagerHelper.removePoints(removalIndices);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public resetMaterialIndices(): void {
|
|
87
|
-
this.#geometryManagerHelper.resetMaterialIndices();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public updateMaterialIndex(index: number, materialIndex: MATERIAL_INDEX): void {
|
|
91
|
-
this.#geometryManagerHelper.updateMaterialIndex(index, materialIndex);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// #endregion Public Methods (10)
|
|
95
|
-
}
|