@xeokit/xeokit-sdk 2.6.0-beta-11 → 2.6.0-beta-13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.0-beta-11",
3
+ "version": "2.6.0-beta-13",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -0,0 +1,135 @@
1
+ const SHRINK_SPEED = 3;
2
+
3
+ /**
4
+ * A PointerCircle shows a circle, centered at the position of the
5
+ * mouse or touch pointer.
6
+ */
7
+ export class PointerCircle {
8
+
9
+ /**
10
+ * Constructs a new PointerCircle.
11
+ * @param viewer The Viewer
12
+ * @param [cfg] PointerCircle configuration.
13
+ * @param [cfg.active=true] Whether PointerCircle is active. The PointerCircle can only be shown when this is `true` (default).
14
+ */
15
+ constructor(viewer, cfg = {}) {
16
+
17
+ this.viewer = viewer;
18
+ this.scene = this.viewer.scene;
19
+ this._circleDiv = document.createElement('div');
20
+ this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._circleDiv, this.viewer.scene.canvas.canvas);
21
+ this._circleDiv.style.backgroundColor = "transparent";
22
+ this._circleDiv.style.border = "2px solid green";
23
+ this._circleDiv.style.borderRadius = "50px";
24
+ this._circleDiv.style.width = "50px";
25
+ this._circleDiv.style.height = "50px";
26
+ this._circleDiv.style.margin = "-200px -200px";
27
+ this._circleDiv.style.zIndex = "100000";
28
+ this._circleDiv.style.position = "absolute";
29
+ this._circleDiv.style.pointerEvents = "none";
30
+
31
+ this._circlePos = null;
32
+
33
+ this._circleMaxRadius = 200;
34
+ this._circleMinRadius = 2;
35
+
36
+ this._active = (cfg.active !== false);
37
+ this._visible = false;
38
+
39
+ this._running = false;
40
+ this._destroyed = false;
41
+ }
42
+
43
+ /**
44
+ * Show the circle at the given canvas coordinates and begin shrinking it.
45
+ */
46
+ start(circlePos) {
47
+ if (this._destroyed) {
48
+ return;
49
+ }
50
+ this._circlePos = circlePos;
51
+ this._running = false;
52
+ this._circleRadius = this._circleMaxRadius;
53
+ this._circleDiv.style.borderRadius = `${this._circleRadius}px`;
54
+ this._circleDiv.style.marginLeft = `${this._circlePos[0] - this._circleRadius}px`;
55
+ this._circleDiv.style.marginTop = `${this._circlePos[1] - this._circleRadius}px`;
56
+
57
+ const startValue = this._circleMaxRadius;
58
+ const endValue = 2;
59
+ let startTime;
60
+ const duration = 300;
61
+
62
+ const animateCircle = (currentTime) => {
63
+ if (!this._running) {
64
+ return;
65
+ }
66
+ if (!startTime) {
67
+ startTime = currentTime;
68
+ }
69
+
70
+ const elapsedTime = currentTime - startTime;
71
+ const progress = Math.min(elapsedTime / duration, 1);
72
+ const interpolatedValue = startValue + (endValue - startValue) * progress;
73
+
74
+ this._circleRadius = interpolatedValue;
75
+ this._circleDiv.style.width = `${this._circleRadius}px`;
76
+ this._circleDiv.style.height = `${this._circleRadius}px`;
77
+ this._circleDiv.style.marginLeft = `${this._circlePos[0] - this._circleRadius / 2}px`;
78
+ this._circleDiv.style.marginTop = `${this._circlePos[1] - this._circleRadius / 2}px`;
79
+
80
+ if (progress < 1) {
81
+ requestAnimationFrame(animateCircle);
82
+ }
83
+ }
84
+ this._running = true;
85
+ requestAnimationFrame(animateCircle);
86
+ this._circleDiv.style.visibility = "visible";
87
+ }
88
+
89
+ /**
90
+ * Stop the shricking circle and hide it.
91
+ */
92
+ stop() {
93
+ if (this._destroyed) {
94
+ return;
95
+ }
96
+ this._running = false;
97
+ this._circleRadius = this._circleMaxRadius;
98
+ this._circleDiv.style.borderRadius = `${this._circleRadius}px`;
99
+ this._circleDiv.style.visibility = "hidden";
100
+ }
101
+
102
+ /**
103
+ * Sets the zoom factor for the lens.
104
+ *
105
+ * This is `2` by default.
106
+ *
107
+ * @param durationMs
108
+ */
109
+ set durationMs(durationMs) {
110
+ this.stop();
111
+ this._durationMs = durationMs;
112
+ }
113
+
114
+ /**
115
+ * Gets the zoom factor for the lens.
116
+ *
117
+ * This is `2` by default.
118
+ *
119
+ * @returns Number
120
+ */
121
+ get durationMs() {
122
+ return this._durationMs;
123
+ }
124
+
125
+ /**
126
+ * Destroys this PointerCircle.
127
+ */
128
+ destroy() {
129
+ if (!this._destroyed) {
130
+ this.stop();
131
+ document.body.removeChild(this._circleDiv);
132
+ this._destroyed = true;
133
+ }
134
+ }
135
+ }
@@ -0,0 +1 @@
1
+ export * from "./PointerCircle.js";
@@ -1,4 +1,5 @@
1
1
  export * from "./ContextMenu/index.js";
