@xeokit/xeokit-sdk 2.4.0-alpha-106 → 2.4.0-beta-1
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 +1 -1
- package/src/viewer/scene/model/MeshClusteringManager.js +31 -0
- package/types/extras/PointerLens/PointerLens.d.ts +144 -0
- package/types/extras/PointerLens/index.d.ts +1 -0
- package/types/extras/index.d.ts +1 -0
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsControl.d.ts +78 -56
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.d.ts +93 -0
- package/types/plugins/AngleMeasurementsPlugin/index.d.ts +2 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.d.ts +78 -54
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.d.ts +71 -0
- package/types/plugins/DistanceMeasurementsPlugin/index.d.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export class MeshClusteringManager {
|
|
2
|
+
|
|
3
|
+
constructor(sceneModel) {
|
|
4
|
+
this.sceneModel = sceneModel;
|
|
5
|
+
this.meshes = [];
|
|
6
|
+
this.entities = [];
|
|
7
|
+
this.clusteredMeshes = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
addMeshCfg(meshCfg) {
|
|
11
|
+
this.meshes.push(meshCfg);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addEntityCfg(entityCfg) {
|
|
15
|
+
this.entities.push(entityCfg);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
doClustering() {
|
|
19
|
+
this.clusteredMeshes = this.meshes;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
finalize() {
|
|
23
|
+
this.doClustering();
|
|
24
|
+
for (let i = 0, len = this.clusteredMeshes.length; i < len; i++) {
|
|
25
|
+
this.sceneModel.addMesh(this.clusteredMeshes[i]);
|
|
26
|
+
}
|
|
27
|
+
for (let i = 0, len = this.entities.length; i < len; i++) {
|
|
28
|
+
this.sceneModel.addEntity(this.entities[i]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {Viewer} from "../../viewer";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A PointerLens shows a magnified view of a {@link Viewer}'s canvas, centered at the position of the
|
|
5
|
+
* mouse or touch pointer.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin, AngleMeasurementsMouseControl, PointerLens } from "../../dist/xeokit-sdk.es.js";
|
|
9
|
+
*
|
|
10
|
+
* const viewer = new Viewer({
|
|
11
|
+
* canvasId: "myCanvas",
|
|
12
|
+
* dtxEnabled: true
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* viewer.camera.eye = [-3.93, 2.85, 27.01];
|
|
16
|
+
* viewer.camera.look = [4.40, 3.72, 8.89];
|
|
17
|
+
* viewer.camera.up = [-0.01, 0.99, 0.039];
|
|
18
|
+
*
|
|
19
|
+
* const xktLoader = new XKTLoaderPlugin(viewer);
|
|
20
|
+
*
|
|
21
|
+
* const sceneModel = xktLoader.load({
|
|
22
|
+
* id: "myModel",
|
|
23
|
+
* src: "../../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt",
|
|
24
|
+
* edges: true
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const angleMeasurements = new AngleMeasurementsPlugin(viewer);
|
|
28
|
+
*
|
|
29
|
+
* const angleMeasurementsMouseControl = new AngleMeasurementsMouseControl(angleMeasurements, {
|
|
30
|
+
* pointerLens : new PointerLens(viewer, {
|
|
31
|
+
* zoomFactor: 2
|
|
32
|
+
* })
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* angleMeasurementsMouseControl.activate();
|
|
36
|
+
*/
|
|
37
|
+
export class PointerLens {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Constructs a new PointerLens.
|
|
41
|
+
*
|
|
42
|
+
* @param {Viewer} viewer The Viewer instance.
|
|
43
|
+
* @param {Object} [cfg] PointerLens configuration.
|
|
44
|
+
* @param {boolean} [cfg.active=true] Whether PointerLens is active. The PointerLens can only be shown when this is `true` (default).
|
|
45
|
+
* @param {number} [cfg.zoomFactor=2] The zoom factor for the lens.
|
|
46
|
+
*/
|
|
47
|
+
constructor(viewer: Viewer, cfg?: {
|
|
48
|
+
active?: boolean;
|
|
49
|
+
zoomFactor?: number;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Sets the zoom factor for the lens.
|
|
54
|
+
*
|
|
55
|
+
* This is `2` by default.
|
|
56
|
+
*
|
|
57
|
+
* @param {number} zoomFactor The zoom factor for the lens.
|
|
58
|
+
*/
|
|
59
|
+
set zoomFactor(zoomFactor: number);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Gets the zoom factor for the lens.
|
|
63
|
+
*
|
|
64
|
+
* This is `2` by default.
|
|
65
|
+
*
|
|
66
|
+
* @returns {number} The zoom factor for the lens.
|
|
67
|
+
*/
|
|
68
|
+
get zoomFactor(): number;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Sets the canvas central position of the lens.
|
|
72
|
+
*
|
|
73
|
+
* @param {number[]} centerPos The canvas central position of the lens.
|
|
74
|
+
*/
|
|
75
|
+
set centerPos(centerPos: number[]);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Gets the canvas central position of the lens.
|
|
79
|
+
*
|
|
80
|
+
* @returns {number[]} The canvas central position of the lens.
|
|
81
|
+
*/
|
|
82
|
+
get centerPos(): number[];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Sets the canvas coordinates of the pointer.
|
|
86
|
+
*
|
|
87
|
+
* @param {number[]} cursorPos The canvas coordinates of the pointer.
|
|
88
|
+
*/
|
|
89
|
+
set cursorPos(cursorPos: number[]);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Gets the canvas coordinates of the pointer.
|
|
93
|
+
*
|
|
94
|
+
* @returns {number[]} The canvas coordinates of the pointer.
|
|
95
|
+
*/
|
|
96
|
+
get cursorPos(): number[];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Sets whether the cursor has snapped to anything.
|
|
100
|
+
*
|
|
101
|
+
* @param {boolean} snapped Whether the cursor has snapped to anything.
|
|
102
|
+
*/
|
|
103
|
+
set snapped(snapped: boolean);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Gets whether the cursor has snapped to anything.
|
|
107
|
+
*
|
|
108
|
+
* @returns {boolean} Whether the cursor has snapped to anything.
|
|
109
|
+
*/
|
|
110
|
+
get snapped(): boolean;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Sets if this PointerLens is active.
|
|
114
|
+
*
|
|
115
|
+
* @param {boolean} active Whether this PointerLens is active.
|
|
116
|
+
*/
|
|
117
|
+
set active(active: boolean);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Gets if this PointerLens is active.
|
|
121
|
+
*
|
|
122
|
+
* @returns {boolean} Whether this PointerLens is active.
|
|
123
|
+
*/
|
|
124
|
+
get active(): boolean;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Sets if this PointerLens is visible.
|
|
128
|
+
*
|
|
129
|
+
* @param {boolean} visible Whether this PointerLens is visible.
|
|
130
|
+
*/
|
|
131
|
+
set visible(visible: boolean);
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Gets if this PointerLens is visible.
|
|
135
|
+
*
|
|
136
|
+
* @returns {boolean} Whether this PointerLens is visible.
|
|
137
|
+
*/
|
|
138
|
+
get visible(): boolean;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Destroys this PointerLens.
|
|
142
|
+
*/
|
|
143
|
+
destroy(): void;
|
|
144
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./PointerLens";
|
package/types/extras/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {Component} from "../../viewer/scene/Component";
|
|
2
|
+
import {AngleMeasurement} from "./AngleMeasurement";
|
|
3
|
+
import {AngleMeasurementsPlugin} from "./AngleMeasurementsPlugin";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates {@link AngleMeasurement}s from mouse and touch input.
|
|
@@ -8,60 +8,82 @@ import { AngleMeasurementsPlugin } from "./AngleMeasurementsPlugin";
|
|
|
8
8
|
* Once the AngleMeasurementControl is activated, the first click on any {@link Entity} begins constructing a {@link AngleMeasurement}, fixing its origin to that Entity. The next click on any Entity will complete the AngleMeasurement, fixing its target to that second Entity. The AngleMeasurementControl will then wait for the next click on any Entity, to begin constructing another AngleMeasurement, and so on, until deactivated.
|
|
9
9
|
*/
|
|
10
10
|
export declare class AngleMeasurementsControl extends Component {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** Gets if this AngleMeasurementsControl is currently active, where it is responding to input.
|
|
18
|
-
*
|
|
19
|
-
* @returns {Boolean}
|
|
20
|
-
*/
|
|
21
|
-
get active(): boolean;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Activates this AngleMeasurementsControl, ready to respond to input.
|
|
25
|
-
*/
|
|
26
|
-
activate(): void;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Deactivates this AngleMeasurementsControl, making it unresponsive to input.
|
|
30
|
-
*
|
|
31
|
-
* Destroys any {@link AngleMeasurement} under construction.
|
|
32
|
-
*/
|
|
33
|
-
deactivate(): void;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Resets this AngleMeasurementsControl.
|
|
37
|
-
*
|
|
38
|
-
* Destroys any {@link AngleMeasurement} under construction.
|
|
39
|
-
*
|
|
40
|
-
* Does nothing if the AngleMeasurementsControl is not active.
|
|
41
|
-
*/
|
|
42
|
-
reset(): void;
|
|
11
|
+
/**
|
|
12
|
+
* The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsControl.
|
|
13
|
+
* @type {AngleMeasurementsPlugin}
|
|
14
|
+
*/
|
|
15
|
+
plugin: AngleMeasurementsPlugin;
|
|
43
16
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
19
|
+
*
|
|
20
|
+
* This is `true` by default.
|
|
21
|
+
*
|
|
22
|
+
* Internally, this deactivates then activates the AngleMeasurementsControl when changed, which means that
|
|
23
|
+
* it will destroy any AngleMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
24
|
+
* and rebinds various input handlers.
|
|
25
|
+
*
|
|
26
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this AngleMeasurementsControl.
|
|
27
|
+
*/
|
|
28
|
+
set snapping(snapping: boolean);
|
|
51
29
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
32
|
+
*
|
|
33
|
+
* This is `true` by default.
|
|
34
|
+
*
|
|
35
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
36
|
+
*/
|
|
37
|
+
get snapping(): boolean;
|
|
59
38
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
39
|
+
/** Gets if this AngleMeasurementsControl is currently active, where it is responding to input.
|
|
40
|
+
*
|
|
41
|
+
* @returns {Boolean}
|
|
42
|
+
*/
|
|
43
|
+
get active(): boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Activates this AngleMeasurementsControl, ready to respond to input.
|
|
47
|
+
*/
|
|
48
|
+
activate(): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Deactivates this AngleMeasurementsControl, making it unresponsive to input.
|
|
52
|
+
*
|
|
53
|
+
* Destroys any {@link AngleMeasurement} under construction.
|
|
54
|
+
*/
|
|
55
|
+
deactivate(): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Resets this AngleMeasurementsControl.
|
|
59
|
+
*
|
|
60
|
+
* Destroys any {@link AngleMeasurement} under construction.
|
|
61
|
+
*
|
|
62
|
+
* Does nothing if the AngleMeasurementsControl is not active.
|
|
63
|
+
*/
|
|
64
|
+
reset(): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Fires when the measurement is ended.
|
|
68
|
+
* @param event The measurementEnd event
|
|
69
|
+
* @param callback Called fired on the event
|
|
70
|
+
* @param scope Scope for the callback
|
|
71
|
+
*/
|
|
72
|
+
on(event: "measurementEnd", callback: (measurement: AngleMeasurement) => void, scope?: any): string
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Fires when the measurement is cancelled.
|
|
76
|
+
* @param event The measurementCancel event
|
|
77
|
+
* @param callback Called fired on the event
|
|
78
|
+
* @param scope Scope for the callback
|
|
79
|
+
*/
|
|
80
|
+
on(event: "measurementCancel", callback: (measurement: AngleMeasurement) => void, scope?: any): string
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Fires when the measurement is started.
|
|
84
|
+
* @param event The measurementStart event
|
|
85
|
+
* @param callback Called fired on the event
|
|
86
|
+
* @param scope Scope for the callback
|
|
87
|
+
*/
|
|
88
|
+
on(event: "measurementStart", callback: (measurement: AngleMeasurement) => void, scope?: any): string
|
|
67
89
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { AngleMeasurementsControl } from "./AngleMeasurementsControl.js";
|
|
2
|
+
import { math } from "../../viewer/scene/math/math.js";
|
|
3
|
+
import {AngleMeasurementsPlugin} from "./AngleMeasurementsPlugin";
|
|
4
|
+
import {PointerLens} from "../../extras/PointerLens/PointerLens";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates {@link AngleMeasurement}s in an {@link AngleMeasurementsPlugin} from mouse input.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin, AngleMeasurementsMouseControl, PointerLens } from "xeokit-sdk.es.js";
|
|
11
|
+
*
|
|
12
|
+
* const viewer = new Viewer({
|
|
13
|
+
* canvasId: "myCanvas",
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* viewer.camera.eye = [-3.93, 2.85, 27.01];
|
|
17
|
+
* viewer.camera.look = [4.40, 3.72, 8.89];
|
|
18
|
+
* viewer.camera.up = [-0.01, 0.99, 0.039];
|
|
19
|
+
*
|
|
20
|
+
* const xktLoader = new XKTLoaderPlugin(viewer);
|
|
21
|
+
*
|
|
22
|
+
* const sceneModel = xktLoader.load({
|
|
23
|
+
* id: "myModel",
|
|
24
|
+
* src: "Duplex.xkt"
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const angleMeasurements = new AngleMeasurementsPlugin(viewer);
|
|
28
|
+
*
|
|
29
|
+
* const pointerLens = new PointerLens(viewer); // Create a PointerLens instance
|
|
30
|
+
*
|
|
31
|
+
* const angleMeasurementsMouseControl = new AngleMeasurementsMouseControl(angleMeasurements, {
|
|
32
|
+
* pointerLens: pointerLens,
|
|
33
|
+
* snapping: true
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* angleMeasurementsMouseControl.activate();
|
|
37
|
+
*/
|
|
38
|
+
export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new AngleMeasurementsMouseControl.
|
|
42
|
+
*
|
|
43
|
+
* @param {AngleMeasurementsPlugin} angleMeasurementsPlugin The AngleMeasurementsPlugin to control.
|
|
44
|
+
* @param {Object} [cfg] Configuration options.
|
|
45
|
+
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use for providing a magnified view of the cursor when snapping is enabled.
|
|
46
|
+
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
|
|
47
|
+
*/
|
|
48
|
+
constructor(angleMeasurementsPlugin: AngleMeasurementsPlugin, cfg?: {
|
|
49
|
+
pointerLens?: PointerLens;
|
|
50
|
+
snapping?: boolean;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets whether this AngleMeasurementsMouseControl is currently active, responding to input.
|
|
55
|
+
*
|
|
56
|
+
* @returns {boolean} True if active, false otherwise.
|
|
57
|
+
*/
|
|
58
|
+
get active(): boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
62
|
+
*
|
|
63
|
+
* @param {boolean} snapping True to enable snap-to-vertex and snap-to-edge, false to disable.
|
|
64
|
+
*/
|
|
65
|
+
set snapping(snapping: boolean);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
69
|
+
*
|
|
70
|
+
* @returns {boolean} True if snap-to-vertex and snap-to-edge are enabled, false otherwise.
|
|
71
|
+
*/
|
|
72
|
+
get snapping(): boolean;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Activates this AngleMeasurementsMouseControl, making it responsive to input.
|
|
76
|
+
*/
|
|
77
|
+
activate(): void;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Deactivates this AngleMeasurementsMouseControl, making it unresponsive to input.
|
|
81
|
+
*/
|
|
82
|
+
deactivate(): void;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Resets this AngleMeasurementsMouseControl, destroying any AngleMeasurement under construction.
|
|
86
|
+
*/
|
|
87
|
+
reset(): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Destroys this AngleMeasurementsMouseControl.
|
|
91
|
+
*/
|
|
92
|
+
destroy(): void;
|
|
93
|
+
}
|
|
@@ -1,65 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {Component} from "../../viewer/scene/Component";
|
|
2
|
+
import {DistanceMeasurement} from "./DistanceMeasurement";
|
|
3
|
+
import {DistanceMeasurementsPlugin} from "./DistanceMeasurementsPlugin";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates {@link DistanceMeasurement}s from mouse and touch input.
|
|
7
7
|
*/
|
|
8
8
|
export declare class DistanceMeasurementsControl extends Component {
|
|
9
|
-
/**
|
|
10
|
-
* The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsControl.
|
|
11
|
-
* @type {DistanceMeasurementsPlugin}
|
|
12
|
-
*/
|
|
13
|
-
plugin: DistanceMeasurementsPlugin;
|
|
14
|
-
|
|
15
|
-
/** Gets if this DistanceMeasurementsControl is currently active, where it is responding to input.
|
|
16
|
-
*
|
|
17
|
-
* @returns {Boolean}
|
|
18
|
-
*/
|
|
19
|
-
get active(): boolean;
|
|
20
9
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Deactivates this DistanceMeasurementsControl, making it unresponsive to input.
|
|
28
|
-
*
|
|
29
|
-
* Destroys any {@link DistanceMeasurement} under construction.
|
|
30
|
-
*/
|
|
31
|
-
deactivate(): void;
|
|
10
|
+
/**
|
|
11
|
+
* The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsControl.
|
|
12
|
+
* @type {DistanceMeasurementsPlugin}
|
|
13
|
+
*/
|
|
14
|
+
plugin: DistanceMeasurementsPlugin;
|
|
32
15
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
18
|
+
*
|
|
19
|
+
* This is `true` by default.
|
|
20
|
+
*
|
|
21
|
+
* Internally, this deactivates then activates the DistanceMeasurementsControl when changed, which means that
|
|
22
|
+
* it will destroy any DistanceMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
23
|
+
* and rebinds various input handlers.
|
|
24
|
+
*
|
|
25
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this DistanceMeasurementsControl.
|
|
26
|
+
*/
|
|
27
|
+
set snapping(snapping: boolean);
|
|
41
28
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
31
|
+
*
|
|
32
|
+
* This is `true` by default.
|
|
33
|
+
*
|
|
34
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
35
|
+
*/
|
|
36
|
+
get snapping(): boolean;
|
|
49
37
|
|
|
50
|
-
/**
|
|
51
|
-
* Fires when the measurement is cancelled.
|
|
52
|
-
* @param event The measurementCancel event
|
|
53
|
-
* @param callback Called fired on the event
|
|
54
|
-
* @param scope Scope for the callback
|
|
55
|
-
*/
|
|
56
|
-
on(event: "measurementCancel", callback: (measurement: DistanceMeasurement) => void, scope?: any): string
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
/** Gets if this DistanceMeasurementsControl is currently active, where it is responding to input.
|
|
40
|
+
*
|
|
41
|
+
* @returns {Boolean}
|
|
42
|
+
*/
|
|
43
|
+
get active(): boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Activates this DistanceMeasurementsControl, ready to respond to input.
|
|
47
|
+
*/
|
|
48
|
+
activate(): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Deactivates this DistanceMeasurementsControl, making it unresponsive to input.
|
|
52
|
+
*
|
|
53
|
+
* Destroys any {@link DistanceMeasurement} under construction.
|
|
54
|
+
*/
|
|
55
|
+
deactivate(): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Resets this DistanceMeasurementsControl.
|
|
59
|
+
*
|
|
60
|
+
* Destroys any {@link DistanceMeasurement} under construction.
|
|
61
|
+
*
|
|
62
|
+
* Does nothing if the DistanceMeasurementsControl is not active.
|
|
63
|
+
*/
|
|
64
|
+
reset(): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Fires when the measurement is ended.
|
|
68
|
+
* @param event The measurementEnd event
|
|
69
|
+
* @param callback Called fired on the event
|
|
70
|
+
* @param scope Scope for the callback
|
|
71
|
+
*/
|
|
72
|
+
on(event: "measurementEnd", callback: (measurement: DistanceMeasurement) => void, scope?: any): string
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Fires when the measurement is cancelled.
|
|
76
|
+
* @param event The measurementCancel event
|
|
77
|
+
* @param callback Called fired on the event
|
|
78
|
+
* @param scope Scope for the callback
|
|
79
|
+
*/
|
|
80
|
+
on(event: "measurementCancel", callback: (measurement: DistanceMeasurement) => void, scope?: any): string
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Fires when the measurement is started.
|
|
84
|
+
* @param event The measurementStart event
|
|
85
|
+
* @param callback Called fired on the event
|
|
86
|
+
* @param scope Scope for the callback
|
|
87
|
+
*/
|
|
88
|
+
on(event: "measurementStart", callback: (measurement: DistanceMeasurement) => void, scope?: any): string
|
|
65
89
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {DistanceMeasurementsControl} from "./DistanceMeasurementsControl.js";
|
|
2
|
+
|
|
3
|
+
import {DistanceMeasurementsPlugin} from "./DistanceMeasurementsPlugin";
|
|
4
|
+
import {PointerLens} from "../../extras/PointerLens/PointerLens";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates {@link DistanceMeasurement}s in a {@link DistanceMeasurementsPlugin} from mouse input.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Usage
|
|
11
|
+
* const distanceMeasurementsControl = new DistanceMeasurementsMouseControl(distanceMeasurementsPlugin, {
|
|
12
|
+
* pointerLens: new PointerLens(viewer),
|
|
13
|
+
* snapping: true
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a DistanceMeasurementsMouseControl bound to the given DistanceMeasurementsPlugin.
|
|
20
|
+
*
|
|
21
|
+
* @param {DistanceMeasurementsPlugin} distanceMeasurementsPlugin The DistanceMeasurementsPlugin to control.
|
|
22
|
+
* @param {Object} cfg Configuration options.
|
|
23
|
+
* @param {PointerLens} [cfg.pointerLens] A PointerLens to provide a magnified view of the cursor when snapping is enabled.
|
|
24
|
+
* @param {boolean} [cfg.snapping=true] Whether to enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsMouseControl.
|
|
25
|
+
*/
|
|
26
|
+
constructor(distanceMeasurementsPlugin: DistanceMeasurementsPlugin, cfg?: {
|
|
27
|
+
pointerLens?: PointerLens;
|
|
28
|
+
snapping?: boolean;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Gets if this DistanceMeasurementsMouseControl is currently active, where it is responding to input.
|
|
33
|
+
*
|
|
34
|
+
* @returns {boolean} True if this DistanceMeasurementsMouseControl is active.
|
|
35
|
+
*/
|
|
36
|
+
get active(): boolean;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
40
|
+
*
|
|
41
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsMouseControl.
|
|
42
|
+
*/
|
|
43
|
+
set snapping(snapping: boolean);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
47
|
+
*
|
|
48
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
49
|
+
*/
|
|
50
|
+
get snapping(): boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Activates this DistanceMeasurementsMouseControl, ready to respond to input.
|
|
54
|
+
*/
|
|
55
|
+
activate(): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Deactivates this DistanceMeasurementsMouseControl, making it unresponsive to input.
|
|
59
|
+
*/
|
|
60
|
+
deactivate(): void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Resets this DistanceMeasurementsMouseControl.
|
|
64
|
+
*/
|
|
65
|
+
reset(): void;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Destroys this DistanceMeasurementsMouseControl.
|
|
69
|
+
*/
|
|
70
|
+
destroy(): void;
|
|
71
|
+
}
|