@shapediver/viewer.rendering-engine.intersection-restriction-engine 3.16.7 → 3.16.9
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/api/implementation/AbstractRestrictionApi.d.ts +12 -12
- package/dist/api/implementation/AbstractRestrictionApi.js +46 -46
- package/dist/api/implementation/AbstractRestrictionApi.js.map +1 -1
- package/dist/api/implementation/AbstractSnapRestrictionApi.d.ts +12 -12
- package/dist/api/implementation/AbstractSnapRestrictionApi.js +46 -46
- package/dist/api/implementation/AbstractSnapRestrictionApi.js.map +1 -1
- package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.d.ts +6 -6
- package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.js +23 -23
- package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.js.map +1 -1
- package/dist/api/implementation/geometry/GeometryRestrictionApi.d.ts +14 -14
- package/dist/api/implementation/geometry/GeometryRestrictionApi.js +53 -53
- package/dist/api/implementation/geometry/GeometryRestrictionApi.js.map +1 -1
- package/dist/api/implementation/line/LineRestrictionApi.d.ts +10 -10
- package/dist/api/implementation/line/LineRestrictionApi.js +39 -39
- package/dist/api/implementation/line/LineRestrictionApi.js.map +1 -1
- package/dist/api/implementation/plane/PlaneRestrictionApi.d.ts +19 -19
- package/dist/api/implementation/plane/PlaneRestrictionApi.js +66 -66
- package/dist/api/implementation/plane/PlaneRestrictionApi.js.map +1 -1
- package/dist/api/implementation/plane/snap/AngularRestrictionApi.d.ts +9 -9
- package/dist/api/implementation/plane/snap/AngularRestrictionApi.js +39 -39
- package/dist/api/implementation/plane/snap/AngularRestrictionApi.js.map +1 -1
- package/dist/api/implementation/plane/snap/AxisRestrictionApi.d.ts +6 -6
- package/dist/api/implementation/plane/snap/AxisRestrictionApi.js +23 -23
- package/dist/api/implementation/plane/snap/AxisRestrictionApi.js.map +1 -1
- package/dist/api/implementation/plane/snap/GridRestrictionApi.d.ts +9 -9
- package/dist/api/implementation/plane/snap/GridRestrictionApi.js +39 -39
- package/dist/api/implementation/plane/snap/GridRestrictionApi.js.map +1 -1
- package/dist/api/implementation/point/PointRestrictionApi.d.ts +9 -9
- package/dist/api/implementation/point/PointRestrictionApi.js +36 -36
- package/dist/api/implementation/point/PointRestrictionApi.js.map +1 -1
- package/dist/api/interfaces/IRestrictionApi.d.ts +10 -10
- package/dist/api/interfaces/IRestrictionApi.js +2 -2
- package/dist/api/interfaces/ISnapRestrictionApi.d.ts +12 -12
- package/dist/api/interfaces/ISnapRestrictionApi.js +2 -2
- package/dist/implementation/EventManager.d.ts +25 -25
- package/dist/implementation/EventManager.d.ts.map +1 -1
- package/dist/implementation/EventManager.js +62 -62
- package/dist/implementation/EventManager.js.map +1 -1
- package/dist/implementation/GeometryMathManager.d.ts +87 -87
- package/dist/implementation/GeometryMathManager.js +260 -260
- package/dist/implementation/GeometryMathManager.js.map +1 -1
- package/dist/implementation/RestrictionManager.d.ts +28 -28
- package/dist/implementation/RestrictionManager.js +323 -323
- package/dist/implementation/RestrictionManager.js.map +1 -1
- package/dist/implementation/restrictions/AbstractRestriction.d.ts +42 -42
- package/dist/implementation/restrictions/AbstractRestriction.js +164 -154
- package/dist/implementation/restrictions/AbstractRestriction.js.map +1 -1
- package/dist/implementation/restrictions/AbstractSnapRestriction.d.ts +35 -35
- package/dist/implementation/restrictions/AbstractSnapRestriction.js +150 -140
- package/dist/implementation/restrictions/AbstractSnapRestriction.js.map +1 -1
- package/dist/implementation/restrictions/RestrictionsHelper.d.ts +10 -10
- package/dist/implementation/restrictions/RestrictionsHelper.d.ts.map +1 -1
- package/dist/implementation/restrictions/RestrictionsHelper.js +50 -50
- package/dist/implementation/restrictions/RestrictionsHelper.js.map +1 -1
- package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.d.ts +17 -17
- package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.js +62 -62
- package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.js.map +1 -1
- package/dist/implementation/restrictions/geometry/GeometryRestriction.d.ts +92 -92
- package/dist/implementation/restrictions/geometry/GeometryRestriction.js +410 -400
- package/dist/implementation/restrictions/geometry/GeometryRestriction.js.map +1 -1
- package/dist/implementation/restrictions/line/LineRestriction.d.ts +58 -58
- package/dist/implementation/restrictions/line/LineRestriction.js +291 -281
- package/dist/implementation/restrictions/line/LineRestriction.js.map +1 -1
- package/dist/implementation/restrictions/plane/PlaneRestriction.d.ts +65 -65
- package/dist/implementation/restrictions/plane/PlaneRestriction.js +306 -306
- package/dist/implementation/restrictions/plane/PlaneRestriction.js.map +1 -1
- package/dist/implementation/restrictions/plane/snap/AngularRestriction.d.ts +39 -39
- package/dist/implementation/restrictions/plane/snap/AngularRestriction.d.ts.map +1 -1
- package/dist/implementation/restrictions/plane/snap/AngularRestriction.js +346 -346
- package/dist/implementation/restrictions/plane/snap/AngularRestriction.js.map +1 -1
- package/dist/implementation/restrictions/plane/snap/AxisRestriction.d.ts +27 -27
- package/dist/implementation/restrictions/plane/snap/AxisRestriction.d.ts.map +1 -1
- package/dist/implementation/restrictions/plane/snap/AxisRestriction.js +239 -229
- package/dist/implementation/restrictions/plane/snap/AxisRestriction.js.map +1 -1
- package/dist/implementation/restrictions/plane/snap/GridRestriction.d.ts +39 -39
- package/dist/implementation/restrictions/plane/snap/GridRestriction.d.ts.map +1 -1
- package/dist/implementation/restrictions/plane/snap/GridRestriction.js +318 -308
- package/dist/implementation/restrictions/plane/snap/GridRestriction.js.map +1 -1
- package/dist/implementation/restrictions/point/PointRestriction.d.ts +45 -45
- package/dist/implementation/restrictions/point/PointRestriction.js +166 -156
- package/dist/implementation/restrictions/point/PointRestriction.js.map +1 -1
- package/dist/index.d.ts +29 -29
- package/dist/index.js +37 -37
- package/dist/interfaces/IDragAnchor.d.ts +8 -8
- package/dist/interfaces/IDragAnchor.js +2 -2
- package/dist/interfaces/IRestriction.d.ts +117 -117
- package/dist/interfaces/IRestriction.d.ts.map +1 -1
- package/dist/interfaces/IRestriction.js +23 -23
- package/dist/interfaces/IRestriction.js.map +1 -1
- package/dist/interfaces/IRestrictionManager.d.ts +13 -13
- package/dist/interfaces/IRestrictionManager.js +2 -2
- package/dist/interfaces/ISnapRestriction.d.ts +81 -81
- package/dist/interfaces/ISnapRestriction.d.ts.map +1 -1
- package/dist/interfaces/ISnapRestriction.js +3 -3
- package/package.json +10 -10
|
@@ -1,309 +1,319 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (__classPrivateFieldGet(this,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.
|
|
148
|
-
}
|
|
149
|
-
get
|
|
150
|
-
return __classPrivateFieldGet(this,
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
// #
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
__classPrivateFieldGet(this,
|
|
263
|
-
|
|
264
|
-
__classPrivateFieldGet(this,
|
|
265
|
-
|
|
266
|
-
//
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
0,
|
|
282
|
-
0,
|
|
283
|
-
1,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
36
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
37
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
38
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
39
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
40
|
+
};
|
|
41
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
42
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
43
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
44
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
45
|
+
};
|
|
46
|
+
var _GridRestriction_activationKey, _GridRestriction_eventEngine, _GridRestriction_planeRestriction, _GridRestriction_active, _GridRestriction_gridHelper, _GridRestriction_gridSize, _GridRestriction_gridUnit, _GridRestriction_gridUnitEditable, _GridRestriction_offsetFromUnit, _GridRestriction_toggleInversion, _GridRestriction_priority;
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.GridRestriction = void 0;
|
|
49
|
+
const viewer_1 = require("@shapediver/viewer");
|
|
50
|
+
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
51
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
52
|
+
const THREE = __importStar(require("three"));
|
|
53
|
+
const AbstractSnapRestriction_1 = require("../../AbstractSnapRestriction");
|
|
54
|
+
// #endregion Type aliases (1)
|
|
55
|
+
// #region Classes (1)
|
|
56
|
+
class GridRestriction extends AbstractSnapRestriction_1.AbstractSnapRestriction {
|
|
57
|
+
// #endregion Properties (9)
|
|
58
|
+
// #region Constructors (1)
|
|
59
|
+
constructor(viewport, geometryMathManager, parentNode, planeRestriction, properties) {
|
|
60
|
+
var _a, _b, _c, _d;
|
|
61
|
+
super(viewport, parentNode, "grid", properties);
|
|
62
|
+
// #region Properties (9)
|
|
63
|
+
_GridRestriction_activationKey.set(this, void 0);
|
|
64
|
+
_GridRestriction_eventEngine.set(this, viewer_shared_services_1.EventEngine.instance);
|
|
65
|
+
_GridRestriction_planeRestriction.set(this, void 0);
|
|
66
|
+
_GridRestriction_active.set(this, false);
|
|
67
|
+
_GridRestriction_gridHelper.set(this, void 0);
|
|
68
|
+
_GridRestriction_gridSize.set(this, 100);
|
|
69
|
+
_GridRestriction_gridUnit.set(this, void 0);
|
|
70
|
+
_GridRestriction_gridUnitEditable.set(this, true);
|
|
71
|
+
_GridRestriction_offsetFromUnit.set(this, gl_matrix_1.vec3.create());
|
|
72
|
+
_GridRestriction_toggleInversion.set(this, false);
|
|
73
|
+
_GridRestriction_priority.set(this, 0);
|
|
74
|
+
__classPrivateFieldSet(this, _GridRestriction_planeRestriction, planeRestriction, "f");
|
|
75
|
+
__classPrivateFieldSet(this, _GridRestriction_activationKey, (properties === null || properties === void 0 ? void 0 : properties.activationKey) || "g", "f");
|
|
76
|
+
this.enabled = (_a = properties === null || properties === void 0 ? void 0 : properties.enabled) !== null && _a !== void 0 ? _a : false;
|
|
77
|
+
this._enabledEditable = (_b = properties === null || properties === void 0 ? void 0 : properties.enabledEditable) !== null && _b !== void 0 ? _b : true;
|
|
78
|
+
this._enableVisualization = (_c = properties === null || properties === void 0 ? void 0 : properties.enableVisualization) !== null && _c !== void 0 ? _c : true;
|
|
79
|
+
// if a grid unit is provided, we toggle it on by default
|
|
80
|
+
if ((properties === null || properties === void 0 ? void 0 : properties.gridUnit) !== undefined && (properties === null || properties === void 0 ? void 0 : properties.gridUnit) !== 0) {
|
|
81
|
+
__classPrivateFieldSet(this, _GridRestriction_toggleInversion, true, "f");
|
|
82
|
+
__classPrivateFieldSet(this, _GridRestriction_gridUnit, properties.gridUnit, "f");
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// we define our own grid unit
|
|
86
|
+
__classPrivateFieldSet(this, _GridRestriction_gridUnit, 1, "f");
|
|
87
|
+
/**
|
|
88
|
+
* Depending on the scene radius, we calculate the grid unit.
|
|
89
|
+
* The grid unit is calculated as follows:
|
|
90
|
+
* - calculate 1% of the scene radius
|
|
91
|
+
* - find the closest power of 10 that is smaller than the 1% of the scene radius
|
|
92
|
+
* - find the closest power of 10 that is larger than the 1% of the scene radius
|
|
93
|
+
* - the grid unit is whichever of the two is closer to the 1% of the scene radius
|
|
94
|
+
*
|
|
95
|
+
* @param sceneRadius
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
const calculateGridUnit = (sceneRadius) => {
|
|
99
|
+
const percentage = 0.01;
|
|
100
|
+
const percentageSceneRadius = sceneRadius * percentage;
|
|
101
|
+
const log10 = Math.log10(percentageSceneRadius);
|
|
102
|
+
const smaller = Math.pow(10, Math.floor(log10));
|
|
103
|
+
const larger = Math.pow(10, Math.ceil(log10));
|
|
104
|
+
const gridUnit = Math.abs(smaller - percentageSceneRadius) <
|
|
105
|
+
Math.abs(larger - percentageSceneRadius)
|
|
106
|
+
? smaller
|
|
107
|
+
: larger;
|
|
108
|
+
return gridUnit;
|
|
109
|
+
};
|
|
110
|
+
if (viewer_1.sceneTree.root.boundingBox.isEmpty()) {
|
|
111
|
+
// add an event listener to update the grid size
|
|
112
|
+
const eventListenerToken = __classPrivateFieldGet(this, _GridRestriction_eventEngine, "f").addListener(viewer_shared_services_1.EVENTTYPE_SCENE.SCENE_BOUNDING_BOX_CHANGE, (e) => {
|
|
113
|
+
const sceneEvent = e;
|
|
114
|
+
if (sceneEvent.boundingBox) {
|
|
115
|
+
const box = new viewer_1.Box(sceneEvent.boundingBox.min, sceneEvent.boundingBox.max);
|
|
116
|
+
if (box.isEmpty())
|
|
117
|
+
return;
|
|
118
|
+
__classPrivateFieldSet(this, _GridRestriction_gridUnit, calculateGridUnit(box.boundingSphere.radius), "f");
|
|
119
|
+
this.createOffsetFromUnit();
|
|
120
|
+
this.createGridVisualization();
|
|
121
|
+
__classPrivateFieldGet(this, _GridRestriction_eventEngine, "f").removeListener(eventListenerToken);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
__classPrivateFieldSet(this, _GridRestriction_gridUnit, calculateGridUnit(viewer_1.sceneTree.root.boundingBox.boundingSphere.radius), "f");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
__classPrivateFieldSet(this, _GridRestriction_gridUnitEditable, (_d = properties === null || properties === void 0 ? void 0 : properties.gridUnitEditable) !== null && _d !== void 0 ? _d : true, "f");
|
|
130
|
+
__classPrivateFieldSet(this, _GridRestriction_priority, (properties === null || properties === void 0 ? void 0 : properties.priority) || 0, "f");
|
|
131
|
+
// create the offset of the grid size to origin
|
|
132
|
+
this.createOffsetFromUnit();
|
|
133
|
+
// calculate offset of grid size to origin
|
|
134
|
+
this.createGridVisualization();
|
|
135
|
+
}
|
|
136
|
+
// #endregion Constructors (1)
|
|
137
|
+
// #region Public Getters And Setters (8)
|
|
138
|
+
get active() {
|
|
139
|
+
return __classPrivateFieldGet(this, _GridRestriction_active, "f");
|
|
140
|
+
}
|
|
141
|
+
set active(value) {
|
|
142
|
+
__classPrivateFieldSet(this, _GridRestriction_active, value, "f");
|
|
143
|
+
if (__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f"))
|
|
144
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").visible = value;
|
|
145
|
+
}
|
|
146
|
+
get enabledEditable() {
|
|
147
|
+
return this._enabledEditable;
|
|
148
|
+
}
|
|
149
|
+
get gridUnit() {
|
|
150
|
+
return __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f");
|
|
151
|
+
}
|
|
152
|
+
set gridUnit(value) {
|
|
153
|
+
if (__classPrivateFieldGet(this, _GridRestriction_gridUnitEditable, "f") === false)
|
|
154
|
+
return;
|
|
155
|
+
__classPrivateFieldSet(this, _GridRestriction_gridUnit, value, "f");
|
|
156
|
+
this.createOffsetFromUnit();
|
|
157
|
+
this.createGridVisualization();
|
|
158
|
+
}
|
|
159
|
+
get gridUnitEditable() {
|
|
160
|
+
return __classPrivateFieldGet(this, _GridRestriction_gridUnitEditable, "f");
|
|
161
|
+
}
|
|
162
|
+
get priority() {
|
|
163
|
+
return __classPrivateFieldGet(this, _GridRestriction_priority, "f");
|
|
164
|
+
}
|
|
165
|
+
set priority(value) {
|
|
166
|
+
__classPrivateFieldSet(this, _GridRestriction_priority, value, "f");
|
|
167
|
+
}
|
|
168
|
+
// #endregion Public Getters And Setters (8)
|
|
169
|
+
// #region Public Methods (2)
|
|
170
|
+
// public get
|
|
171
|
+
snap(ray, point, distance, metaData) {
|
|
172
|
+
var _a;
|
|
173
|
+
// check if the activation key is pressed
|
|
174
|
+
let isKeyToggled = ((_a = metaData === null || metaData === void 0 ? void 0 : metaData.toggledKeys) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
|
|
175
|
+
(metaData === null || metaData === void 0 ? void 0 : metaData.toggledKeys[0]) === __classPrivateFieldGet(this, _GridRestriction_activationKey, "f");
|
|
176
|
+
// invert the result if toggleInversion is set
|
|
177
|
+
if (__classPrivateFieldGet(this, _GridRestriction_toggleInversion, "f"))
|
|
178
|
+
isKeyToggled = !isKeyToggled;
|
|
179
|
+
// if the restriction is not enabled and the activation key is set and the key is not pressed, return
|
|
180
|
+
if (this.enabled === false && !isKeyToggled)
|
|
181
|
+
return;
|
|
182
|
+
/**
|
|
183
|
+
* Explanation of the following code:
|
|
184
|
+
* 1. Calculate the projection of the origin onto the plane that is created by the point and the normal
|
|
185
|
+
* 2. Move the grid helper to the projected origin
|
|
186
|
+
*/
|
|
187
|
+
// vector from the point to the origin
|
|
188
|
+
const v = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin, point);
|
|
189
|
+
// dot product of the vector and the normal
|
|
190
|
+
const dot = gl_matrix_1.vec3.dot(v, __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal);
|
|
191
|
+
// projection of the origin onto the plane that is created by the point and the normal
|
|
192
|
+
const projectedOrigin = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal, dot));
|
|
193
|
+
// we move the grid helper to the projected origin
|
|
194
|
+
if (__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f")) {
|
|
195
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").position.copy(new THREE.Vector3(projectedOrigin[0], projectedOrigin[1], projectedOrigin[2]));
|
|
196
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").visible = false;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Explanation of the following code:
|
|
200
|
+
* 1. Rotate the point so that the normal of the plane is aligned with the Z axis (with previously calculated transformation matrix)
|
|
201
|
+
* 2. Snap the point to the grid
|
|
202
|
+
* 3. Rotate the point back to the original coordinate system (with previously calculated transformation matrix)
|
|
203
|
+
*/
|
|
204
|
+
// Apply the transformation to the point
|
|
205
|
+
const rotatedPoint = gl_matrix_1.vec3.transformMat4(gl_matrix_1.vec3.create(), point, __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").transformationToXYPlaneMatrix);
|
|
206
|
+
// Snap the offset to the grid
|
|
207
|
+
const snappedOffset = gl_matrix_1.vec3.create();
|
|
208
|
+
snappedOffset[0] =
|
|
209
|
+
Math.round(rotatedPoint[0] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) * __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") -
|
|
210
|
+
__classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[0];
|
|
211
|
+
snappedOffset[1] =
|
|
212
|
+
Math.round(rotatedPoint[1] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) * __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") -
|
|
213
|
+
__classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[1];
|
|
214
|
+
snappedOffset[2] = rotatedPoint[2];
|
|
215
|
+
// Move the snapped point back to the original coordinate system
|
|
216
|
+
const snappedPoint = gl_matrix_1.vec3.transformMat4(gl_matrix_1.vec3.create(), snappedOffset, __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").transformationFromXYPlaneMatrix);
|
|
217
|
+
return {
|
|
218
|
+
targetPoint: snappedPoint,
|
|
219
|
+
closestIntersectionPoint: point,
|
|
220
|
+
distanceOriginToClosestIntersectionPointSquared: distance,
|
|
221
|
+
distanceClosestPointToTargetPointSquared: gl_matrix_1.vec3.sqrDist(snappedPoint, point),
|
|
222
|
+
restriction: __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f"),
|
|
223
|
+
snapRestriction: this,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
updatePlaneDefinition() {
|
|
227
|
+
this.createOffsetFromUnit();
|
|
228
|
+
this.createGridVisualization();
|
|
229
|
+
}
|
|
230
|
+
// #endregion Public Methods (2)
|
|
231
|
+
// #region Protected Methods (1)
|
|
232
|
+
visibilityChanged(visible) {
|
|
233
|
+
if (visible === false) {
|
|
234
|
+
if (__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f")) {
|
|
235
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").visible = false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// #endregion Protected Methods (1)
|
|
240
|
+
// #region Private Methods (2)
|
|
241
|
+
createGridVisualization() {
|
|
242
|
+
if (!this._createHelperObjects)
|
|
243
|
+
return;
|
|
244
|
+
if (__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f")) {
|
|
245
|
+
this._object3D.remove(__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f"));
|
|
246
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").dispose();
|
|
247
|
+
}
|
|
248
|
+
const bb = new viewer_1.Box();
|
|
249
|
+
for (let i = 0; i < viewer_1.sceneTree.root.children.length; i++) {
|
|
250
|
+
if (viewer_1.sceneTree.root.children[i].sessionNode === true) {
|
|
251
|
+
bb.union(viewer_1.sceneTree.root.children[i].boundingBox);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const radius = bb.boundingSphere.radius;
|
|
255
|
+
__classPrivateFieldSet(this, _GridRestriction_gridSize, radius * 2, "f");
|
|
256
|
+
if (__classPrivateFieldGet(this, _GridRestriction_gridSize, "f") === Infinity ||
|
|
257
|
+
__classPrivateFieldGet(this, _GridRestriction_gridSize, "f") === -Infinity ||
|
|
258
|
+
isNaN(__classPrivateFieldGet(this, _GridRestriction_gridSize, "f")) ||
|
|
259
|
+
__classPrivateFieldGet(this, _GridRestriction_gridSize, "f") === 0)
|
|
260
|
+
__classPrivateFieldSet(this, _GridRestriction_gridSize, 100, "f");
|
|
261
|
+
// if the grid size is not divisible by the grid unit, we need to adjust the grid size
|
|
262
|
+
let gridSize = __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") * Math.ceil(__classPrivateFieldGet(this, _GridRestriction_gridSize, "f") / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f"));
|
|
263
|
+
// if the number of divisions is odd, we need to add one more division
|
|
264
|
+
if ((gridSize / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) % 2 === 1)
|
|
265
|
+
gridSize += __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f");
|
|
266
|
+
// todo adjust grid size so that is divisible by grid unit
|
|
267
|
+
__classPrivateFieldSet(this, _GridRestriction_gridHelper, new THREE.GridHelper(gridSize, gridSize / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f"), 0x666666, 0x222222), "f");
|
|
268
|
+
const adjustedOrigin = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin, __classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f"));
|
|
269
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").position.copy(new THREE.Vector3(adjustedOrigin[0], adjustedOrigin[1], adjustedOrigin[2]));
|
|
270
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").visible = false;
|
|
271
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").renderOrder = 100;
|
|
272
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").material.depthTest =
|
|
273
|
+
false;
|
|
274
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").material.transparent =
|
|
275
|
+
true;
|
|
276
|
+
// three.js uses a right-handed coordinate system, so we need to rotate the grid helper
|
|
277
|
+
const rotationMatrix = new THREE.Matrix4().fromArray([
|
|
278
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorU[0],
|
|
279
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorU[1],
|
|
280
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorU[2],
|
|
281
|
+
0,
|
|
282
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorV[0],
|
|
283
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorV[1],
|
|
284
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorV[2],
|
|
285
|
+
0,
|
|
286
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal[0],
|
|
287
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal[1],
|
|
288
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal[2],
|
|
289
|
+
0,
|
|
290
|
+
0,
|
|
291
|
+
0,
|
|
292
|
+
0,
|
|
293
|
+
1,
|
|
294
|
+
]);
|
|
295
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").rotation.setFromRotationMatrix(rotationMatrix);
|
|
296
|
+
// three.js grid helper is created in the XY plane, so we need to rotate it by 90 degrees around the X axis
|
|
297
|
+
__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").rotateX(Math.PI / 2);
|
|
298
|
+
this._object3D.add(__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f"));
|
|
299
|
+
}
|
|
300
|
+
createOffsetFromUnit() {
|
|
301
|
+
// Calculate the offset of the rotated point from the rotated origin
|
|
302
|
+
__classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[0] =
|
|
303
|
+
__classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") *
|
|
304
|
+
Math.round(__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[0] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) -
|
|
305
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[0];
|
|
306
|
+
__classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[1] =
|
|
307
|
+
__classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") *
|
|
308
|
+
Math.round(__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[1] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) -
|
|
309
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[1];
|
|
310
|
+
__classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[2] =
|
|
311
|
+
__classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") *
|
|
312
|
+
Math.round(__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[2] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) -
|
|
313
|
+
__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[2];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
exports.GridRestriction = GridRestriction;
|
|
317
|
+
_GridRestriction_activationKey = new WeakMap(), _GridRestriction_eventEngine = new WeakMap(), _GridRestriction_planeRestriction = new WeakMap(), _GridRestriction_active = new WeakMap(), _GridRestriction_gridHelper = new WeakMap(), _GridRestriction_gridSize = new WeakMap(), _GridRestriction_gridUnit = new WeakMap(), _GridRestriction_gridUnitEditable = new WeakMap(), _GridRestriction_offsetFromUnit = new WeakMap(), _GridRestriction_toggleInversion = new WeakMap(), _GridRestriction_priority = new WeakMap();
|
|
318
|
+
// #endregion Classes (1)
|
|
309
319
|
//# sourceMappingURL=GridRestriction.js.map
|