@shapediver/viewer.rendering-engine.intersection-restriction-engine 3.5.0

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 (131) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +3 -0
  3. package/dist/api/implementation/AbstractRestrictionApi.d.ts +10 -0
  4. package/dist/api/implementation/AbstractRestrictionApi.d.ts.map +1 -0
  5. package/dist/api/implementation/AbstractRestrictionApi.js +38 -0
  6. package/dist/api/implementation/AbstractRestrictionApi.js.map +1 -0
  7. package/dist/api/implementation/AbstractSnapRestrictionApi.d.ts +13 -0
  8. package/dist/api/implementation/AbstractSnapRestrictionApi.d.ts.map +1 -0
  9. package/dist/api/implementation/AbstractSnapRestrictionApi.js +47 -0
  10. package/dist/api/implementation/AbstractSnapRestrictionApi.js.map +1 -0
  11. package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.d.ts +7 -0
  12. package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.d.ts.map +1 -0
  13. package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.js +24 -0
  14. package/dist/api/implementation/camera_plane/CameraPlaneRestrictionApi.js.map +1 -0
  15. package/dist/api/implementation/geometry/GeometryRestrictionApi.d.ts +15 -0
  16. package/dist/api/implementation/geometry/GeometryRestrictionApi.d.ts.map +1 -0
  17. package/dist/api/implementation/geometry/GeometryRestrictionApi.js +54 -0
  18. package/dist/api/implementation/geometry/GeometryRestrictionApi.js.map +1 -0
  19. package/dist/api/implementation/line/LineRestrictionApi.d.ts +11 -0
  20. package/dist/api/implementation/line/LineRestrictionApi.d.ts.map +1 -0
  21. package/dist/api/implementation/line/LineRestrictionApi.js +40 -0
  22. package/dist/api/implementation/line/LineRestrictionApi.js.map +1 -0
  23. package/dist/api/implementation/plane/PlaneRestrictionApi.d.ts +20 -0
  24. package/dist/api/implementation/plane/PlaneRestrictionApi.d.ts.map +1 -0
  25. package/dist/api/implementation/plane/PlaneRestrictionApi.js +67 -0
  26. package/dist/api/implementation/plane/PlaneRestrictionApi.js.map +1 -0
  27. package/dist/api/implementation/plane/snap/AngularRestrictionApi.d.ts +10 -0
  28. package/dist/api/implementation/plane/snap/AngularRestrictionApi.d.ts.map +1 -0
  29. package/dist/api/implementation/plane/snap/AngularRestrictionApi.js +40 -0
  30. package/dist/api/implementation/plane/snap/AngularRestrictionApi.js.map +1 -0
  31. package/dist/api/implementation/plane/snap/AxisRestrictionApi.d.ts +7 -0
  32. package/dist/api/implementation/plane/snap/AxisRestrictionApi.d.ts.map +1 -0
  33. package/dist/api/implementation/plane/snap/AxisRestrictionApi.js +24 -0
  34. package/dist/api/implementation/plane/snap/AxisRestrictionApi.js.map +1 -0
  35. package/dist/api/implementation/plane/snap/GridRestrictionApi.d.ts +10 -0
  36. package/dist/api/implementation/plane/snap/GridRestrictionApi.d.ts.map +1 -0
  37. package/dist/api/implementation/plane/snap/GridRestrictionApi.js +40 -0
  38. package/dist/api/implementation/plane/snap/GridRestrictionApi.js.map +1 -0
  39. package/dist/api/implementation/point/PointRestrictionApi.d.ts +10 -0
  40. package/dist/api/implementation/point/PointRestrictionApi.d.ts.map +1 -0
  41. package/dist/api/implementation/point/PointRestrictionApi.js +37 -0
  42. package/dist/api/implementation/point/PointRestrictionApi.js.map +1 -0
  43. package/dist/api/interfaces/IRestrictionApi.d.ts +11 -0
  44. package/dist/api/interfaces/IRestrictionApi.d.ts.map +1 -0
  45. package/dist/api/interfaces/IRestrictionApi.js +3 -0
  46. package/dist/api/interfaces/IRestrictionApi.js.map +1 -0
  47. package/dist/api/interfaces/ISnapRestrictionApi.d.ts +13 -0
  48. package/dist/api/interfaces/ISnapRestrictionApi.d.ts.map +1 -0
  49. package/dist/api/interfaces/ISnapRestrictionApi.js +3 -0
  50. package/dist/api/interfaces/ISnapRestrictionApi.js.map +1 -0
  51. package/dist/implementation/EventManager.d.ts +26 -0
  52. package/dist/implementation/EventManager.d.ts.map +1 -0
  53. package/dist/implementation/EventManager.js +63 -0
  54. package/dist/implementation/EventManager.js.map +1 -0
  55. package/dist/implementation/GeometryMathManager.d.ts +82 -0
  56. package/dist/implementation/GeometryMathManager.d.ts.map +1 -0
  57. package/dist/implementation/GeometryMathManager.js +240 -0
  58. package/dist/implementation/GeometryMathManager.js.map +1 -0
  59. package/dist/implementation/RestrictionManager.d.ts +29 -0
  60. package/dist/implementation/RestrictionManager.d.ts.map +1 -0
  61. package/dist/implementation/RestrictionManager.js +220 -0
  62. package/dist/implementation/RestrictionManager.js.map +1 -0
  63. package/dist/implementation/restrictions/AbstractRestriction.d.ts +42 -0
  64. package/dist/implementation/restrictions/AbstractRestriction.d.ts.map +1 -0
  65. package/dist/implementation/restrictions/AbstractRestriction.js +130 -0
  66. package/dist/implementation/restrictions/AbstractRestriction.js.map +1 -0
  67. package/dist/implementation/restrictions/AbstractSnapRestriction.d.ts +32 -0
  68. package/dist/implementation/restrictions/AbstractSnapRestriction.d.ts.map +1 -0
  69. package/dist/implementation/restrictions/AbstractSnapRestriction.js +125 -0
  70. package/dist/implementation/restrictions/AbstractSnapRestriction.js.map +1 -0
  71. package/dist/implementation/restrictions/RestrictionsHelper.d.ts +11 -0
  72. package/dist/implementation/restrictions/RestrictionsHelper.d.ts.map +1 -0
  73. package/dist/implementation/restrictions/RestrictionsHelper.js +47 -0
  74. package/dist/implementation/restrictions/RestrictionsHelper.js.map +1 -0
  75. package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.d.ts +19 -0
  76. package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.d.ts.map +1 -0
  77. package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.js +64 -0
  78. package/dist/implementation/restrictions/camera_plane/CameraPlaneRestriction.js.map +1 -0
  79. package/dist/implementation/restrictions/geometry/GeometryRestriction.d.ts +41 -0
  80. package/dist/implementation/restrictions/geometry/GeometryRestriction.d.ts.map +1 -0
  81. package/dist/implementation/restrictions/geometry/GeometryRestriction.js +259 -0
  82. package/dist/implementation/restrictions/geometry/GeometryRestriction.js.map +1 -0
  83. package/dist/implementation/restrictions/line/LineRestriction.d.ts +28 -0
  84. package/dist/implementation/restrictions/line/LineRestriction.d.ts.map +1 -0
  85. package/dist/implementation/restrictions/line/LineRestriction.js +104 -0
  86. package/dist/implementation/restrictions/line/LineRestriction.js.map +1 -0
  87. package/dist/implementation/restrictions/plane/PlaneRestriction.d.ts +68 -0
  88. package/dist/implementation/restrictions/plane/PlaneRestriction.d.ts.map +1 -0
  89. package/dist/implementation/restrictions/plane/PlaneRestriction.js +259 -0
  90. package/dist/implementation/restrictions/plane/PlaneRestriction.js.map +1 -0
  91. package/dist/implementation/restrictions/plane/snap/AngularRestriction.d.ts +41 -0
  92. package/dist/implementation/restrictions/plane/snap/AngularRestriction.d.ts.map +1 -0
  93. package/dist/implementation/restrictions/plane/snap/AngularRestriction.js +321 -0
  94. package/dist/implementation/restrictions/plane/snap/AngularRestriction.js.map +1 -0
  95. package/dist/implementation/restrictions/plane/snap/AxisRestriction.d.ts +28 -0
  96. package/dist/implementation/restrictions/plane/snap/AxisRestriction.d.ts.map +1 -0
  97. package/dist/implementation/restrictions/plane/snap/AxisRestriction.js +172 -0
  98. package/dist/implementation/restrictions/plane/snap/AxisRestriction.js.map +1 -0
  99. package/dist/implementation/restrictions/plane/snap/GridRestriction.d.ts +40 -0
  100. package/dist/implementation/restrictions/plane/snap/GridRestriction.d.ts.map +1 -0
  101. package/dist/implementation/restrictions/plane/snap/GridRestriction.js +211 -0
  102. package/dist/implementation/restrictions/plane/snap/GridRestriction.js.map +1 -0
  103. package/dist/implementation/restrictions/point/PointRestriction.d.ts +25 -0
  104. package/dist/implementation/restrictions/point/PointRestriction.d.ts.map +1 -0
  105. package/dist/implementation/restrictions/point/PointRestriction.js +78 -0
  106. package/dist/implementation/restrictions/point/PointRestriction.js.map +1 -0
  107. package/dist/index.d.ts +30 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +38 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/interfaces/IDragAnchor.d.ts +9 -0
  112. package/dist/interfaces/IDragAnchor.d.ts.map +1 -0
  113. package/dist/interfaces/IDragAnchor.js +3 -0
  114. package/dist/interfaces/IDragAnchor.js.map +1 -0
  115. package/dist/interfaces/IRestriction.d.ts +89 -0
  116. package/dist/interfaces/IRestriction.d.ts.map +1 -0
  117. package/dist/interfaces/IRestriction.js +25 -0
  118. package/dist/interfaces/IRestriction.js.map +1 -0
  119. package/dist/interfaces/IRestrictionManager.d.ts +14 -0
  120. package/dist/interfaces/IRestrictionManager.d.ts.map +1 -0
  121. package/dist/interfaces/IRestrictionManager.js +3 -0
  122. package/dist/interfaces/IRestrictionManager.js.map +1 -0
  123. package/dist/interfaces/ISnapRestriction.d.ts +67 -0
  124. package/dist/interfaces/ISnapRestriction.d.ts.map +1 -0
  125. package/dist/interfaces/ISnapRestriction.js +4 -0
  126. package/dist/interfaces/ISnapRestriction.js.map +1 -0
  127. package/dist/interfaces/IVisualizationSettings.d.ts +33 -0
  128. package/dist/interfaces/IVisualizationSettings.d.ts.map +1 -0
  129. package/dist/interfaces/IVisualizationSettings.js +3 -0
  130. package/dist/interfaces/IVisualizationSettings.js.map +1 -0
  131. package/package.json +54 -0
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateDragMatrix = void 0;
4
+ const gl_matrix_1 = require("gl-matrix");
5
+ const calculateDragMatrix = (snapPoint, snapRotation, dragOrigin, dragAnchors = [], closestPoint) => {
6
+ if (dragAnchors.length > 0) {
7
+ const results = [];
8
+ for (let i = 0; i < dragAnchors.length; i++) {
9
+ const matrix = calculateMatrix(dragAnchors[i].position, dragAnchors[i].rotation || { axis: gl_matrix_1.vec3.fromValues(0, 0, 1), angle: 0 }, snapPoint, snapRotation);
10
+ const point = gl_matrix_1.vec3.transformMat4(gl_matrix_1.vec3.create(), dragOrigin, matrix);
11
+ results.push({ matrix, point, dragAnchor: dragAnchors[i] });
12
+ }
13
+ results.sort((a, b) => gl_matrix_1.vec3.distance(a.point, closestPoint) - gl_matrix_1.vec3.distance(b.point, closestPoint));
14
+ return results[0];
15
+ }
16
+ else {
17
+ return {
18
+ matrix: calculateMatrix(dragOrigin, { axis: gl_matrix_1.vec3.fromValues(0, 0, 1), angle: 0 }, snapPoint, snapRotation),
19
+ point: dragOrigin
20
+ };
21
+ }
22
+ };
23
+ exports.calculateDragMatrix = calculateDragMatrix;
24
+ const calculateMatrix = (dragPoint, dragRotation, snapPoint, snapRotation) => {
25
+ const rotationMatrix = gl_matrix_1.mat4.create();
26
+ // apply inverted anchor matrix
27
+ const dragMatrix = gl_matrix_1.mat4.fromRotation(gl_matrix_1.mat4.create(), dragRotation.angle, dragRotation.axis);
28
+ let invertedDragMatrix = gl_matrix_1.mat4.invert(gl_matrix_1.mat4.create(), dragMatrix);
29
+ if (!invertedDragMatrix)
30
+ invertedDragMatrix = gl_matrix_1.mat4.create();
31
+ gl_matrix_1.mat4.multiply(rotationMatrix, rotationMatrix, invertedDragMatrix);
32
+ // apply snap matrix
33
+ const snapMatrix = gl_matrix_1.mat4.fromRotation(gl_matrix_1.mat4.create(), snapRotation.angle, snapRotation.axis);
34
+ gl_matrix_1.mat4.multiply(rotationMatrix, rotationMatrix, snapMatrix);
35
+ // the dragAnchor in the rotated space
36
+ const dragPointTransformed = gl_matrix_1.vec3.transformMat4(gl_matrix_1.vec3.create(), dragPoint, rotationMatrix);
37
+ // distance between snap point and transformed anchor
38
+ const dragTranslation = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), snapPoint, dragPointTransformed);
39
+ // transformation of the difference
40
+ let invertedRotationMatrix = gl_matrix_1.mat4.invert(gl_matrix_1.mat4.create(), rotationMatrix);
41
+ if (!invertedRotationMatrix)
42
+ invertedRotationMatrix = gl_matrix_1.mat4.create();
43
+ gl_matrix_1.vec3.transformMat4(dragTranslation, dragTranslation, invertedRotationMatrix);
44
+ const translationMatrix = gl_matrix_1.mat4.fromTranslation(gl_matrix_1.mat4.create(), dragTranslation);
45
+ return gl_matrix_1.mat4.multiply(gl_matrix_1.mat4.create(), rotationMatrix, translationMatrix);
46
+ };
47
+ //# sourceMappingURL=RestrictionsHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestrictionsHelper.js","sourceRoot":"","sources":["../../../src/implementation/restrictions/RestrictionsHelper.ts"],"names":[],"mappings":";;;AACA,yCAAuC;AAEhC,MAAM,mBAAmB,GAC5B,CACI,SAAe,EACf,YAGC,EACD,UAAgB,EAChB,cAA6B,EAAE,EAC/B,YAAkB,EAKpB,EAAE;IACA,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QACxB,MAAM,OAAO,GAIP,EAAE,CAAC;QACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACzC,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,IAAI,EAAE,gBAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;YAC1J,MAAM,KAAK,GAAG,gBAAI,CAAC,aAAa,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,UAAW,EAAE,MAAM,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC/D;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,gBAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,YAAa,CAAC,GAAG,gBAAI,CAAC,QAAQ,CAAC,CAAC,CA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AE,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;IAE1F,qDAAqD;IACrD,MAAM,eAAe,GAAG,gBAAI,CAAC,GAAG,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;IAEjF,mCAAmC;IACnC,IAAI,sBAAsB,GAAG,gBAAI,CAAC,MAAM,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC;IACxE,IAAI,CAAC,sBAAsB;QACvB,sBAAsB,GAAG,gBAAI,CAAC,MAAM,EAAE,CAAC;IAE3C,gBAAI,CAAC,aAAa,CAAC,eAAe,EAAE,eAAe,EAAE,sBAAsB,CAAC,CAAC;IAC7E,MAAM,iBAAiB,GAAG,gBAAI,CAAC,eAAe,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC;IAE/E,OAAO,gBAAI,CAAC,QAAQ,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAC3E,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { AbstractRestriction } from '../AbstractRestriction';
2
+ import { GeometryMathManager } from '../../GeometryMathManager';
3
+ import { IRay } from '@shapediver/viewer.rendering-engine.intersection-engine';
4
+ import { IRestriction, RestrictionMetaData, RestrictionPropertiesBase, RestrictionResult } from '../../../interfaces/IRestriction';
5
+ import { ISnapRestriction } from '../../../interfaces/ISnapRestriction';
6
+ import { ITreeNode, IViewportApi } from '@shapediver/viewer';
7
+ import { IVisualizationSettings } from '../../../interfaces/IVisualizationSettings';
8
+ export declare type CameraPlaneRestrictionProperties = RestrictionPropertiesBase;
9
+ export declare class CameraPlaneRestriction extends AbstractRestriction implements IRestriction {
10
+ #private;
11
+ constructor(viewport: IViewportApi, geometryMathManager: GeometryMathManager, parentNode: ITreeNode, id: string, settings: IVisualizationSettings, properties: CameraPlaneRestrictionProperties);
12
+ get priority(): number;
13
+ get snapRestrictions(): {
14
+ [key: string]: ISnapRestriction;
15
+ };
16
+ rayTrace(ray: IRay, metaData: RestrictionMetaData): RestrictionResult | undefined;
17
+ protected visibilityChanged(): void;
18
+ }
19
+ //# sourceMappingURL=CameraPlaneRestriction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CameraPlaneRestriction.d.ts","sourceRoot":"","sources":["../../../../src/implementation/restrictions/camera_plane/CameraPlaneRestriction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,IAAI,EAAE,MAAM,yDAAyD,CAAC;AAC/E,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAKpF,oBAAY,gCAAgC,GAAG,yBAAyB,CAAC;AAMzE,qBAAa,sBAAuB,SAAQ,mBAAoB,YAAW,YAAY;;gBAYvE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,UAAU,EAAE,gCAAgC;IAU/L,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,gBAAgB,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;KAAE,CAElE;IAMM,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,mBAAmB,GAAG,iBAAiB,GAAG,SAAS;IAoBxF,SAAS,CAAC,iBAAiB,IAAI,IAAI;CAGtC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ 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");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _CameraPlaneRestriction_viewport, _CameraPlaneRestriction_dragPlane, _CameraPlaneRestriction_snapRestrictions;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CameraPlaneRestriction = void 0;
16
+ const AbstractRestriction_1 = require("../AbstractRestriction");
17
+ const viewer_shared_math_1 = require("@shapediver/viewer.shared.math");
18
+ const gl_matrix_1 = require("gl-matrix");
19
+ // #endregion Type aliases (1)
20
+ // #region Classes (1)
21
+ class CameraPlaneRestriction extends AbstractRestriction_1.AbstractRestriction {
22
+ // #endregion Properties (3)
23
+ // #region Constructors (1)
24
+ constructor(viewport, geometryMathManager, parentNode, id, settings, properties) {
25
+ super(viewport, parentNode, id, properties);
26
+ // #region Properties (3)
27
+ _CameraPlaneRestriction_viewport.set(this, void 0);
28
+ _CameraPlaneRestriction_dragPlane.set(this, void 0);
29
+ _CameraPlaneRestriction_snapRestrictions.set(this, {});
30
+ __classPrivateFieldSet(this, _CameraPlaneRestriction_viewport, viewport, "f");
31
+ }
32
+ // #endregion Constructors (1)
33
+ // #region Public Getters And Setters (2)
34
+ get priority() {
35
+ return -1;
36
+ }
37
+ get snapRestrictions() {
38
+ return __classPrivateFieldGet(this, _CameraPlaneRestriction_snapRestrictions, "f");
39
+ }
40
+ // #endregion Public Getters And Setters (2)
41
+ // #region Public Methods (1)
42
+ rayTrace(ray, metaData) {
43
+ var _a;
44
+ const cameraDirection = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _CameraPlaneRestriction_viewport, "f").camera.target, __classPrivateFieldGet(this, _CameraPlaneRestriction_viewport, "f").camera.position));
45
+ __classPrivateFieldSet(this, _CameraPlaneRestriction_dragPlane, new viewer_shared_math_1.Plane().setFromNormalAndCoplanarPoint(cameraDirection, metaData.startPoint || gl_matrix_1.vec3.create()), "f");
46
+ const distance = (_a = __classPrivateFieldGet(this, _CameraPlaneRestriction_dragPlane, "f")) === null || _a === void 0 ? void 0 : _a.intersect(ray.origin, ray.direction);
47
+ if (distance && distance > 0) {
48
+ const point = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), ray.direction, gl_matrix_1.vec3.fromValues(distance, distance, distance)), ray.origin);
49
+ return {
50
+ distance,
51
+ point,
52
+ restriction: this
53
+ };
54
+ }
55
+ return;
56
+ }
57
+ // #endregion Public Methods (1)
58
+ // #region Protected Methods (1)
59
+ visibilityChanged() { }
60
+ }
61
+ exports.CameraPlaneRestriction = CameraPlaneRestriction;
62
+ _CameraPlaneRestriction_viewport = new WeakMap(), _CameraPlaneRestriction_dragPlane = new WeakMap(), _CameraPlaneRestriction_snapRestrictions = new WeakMap();
63
+ // #endregion Classes (1)
64
+ //# sourceMappingURL=CameraPlaneRestriction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CameraPlaneRestriction.js","sourceRoot":"","sources":["../../../../src/implementation/restrictions/camera_plane/CameraPlaneRestriction.ts"],"names":[],"mappings":";;;;;;;;;;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,GAAG,CAAC,EAAE;YAC1B,MAAM,KAAK,GAAG,gBAAI,CAAC,GAAG,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,gBAAI,CAAC,QAAQ,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,SAAS,EAAE,gBAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;YAC9I,OAAO;gBACH,QAAQ;gBACR,KAAK;gBACL,WAAW,EAAE,IAAI;aACpB,CAAC;SACL;QACD,OAAO;IACX,CAAC;IAED,gCAAgC;IAEhC,gCAAgC;IAEtB,iBAAiB,KAAW,CAAC;CAG1C;AAzDD,wDAyDC;;AAED,yBAAyB"}
@@ -0,0 +1,41 @@
1
+ import { AbstractRestriction } from '../AbstractRestriction';
2
+ import { GeometryMathManager } from '../../GeometryMathManager';
3
+ import { IRay } from '@shapediver/viewer.rendering-engine.intersection-engine';
4
+ import { IRestriction, RestrictionMetaData, RestrictionPropertiesBase, RestrictionResult } from '../../../interfaces/IRestriction';
5
+ import { ISnapRestriction } from '../../../interfaces/ISnapRestriction';
6
+ import { ITreeNode } from '@shapediver/viewer.shared.node-tree';
7
+ import { IViewportApi } from '@shapediver/viewer';
8
+ import { IVisualizationSettings } from '../../../interfaces/IVisualizationSettings';
9
+ export declare type GeometryRestrictionProperties = {
10
+ /**
11
+ * The nodes to restrict the interaction to.
12
+ */
13
+ nodes: ITreeNode[];
14
+ /**
15
+ * If the geometry should be displayed as wireframe.
16
+ */
17
+ wireframe?: boolean;
18
+ /**
19
+ * The color of the wireframe.
20
+ */
21
+ wireframeColor?: string;
22
+ } & RestrictionPropertiesBase;
23
+ export declare class GeometryRestriction extends AbstractRestriction implements IRestriction {
24
+ #private;
25
+ constructor(viewport: IViewportApi, geometryMathManager: GeometryMathManager, parentNode: ITreeNode, id: string, settings: IVisualizationSettings, properties: GeometryRestrictionProperties);
26
+ get priority(): number;
27
+ get snapRestrictions(): {
28
+ [key: string]: ISnapRestriction;
29
+ };
30
+ get snapToEdges(): boolean;
31
+ set snapToEdges(value: boolean);
32
+ get snapToFaces(): boolean;
33
+ set snapToFaces(value: boolean);
34
+ get snapToVertices(): boolean;
35
+ set snapToVertices(value: boolean);
36
+ rayTrace(ray: IRay, metaData?: RestrictionMetaData): RestrictionResult | undefined;
37
+ updateNodes(nodes: ITreeNode[]): void;
38
+ protected visibilityChanged(): void;
39
+ private updateIntersectionThresholds;
40
+ }
41
+ //# sourceMappingURL=GeometryRestriction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeometryRestriction.d.ts","sourceRoot":"","sources":["../../../../src/implementation/restrictions/geometry/GeometryRestriction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,yDAAyD,CAAC;AAC/E,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACpB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAa,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAKpF,oBAAY,6BAA6B,GAAG;IACxC;;OAEG;IACH,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG,yBAAyB,CAAC;AAM9B,qBAAa,mBAAoB,SAAQ,mBAAoB,YAAW,YAAY;;gBAiCpE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,UAAU,EAAE,6BAA6B;IA0B5L,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,gBAAgB,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;KAAE,CAElE;IAED,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,WAAW,CAAC,KAAK,EAAE,OAAO,EAEpC;IAED,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,WAAW,CAAC,KAAK,EAAE,OAAO,EAEpC;IAED,IAAW,cAAc,IAAI,OAAO,CAEnC;IAED,IAAW,cAAc,CAAC,KAAK,EAAE,OAAO,EAEvC;IAMM,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,GAAG,SAAS;IA2GlF,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE;IAmCrC,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAMnC,OAAO,CAAC,4BAA4B;CAOvC"}
@@ -0,0 +1,259 @@
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 _GeometryRestriction_eventEngine, _GeometryRestriction_rayCasterParams, _GeometryRestriction_raycaster, _GeometryRestriction_viewport, _GeometryRestriction_geometryMathManager, _GeometryRestriction_lineIntersectionPercentage, _GeometryRestriction_nodes, _GeometryRestriction_pointIntersectionPercentage, _GeometryRestriction_sceneBoundingSphereRadius, _GeometryRestriction_settings, _GeometryRestriction_snapRestrictions, _GeometryRestriction_snapToEdges, _GeometryRestriction_snapToFaces, _GeometryRestriction_snapToVertices, _GeometryRestriction_visualizationObject, _GeometryRestriction_wireframe, _GeometryRestriction_wireframeColor;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.GeometryRestriction = void 0;
39
+ const THREE = __importStar(require("three"));
40
+ const AbstractRestriction_1 = require("../AbstractRestriction");
41
+ const viewer_shared_math_1 = require("@shapediver/viewer.shared.math");
42
+ const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
43
+ const viewer_1 = require("@shapediver/viewer");
44
+ const gl_matrix_1 = require("gl-matrix");
45
+ // #endregion Type aliases (1)
46
+ // #region Classes (1)
47
+ class GeometryRestriction extends AbstractRestriction_1.AbstractRestriction {
48
+ // #endregion Properties (17)
49
+ // #region Constructors (1)
50
+ constructor(viewport, geometryMathManager, parentNode, id, settings, properties) {
51
+ var _a, _b;
52
+ super(viewport, parentNode, id, properties);
53
+ // #region Properties (17)
54
+ _GeometryRestriction_eventEngine.set(this, viewer_shared_services_1.EventEngine.instance);
55
+ _GeometryRestriction_rayCasterParams.set(this, {
56
+ Line: { threshold: 1 },
57
+ Line2: { threshold: 1 },
58
+ Points: { threshold: 1 },
59
+ Mesh: {},
60
+ LOD: {},
61
+ Sprite: {}
62
+ });
63
+ _GeometryRestriction_raycaster.set(this, new THREE.Raycaster());
64
+ _GeometryRestriction_viewport.set(this, void 0);
65
+ _GeometryRestriction_geometryMathManager.set(this, void 0);
66
+ _GeometryRestriction_lineIntersectionPercentage.set(this, 0.025);
67
+ _GeometryRestriction_nodes.set(this, []);
68
+ _GeometryRestriction_pointIntersectionPercentage.set(this, 0.025);
69
+ _GeometryRestriction_sceneBoundingSphereRadius.set(this, 0);
70
+ _GeometryRestriction_settings.set(this, void 0);
71
+ _GeometryRestriction_snapRestrictions.set(this, {});
72
+ _GeometryRestriction_snapToEdges.set(this, true);
73
+ _GeometryRestriction_snapToFaces.set(this, true);
74
+ _GeometryRestriction_snapToVertices.set(this, true);
75
+ _GeometryRestriction_visualizationObject.set(this, new THREE.Object3D());
76
+ _GeometryRestriction_wireframe.set(this, void 0);
77
+ _GeometryRestriction_wireframeColor.set(this, void 0);
78
+ __classPrivateFieldSet(this, _GeometryRestriction_viewport, viewport, "f");
79
+ __classPrivateFieldSet(this, _GeometryRestriction_settings, settings, "f");
80
+ __classPrivateFieldSet(this, _GeometryRestriction_geometryMathManager, geometryMathManager, "f");
81
+ __classPrivateFieldSet(this, _GeometryRestriction_wireframe, (_a = properties.wireframe) !== null && _a !== void 0 ? _a : true, "f");
82
+ __classPrivateFieldSet(this, _GeometryRestriction_wireframeColor, (_b = properties.wireframeColor) !== null && _b !== void 0 ? _b : __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").points.color_1, "f");
83
+ __classPrivateFieldSet(this, _GeometryRestriction_sceneBoundingSphereRadius, viewer_1.sceneTree.root.boundingBox.boundingSphere.radius, "f");
84
+ this.updateIntersectionThresholds();
85
+ __classPrivateFieldGet(this, _GeometryRestriction_eventEngine, "f").addListener(viewer_shared_services_1.EVENTTYPE.SCENE.SCENE_BOUNDING_BOX_CHANGE, (e) => {
86
+ const event = e;
87
+ if (event.viewportId === __classPrivateFieldGet(this, _GeometryRestriction_viewport, "f").id) {
88
+ const boundingBox = new viewer_shared_math_1.Box(event.boundingBox.min, event.boundingBox.max);
89
+ __classPrivateFieldSet(this, _GeometryRestriction_sceneBoundingSphereRadius, boundingBox.boundingSphere.radius, "f");
90
+ this.updateIntersectionThresholds();
91
+ }
92
+ });
93
+ this.updateNodes(properties.nodes);
94
+ }
95
+ // #endregion Constructors (1)
96
+ // #region Public Getters And Setters (8)
97
+ get priority() {
98
+ return 0;
99
+ }
100
+ get snapRestrictions() {
101
+ return __classPrivateFieldGet(this, _GeometryRestriction_snapRestrictions, "f");
102
+ }
103
+ get snapToEdges() {
104
+ return __classPrivateFieldGet(this, _GeometryRestriction_snapToEdges, "f");
105
+ }
106
+ set snapToEdges(value) {
107
+ __classPrivateFieldSet(this, _GeometryRestriction_snapToEdges, value, "f");
108
+ }
109
+ get snapToFaces() {
110
+ return __classPrivateFieldGet(this, _GeometryRestriction_snapToFaces, "f");
111
+ }
112
+ set snapToFaces(value) {
113
+ __classPrivateFieldSet(this, _GeometryRestriction_snapToFaces, value, "f");
114
+ }
115
+ get snapToVertices() {
116
+ return __classPrivateFieldGet(this, _GeometryRestriction_snapToVertices, "f");
117
+ }
118
+ set snapToVertices(value) {
119
+ __classPrivateFieldSet(this, _GeometryRestriction_snapToVertices, value, "f");
120
+ }
121
+ // #endregion Public Getters And Setters (8)
122
+ // #region Public Methods (3)
123
+ rayTrace(ray, metaData) {
124
+ if (this.enabled === false)
125
+ return;
126
+ if (__classPrivateFieldGet(this, _GeometryRestriction_snapToVertices, "f") === false && __classPrivateFieldGet(this, _GeometryRestriction_snapToEdges, "f") === false && __classPrivateFieldGet(this, _GeometryRestriction_snapToFaces, "f") === false)
127
+ return;
128
+ // assign raycaster parameters
129
+ __classPrivateFieldGet(this, _GeometryRestriction_raycaster, "f").params = __classPrivateFieldGet(this, _GeometryRestriction_rayCasterParams, "f");
130
+ __classPrivateFieldGet(this, _GeometryRestriction_raycaster, "f").ray.direction.set(ray.direction[0], ray.direction[1], ray.direction[2]);
131
+ __classPrivateFieldGet(this, _GeometryRestriction_raycaster, "f").ray.origin.set(ray.origin[0], ray.origin[1], ray.origin[2]);
132
+ // intersect all nodes
133
+ let intersections = [];
134
+ __classPrivateFieldGet(this, _GeometryRestriction_nodes, "f").forEach(node => {
135
+ const threeJsObject = node.convertedObject[__classPrivateFieldGet(this, _GeometryRestriction_viewport, "f").id];
136
+ if (threeJsObject) {
137
+ const currentIntersections = __classPrivateFieldGet(this, _GeometryRestriction_raycaster, "f").intersectObject(threeJsObject);
138
+ intersections = intersections.concat(currentIntersections);
139
+ }
140
+ });
141
+ // sort
142
+ intersections.sort((a, b) => a.distance - b.distance);
143
+ // return first intersection
144
+ if (intersections.length > 0) {
145
+ const object = intersections[0].object;
146
+ const geometry = object.geometry;
147
+ const positionAttribute = geometry.getAttribute('position');
148
+ if (object instanceof THREE.Points && intersections[0].index !== undefined) {
149
+ if (!__classPrivateFieldGet(this, _GeometryRestriction_snapToVertices, "f"))
150
+ return;
151
+ const vertex = new THREE.Vector3();
152
+ vertex.fromBufferAttribute(positionAttribute, intersections[0].index);
153
+ object.localToWorld(vertex);
154
+ return { point: gl_matrix_1.vec3.fromValues(vertex.x, vertex.y, vertex.z), distance: intersections[0].distance, restriction: this };
155
+ }
156
+ const intersectionPoint = intersections[0].point;
157
+ const intersectionPointVec3 = gl_matrix_1.vec3.fromValues(intersectionPoint.x, intersectionPoint.y, intersectionPoint.z);
158
+ if (!intersections[0].face)
159
+ return { point: intersectionPointVec3, distance: intersections[0].distance, restriction: this };
160
+ if (__classPrivateFieldGet(this, _GeometryRestriction_snapToVertices, "f") === true || __classPrivateFieldGet(this, _GeometryRestriction_snapToEdges, "f") === true) {
161
+ const vertexA = new THREE.Vector3();
162
+ vertexA.fromBufferAttribute(positionAttribute, intersections[0].face.a);
163
+ object.localToWorld(vertexA);
164
+ const vertexAVec3 = gl_matrix_1.vec3.fromValues(vertexA.x, vertexA.y, vertexA.z);
165
+ const vertexB = new THREE.Vector3();
166
+ vertexB.fromBufferAttribute(positionAttribute, intersections[0].face.b);
167
+ object.localToWorld(vertexB);
168
+ const vertexBVec3 = gl_matrix_1.vec3.fromValues(vertexB.x, vertexB.y, vertexB.z);
169
+ const vertexC = new THREE.Vector3();
170
+ vertexC.fromBufferAttribute(positionAttribute, intersections[0].face.c);
171
+ object.localToWorld(vertexC);
172
+ const vertexCVec3 = gl_matrix_1.vec3.fromValues(vertexC.x, vertexC.y, vertexC.z);
173
+ if (__classPrivateFieldGet(this, _GeometryRestriction_snapToVertices, "f") === true) {
174
+ const distanceA = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").screenSpaceDistanceCheck(intersectionPointVec3, vertexAVec3, __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").points.size_0 * __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").distanceMultiplicationFactor);
175
+ const distanceB = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").screenSpaceDistanceCheck(intersectionPointVec3, vertexBVec3, __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").points.size_0 * __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").distanceMultiplicationFactor);
176
+ const distanceC = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").screenSpaceDistanceCheck(intersectionPointVec3, vertexCVec3, __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").points.size_0 * __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").distanceMultiplicationFactor);
177
+ // part 1 - check if the intersection point is close to a vertex
178
+ if (distanceA.check && distanceA.distanceSquared < distanceB.distanceSquared && distanceA.distanceSquared < distanceC.distanceSquared) {
179
+ return { point: vertexAVec3, restriction: this };
180
+ }
181
+ else if (distanceB.check && distanceB.distanceSquared < distanceA.distanceSquared && distanceB.distanceSquared < distanceC.distanceSquared) {
182
+ return { point: vertexBVec3, restriction: this };
183
+ }
184
+ else if (distanceC.check && distanceC.distanceSquared < distanceA.distanceSquared && distanceC.distanceSquared < distanceB.distanceSquared) {
185
+ return { point: vertexCVec3, restriction: this };
186
+ }
187
+ }
188
+ if (__classPrivateFieldGet(this, _GeometryRestriction_snapToEdges, "f") === true) {
189
+ // part 2 - check if the intersection point is close to an edge
190
+ // create the closest points on the edges
191
+ const closestPointOnEdgeAB = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").closestPointOnLine(vertexAVec3, vertexBVec3, intersectionPointVec3);
192
+ const closestPointOnEdgeBC = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").closestPointOnLine(vertexBVec3, vertexCVec3, intersectionPointVec3);
193
+ const closestPointOnEdgeCA = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").closestPointOnLine(vertexCVec3, vertexAVec3, intersectionPointVec3);
194
+ // create the distances
195
+ const distanceAB = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").screenSpaceDistanceCheck(intersectionPointVec3, closestPointOnEdgeAB, __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").points.size_0 * __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").distanceMultiplicationFactor);
196
+ const distanceBC = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").screenSpaceDistanceCheck(intersectionPointVec3, closestPointOnEdgeBC, __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").points.size_0 * __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").distanceMultiplicationFactor);
197
+ const distanceCA = __classPrivateFieldGet(this, _GeometryRestriction_geometryMathManager, "f").screenSpaceDistanceCheck(intersectionPointVec3, closestPointOnEdgeCA, __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").points.size_0 * __classPrivateFieldGet(this, _GeometryRestriction_settings, "f").distanceMultiplicationFactor);
198
+ // check if the intersection point is close to an edge
199
+ if (distanceAB.check && distanceAB.distanceSquared < distanceBC.distanceSquared && distanceAB.distanceSquared < distanceCA.distanceSquared) {
200
+ return { point: closestPointOnEdgeAB, restriction: this };
201
+ }
202
+ else if (distanceBC.check && distanceBC.distanceSquared < distanceAB.distanceSquared && distanceBC.distanceSquared < distanceCA.distanceSquared) {
203
+ return { point: closestPointOnEdgeBC, restriction: this };
204
+ }
205
+ else if (distanceCA.check && distanceCA.distanceSquared < distanceAB.distanceSquared && distanceCA.distanceSquared < distanceBC.distanceSquared) {
206
+ return { point: closestPointOnEdgeCA, restriction: this };
207
+ }
208
+ }
209
+ }
210
+ if (__classPrivateFieldGet(this, _GeometryRestriction_snapToFaces, "f") === true) {
211
+ // part 3 - face intersection
212
+ return { point: gl_matrix_1.vec3.fromValues(intersectionPoint.x, intersectionPoint.y, intersectionPoint.z), distance: intersections[0].distance, restriction: this };
213
+ }
214
+ }
215
+ return;
216
+ }
217
+ updateNodes(nodes) {
218
+ __classPrivateFieldSet(this, _GeometryRestriction_nodes, nodes, "f");
219
+ if (__classPrivateFieldGet(this, _GeometryRestriction_wireframe, "f")) {
220
+ __classPrivateFieldGet(this, _GeometryRestriction_visualizationObject, "f").traverse((object) => {
221
+ if (object instanceof THREE.LineSegments) {
222
+ object.geometry.dispose();
223
+ object.material.dispose();
224
+ }
225
+ });
226
+ this._object3D.remove(__classPrivateFieldGet(this, _GeometryRestriction_visualizationObject, "f"));
227
+ __classPrivateFieldSet(this, _GeometryRestriction_visualizationObject, new THREE.Object3D(), "f");
228
+ __classPrivateFieldGet(this, _GeometryRestriction_nodes, "f").forEach(node => {
229
+ const threeJsObject = node.convertedObject[__classPrivateFieldGet(this, _GeometryRestriction_viewport, "f").id];
230
+ if (threeJsObject) {
231
+ threeJsObject.updateMatrixWorld(true);
232
+ threeJsObject.traverse((object) => {
233
+ if (object instanceof THREE.Mesh) {
234
+ const wireframe = new THREE.WireframeGeometry(object.geometry);
235
+ const line = new THREE.LineSegments(wireframe, new THREE.LineBasicMaterial({ color: new THREE.Color(__classPrivateFieldGet(this, _GeometryRestriction_wireframeColor, "f")) }));
236
+ line.applyMatrix4(object.matrixWorld);
237
+ __classPrivateFieldGet(this, _GeometryRestriction_visualizationObject, "f").add(line);
238
+ }
239
+ });
240
+ }
241
+ });
242
+ this._object3D.add(__classPrivateFieldGet(this, _GeometryRestriction_visualizationObject, "f"));
243
+ }
244
+ }
245
+ // #endregion Public Methods (3)
246
+ // #region Protected Methods (1)
247
+ visibilityChanged() { }
248
+ // #endregion Protected Methods (1)
249
+ // #region Private Methods (1)
250
+ updateIntersectionThresholds() {
251
+ __classPrivateFieldGet(this, _GeometryRestriction_rayCasterParams, "f").Points.threshold = __classPrivateFieldGet(this, _GeometryRestriction_sceneBoundingSphereRadius, "f") * __classPrivateFieldGet(this, _GeometryRestriction_pointIntersectionPercentage, "f");
252
+ __classPrivateFieldGet(this, _GeometryRestriction_rayCasterParams, "f").Line.threshold = __classPrivateFieldGet(this, _GeometryRestriction_sceneBoundingSphereRadius, "f") * __classPrivateFieldGet(this, _GeometryRestriction_lineIntersectionPercentage, "f");
253
+ __classPrivateFieldGet(this, _GeometryRestriction_rayCasterParams, "f").Line2.threshold = __classPrivateFieldGet(this, _GeometryRestriction_sceneBoundingSphereRadius, "f") * __classPrivateFieldGet(this, _GeometryRestriction_lineIntersectionPercentage, "f");
254
+ }
255
+ }
256
+ exports.GeometryRestriction = GeometryRestriction;
257
+ _GeometryRestriction_eventEngine = new WeakMap(), _GeometryRestriction_rayCasterParams = new WeakMap(), _GeometryRestriction_raycaster = new WeakMap(), _GeometryRestriction_viewport = new WeakMap(), _GeometryRestriction_geometryMathManager = new WeakMap(), _GeometryRestriction_lineIntersectionPercentage = new WeakMap(), _GeometryRestriction_nodes = new WeakMap(), _GeometryRestriction_pointIntersectionPercentage = new WeakMap(), _GeometryRestriction_sceneBoundingSphereRadius = new WeakMap(), _GeometryRestriction_settings = new WeakMap(), _GeometryRestriction_snapRestrictions = new WeakMap(), _GeometryRestriction_snapToEdges = new WeakMap(), _GeometryRestriction_snapToFaces = new WeakMap(), _GeometryRestriction_snapToVertices = new WeakMap(), _GeometryRestriction_visualizationObject = new WeakMap(), _GeometryRestriction_wireframe = new WeakMap(), _GeometryRestriction_wireframeColor = new WeakMap();
258
+ // #endregion Classes (1)
259
+ //# sourceMappingURL=GeometryRestriction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeometryRestriction.js","sourceRoot":"","sources":["../../../../src/implementation/restrictions/geometry/GeometryRestriction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,gEAA6D;AAC7D,uEAAqD;AACrD,+EAA4E;AAY5E,+CAA6D;AAE7D,yCAAiC;AAmBjC,8BAA8B;AAE9B,sBAAsB;AAEtB,MAAa,mBAAoB,SAAQ,yCAAmB;IA6BxD,6BAA6B;IAE7B,2BAA2B;IAE3B,YAAY,QAAsB,EAAE,mBAAwC,EAAE,UAAqB,EAAE,EAAU,EAAE,QAAgC,EAAE,UAAyC;;QACxL,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QAjChD,0BAA0B;QAE1B,2CAAqC,oCAAW,CAAC,QAAQ,EAAC;QAC1D,+CAAuD;YACnD,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;YACtB,KAAK,EAAE,EAAE,SAAS,E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,CAAC;CAGJ;AA1PD,kDA0PC;;AAED,yBAAyB"}
@@ -0,0 +1,28 @@
1
+ import { AbstractRestriction } from '../AbstractRestriction';
2
+ import { GeometryMathManager } from '../../GeometryMathManager';
3
+ import { IRay } from '@shapediver/viewer.rendering-engine.intersection-engine';
4
+ import { IRestriction, RestrictionMetaData, RestrictionPropertiesBase, RestrictionResult } from '../../../interfaces/IRestriction';
5
+ import { ISnapRestriction } from '../../../interfaces/ISnapRestriction';
6
+ import { ITreeNode } from '@shapediver/viewer.shared.node-tree';
7
+ import { IViewportApi } from '@shapediver/viewer';
8
+ import { IVisualizationSettings } from '../../../interfaces/IVisualizationSettings';
9
+ import { vec3 } from 'gl-matrix';
10
+ export declare type LineRestrictionProperties = {
11
+ point1: vec3;
12
+ point2: vec3;
13
+ radius?: number;
14
+ } & RestrictionPropertiesBase;
15
+ export declare class LineRestriction extends AbstractRestriction implements IRestriction {
16
+ #private;
17
+ constructor(viewport: IViewportApi, geometryMathManager: GeometryMathManager, parentNode: ITreeNode, id: string, settings: IVisualizationSettings, properties: LineRestrictionProperties);
18
+ get point1(): vec3;
19
+ get point2(): vec3;
20
+ get priority(): number;
21
+ get radius(): number;
22
+ get snapRestrictions(): {
23
+ [key: string]: ISnapRestriction;
24
+ };
25
+ rayTrace(ray: IRay, metaData?: RestrictionMetaData): RestrictionResult | undefined;
26
+ protected visibilityChanged(): void;
27
+ }
28
+ //# sourceMappingURL=LineRestriction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineRestriction.d.ts","sourceRoot":"","sources":["../../../../src/implementation/restrictions/line/LineRestriction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,yDAAyD,CAAC;AAC/E,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,oBAAY,yBAAyB,GAAG;IACpC,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,yBAAyB,CAAC;AAM9B,qBAAa,eAAgB,SAAQ,mBAAoB,YAAW,YAAY;;gBAgBhE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,UAAU,EAAE,yBAAyB;IAoBxL,IAAW,MAAM,IAAI,IAAI,CAExB;IAED,IAAW,MAAM,IAAI,IAAI,CAExB;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,gBAAgB,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;KAAE,CAElE;IAMM,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,GAAG,SAAS;IA0CzF,SAAS,CAAC,iBAAiB,IAAI,IAAI;CAGtC"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ 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");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _LineRestriction_viewport, _LineRestriction_dragLineLength, _LineRestriction_dragRay, _LineRestriction_point1, _LineRestriction_point2, _LineRestriction_radius, _LineRestriction_snapRestrictions;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.LineRestriction = void 0;
16
+ const AbstractRestriction_1 = require("../AbstractRestriction");
17
+ const gl_matrix_1 = require("gl-matrix");
18
+ // #endregion Type aliases (1)
19
+ // #region Classes (1)
20
+ class LineRestriction extends AbstractRestriction_1.AbstractRestriction {
21
+ // #endregion Properties (7)
22
+ // #region Constructors (1)
23
+ constructor(viewport, geometryMathManager, parentNode, id, settings, properties) {
24
+ super(viewport, parentNode, id, properties);
25
+ // #region Properties (7)
26
+ _LineRestriction_viewport.set(this, void 0);
27
+ _LineRestriction_dragLineLength.set(this, void 0);
28
+ _LineRestriction_dragRay.set(this, void 0);
29
+ _LineRestriction_point1.set(this, void 0);
30
+ _LineRestriction_point2.set(this, void 0);
31
+ _LineRestriction_radius.set(this, void 0);
32
+ _LineRestriction_snapRestrictions.set(this, {});
33
+ __classPrivateFieldSet(this, _LineRestriction_viewport, viewport, "f");
34
+ __classPrivateFieldSet(this, _LineRestriction_point1, properties.point1, "f");
35
+ __classPrivateFieldSet(this, _LineRestriction_point2, properties.point2, "f");
36
+ __classPrivateFieldSet(this, _LineRestriction_radius, properties.radius || 0, "f");
37
+ const direction = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _LineRestriction_point2, "f"), __classPrivateFieldGet(this, _LineRestriction_point1, "f"));
38
+ __classPrivateFieldSet(this, _LineRestriction_dragLineLength, gl_matrix_1.vec3.length(direction), "f");
39
+ __classPrivateFieldSet(this, _LineRestriction_dragRay, {
40
+ origin: __classPrivateFieldGet(this, _LineRestriction_point1, "f"),
41
+ 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")))
42
+ }, "f");
43
+ }
44
+ // #endregion Constructors (1)
45
+ // #region Public Getters And Setters (5)
46
+ get point1() {
47
+ return __classPrivateFieldGet(this, _LineRestriction_point1, "f");
48
+ }
49
+ get point2() {
50
+ return __classPrivateFieldGet(this, _LineRestriction_point2, "f");
51
+ }
52
+ get priority() {
53
+ return -1;
54
+ }
55
+ get radius() {
56
+ return __classPrivateFieldGet(this, _LineRestriction_radius, "f");
57
+ }
58
+ get snapRestrictions() {
59
+ return __classPrivateFieldGet(this, _LineRestriction_snapRestrictions, "f");
60
+ }
61
+ // #endregion Public Getters And Setters (5)
62
+ // #region Public Methods (1)
63
+ rayTrace(ray, metaData) {
64
+ const planeNormal = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), ray.direction, __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").direction);
65
+ 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));
66
+ 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));
67
+ 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);
68
+ 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);
69
+ let pointA = gl_matrix_1.vec3.create();
70
+ if (da < 0) {
71
+ gl_matrix_1.vec3.copy(pointA, ray.origin);
72
+ }
73
+ else {
74
+ 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)));
75
+ }
76
+ let pointB = gl_matrix_1.vec3.create();
77
+ if (db < 0) {
78
+ gl_matrix_1.vec3.copy(pointB, __classPrivateFieldGet(this, _LineRestriction_dragRay, "f").origin);
79
+ }
80
+ else if (db < __classPrivateFieldGet(this, _LineRestriction_dragLineLength, "f")) {
81
+ 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)));
82
+ }
83
+ else {
84
+ gl_matrix_1.vec3.copy(pointB, __classPrivateFieldGet(this, _LineRestriction_point2, "f"));
85
+ }
86
+ const distance = gl_matrix_1.vec3.distance(pointA, pointB);
87
+ if (distance < __classPrivateFieldGet(this, _LineRestriction_radius, "f")) {
88
+ return {
89
+ distance,
90
+ point: pointB,
91
+ closestPointOnRay: pointA,
92
+ restriction: this
93
+ };
94
+ }
95
+ return;
96
+ }
97
+ // #endregion Public Methods (1)
98
+ // #region Protected Methods (1)
99
+ visibilityChanged() { }
100
+ }
101
+ exports.LineRestriction = LineRestriction;
102
+ _LineRestriction_viewport = new WeakMap(), _LineRestriction_dragLineLength = new WeakMap(), _LineRestriction_dragRay = new WeakMap(), _LineRestriction_point1 = new WeakMap(), _LineRestriction_point2 = new WeakMap(), _LineRestriction_radius = new WeakMap(), _LineRestriction_snapRestrictions = new WeakMap();
103
+ // #endregion Classes (1)
104
+ //# sourceMappingURL=LineRestriction.js.map