@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 @@
1
+ {"version":3,"file":"GridRestriction.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/restrictions/plane/snap/GridRestriction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAEH,SAAS,EACT,YAAY,EAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,yDAAyD,CAAC;AAC/E,OAAO,EACH,mBAAmB,EACnB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC;;GAEG;AACH,oBAAY,yBAAyB,GAAG;IACpC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B,GAAG,yBAAyB,CAAC;AAM9B,qBAAa,eAAgB,SAAQ,uBAAwB,YAAW,gBAAgB;;gBAkBxE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,CAAC,EAAE,yBAAyB;IAuB/K,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED,IAAW,MAAM,CAAC,KAAK,EAAE,OAAO,EAI/B;IAED,IAAW,eAAe,IAAI,OAAO,CAEpC;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,QAAQ,CAAC,KAAK,EAAE,MAAM,EAMhC;IAED,IAAW,gBAAgB,IAAI,OAAO,CAErC;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,QAAQ,CAAC,KAAK,EAAE,MAAM,EAEhC;IAOM,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,mBAAmB,GAAG,iBAAiB,GAAG,SAAS;IA+C1F,qBAAqB,IAAI,IAAI;IASpC,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAYnD,OAAO,CAAC,uBAAuB;IAiD/B,OAAO,CAAC,oBAAoB;CAQ/B"}
@@ -0,0 +1,211 @@
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 _GridRestriction_activationKey, _GridRestriction_planeRestriction, _GridRestriction_active, _GridRestriction_gridHelper, _GridRestriction_gridSize, _GridRestriction_gridUnit, _GridRestriction_gridUnitEditable, _GridRestriction_offsetFromUnit, _GridRestriction_priority;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.GridRestriction = void 0;
39
+ const THREE = __importStar(require("three"));
40
+ const AbstractSnapRestriction_1 = require("../../AbstractSnapRestriction");
41
+ const viewer_1 = require("@shapediver/viewer");
42
+ const gl_matrix_1 = require("gl-matrix");
43
+ // #endregion Type aliases (1)
44
+ // #region Classes (1)
45
+ class GridRestriction extends AbstractSnapRestriction_1.AbstractSnapRestriction {
46
+ // #endregion Properties (9)
47
+ // #region Constructors (1)
48
+ constructor(viewport, geometryMathManager, parentNode, planeRestriction, properties) {
49
+ var _a, _b, _c;
50
+ super(viewport, parentNode, 'grid');
51
+ // #region Properties (9)
52
+ _GridRestriction_activationKey.set(this, void 0);
53
+ _GridRestriction_planeRestriction.set(this, void 0);
54
+ _GridRestriction_active.set(this, false);
55
+ _GridRestriction_gridHelper.set(this, void 0);
56
+ _GridRestriction_gridSize.set(this, 100);
57
+ _GridRestriction_gridUnit.set(this, void 0);
58
+ _GridRestriction_gridUnitEditable.set(this, true);
59
+ _GridRestriction_offsetFromUnit.set(this, gl_matrix_1.vec3.create());
60
+ _GridRestriction_priority.set(this, 0);
61
+ __classPrivateFieldSet(this, _GridRestriction_planeRestriction, planeRestriction, "f");
62
+ __classPrivateFieldSet(this, _GridRestriction_activationKey, (properties === null || properties === void 0 ? void 0 : properties.activationKey) || 'g', "f");
63
+ this.enabled = (_a = properties === null || properties === void 0 ? void 0 : properties.enabled) !== null && _a !== void 0 ? _a : false;
64
+ this._enabledEditable = (_b = properties === null || properties === void 0 ? void 0 : properties.enabledEditable) !== null && _b !== void 0 ? _b : true;
65
+ __classPrivateFieldSet(this, _GridRestriction_gridUnit, (properties === null || properties === void 0 ? void 0 : properties.gridUnit) || 1, "f");
66
+ __classPrivateFieldSet(this, _GridRestriction_gridUnitEditable, (_c = properties === null || properties === void 0 ? void 0 : properties.gridUnitEditable) !== null && _c !== void 0 ? _c : true, "f");
67
+ __classPrivateFieldSet(this, _GridRestriction_priority, (properties === null || properties === void 0 ? void 0 : properties.priority) || 0, "f");
68
+ // create the offset of the grid size to origin
69
+ this.createOffsetFromUnit();
70
+ // calculate offset of grid size to origin
71
+ this.createGridVisualization();
72
+ }
73
+ // #endregion Constructors (1)
74
+ // #region Public Getters And Setters (8)
75
+ get active() {
76
+ return __classPrivateFieldGet(this, _GridRestriction_active, "f");
77
+ }
78
+ set active(value) {
79
+ __classPrivateFieldSet(this, _GridRestriction_active, value, "f");
80
+ if (__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f"))
81
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").visible = value;
82
+ }
83
+ get enabledEditable() {
84
+ return this._enabledEditable;
85
+ }
86
+ get gridUnit() {
87
+ return __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f");
88
+ }
89
+ set gridUnit(value) {
90
+ if (__classPrivateFieldGet(this, _GridRestriction_gridUnitEditable, "f") === false)
91
+ return;
92
+ __classPrivateFieldSet(this, _GridRestriction_gridUnit, value, "f");
93
+ this.createOffsetFromUnit();
94
+ this.createGridVisualization();
95
+ }
96
+ get gridUnitEditable() {
97
+ return __classPrivateFieldGet(this, _GridRestriction_gridUnitEditable, "f");
98
+ }
99
+ get priority() {
100
+ return __classPrivateFieldGet(this, _GridRestriction_priority, "f");
101
+ }
102
+ set priority(value) {
103
+ __classPrivateFieldSet(this, _GridRestriction_priority, value, "f");
104
+ }
105
+ // #endregion Public Getters And Setters (8)
106
+ // #region Public Methods (2)
107
+ // public get
108
+ snap(ray, point, metaData) {
109
+ var _a;
110
+ // if the restriction is not enabled OR the activation key is set and the key is not pressed, return
111
+ if (this.enabled === false && !(((_a = metaData === null || metaData === void 0 ? void 0 : metaData.pressedKeys) === null || _a === void 0 ? void 0 : _a.length) === 1 && (metaData === null || metaData === void 0 ? void 0 : metaData.pressedKeys[0]) === __classPrivateFieldGet(this, _GridRestriction_activationKey, "f")))
112
+ return;
113
+ /**
114
+ * Explanation of the following code:
115
+ * 1. Calculate the projection of the origin onto the plane that is created by the point and the normal
116
+ * 2. Move the grid helper to the projected origin
117
+ */
118
+ // vector from the point to the origin
119
+ const v = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin, point);
120
+ // dot product of the vector and the normal
121
+ const dot = gl_matrix_1.vec3.dot(v, __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal);
122
+ // projection of the origin onto the plane that is created by the point and the normal
123
+ const projectedOrigin = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin, gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal, dot));
124
+ // we move the grid helper to the projected origin
125
+ if (__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f")) {
126
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").position.copy(new THREE.Vector3(projectedOrigin[0], projectedOrigin[1], projectedOrigin[2]));
127
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").visible = false;
128
+ }
129
+ /**
130
+ * Explanation of the following code:
131
+ * 1. Rotate the point so that the normal of the plane is aligned with the Z axis (with previously calculated transformation matrix)
132
+ * 2. Snap the point to the grid
133
+ * 3. Rotate the point back to the original coordinate system (with previously calculated transformation matrix)
134
+ */
135
+ // Apply the transformation to the point
136
+ const rotatedPoint = gl_matrix_1.vec3.transformMat4(gl_matrix_1.vec3.create(), point, __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").transformationToXYPlaneMatrix);
137
+ // Snap the offset to the grid
138
+ const snappedOffset = gl_matrix_1.vec3.create();
139
+ snappedOffset[0] = Math.round(rotatedPoint[0] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) * __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") - __classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[0];
140
+ snappedOffset[1] = Math.round(rotatedPoint[1] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) * __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") - __classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[1];
141
+ snappedOffset[2] = rotatedPoint[2];
142
+ // Move the snapped point back to the original coordinate system
143
+ const snappedPoint = gl_matrix_1.vec3.transformMat4(gl_matrix_1.vec3.create(), snappedOffset, __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").transformationFromXYPlaneMatrix);
144
+ return { point: snappedPoint, restriction: __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f"), snapRestriction: this };
145
+ }
146
+ updatePlaneDefinition() {
147
+ this.createOffsetFromUnit();
148
+ this.createGridVisualization();
149
+ }
150
+ // #endregion Public Methods (2)
151
+ // #region Protected Methods (1)
152
+ visibilityChanged(visible) {
153
+ if (visible === false) {
154
+ if (__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f")) {
155
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").visible = false;
156
+ }
157
+ }
158
+ }
159
+ // #endregion Protected Methods (1)
160
+ // #region Private Methods (2)
161
+ createGridVisualization() {
162
+ if (__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f")) {
163
+ this._object3D.remove(__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f"));
164
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").dispose();
165
+ }
166
+ const bb = new viewer_1.Box();
167
+ for (let i = 0; i < viewer_1.sceneTree.root.children.length; i++) {
168
+ if (viewer_1.sceneTree.root.children[i].sessionNode === true) {
169
+ bb.union(viewer_1.sceneTree.root.children[i].boundingBox);
170
+ }
171
+ }
172
+ const radius = bb.boundingSphere.radius;
173
+ __classPrivateFieldSet(this, _GridRestriction_gridSize, radius * 2, "f");
174
+ if (__classPrivateFieldGet(this, _GridRestriction_gridSize, "f") === Infinity || __classPrivateFieldGet(this, _GridRestriction_gridSize, "f") === -Infinity || isNaN(__classPrivateFieldGet(this, _GridRestriction_gridSize, "f")) || __classPrivateFieldGet(this, _GridRestriction_gridSize, "f") === 0)
175
+ __classPrivateFieldSet(this, _GridRestriction_gridSize, 100, "f");
176
+ // if the grid size is not divisible by the grid unit, we need to adjust the grid size
177
+ let gridSize = __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") * Math.ceil(__classPrivateFieldGet(this, _GridRestriction_gridSize, "f") / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f"));
178
+ // if the number of divisions is odd, we need to add one more division
179
+ if (gridSize / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") % 2 === 1)
180
+ gridSize += __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f");
181
+ // todo adjust grid size so that is divisible by grid unit
182
+ __classPrivateFieldSet(this, _GridRestriction_gridHelper, new THREE.GridHelper(gridSize, gridSize / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f"), 0x666666, 0x222222), "f");
183
+ const adjustedOrigin = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin, __classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f"));
184
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").position.copy(new THREE.Vector3(adjustedOrigin[0], adjustedOrigin[1], adjustedOrigin[2]));
185
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").visible = false;
186
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").renderOrder = 100;
187
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").material.depthTest = false;
188
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").material.transparent = true;
189
+ // three.js uses a right-handed coordinate system, so we need to rotate the grid helper
190
+ const rotationMatrix = new THREE.Matrix4().fromArray([
191
+ __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorU[0], __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorU[1], __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorU[2], 0,
192
+ __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorV[0], __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorV[1], __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").vectorV[2], 0,
193
+ __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal[0], __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal[1], __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").normal[2], 0,
194
+ 0, 0, 0, 1
195
+ ]);
196
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").rotation.setFromRotationMatrix(rotationMatrix);
197
+ // three.js grid helper is created in the XY plane, so we need to rotate it by 90 degrees around the X axis
198
+ __classPrivateFieldGet(this, _GridRestriction_gridHelper, "f").rotateX(Math.PI / 2);
199
+ this._object3D.add(__classPrivateFieldGet(this, _GridRestriction_gridHelper, "f"));
200
+ }
201
+ createOffsetFromUnit() {
202
+ // Calculate the offset of the rotated point from the rotated origin
203
+ __classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[0] = __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") * Math.round(__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[0] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) - __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[0];
204
+ __classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[1] = __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") * Math.round(__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[1] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) - __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[1];
205
+ __classPrivateFieldGet(this, _GridRestriction_offsetFromUnit, "f")[2] = __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f") * Math.round(__classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[2] / __classPrivateFieldGet(this, _GridRestriction_gridUnit, "f")) - __classPrivateFieldGet(this, _GridRestriction_planeRestriction, "f").origin[2];
206
+ }
207
+ }
208
+ exports.GridRestriction = GridRestriction;
209
+ _GridRestriction_activationKey = new WeakMap(), _GridRestriction_planeRestriction = new WeakMap(), _GridRestriction_active = new WeakMap(), _GridRestriction_gridHelper = new WeakMap(), _GridRestriction_gridSize = new WeakMap(), _GridRestriction_gridUnit = new WeakMap(), _GridRestriction_gridUnitEditable = new WeakMap(), _GridRestriction_offsetFromUnit = new WeakMap(), _GridRestriction_priority = new WeakMap();
210
+ // #endregion Classes (1)
211
+ //# sourceMappingURL=GridRestriction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GridRestriction.js","sourceRoot":"","sources":["../../../../../src/implementation/restrictions/plane/snap/GridRestriction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,2EAAwE;AACxE,+CAK4B;AAS5B,yCAAiC;AAoBjC,8BAA8B;AAE9B,sBAAsB;AAEtB,MAAa,eAAgB,SAAQ,iDAAuB;IAcxD,4BAA4B;IAE5B,2BAA2B;IAE3B,YAAY,QAAsB,EAAE,mBAAwC,EAAE,UAAqB,EAAE,gBAAkC,EAAE,UAAsC;;QAC3K,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QAlBxC,yBAAyB;QAEzB,iDAAgC;QAChC,oDAA6C;QAE7C,kCAAmB,KAAK,EAAC;QACzB,8CAA+B;QAC/B,oCAAoB,GAAG,EAAC;QACxB,4CAAkB;QAClB,4CAA6B,IAAI,EAAC;QAClC,0CAAwB,gBAAI,CAAC,MAAM,EAAE,EAAC;QACtC,oCAAoB,CAAC,EAAC;QASlB,uBAAA,IAAI,qCAAqB,gBAAgB,MAAA,CAAC;QAE1C,uBAAA,IAAI,kCAAkB,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,aAAa,KAAI,GAAG,MAAA,CAAC;QACv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CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,uBAAA,IAAI,iCAAU,CAAC,GAAG,uBAAA,IAAI,yCAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5I,uBAAA,IAAI,uCAAgB,CAAC,CAAC,CAAC,GAAG,uBAAA,IAAI,iCAAU,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAA,IAAI,yCAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,uBAAA,IAAI,iCAAU,CAAC,GAAG,uBAAA,IAAI,yCAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAChJ,CAAC;CAGJ;AAjND,0CAiNC;;AAED,yBAAyB"}
@@ -0,0 +1,25 @@
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
+ import { vec3 } from 'gl-matrix';
9
+ export declare type PointRestrictionProperties = {
10
+ point: vec3;
11
+ radius?: number;
12
+ } & RestrictionPropertiesBase;
13
+ export declare class PointRestriction extends AbstractRestriction implements IRestriction {
14
+ #private;
15
+ constructor(viewport: IViewportApi, geometryMathManager: GeometryMathManager, parentNode: ITreeNode, id: string, settings: IVisualizationSettings, properties: PointRestrictionProperties);
16
+ get point(): vec3;
17
+ get priority(): number;
18
+ get radius(): number;
19
+ get snapRestrictions(): {
20
+ [key: string]: ISnapRestriction;
21
+ };
22
+ rayTrace(ray: IRay, metaData?: RestrictionMetaData): RestrictionResult | undefined;
23
+ protected visibilityChanged(): void;
24
+ }
25
+ //# sourceMappingURL=PointRestriction.d.ts.map
@@ -0,0 +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,IAAI;CAGtC"}
@@ -0,0 +1,78 @@
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 _PointRestriction_viewport, _PointRestriction_point, _PointRestriction_radius, _PointRestriction_snapRestrictions;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PointRestriction = 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 PointRestriction extends AbstractRestriction_1.AbstractRestriction {
21
+ // #endregion Properties (4)
22
+ // #region Constructors (1)
23
+ constructor(viewport, geometryMathManager, parentNode, id, settings, properties) {
24
+ super(viewport, parentNode, id, properties);
25
+ // #region Properties (4)
26
+ _PointRestriction_viewport.set(this, void 0);
27
+ _PointRestriction_point.set(this, void 0);
28
+ _PointRestriction_radius.set(this, void 0);
29
+ _PointRestriction_snapRestrictions.set(this, {});
30
+ __classPrivateFieldSet(this, _PointRestriction_viewport, viewport, "f");
31
+ __classPrivateFieldSet(this, _PointRestriction_point, properties.point, "f");
32
+ __classPrivateFieldSet(this, _PointRestriction_radius, properties.radius || 0, "f");
33
+ }
34
+ // #endregion Constructors (1)
35
+ // #region Public Getters And Setters (4)
36
+ get point() {
37
+ return __classPrivateFieldGet(this, _PointRestriction_point, "f");
38
+ }
39
+ get priority() {
40
+ return -1;
41
+ }
42
+ get radius() {
43
+ return __classPrivateFieldGet(this, _PointRestriction_radius, "f");
44
+ }
45
+ get snapRestrictions() {
46
+ return __classPrivateFieldGet(this, _PointRestriction_snapRestrictions, "f");
47
+ }
48
+ // #endregion Public Getters And Setters (4)
49
+ // #region Public Methods (1)
50
+ rayTrace(ray, metaData) {
51
+ const closestPoint = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), __classPrivateFieldGet(this, _PointRestriction_point, "f"), ray.origin);
52
+ const directionDistance = gl_matrix_1.vec3.dot(closestPoint, ray.direction);
53
+ if (directionDistance < 0) {
54
+ gl_matrix_1.vec3.copy(closestPoint, ray.origin);
55
+ }
56
+ else {
57
+ gl_matrix_1.vec3.multiply(closestPoint, gl_matrix_1.vec3.copy(closestPoint, ray.direction), gl_matrix_1.vec3.fromValues(directionDistance, directionDistance, directionDistance));
58
+ gl_matrix_1.vec3.add(closestPoint, closestPoint, ray.origin);
59
+ }
60
+ const distance = gl_matrix_1.vec3.distance(closestPoint, __classPrivateFieldGet(this, _PointRestriction_point, "f"));
61
+ if (distance < __classPrivateFieldGet(this, _PointRestriction_radius, "f")) {
62
+ return {
63
+ distance,
64
+ point: __classPrivateFieldGet(this, _PointRestriction_point, "f"),
65
+ closestPointOnRay: closestPoint,
66
+ restriction: this,
67
+ };
68
+ }
69
+ return;
70
+ }
71
+ // #endregion Public Methods (1)
72
+ // #region Protected Methods (1)
73
+ visibilityChanged() { }
74
+ }
75
+ exports.PointRestriction = PointRestriction;
76
+ _PointRestriction_viewport = new WeakMap(), _PointRestriction_point = new WeakMap(), _PointRestriction_radius = new WeakMap(), _PointRestriction_snapRestrictions = new WeakMap();
77
+ // #endregion Classes (1)
78
+ //# sourceMappingURL=PointRestriction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PointRestriction.js","sourceRoot":"","sources":["../../../../src/implementation/restrictions/point/PointRestriction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAA6D;AAY7D,yCAAiC;AASjC,8BAA8B;AAE9B,sBAAsB;AAEtB,MAAa,gBAAiB,SAAQ,yCAAmB;IASrD,4BAA4B;IAE5B,2BAA2B;IAE3B,YAAY,QAAsB,EAAE,mBAAwC,EAAE,UAAqB,EAAE,EAAU,EAAE,QAAgC,EAAE,UAAsC;QACrL,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QAbhD,yBAAyB;QAEzB,6CAAiC;QAEjC,0CAAa;QACb,2CAAgB;QAChB,6CAAyD,EAAE,EAAC;QASxD,uBAAA,IAAI,8BAAa,QAAQ,MAAA,CAAC;QAC1B,uBAAA,IAAI,2BAAU,UAAU,CAAC,KAAK,MAAA,CAAC;QAC/B,uBAAA,IAAI,4BAAW,UAAU,CAAC,MAAM,IAAI,CAAC,MAAA,CAAC;IAC1C,CAAC;IAED,8BAA8B;IAE9B,yCAAyC;IAEzC,IAAW,KAAK;QACZ,OAAO,uBAAA,IAAI,+BAAO,CAAC;IACvB,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,CAAC,CAAC,CAAC;IACd,CAAC;IAED,IAAW,MAAM;QACb,OAAO,uBAAA,IAAI,gCAAQ,CAAC;IACxB,CAAC;IAED,IAAW,gBAAgB;QACvB,OAAO,uBAAA,IAAI,0CAAkB,CAAC;IAClC,CAAC;IAED,4CAA4C;IAE5C,6BAA6B;IAEtB,QAAQ,CAAC,GAAS,EAAE,QAA8B;QACrD,MAAM,YAAY,GAAG,gBAAI,CAAC,GAAG,CAAC,gBAAI,CAAC,MAAM,EAAE,EAAE,uBAAA,IAAI,+BAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QACtE,MAAM,iBAAiB,GAAG,gBAAI,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;QAEhE,IAAI,iBAAiB,GAAG,CAAC,EAAE;YACvB,gBAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;SACvC;aAAM;YACH,gBAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,gBAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,gBAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;YAC9I,gBAAI,CAAC,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;SACpD;QAED,MAAM,QAAQ,GAAG,gBAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,uBAAA,IAAI,+BAAO,CAAC,CAAC;QAC1D,IAAI,QAAQ,GAAG,uBAAA,IAAI,gCAAQ,EAAE;YACzB,OAAO;gBACH,QAAQ;gBACR,KAAK,EAAE,uBAAA,IAAI,+BAAO;gBAClB,iBAAiB,EAAE,YAAY;gBAC/B,WAAW,EAAE,IAAI;aACpB,CAAC;SACL;QACD,OAAO;IACX,CAAC;IAED,gCAAgC;IAEhC,gCAAgC;IAEtB,iBAAiB,KAAW,CAAC;CAG1C;AA3ED,4CA2EC;;AAED,yBAAyB"}
@@ -0,0 +1,30 @@
1
+ import { AngularRestrictionApi } from './api/implementation/plane/snap/AngularRestrictionApi';
2
+ import { AngularRestrictionProperties } from './implementation/restrictions/plane/snap/AngularRestriction';
3
+ import { AxisRestrictionApi } from './api/implementation/plane/snap/AxisRestrictionApi';
4
+ import { AxisRestrictionProperties } from './implementation/restrictions/plane/snap/AxisRestriction';
5
+ import { CameraPlaneRestriction, CameraPlaneRestrictionProperties } from './implementation/restrictions/camera_plane/CameraPlaneRestriction';
6
+ import { CameraPlaneRestrictionApi } from './api/implementation/camera_plane/CameraPlaneRestrictionApi';
7
+ import { DraggingRestrictionMetaData, DrawingRestrictionMetaData, IRestriction, RayTraceResult, RESTRICTION_TYPE, RestrictionMetaData, RestrictionProperties } from './interfaces/IRestriction';
8
+ import { EventManager } from './implementation/EventManager';
9
+ import { GeometryMathManager } from './implementation/GeometryMathManager';
10
+ import { GeometryRestriction, GeometryRestrictionProperties } from './implementation/restrictions/geometry/GeometryRestriction';
11
+ import { GeometryRestrictionApi } from './api/implementation/geometry/GeometryRestrictionApi';
12
+ import { GridRestrictionApi } from './api/implementation/plane/snap/GridRestrictionApi';
13
+ import { GridRestrictionProperties } from './implementation/restrictions/plane/snap/GridRestriction';
14
+ import { IDragAnchor } from './interfaces/IDragAnchor';
15
+ import { IRestrictionApi } from './api/interfaces/IRestrictionApi';
16
+ import { IRestrictionManager } from './interfaces/IRestrictionManager';
17
+ import { ISnapRestriction, SnapRestrictionProperties } from './interfaces/ISnapRestriction';
18
+ import { ISnapRestrictionApi } from './api/interfaces/ISnapRestrictionApi';
19
+ import { IVisualizationSettings } from './interfaces/IVisualizationSettings';
20
+ import { LineRestriction, LineRestrictionProperties } from './implementation/restrictions/line/LineRestriction';
21
+ import { LineRestrictionApi } from './api/implementation/line/LineRestrictionApi';
22
+ import { PlaneRestriction, PlaneRestrictionProperties } from './implementation/restrictions/plane/PlaneRestriction';
23
+ import { PlaneRestrictionApi } from './api/implementation/plane/PlaneRestrictionApi';
24
+ import { PointRestriction, PointRestrictionProperties } from './implementation/restrictions/point/PointRestriction';
25
+ import { PointRestrictionApi } from './api/implementation/point/PointRestrictionApi';
26
+ import { RestrictionManager } from './implementation/RestrictionManager';
27
+ export { IRestrictionManager, RestrictionManager, EventManager, GeometryMathManager, IDragAnchor, IRestriction, ISnapRestriction, IVisualizationSettings };
28
+ export { RESTRICTION_TYPE, RayTraceResult, RestrictionProperties, RestrictionMetaData, DrawingRestrictionMetaData, DraggingRestrictionMetaData, SnapRestrictionProperties, PlaneRestriction, PlaneRestrictionProperties, AngularRestrictionProperties, AxisRestrictionProperties, GridRestrictionProperties, GeometryRestriction, GeometryRestrictionProperties, PointRestriction, PointRestrictionProperties, LineRestriction, LineRestrictionProperties, CameraPlaneRestriction, CameraPlaneRestrictionProperties };
29
+ export { IRestrictionApi, ISnapRestrictionApi, PlaneRestrictionApi, AngularRestrictionApi, AxisRestrictionApi, GridRestrictionApi, GeometryRestrictionApi, CameraPlaneRestrictionApi, PointRestrictionApi, LineRestrictionApi };
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAC9F,OAAO,EAAE,4BAA4B,EAAE,MAAM,6DAA6D,CAAC;AAC3G,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAC;AACrG,OAAO,EAAE,sBAAsB,EAAE,gCAAgC,EAAE,MAAM,mEAAmE,CAAC;AAC7I,OAAO,EAAE,yBAAyB,EAAE,MAAM,6DAA6D,CAAC;AACxG,OAAO,EACH,2BAA2B,EAC3B,0BAA0B,EAC1B,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,4DAA4D,CAAC;AAChI,OAAO,EAAE,sBAAsB,EAAE,MAAM,sDAAsD,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAC;AACrG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,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AAyB,EAAE,mBAAmB,EAAE,kBAAkB,EACjL,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LineRestrictionApi = exports.PointRestrictionApi = exports.CameraPlaneRestrictionApi = exports.GeometryRestrictionApi = exports.GridRestrictionApi = exports.AxisRestrictionApi = exports.AngularRestrictionApi = exports.PlaneRestrictionApi = exports.CameraPlaneRestriction = exports.LineRestriction = exports.PointRestriction = exports.GeometryRestriction = exports.PlaneRestriction = exports.RESTRICTION_TYPE = exports.GeometryMathManager = exports.EventManager = exports.RestrictionManager = void 0;
4
+ const AngularRestrictionApi_1 = require("./api/implementation/plane/snap/AngularRestrictionApi");
5
+ Object.defineProperty(exports, "AngularRestrictionApi", { enumerable: true, get: function () { return AngularRestrictionApi_1.AngularRestrictionApi; } });
6
+ const AxisRestrictionApi_1 = require("./api/implementation/plane/snap/AxisRestrictionApi");
7
+ Object.defineProperty(exports, "AxisRestrictionApi", { enumerable: true, get: function () { return AxisRestrictionApi_1.AxisRestrictionApi; } });
8
+ const CameraPlaneRestriction_1 = require("./implementation/restrictions/camera_plane/CameraPlaneRestriction");
9
+ Object.defineProperty(exports, "CameraPlaneRestriction", { enumerable: true, get: function () { return CameraPlaneRestriction_1.CameraPlaneRestriction; } });
10
+ const CameraPlaneRestrictionApi_1 = require("./api/implementation/camera_plane/CameraPlaneRestrictionApi");
11
+ Object.defineProperty(exports, "CameraPlaneRestrictionApi", { enumerable: true, get: function () { return CameraPlaneRestrictionApi_1.CameraPlaneRestrictionApi; } });
12
+ const IRestriction_1 = require("./interfaces/IRestriction");
13
+ Object.defineProperty(exports, "RESTRICTION_TYPE", { enumerable: true, get: function () { return IRestriction_1.RESTRICTION_TYPE; } });
14
+ const EventManager_1 = require("./implementation/EventManager");
15
+ Object.defineProperty(exports, "EventManager", { enumerable: true, get: function () { return EventManager_1.EventManager; } });
16
+ const GeometryMathManager_1 = require("./implementation/GeometryMathManager");
17
+ Object.defineProperty(exports, "GeometryMathManager", { enumerable: true, get: function () { return GeometryMathManager_1.GeometryMathManager; } });
18
+ const GeometryRestriction_1 = require("./implementation/restrictions/geometry/GeometryRestriction");
19
+ Object.defineProperty(exports, "GeometryRestriction", { enumerable: true, get: function () { return GeometryRestriction_1.GeometryRestriction; } });
20
+ const GeometryRestrictionApi_1 = require("./api/implementation/geometry/GeometryRestrictionApi");
21
+ Object.defineProperty(exports, "GeometryRestrictionApi", { enumerable: true, get: function () { return GeometryRestrictionApi_1.GeometryRestrictionApi; } });
22
+ const GridRestrictionApi_1 = require("./api/implementation/plane/snap/GridRestrictionApi");
23
+ Object.defineProperty(exports, "GridRestrictionApi", { enumerable: true, get: function () { return GridRestrictionApi_1.GridRestrictionApi; } });
24
+ const LineRestriction_1 = require("./implementation/restrictions/line/LineRestriction");
25
+ Object.defineProperty(exports, "LineRestriction", { enumerable: true, get: function () { return LineRestriction_1.LineRestriction; } });
26
+ const LineRestrictionApi_1 = require("./api/implementation/line/LineRestrictionApi");
27
+ Object.defineProperty(exports, "LineRestrictionApi", { enumerable: true, get: function () { return LineRestrictionApi_1.LineRestrictionApi; } });
28
+ const PlaneRestriction_1 = require("./implementation/restrictions/plane/PlaneRestriction");
29
+ Object.defineProperty(exports, "PlaneRestriction", { enumerable: true, get: function () { return PlaneRestriction_1.PlaneRestriction; } });
30
+ const PlaneRestrictionApi_1 = require("./api/implementation/plane/PlaneRestrictionApi");
31
+ Object.defineProperty(exports, "PlaneRestrictionApi", { enumerable: true, get: function () { return PlaneRestrictionApi_1.PlaneRestrictionApi; } });
32
+ const PointRestriction_1 = require("./implementation/restrictions/point/PointRestriction");
33
+ Object.defineProperty(exports, "PointRestriction", { enumerable: true, get: function () { return PointRestriction_1.PointRestriction; } });
34
+ const PointRestrictionApi_1 = require("./api/implementation/point/PointRestrictionApi");
35
+ Object.defineProperty(exports, "PointRestrictionApi", { enumerable: true, get: function () { return PointRestrictionApi_1.PointRestrictionApi; } });
36
+ const RestrictionManager_1 = require("./implementation/RestrictionManager");
37
+ Object.defineProperty(exports, "RestrictionManager", { enumerable: true, get: function () { return RestrictionManager_1.RestrictionManager; } });
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iGAA8F;AAqDrE,sGArDhB,6CAAqB,OAqDgB;AAnD9C,2FAAwF;AAmDxC,mGAnDvC,uCAAkB,OAmDuC;AAjDlE,8GAA6I;AA4CzI,uGA5CK,+CAAsB,OA4CL;AA3C1B,2GAAwG;AAgDQ,0GAhDvG,qDAAyB,OAgDuG;AA/CzI,4DAQmC;AA2B/B,iGA9BA,+BAAgB,OA8BA;AA1BpB,gEAA6D;AAqBhB,6FArBpC,2BAAY,OAqBoC;AApBzD,8EAA2E;AAoBhB,oGApBlD,yCAAmB,OAoBkD;AAnB9E,oGAAgI;AA4B5H,oGA5BK,yCAAmB,OA4BL;AA3BvB,iGAA8F;AAmCN,uGAnC/E,+CAAsB,OAmC+E;AAlC9G,2FAAwF;AAkCpB,mGAlC3D,uCAAkB,OAkC2D;AA1BtF,wFAAgH;AAoB5G,gGApBK,iCAAe,OAoBL;AAnBnB,qFAAkF;AAyB8E,mGAzBvJ,uCAAkB,OAyBuJ;AAxBlL,2FAAoH;AAchH,iGAdK,mCAAgB,OAcL;AAbpB,wFAAqF;AAuBjF,oGAvBK,yCAAmB,OAuBL;AAtBvB,2FAAoH;AAehH,iGAfK,mCAAgB,OAeL;AAdpB,wFAAqF;AAqBsD,oGArBlI,yCAAmB,OAqBkI;AApB9J,4EAAyE;AAGhD,mGAHhB,uCAAkB,OAGgB"}
@@ -0,0 +1,9 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ export interface IDragAnchor {
3
+ position: vec3;
4
+ rotation?: {
5
+ axis: vec3;
6
+ angle: number;
7
+ };
8
+ }
9
+ //# sourceMappingURL=IDragAnchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDragAnchor.d.ts","sourceRoot":"","sources":["../../src/interfaces/IDragAnchor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,WAAW,WAAW;IAGxB,QAAQ,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE;QACP,IAAI,EAAE,IAAI,CAAC;QACX,KAAK,EAAE,MAAM,CAAA;KAChB,CAAA;CAGJ"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IDragAnchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDragAnchor.js","sourceRoot":"","sources":["../../src/interfaces/IDragAnchor.ts"],"names":[],"mappings":""}
@@ -0,0 +1,89 @@
1
+ import { IDragAnchor } from './IDragAnchor';
2
+ import { IRay } from '@shapediver/viewer.rendering-engine.intersection-engine';
3
+ import { ISnapRestriction } from './ISnapRestriction';
4
+ import { ITreeNode } from '@shapediver/viewer.shared.node-tree';
5
+ import { mat4, vec3 } from 'gl-matrix';
6
+ import { PointRestrictionProperties } from '../implementation/restrictions/point/PointRestriction';
7
+ import { CameraPlaneRestrictionProperties } from '../implementation/restrictions/camera_plane/CameraPlaneRestriction';
8
+ import { GeometryRestrictionProperties } from '../implementation/restrictions/geometry/GeometryRestriction';
9
+ import { LineRestrictionProperties } from '../implementation/restrictions/line/LineRestriction';
10
+ import { PlaneRestrictionProperties } from '../implementation/restrictions/plane/PlaneRestriction';
11
+ export declare type RayTraceResult = {
12
+ distance?: number;
13
+ transformation?: mat4;
14
+ dragAnchor?: IDragAnchor;
15
+ point: vec3;
16
+ restriction: IRestriction | ISnapRestriction;
17
+ };
18
+ export declare type RestrictionProperties = PointRestrictionProperties | PlaneRestrictionProperties | LineRestrictionProperties | GeometryRestrictionProperties | CameraPlaneRestrictionProperties;
19
+ export declare type RestrictionPropertiesBase = {
20
+ id?: string;
21
+ /**
22
+ * Type of the restriction
23
+ */
24
+ type: RESTRICTION_TYPE;
25
+ rotation?: {
26
+ axis: vec3;
27
+ angle: number;
28
+ };
29
+ };
30
+ export declare type RestrictionResult = {
31
+ point: vec3;
32
+ closestPointOnRay?: vec3;
33
+ distance?: number;
34
+ restriction: IRestriction;
35
+ snapRestriction?: ISnapRestriction;
36
+ };
37
+ export interface DraggingRestrictionMetaData extends RestrictionMetaData {
38
+ dragAnchors?: IDragAnchor[];
39
+ dragOrigin: vec3;
40
+ node: ITreeNode;
41
+ type: 'dragging';
42
+ }
43
+ export interface DrawingRestrictionMetaData extends RestrictionMetaData {
44
+ index?: number;
45
+ positionArray?: Float32Array;
46
+ type: 'drawing';
47
+ }
48
+ export interface IRestriction {
49
+ readonly id: string;
50
+ readonly priority: number;
51
+ readonly snapRestrictions: {
52
+ [key: string]: ISnapRestriction;
53
+ };
54
+ readonly type: RESTRICTION_TYPE;
55
+ enabled: boolean;
56
+ rotation: {
57
+ axis: vec3;
58
+ angle: number;
59
+ };
60
+ showVisualization: boolean;
61
+ /**
62
+ * Ray trace the restriction.
63
+ * If the ray does not intersect the restriction, the method returns undefined.
64
+ *
65
+ * @param ray The ray to trace.
66
+ * @param metaData The meta data of the ray.
67
+ * @returns The intersection point of the ray with the restriction.
68
+ */
69
+ rayTrace(ray: IRay, metaData?: RestrictionMetaData): RestrictionResult | undefined;
70
+ /**
71
+ * Remove the visualization of the restriction.
72
+ */
73
+ removeVisualization(): void;
74
+ }
75
+ export interface RestrictionMetaData {
76
+ pressedKeys?: string[];
77
+ startPoint?: vec3;
78
+ type: 'drawing' | 'dragging';
79
+ }
80
+ export declare enum RESTRICTION_TYPE {
81
+ PLANE = "plane",
82
+ GEOMETRY = "geometry",
83
+ POINT = "point",
84
+ LINE = "line",
85
+ CAMERA_PLANE = "camera_plane"
86
+ }
87
+ export declare const isDrawingRestriction: (metaData?: RestrictionMetaData) => metaData is DrawingRestrictionMetaData;
88
+ export declare const isDraggingRestriction: (metaData?: RestrictionMetaData) => metaData is DraggingRestrictionMetaData;
89
+ //# sourceMappingURL=IRestriction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRestriction.d.ts","sourceRoot":"","sources":["../../src/interfaces/IRestriction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,yDAAyD,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,uDAAuD,CAAC;AACnG,OAAO,EAAE,gCAAgC,EAAE,MAAM,oEAAoE,CAAC;AACtH,OAAO,EAAE,6BAA6B,EAAE,MAAM,6DAA6D,CAAC;AAC5G,OAAO,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAC;AAChG,OAAO,EAAE,0BAA0B,EAAE,MAAM,uDAAuD,CAAC;AAInG,oBAAY,cAAc,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,WAAW,EAAE,YAAY,GAAG,gBAAgB,CAAA;CAAE,CAAC;AAC/J,oBAAY,qBAAqB,GAAG,0BAA0B,GAAG,0BAA0B,GAAG,yBAAyB,GAAG,6BAA6B,GAAG,gCAAgC,CAAC;AAC3L,oBAAY,yBAAyB,GAAG;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,gBAAgB,CAAC;IAEvB,QAAQ,CAAC,EAAE;QACP,IAAI,EAAE,IAAI,CAAC;QACX,KAAK,EAAE,MAAM,CAAA;KAChB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CAAC,EAAE,IAAI,CAAC;IAClB,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;CAGhC;AAMD,oBAAY,gBAAgB;IACxB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,YAAY,iBAAiB;CAChC;AAMD,eAAO,MAAM,oBAAoB,cAAe,mBAAmB,2CAElE,CAAC;AACF,eAAO,MAAM,qBAAqB,cAAe,mBAAmB,4CAEnE,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDraggingRestriction = exports.isDrawingRestriction = exports.RESTRICTION_TYPE = void 0;
4
+ // #endregion Interfaces (4)
5
+ // #region Enums (1)
6
+ var RESTRICTION_TYPE;
7
+ (function (RESTRICTION_TYPE) {
8
+ RESTRICTION_TYPE["PLANE"] = "plane";
9
+ RESTRICTION_TYPE["GEOMETRY"] = "geometry";
10
+ RESTRICTION_TYPE["POINT"] = "point";
11
+ RESTRICTION_TYPE["LINE"] = "line";
12
+ RESTRICTION_TYPE["CAMERA_PLANE"] = "camera_plane";
13
+ })(RESTRICTION_TYPE = exports.RESTRICTION_TYPE || (exports.RESTRICTION_TYPE = {}));
14
+ // #endregion Enums (1)
15
+ // #region Variables (2)
16
+ const isDrawingRestriction = (metaData) => {
17
+ return (metaData === null || metaData === void 0 ? void 0 : metaData.type) === 'drawing';
18
+ };
19
+ exports.isDrawingRestriction = isDrawingRestriction;
20
+ const isDraggingRestriction = (metaData) => {
21
+ return (metaData === null || metaData === void 0 ? void 0 : metaData.type) === 'dragging';
22
+ };
23
+ exports.isDraggingRestriction = isDraggingRestriction;
24
+ // #endregion Variables (2)
25
+ //# sourceMappingURL=IRestriction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRestriction.js","sourceRoot":"","sources":["../../src/interfaces/IRestriction.ts"],"names":[],"mappings":";;;AAqGA,4BAA4B;AAE5B,oBAAoB;AAEpB,IAAY,gBAMX;AAND,WAAY,gBAAgB;IACxB,mCAAe,CAAA;IACf,yCAAqB,CAAA;IACrB,mCAAe,CAAA;IACf,iCAAa,CAAA;IACb,iDAA6B,CAAA;AACjC,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAM3B;AAED,uBAAuB;AAEvB,wBAAwB;AAEjB,MAAM,oBAAoB,GAAG,CAAC,QAA8B,EAA0C,EAAE;IAC3G,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,SAAS,CAAC;AACxC,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B;AACK,MAAM,qBAAqB,GAAG,CAAC,QAA8B,EAA2C,EAAE;IAC7G,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,UAAU,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC;AAEF,2BAA2B"}
@@ -0,0 +1,14 @@
1
+ import { DraggingRestrictionMetaData, DrawingRestrictionMetaData, IRestriction, RayTraceResult, RestrictionProperties } from './IRestriction';
2
+ import { IRay } from '@shapediver/viewer.rendering-engine.intersection-engine';
3
+ export interface IRestrictionManager {
4
+ readonly restrictions: {
5
+ [token: string]: IRestriction;
6
+ };
7
+ showRestrictionVisualization: boolean;
8
+ addRestriction(properties: RestrictionProperties): string | undefined;
9
+ close(): void;
10
+ getRestriction(token: string): IRestriction | undefined;
11
+ rayTrace(ray: IRay, metaData?: DrawingRestrictionMetaData | DraggingRestrictionMetaData): RayTraceResult | undefined;
12
+ removeRestriction(token: string): boolean;
13
+ }
14
+ //# sourceMappingURL=IRestrictionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRestrictionManager.d.ts","sourceRoot":"","sources":["../../src/interfaces/IRestrictionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,2BAA2B,EAC3B,0BAA0B,EAC1B,YAAY,EACZ,cAAc,EACd,qBAAqB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,yDAAyD,CAAC;AAE/E,MAAM,WAAW,mBAAmB;IAGhC,QAAQ,CAAC,YAAY,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAA;KAAE,CAAC;IAEzD,4BAA4B,EAAE,OAAO,CAAC;IAMtC,cAAc,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAAC;IACtE,KAAK,IAAI,IAAI,CAAC;IACd,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IACxD,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,0BAA0B,GAAG,2BAA2B,GAAG,cAAc,GAAG,SAAS,CAAC;IACrH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAG7C"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IRestrictionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRestrictionManager.js","sourceRoot":"","sources":["../../src/interfaces/IRestrictionManager.ts"],"names":[],"mappings":""}