2
2
  export * from "./PointerLens/index.js";
3
3
  export * from "./collision/index.js";
4
- export * from "./MarqueePicker/index.js";
4
+ export * from "./MarqueePicker/index.js";
5
+ export * from "./PointerCircle/index.js";
@@ -203,6 +203,46 @@ import {AngleMeasurementsMouseControl} from "./AngleMeasurementsMouseControl.js"
203
203
  * });
204
204
  * });
205
205
  * ````
206
+ *
207
+ * ## Example 5: Creating AngleMeasurements with Touch Input
208
+ *
209
+ * In our fifth example, we'll show how to create angle measurements with touch input, with snapping
210
+ * to the nearest vertex or edge. While creating the measurements, a long-touch when setting the
211
+ * start, corner or end point will cause the point to snap to the nearest vertex or edge. A quick
212
+ * touch-release will immediately set the point at the tapped position on the object surface.
213
+ *
214
+ * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/measurement/#angle_createWithTouch_snapping)]
215
+ *
216
+ * ````javascript
217
+ * import {Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin, AngleMeasurementsTouchControl} from "xeokit-sdk.es.js";
218
+ *
219
+ * const viewer = new Viewer({
220
+ * canvasId: "myCanvas",
221
+ * transparent: true
222
+ * });
223
+ *
224
+ * viewer.scene.camera.eye = [-2.37, 18.97, -26.12];
225
+ * viewer.scene.camera.look = [10.97, 5.82, -11.22];
226
+ * viewer.scene.camera.up = [0.36, 0.83, 0.40];
227
+ *
228
+ * const xktLoader = new XKTLoaderPlugin(viewer);
229
+ *
230
+ * const angleMeasurements = new AngleMeasurementsPlugin(viewer);
231
+ *
232
+ * const model = xktLoader.load({
233
+ * src: "./models/xkt/duplex/duplex.xkt"
234
+ * });
235
+ *
236
+ * const angleMeasurements = new AngleMeasurementsPlugin(viewer);
237
+ *
238
+ * const angleMeasurementsTouchControl = new AngleMeasurementsTouchControl(angleMeasurements, {
239
+ * pointerLens : new PointerLens(viewer),
240
+ * snapToVertex: true,
241
+ * snapToEdge: true
242
+ * })
243
+ *
244
+ * angleMeasurementsTouchControl.activate();
245
+ * ````
206
246
  */
207
247
  export class AngleMeasurementsPlugin extends Plugin {
208
248