@shapediver/viewer.rendering-engine.intersection-restriction-engine 3.16.8 → 3.16.10

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 (95) hide show
  1. package/dist/api/implementation/AbstractRestrictionApi.d.ts +12 -12
  2. package/dist/api/implementation/AbstractRestrictionApi.js +46 -46
  3. package/dist/api/implementation/AbstractRestrictionApi.js.map +1 -1
  4. package/dist/api/implementation/AbstractSnapRestrictionApi.d.ts +12 -12
  5. package/dist/api/implementation/AbstractSnapRestrictionApi.js +46 -46
  6. package/dist/api/implementation/AbstractSnapRestrictionApi.js.map +1 -1
  7. package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.d.ts +6 -6
  8. package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.js +23 -23
  9. package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.js.map +1 -1
  10. package/dist/api/implementation/geometry/GeometryRestrictionApi.d.ts +14 -14
  11. package/dist/api/implementation/geometry/GeometryRestrictionApi.js +53 -53
  12. package/dist/api/implementation/geometry/GeometryRestrictionApi.js.map +1 -1
  13. package/dist/api/implementation/line/LineRestrictionApi.d.ts +10 -10
  14. package/dist/api/implementation/line/LineRestrictionApi.js +39 -39
  15. package/dist/api/implementation/line/LineRestrictionApi.js.map +1 -1
  16. package/dist/api/implementation/plane/PlaneRestrictionApi.d.ts +19 -19
  17. package/dist/api/implementation/plane/PlaneRestrictionApi.js +66 -66
  18. package/dist/api/implementation/plane/PlaneRestrictionApi.js.map +1 -1
  19. package/dist/api/implementation/plane/snap/AngularRestrictionApi.d.ts +9 -9
  20. package/dist/api/implementation/plane/snap/AngularRestrictionApi.js +39 -39
  21. package/dist/api/implementation/plane/snap/AngularRestrictionApi.js.map +1 -1
  22. package/dist/api/implementation/plane/snap/AxisRestrictionApi.d.ts +6 -6
  23. package/dist/api/implementation/plane/snap/AxisRestrictionApi.js +23 -23
  24. package/dist/api/implementation/plane/snap/AxisRestrictionApi.js.map +1 -1
  25. package/dist/api/implementation/plane/snap/GridRestrictionApi.d.ts +9 -9
  26. package/dist/api/implementation/plane/snap/GridRestrictionApi.js +39 -39
  27. package/dist/api/implementation/plane/snap/GridRestrictionApi.js.map +1 -1
  28. package/dist/api/implementation/point/PointRestrictionApi.d.ts +9 -9
  29. package/dist/api/implementation/point/PointRestrictionApi.js +36 -36
  30. package/dist/api/implementation/point/PointRestrictionApi.js.map +1 -1
  31. package/dist/api/interfaces/IRestrictionApi.d.ts +10 -10
  32. package/dist/api/interfaces/IRestrictionApi.js +2 -2
  33. package/dist/api/interfaces/ISnapRestrictionApi.d.ts +12 -12
  34. package/dist/api/interfaces/ISnapRestrictionApi.js +2 -2
  35. package/dist/implementation/EventManager.d.ts +25 -25
  36. package/dist/implementation/EventManager.d.ts.map +1 -1
  37. package/dist/implementation/EventManager.js +62 -62
  38. package/dist/implementation/EventManager.js.map +1 -1
  39. package/dist/implementation/GeometryMathManager.d.ts +87 -87
  40. package/dist/implementation/GeometryMathManager.js +260 -260
  41. package/dist/implementation/GeometryMathManager.js.map +1 -1
  42. package/dist/implementation/RestrictionManager.d.ts +28 -28
  43. package/dist/implementation/RestrictionManager.js +323 -323
  44. package/dist/implementation/RestrictionManager.js.map +1 -1
  45. package/dist/implementation/restrictions/AbstractRestriction.d.ts +42 -42
  46. package/dist/implementation/restrictions/AbstractRestriction.js +164 -154
  47. package/dist/implementation/restrictions/AbstractRestriction.js.map +1 -1
  48. package/dist/implementation/restrictions/AbstractSnapRestriction.d.ts +35 -35
  49. package/dist/implementation/restrictions/AbstractSnapRestriction.js +150 -140
  50. package/dist/implementation/restrictions/AbstractSnapRestriction.js.map +1 -1
  51. package/dist/implementation/restrictions/RestrictionsHelper.d.ts +10 -10
  52. package/dist/implementation/restrictions/RestrictionsHelper.d.ts.map +1 -1
  53. package/dist/implementation/restrictions/RestrictionsHelper.js +50 -50
  54. package/dist/implementation/restrictions/RestrictionsHelper.js.map +1 -1
  55. package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.d.ts +17 -17
  56. package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.js +62 -62
  57. package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.js.map +1 -1
  58. package/dist/implementation/restrictions/geometry/GeometryRestriction.d.ts +92 -92
  59. package/dist/implementation/restrictions/geometry/GeometryRestriction.js +410 -400
  60. package/dist/implementation/restrictions/geometry/GeometryRestriction.js.map +1 -1
  61. package/dist/implementation/restrictions/line/LineRestriction.d.ts +58 -58
  62. package/dist/implementation/restrictions/line/LineRestriction.js +291 -281
  63. package/dist/implementation/restrictions/line/LineRestriction.js.map +1 -1
  64. package/dist/implementation/restrictions/plane/PlaneRestriction.d.ts +65 -65
  65. package/dist/implementation/restrictions/plane/PlaneRestriction.js +306 -306
  66. package/dist/implementation/restrictions/plane/PlaneRestriction.js.map +1 -1
  67. package/dist/implementation/restrictions/plane/snap/AngularRestriction.d.ts +39 -39
  68. package/dist/implementation/restrictions/plane/snap/AngularRestriction.d.ts.map +1 -1
  69. package/dist/implementation/restrictions/plane/snap/AngularRestriction.js +346 -346
  70. package/dist/implementation/restrictions/plane/snap/AngularRestriction.js.map +1 -1
  71. package/dist/implementation/restrictions/plane/snap/AxisRestriction.d.ts +27 -27
  72. package/dist/implementation/restrictions/plane/snap/AxisRestriction.d.ts.map +1 -1
  73. package/dist/implementation/restrictions/plane/snap/AxisRestriction.js +239 -229
  74. package/dist/implementation/restrictions/plane/snap/AxisRestriction.js.map +1 -1
  75. package/dist/implementation/restrictions/plane/snap/GridRestriction.d.ts +39 -39
  76. package/dist/implementation/restrictions/plane/snap/GridRestriction.d.ts.map +1 -1
  77. package/dist/implementation/restrictions/plane/snap/GridRestriction.js +318 -308
  78. package/dist/implementation/restrictions/plane/snap/GridRestriction.js.map +1 -1
  79. package/dist/implementation/restrictions/point/PointRestriction.d.ts +45 -45
  80. package/dist/implementation/restrictions/point/PointRestriction.js +166 -156
  81. package/dist/implementation/restrictions/point/PointRestriction.js.map +1 -1
  82. package/dist/index.d.ts +29 -29
  83. package/dist/index.js +37 -37
  84. package/dist/interfaces/IDragAnchor.d.ts +8 -8
  85. package/dist/interfaces/IDragAnchor.js +2 -2
  86. package/dist/interfaces/IRestriction.d.ts +117 -117
  87. package/dist/interfaces/IRestriction.d.ts.map +1 -1
  88. package/dist/interfaces/IRestriction.js +23 -23
  89. package/dist/interfaces/IRestriction.js.map +1 -1
  90. package/dist/interfaces/IRestrictionManager.d.ts +13 -13
  91. package/dist/interfaces/IRestrictionManager.js +2 -2
  92. package/dist/interfaces/ISnapRestriction.d.ts +81 -81
  93. package/dist/interfaces/ISnapRestriction.d.ts.map +1 -1
  94. package/dist/interfaces/ISnapRestriction.js +3 -3
  95. package/package.json +10 -10
@@ -1,282 +1,292 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
- if (kind === "m") throw new TypeError("Private method is not writable");
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
- 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");
29
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
- };
31
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
32
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
33
- 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");
34
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
- };
36
- var _LineRestriction_viewport, _LineRestriction_dragLineLength, _LineRestriction_dragRay, _LineRestriction_point1, _LineRestriction_point1Restriction, _LineRestriction_point2, _LineRestriction_point2Restriction, _LineRestriction_radius, _LineRestriction_settings, _LineRestriction_snapRestrictions, _LineRestriction_visualizationObject, _LineRestriction_wireframe, _LineRestriction_wireframeColor, _LineRestriction_wireframeDepthTest;
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.LineRestriction = void 0;
39
- const gl_matrix_1 = require("gl-matrix");
40
- const THREE = __importStar(require("three"));
41
- const IRestriction_1 = require("../../../interfaces/IRestriction");
42
- const AbstractRestriction_1 = require("../AbstractRestriction");
43
- const PointRestriction_1 = require("../point/PointRestriction");
44
- // #endregion Type aliases (1)
45
- // #region Classes (1)
46
- class LineRestriction extends AbstractRestriction_1.AbstractRestriction {
47
- // #endregion Properties (11)
48
- // #region Constructors (1)
49
- constructor(viewport, geometryMathManager, parentNode, id, settings, properties) {
50
- var _a, _b, _c, _d, _e;
51
- super(viewport, parentNode, id, properties);
52
- // #region Properties (11)
53
- _LineRestriction_viewport.set(this, void 0);
54
- _LineRestriction_dragLineLength.set(this, void 0);
55
- _LineRestriction_dragRay.set(this, void 0);
56
- _LineRestriction_point1.set(this, void 0);
57
- _LineRestriction_point1Restriction.set(this, void 0);
58
- _LineRestriction_point2.set(this, void 0);
59
- _LineRestriction_point2Restriction.set(this, void 0);
60
- _LineRestriction_radius.set(this, void 0);
61
- _LineRestriction_settings.set(this, void 0);
62
- _LineRestriction_snapRestrictions.set(this, {});
63
- _LineRestriction_visualizationObject.set(this, new THREE.Object3D());
64
- _LineRestriction_wireframe.set(this, void 0);
65
- _LineRestriction_wireframeColor.set(this, void 0);
66
- _LineRestriction_wireframeDepthTest.set(this, void 0);
67
- __classPrivateFieldSet(this, _LineRestriction_viewport, viewport, "f");
68
- __classPrivateFieldSet(this, _LineRestriction_point1, properties.point1, "f");
69
- __classPrivateFieldSet(this, _LineRestriction_point2, properties.point2, "f");
70
- __classPrivateFieldSet(this, _LineRestriction_radius, properties.radius || 0, "f");
71
- __classPrivateFieldSet(this, _LineRestriction_settings, settings, "f");
72
- __classPrivateFieldSet(this, _LineRestriction_wireframe, (_b = (_a = properties.wireframe) !== null && _a !== void 0 ? _a : settings.wireframe) !== null && _b !== void 0 ? _b : true, "f");
73
- __classPrivateFieldSet(this, _LineRestriction_wireframeColor, (_d = (_c = properties.wireframeColor) !== null && _c !== void 0 ? _c : settings.wireframeColor) !== null && _d !== void 0 ? _d : settings.points.color_1, "f");
74
- __classPrivateFieldSet(this, _LineRestriction_wireframeDepthTest, (_e = properties.wireframeDepthTest) !== null && _e !== void 0 ? _e : false, "f");
75
- if (properties.point1Radius !== undefined) {
76
- __classPrivateFieldSet(this, _LineRestriction_point1Restriction, new PointRestriction_1.PointRestriction(viewport, geometryMathManager, parentNode, id, settings, {
77
- type: IRestriction_1.RESTRICTION_TYPE.POINT,
78
- point: properties.point1,
79
- radius: properties.point1Radius,
80
- wireframe: properties.wireframe,
81
- wireframeColor: properties.wireframeColor,
82
- wireframeDepthTest: properties.wireframeDepthTest,
83
- }), "f");
84
- }
85
- if (properties.point2Radius !== undefined) {
86
- __classPrivateFieldSet(this, _LineRestriction_point2Restriction, new PointRestriction_1.PointRestriction(viewport, geometryMathManager, parentNode, id, settings, {
87
- type: IRestriction_1.RESTRICTION_TYPE.POINT,
88
- point: properties.point2,
89
- radius: properties.point2Radius,
90
- wireframe: properties.wireframe,
91
- wireframeColor: properties.wireframeColor,
92
- wireframeDepthTest: properties.wireframeDepthTest,
93
- }), "f");
94
- }
95
- const direction = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_point2, "f"), __classPrivateFieldGet(this, _LineRestriction_point1, "f"));
96
- __classPrivateFieldSet(this, _LineRestriction_dragLineLength, gl_matrix_1.vec3.length(direction), "f");
97
- __classPrivateFieldSet(this, _LineRestriction_dragRay, {
98
- origin: __classPrivateFieldGet(this, _LineRestriction_point1, "f"),
99
- direction: gl_matrix_1.vec3.divide(gl_matrix_1.vec3.create(), direction, gl_matrix_1.vec3.fromValues(__classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f"), __classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f"), __classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f"))),
100
- }, "f");
101
- if (__classPrivateFieldGet(this, _LineRestriction_wireframe, "f")) {
102
- const geometry = new THREE.BufferGeometry();
103
- geometry.setAttribute("position", new THREE.Float32BufferAttribute([
104
- __classPrivateFieldGet(this, _LineRestriction_point1, "f")[0],
105
- __classPrivateFieldGet(this, _LineRestriction_point1, "f")[1],
106
- __classPrivateFieldGet(this, _LineRestriction_point1, "f")[2],
107
- __classPrivateFieldGet(this, _LineRestriction_point2, "f")[0],
108
- __classPrivateFieldGet(this, _LineRestriction_point2, "f")[1],
109
- __classPrivateFieldGet(this, _LineRestriction_point2, "f")[2],
110
- ], 3));
111
- const line = new THREE.Line(geometry, new THREE.LineBasicMaterial({
112
- color: new THREE.Color(__classPrivateFieldGet(this, _LineRestriction_wireframeColor, "f")),
113
- depthTest: __classPrivateFieldGet(this, _LineRestriction_wireframeDepthTest, "f"),
114
- depthWrite: !__classPrivateFieldGet(this, _LineRestriction_wireframeDepthTest, "f"),
115
- }));
116
- line.matrixAutoUpdate = false;
117
- line.renderOrder = 100;
118
- __classPrivateFieldGet(this, _LineRestriction_visualizationObject, "f").add(line);
119
- this._object3D.add(__classPrivateFieldGet(this, _LineRestriction_visualizationObject, "f"));
120
- }
121
- }
122
- // #endregion Constructors (1)
123
- // #region Public Getters And Setters (5)
124
- get point1() {
125
- return __classPrivateFieldGet(this, _LineRestriction_point1, "f");
126
- }
127
- get point1Restriction() {
128
- return __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f");
129
- }
130
- get point2() {
131
- return __classPrivateFieldGet(this, _LineRestriction_point2, "f");
132
- }
133
- get point2Restriction() {
134
- return __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f");
135
- }
136
- get radius() {
137
- return __classPrivateFieldGet(this, _LineRestriction_radius, "f");
138
- }
139
- get snapRestrictions() {
140
- return __classPrivateFieldGet(this, _LineRestriction_snapRestrictions, "f");
141
- }
142
- // #endregion Public Getters And Setters (5)
143
- // #region Public Methods (1)
144
- isWithinRadius(point) {
145
- var _a, _b;
146
- // Check distance from point to the start of the cylinder
147
- const distance = gl_matrix_1.vec3.squaredDistance(point, __classPrivateFieldGet(this, _LineRestriction_point1, "f"));
148
- const squaredRadius1 = ((_a = __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f")) === null || _a === void 0 ? void 0 : _a.radius)
149
- ? __classPrivateFieldGet(this, _LineRestriction_radius, "f") > __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f").radius
150
- ? __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")
151
- : __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f").radius *
152
- __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f").radius
153
- : __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f");
154
- if (distance < squaredRadius1) {
155
- return true;
156
- }
157
- // Check distance from point to the end of the cylinder
158
- const distance2 = gl_matrix_1.vec3.squaredDistance(point, __classPrivateFieldGet(this, _LineRestriction_point2, "f"));
159
- const squaredRadius2 = ((_b = __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f")) === null || _b === void 0 ? void 0 : _b.radius)
160
- ? __classPrivateFieldGet(this, _LineRestriction_radius, "f") > __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f").radius
161
- ? __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")
162
- : __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f").radius *
163
- __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f").radius
164
- : __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f");
165
- if (distance2 < squaredRadius2) {
166
- return true;
167
- }
168
- // Calculate the closest point on the line segment (between point1 and point2)
169
- const lineDir = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_point2, "f"), __classPrivateFieldGet(this, _LineRestriction_point1, "f")); // Direction of the line segment
170
- const lineLengthSquared = gl_matrix_1.vec3.squaredLength(lineDir);
171
- // Project the point onto the line (scaled projection)
172
- const projection = gl_matrix_1.vec3.dot(gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), point, __classPrivateFieldGet(this, _LineRestriction_point1, "f")), lineDir) /
173
- lineLengthSquared;
174
- // Clamp the projection value to ensure it's within the line segment
175
- const clampedProjection = Math.max(0, Math.min(1, projection));
176
- // Calculate the closest point on the segment
177
- const closestPointOnLine = gl_matrix_1.vec3.scaleAndAdd(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_point1, "f"), lineDir, clampedProjection);
178
- // Check if the point is within the radius of the line
179
- const distance3 = gl_matrix_1.vec3.squaredDistance(point, closestPointOnLine);
180
- if (distance3 < __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")) {
181
- return true;
182
- }
183
- // If all checks fail, return false
184
- return false;
185
- }
186
- rayTrace(ray, metaData) {
187
- const planeNormal = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), ray.direction, __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction);
188
- const Na = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), ray.direction, planeNormal));
189
- const Nb = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction, planeNormal));
190
- const da = gl_matrix_1.vec3.dot(gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin, ray.origin), Nb) / gl_matrix_1.vec3.dot(ray.direction, Nb);
191
- const db = gl_matrix_1.vec3.dot(gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), ray.origin, __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin), Na) / gl_matrix_1.vec3.dot(__classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction, Na);
192
- let pointA = gl_matrix_1.vec3.create();
193
- if (da < 0) {
194
- gl_matrix_1.vec3.copy(pointA, ray.origin);
195
- }
196
- else {
197
- pointA = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), ray.origin, gl_matrix_1.vec3.mul(gl_matrix_1.vec3.create(), ray.direction, gl_matrix_1.vec3.fromValues(da, da, da)));
198
- }
199
- let pointB = gl_matrix_1.vec3.create();
200
- if (db < 0) {
201
- gl_matrix_1.vec3.copy(pointB, __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin);
202
- }
203
- else if (db < __classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f")) {
204
- pointB = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin, gl_matrix_1.vec3.mul(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction, gl_matrix_1.vec3.fromValues(db, db, db)));
205
- }
206
- else {
207
- gl_matrix_1.vec3.copy(pointB, __classPrivateFieldGet(this, _LineRestriction_point2, "f"));
208
- }
209
- // first, check the simple cases
210
- // if there the restrictions for the points are set, we need to check them
211
- const result1 = __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f")
212
- ? __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f").rayTrace(ray)
213
- : undefined;
214
- const result2 = __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f")
215
- ? __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f").rayTrace(ray)
216
- : undefined;
217
- // return the closest result
218
- if (result1 || result2) {
219
- if (result1 && result2) {
220
- if (result1.distanceOriginToClosestIntersectionPointSquared <
221
- result2.distanceOriginToClosestIntersectionPointSquared) {
222
- return {
223
- closestIntersectionPoint: result1.closestIntersectionPoint,
224
- distanceOriginToClosestIntersectionPointSquared: result1.distanceOriginToClosestIntersectionPointSquared,
225
- targetPoint: result1.targetPoint,
226
- distanceClosestPointToTargetPointSquared: result1.distanceClosestPointToTargetPointSquared,
227
- restriction: this,
228
- };
229
- }
230
- return {
231
- closestIntersectionPoint: result2.closestIntersectionPoint,
232
- distanceOriginToClosestIntersectionPointSquared: result2.distanceOriginToClosestIntersectionPointSquared,
233
- targetPoint: result2.targetPoint,
234
- distanceClosestPointToTargetPointSquared: result2.distanceClosestPointToTargetPointSquared,
235
- restriction: this,
236
- };
237
- }
238
- const result = (result1 || result2);
239
- return {
240
- closestIntersectionPoint: result.closestIntersectionPoint,
241
- distanceOriginToClosestIntersectionPointSquared: result.distanceOriginToClosestIntersectionPointSquared,
242
- targetPoint: result.targetPoint,
243
- distanceClosestPointToTargetPointSquared: result.distanceClosestPointToTargetPointSquared,
244
- restriction: this,
245
- };
246
- }
247
- const distance = gl_matrix_1.vec3.squaredDistance(pointA, pointB);
248
- if (distance < __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")) {
249
- // check if origin is inside the cylinder
250
- const distanceOrigin = gl_matrix_1.vec3.squaredDistance(ray.origin, pointB);
251
- if (distanceOrigin < __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")) {
252
- return {
253
- closestIntersectionPoint: pointA,
254
- distanceOriginToClosestIntersectionPointSquared: gl_matrix_1.vec3.sqrDist(ray.origin, pointA),
255
- targetPoint: pointB,
256
- distanceClosestPointToTargetPointSquared: distance,
257
- restriction: this,
258
- };
259
- }
260
- // now we calculate the closest point on the cylinder to the ray
261
- const offset = Math.sqrt(__classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f") - distance);
262
- // Compute the entry distance
263
- const entry = da - offset;
264
- const closestIntersectionPoint = gl_matrix_1.vec3.scaleAndAdd(gl_matrix_1.vec3.create(), ray.origin, ray.direction, entry);
265
- return {
266
- closestIntersectionPoint,
267
- distanceOriginToClosestIntersectionPointSquared: entry * entry,
268
- targetPoint: pointB,
269
- distanceClosestPointToTargetPointSquared: distance,
270
- restriction: this,
271
- };
272
- }
273
- return;
274
- }
275
- // #endregion Public Methods (1)
276
- // #region Protected Methods (1)
277
- visibilityChanged() { }
278
- }
279
- exports.LineRestriction = LineRestriction;
280
- _LineRestriction_viewport = new WeakMap(), _LineRestriction_dragLineLength = new WeakMap(), _LineRestriction_dragRay = new WeakMap(), _LineRestriction_point1 = new WeakMap(), _LineRestriction_point1Restriction = new WeakMap(), _LineRestriction_point2 = new WeakMap(), _LineRestriction_point2Restriction = new WeakMap(), _LineRestriction_radius = new WeakMap(), _LineRestriction_settings = new WeakMap(), _LineRestriction_snapRestrictions = new WeakMap(), _LineRestriction_visualizationObject = new WeakMap(), _LineRestriction_wireframe = new WeakMap(), _LineRestriction_wireframeColor = new WeakMap(), _LineRestriction_wireframeDepthTest = new WeakMap();
281
- // #endregion Classes (1)
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 _LineRestriction_viewport, _LineRestriction_dragLineLength, _LineRestriction_dragRay, _LineRestriction_point1, _LineRestriction_point1Restriction, _LineRestriction_point2, _LineRestriction_point2Restriction, _LineRestriction_radius, _LineRestriction_settings, _LineRestriction_snapRestrictions, _LineRestriction_visualizationObject, _LineRestriction_wireframe, _LineRestriction_wireframeColor, _LineRestriction_wireframeDepthTest;
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.LineRestriction = void 0;
49
+ const gl_matrix_1 = require("gl-matrix");
50
+ const THREE = __importStar(require("three"));
51
+ const IRestriction_1 = require("../../../interfaces/IRestriction");
52
+ const AbstractRestriction_1 = require("../AbstractRestriction");
53
+ const PointRestriction_1 = require("../point/PointRestriction");
54
+ // #endregion Type aliases (1)
55
+ // #region Classes (1)
56
+ class LineRestriction extends AbstractRestriction_1.AbstractRestriction {
57
+ // #endregion Properties (11)
58
+ // #region Constructors (1)
59
+ constructor(viewport, geometryMathManager, parentNode, id, settings, properties) {
60
+ var _a, _b, _c, _d, _e;
61
+ super(viewport, parentNode, id, properties);
62
+ // #region Properties (11)
63
+ _LineRestriction_viewport.set(this, void 0);
64
+ _LineRestriction_dragLineLength.set(this, void 0);
65
+ _LineRestriction_dragRay.set(this, void 0);
66
+ _LineRestriction_point1.set(this, void 0);
67
+ _LineRestriction_point1Restriction.set(this, void 0);
68
+ _LineRestriction_point2.set(this, void 0);
69
+ _LineRestriction_point2Restriction.set(this, void 0);
70
+ _LineRestriction_radius.set(this, void 0);
71
+ _LineRestriction_settings.set(this, void 0);
72
+ _LineRestriction_snapRestrictions.set(this, {});
73
+ _LineRestriction_visualizationObject.set(this, new THREE.Object3D());
74
+ _LineRestriction_wireframe.set(this, void 0);
75
+ _LineRestriction_wireframeColor.set(this, void 0);
76
+ _LineRestriction_wireframeDepthTest.set(this, void 0);
77
+ __classPrivateFieldSet(this, _LineRestriction_viewport, viewport, "f");
78
+ __classPrivateFieldSet(this, _LineRestriction_point1, properties.point1, "f");
79
+ __classPrivateFieldSet(this, _LineRestriction_point2, properties.point2, "f");
80
+ __classPrivateFieldSet(this, _LineRestriction_radius, properties.radius || 0, "f");
81
+ __classPrivateFieldSet(this, _LineRestriction_settings, settings, "f");
82
+ __classPrivateFieldSet(this, _LineRestriction_wireframe, (_b = (_a = properties.wireframe) !== null && _a !== void 0 ? _a : settings.wireframe) !== null && _b !== void 0 ? _b : true, "f");
83
+ __classPrivateFieldSet(this, _LineRestriction_wireframeColor, (_d = (_c = properties.wireframeColor) !== null && _c !== void 0 ? _c : settings.wireframeColor) !== null && _d !== void 0 ? _d : settings.points.color_1, "f");
84
+ __classPrivateFieldSet(this, _LineRestriction_wireframeDepthTest, (_e = properties.wireframeDepthTest) !== null && _e !== void 0 ? _e : false, "f");
85
+ if (properties.point1Radius !== undefined) {
86
+ __classPrivateFieldSet(this, _LineRestriction_point1Restriction, new PointRestriction_1.PointRestriction(viewport, geometryMathManager, parentNode, id, settings, {
87
+ type: IRestriction_1.RESTRICTION_TYPE.POINT,
88
+ point: properties.point1,
89
+ radius: properties.point1Radius,
90
+ wireframe: properties.wireframe,
91
+ wireframeColor: properties.wireframeColor,
92
+ wireframeDepthTest: properties.wireframeDepthTest,
93
+ }), "f");
94
+ }
95
+ if (properties.point2Radius !== undefined) {
96
+ __classPrivateFieldSet(this, _LineRestriction_point2Restriction, new PointRestriction_1.PointRestriction(viewport, geometryMathManager, parentNode, id, settings, {
97
+ type: IRestriction_1.RESTRICTION_TYPE.POINT,
98
+ point: properties.point2,
99
+ radius: properties.point2Radius,
100
+ wireframe: properties.wireframe,
101
+ wireframeColor: properties.wireframeColor,
102
+ wireframeDepthTest: properties.wireframeDepthTest,
103
+ }), "f");
104
+ }
105
+ const direction = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_point2, "f"), __classPrivateFieldGet(this, _LineRestriction_point1, "f"));
106
+ __classPrivateFieldSet(this, _LineRestriction_dragLineLength, gl_matrix_1.vec3.length(direction), "f");
107
+ __classPrivateFieldSet(this, _LineRestriction_dragRay, {
108
+ origin: __classPrivateFieldGet(this, _LineRestriction_point1, "f"),
109
+ direction: gl_matrix_1.vec3.divide(gl_matrix_1.vec3.create(), direction, gl_matrix_1.vec3.fromValues(__classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f"), __classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f"), __classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f"))),
110
+ }, "f");
111
+ if (__classPrivateFieldGet(this, _LineRestriction_wireframe, "f")) {
112
+ const geometry = new THREE.BufferGeometry();
113
+ geometry.setAttribute("position", new THREE.Float32BufferAttribute([
114
+ __classPrivateFieldGet(this, _LineRestriction_point1, "f")[0],
115
+ __classPrivateFieldGet(this, _LineRestriction_point1, "f")[1],
116
+ __classPrivateFieldGet(this, _LineRestriction_point1, "f")[2],
117
+ __classPrivateFieldGet(this, _LineRestriction_point2, "f")[0],
118
+ __classPrivateFieldGet(this, _LineRestriction_point2, "f")[1],
119
+ __classPrivateFieldGet(this, _LineRestriction_point2, "f")[2],
120
+ ], 3));
121
+ const line = new THREE.Line(geometry, new THREE.LineBasicMaterial({
122
+ color: new THREE.Color(__classPrivateFieldGet(this, _LineRestriction_wireframeColor, "f")),
123
+ depthTest: __classPrivateFieldGet(this, _LineRestriction_wireframeDepthTest, "f"),
124
+ depthWrite: !__classPrivateFieldGet(this, _LineRestriction_wireframeDepthTest, "f"),
125
+ }));
126
+ line.matrixAutoUpdate = false;
127
+ line.renderOrder = 100;
128
+ __classPrivateFieldGet(this, _LineRestriction_visualizationObject, "f").add(line);
129
+ this._object3D.add(__classPrivateFieldGet(this, _LineRestriction_visualizationObject, "f"));
130
+ }
131
+ }
132
+ // #endregion Constructors (1)
133
+ // #region Public Getters And Setters (5)
134
+ get point1() {
135
+ return __classPrivateFieldGet(this, _LineRestriction_point1, "f");
136
+ }
137
+ get point1Restriction() {
138
+ return __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f");
139
+ }
140
+ get point2() {
141
+ return __classPrivateFieldGet(this, _LineRestriction_point2, "f");
142
+ }
143
+ get point2Restriction() {
144
+ return __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f");
145
+ }
146
+ get radius() {
147
+ return __classPrivateFieldGet(this, _LineRestriction_radius, "f");
148
+ }
149
+ get snapRestrictions() {
150
+ return __classPrivateFieldGet(this, _LineRestriction_snapRestrictions, "f");
151
+ }
152
+ // #endregion Public Getters And Setters (5)
153
+ // #region Public Methods (1)
154
+ isWithinRadius(point) {
155
+ var _a, _b;
156
+ // Check distance from point to the start of the cylinder
157
+ const distance = gl_matrix_1.vec3.squaredDistance(point, __classPrivateFieldGet(this, _LineRestriction_point1, "f"));
158
+ const squaredRadius1 = ((_a = __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f")) === null || _a === void 0 ? void 0 : _a.radius)
159
+ ? __classPrivateFieldGet(this, _LineRestriction_radius, "f") > __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f").radius
160
+ ? __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")
161
+ : __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f").radius *
162
+ __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f").radius
163
+ : __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f");
164
+ if (distance < squaredRadius1) {
165
+ return true;
166
+ }
167
+ // Check distance from point to the end of the cylinder
168
+ const distance2 = gl_matrix_1.vec3.squaredDistance(point, __classPrivateFieldGet(this, _LineRestriction_point2, "f"));
169
+ const squaredRadius2 = ((_b = __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f")) === null || _b === void 0 ? void 0 : _b.radius)
170
+ ? __classPrivateFieldGet(this, _LineRestriction_radius, "f") > __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f").radius
171
+ ? __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")
172
+ : __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f").radius *
173
+ __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f").radius
174
+ : __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f");
175
+ if (distance2 < squaredRadius2) {
176
+ return true;
177
+ }
178
+ // Calculate the closest point on the line segment (between point1 and point2)
179
+ const lineDir = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_point2, "f"), __classPrivateFieldGet(this, _LineRestriction_point1, "f")); // Direction of the line segment
180
+ const lineLengthSquared = gl_matrix_1.vec3.squaredLength(lineDir);
181
+ // Project the point onto the line (scaled projection)
182
+ const projection = gl_matrix_1.vec3.dot(gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), point, __classPrivateFieldGet(this, _LineRestriction_point1, "f")), lineDir) /
183
+ lineLengthSquared;
184
+ // Clamp the projection value to ensure it's within the line segment
185
+ const clampedProjection = Math.max(0, Math.min(1, projection));
186
+ // Calculate the closest point on the segment
187
+ const closestPointOnLine = gl_matrix_1.vec3.scaleAndAdd(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_point1, "f"), lineDir, clampedProjection);
188
+ // Check if the point is within the radius of the line
189
+ const distance3 = gl_matrix_1.vec3.squaredDistance(point, closestPointOnLine);
190
+ if (distance3 < __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")) {
191
+ return true;
192
+ }
193
+ // If all checks fail, return false
194
+ return false;
195
+ }
196
+ rayTrace(ray, metaData) {
197
+ const planeNormal = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), ray.direction, __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction);
198
+ const Na = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), ray.direction, planeNormal));
199
+ const Nb = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction, planeNormal));
200
+ const da = gl_matrix_1.vec3.dot(gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin, ray.origin), Nb) / gl_matrix_1.vec3.dot(ray.direction, Nb);
201
+ const db = gl_matrix_1.vec3.dot(gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), ray.origin, __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin), Na) / gl_matrix_1.vec3.dot(__classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction, Na);
202
+ let pointA = gl_matrix_1.vec3.create();
203
+ if (da < 0) {
204
+ gl_matrix_1.vec3.copy(pointA, ray.origin);
205
+ }
206
+ else {
207
+ pointA = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), ray.origin, gl_matrix_1.vec3.mul(gl_matrix_1.vec3.create(), ray.direction, gl_matrix_1.vec3.fromValues(da, da, da)));
208
+ }
209
+ let pointB = gl_matrix_1.vec3.create();
210
+ if (db < 0) {
211
+ gl_matrix_1.vec3.copy(pointB, __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin);
212
+ }
213
+ else if (db < __classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f")) {
214
+ pointB = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin, gl_matrix_1.vec3.mul(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction, gl_matrix_1.vec3.fromValues(db, db, db)));
215
+ }
216
+ else {
217
+ gl_matrix_1.vec3.copy(pointB, __classPrivateFieldGet(this, _LineRestriction_point2, "f"));
218
+ }
219
+ // first, check the simple cases
220
+ // if there the restrictions for the points are set, we need to check them
221
+ const result1 = __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f")
222
+ ? __classPrivateFieldGet(this, _LineRestriction_point1Restriction, "f").rayTrace(ray)
223
+ : undefined;
224
+ const result2 = __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f")
225
+ ? __classPrivateFieldGet(this, _LineRestriction_point2Restriction, "f").rayTrace(ray)
226
+ : undefined;
227
+ // return the closest result
228
+ if (result1 || result2) {
229
+ if (result1 && result2) {
230
+ if (result1.distanceOriginToClosestIntersectionPointSquared <
231
+ result2.distanceOriginToClosestIntersectionPointSquared) {
232
+ return {
233
+ closestIntersectionPoint: result1.closestIntersectionPoint,
234
+ distanceOriginToClosestIntersectionPointSquared: result1.distanceOriginToClosestIntersectionPointSquared,
235
+ targetPoint: result1.targetPoint,
236
+ distanceClosestPointToTargetPointSquared: result1.distanceClosestPointToTargetPointSquared,
237
+ restriction: this,
238
+ };
239
+ }
240
+ return {
241
+ closestIntersectionPoint: result2.closestIntersectionPoint,
242
+ distanceOriginToClosestIntersectionPointSquared: result2.distanceOriginToClosestIntersectionPointSquared,
243
+ targetPoint: result2.targetPoint,
244
+ distanceClosestPointToTargetPointSquared: result2.distanceClosestPointToTargetPointSquared,
245
+ restriction: this,
246
+ };
247
+ }
248
+ const result = (result1 || result2);
249
+ return {
250
+ closestIntersectionPoint: result.closestIntersectionPoint,
251
+ distanceOriginToClosestIntersectionPointSquared: result.distanceOriginToClosestIntersectionPointSquared,
252
+ targetPoint: result.targetPoint,
253
+ distanceClosestPointToTargetPointSquared: result.distanceClosestPointToTargetPointSquared,
254
+ restriction: this,
255
+ };
256
+ }
257
+ const distance = gl_matrix_1.vec3.squaredDistance(pointA, pointB);
258
+ if (distance < __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")) {
259
+ // check if origin is inside the cylinder
260
+ const distanceOrigin = gl_matrix_1.vec3.squaredDistance(ray.origin, pointB);
261
+ if (distanceOrigin < __classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f")) {
262
+ return {
263
+ closestIntersectionPoint: pointA,
264
+ distanceOriginToClosestIntersectionPointSquared: gl_matrix_1.vec3.sqrDist(ray.origin, pointA),
265
+ targetPoint: pointB,
266
+ distanceClosestPointToTargetPointSquared: distance,
267
+ restriction: this,
268
+ };
269
+ }
270
+ // now we calculate the closest point on the cylinder to the ray
271
+ const offset = Math.sqrt(__classPrivateFieldGet(this, _LineRestriction_radius, "f") * __classPrivateFieldGet(this, _LineRestriction_radius, "f") - distance);
272
+ // Compute the entry distance
273
+ const entry = da - offset;
274
+ const closestIntersectionPoint = gl_matrix_1.vec3.scaleAndAdd(gl_matrix_1.vec3.create(), ray.origin, ray.direction, entry);
275
+ return {
276
+ closestIntersectionPoint,
277
+ distanceOriginToClosestIntersectionPointSquared: entry * entry,
278
+ targetPoint: pointB,
279
+ distanceClosestPointToTargetPointSquared: distance,
280
+ restriction: this,
281
+ };
282
+ }
283
+ return;
284
+ }
285
+ // #endregion Public Methods (1)
286
+ // #region Protected Methods (1)
287
+ visibilityChanged() { }
288
+ }
289
+ exports.LineRestriction = LineRestriction;
290
+ _LineRestriction_viewport = new WeakMap(), _LineRestriction_dragLineLength = new WeakMap(), _LineRestriction_dragRay = new WeakMap(), _LineRestriction_point1 = new WeakMap(), _LineRestriction_point1Restriction = new WeakMap(), _LineRestriction_point2 = new WeakMap(), _LineRestriction_point2Restriction = new WeakMap(), _LineRestriction_radius = new WeakMap(), _LineRestriction_settings = new WeakMap(), _LineRestriction_snapRestrictions = new WeakMap(), _LineRestriction_visualizationObject = new WeakMap(), _LineRestriction_wireframe = new WeakMap(), _LineRestriction_wireframeColor = new WeakMap(), _LineRestriction_wireframeDepthTest = new WeakMap();
291
+ // #endregion Classes (1)
282
292
  //# sourceMappingURL=LineRestriction.js.map