@xtctwins/tctwins-core 1.0.19 → 1.0.21

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.
@@ -3,147 +3,160 @@ import { DistanceMeasurementsControl } from "./DistanceMeasurementsControl";
3
3
  import { DistanceMeasurement } from "./DistanceMeasurement";
4
4
 
5
5
  export declare type DistanceMeasurementsPluginConfiguration = {
6
- /** Optional ID for this plugin, so that we can find it within {@link Viewer.plugins}. */
7
- id?: string;
8
- /** The minimum length, in pixels, of an axis wire beyond which its label is shown. */
9
- labelMinAxisLength?: number;
10
- /** Container DOM element for markers and labels. Defaults to ````document.body````. */
11
- container?: HTMLElement;
12
- /** The default value of the DistanceMeasurements `visible` property. */
13
- defaultVisible?: boolean;
14
- /** The default value of the DistanceMeasurements `originVisible` property. */
15
- defaultOriginVisible?: boolean;
16
- /** The default value of the DistanceMeasurements `targetVisible` property. */
17
- defaultTargetVisible?: boolean;
18
- /** The default value of the DistanceMeasurements `wireVisible` property. */
19
- defaultWireVisible?: boolean;
20
- /** The default value of the DistanceMeasurements `axisVisible` property. */
21
- defaultAxisVisible?: boolean;
22
- /** The default color of the length dots, wire and label. */
23
- defaultColor?: string;
24
- /** If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels). */
25
- zIndex?: number;
6
+ /** Optional ID for this plugin, so that we can find it within {@link Viewer.plugins}. */
7
+ id?: string;
8
+ /** The minimum length, in pixels, of an axis wire beyond which its label is shown. */
9
+ labelMinAxisLength?: number;
10
+ /** Container DOM element for markers and labels. Defaults to ````document.body````. */
11
+ container?: HTMLElement;
12
+ /** The default value of the DistanceMeasurements `visible` property. */
13
+ defaultVisible?: boolean;
14
+ /** The default value of the DistanceMeasurements `originVisible` property. */
15
+ defaultOriginVisible?: boolean;
16
+ /** The default value of the DistanceMeasurements `targetVisible` property. */
17
+ defaultTargetVisible?: boolean;
18
+ /** The default value of the DistanceMeasurements `wireVisible` property. */
19
+ defaultWireVisible?: boolean;
20
+ /** The default value of the DistanceMeasurements `axisVisible` property. */
21
+ defaultAxisVisible?: boolean;
22
+ /** The default color of the length dots, wire and label. */
23
+ defaultColor?: string;
24
+ /** If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels). */
25
+ zIndex?: number;
26
26
  };
27
27
 
28
28
  /**
29
29
  * {@link Viewer} plugin for measuring point-to-point distances.
30
30
  */
31
31
  export declare class DistanceMeasurementsPlugin extends Plugin {
32
- /**
33
- * @constructor
34
- * @param {Viewer} viewer The Viewer.
35
- * @param {DistanceMeasurementsPluginConfiguration} [cfg] Plugin configuration.
36
- */
37
- constructor(viewer: Viewer, cfg?: DistanceMeasurementsPluginConfiguration);
38
-
39
- /**
40
- * Sets the minimum length, in pixels, of an axis wire beyond which its label is shown.
41
- *
42
- * The axis wire's label is not shown when its length is less than this value.
43
- *
44
- * This is ````25```` pixels by default.
45
- *
46
- * Must not be less than ````1````.
47
- *
48
- * @type {number}
49
- */
50
- set labelMinAxisLength(arg: number);
32
+ /**
33
+ * @constructor
34
+ * @param {Viewer} viewer The Viewer.
35
+ * @param {DistanceMeasurementsPluginConfiguration} [cfg] Plugin configuration.
36
+ */
37
+ constructor(viewer: Viewer, cfg?: DistanceMeasurementsPluginConfiguration);
51
38
 
52
- /**
53
- * Gets the minimum length, in pixels, of an axis wire beyond which its label is shown.
54
- * @returns {number}
55
- */
56
- get labelMinAxisLength(): number;
57
-
58
- /**
59
- * Gets the {@link DistanceMeasurementsControl}, which creates {@link DistanceMeasurement}s from user input.
60
- *
61
- * @type {DistanceMeasurementsControl}
62
- */
63
- get control(): DistanceMeasurementsControl;
39
+ /**
40
+ * Sets the minimum length, in pixels, of an axis wire beyond which its label is shown.
41
+ *
42
+ * The axis wire's label is not shown when its length is less than this value.
43
+ *
44
+ * This is ````25```` pixels by default.
45
+ *
46
+ * Must not be less than ````1````.
47
+ *
48
+ * @type {number}
49
+ */
50
+ set labelMinAxisLength(arg: number);
64
51
 
65
- /**
66
- * Gets the existing {@link DistanceMeasurement}s, each mapped to its {@link DistanceMeasurement.id}.
67
- *
68
- * @type {{String:DistanceMeasurement}}
69
- */
70
- get measurements(): { [key:string]: DistanceMeasurement };
52
+ /**
53
+ * Gets the minimum length, in pixels, of an axis wire beyond which its label is shown.
54
+ * @returns {number}
55
+ */
56
+ get labelMinAxisLength(): number;
71
57
 
72
- /**
73
- * Creates a {@link DistanceMeasurement}.
74
- *
75
- * The DistanceMeasurement is then registered by {@link DistanceMeasurement.id} in {@link DistanceMeasurementsPlugin.measurements}.
76
- *
77
- * @param {Object} params {@link DistanceMeasurement} configuration.
78
- * @param {String} params.id Unique ID to assign to {@link DistanceMeasurement.id}. The DistanceMeasurement will be registered by this in {@link DistanceMeasurementsPlugin.measurements} and {@link Scene.components}. Must be unique among all components in the {@link Viewer}.
79
- * @param {Number[]} params.origin.worldPos Origin World-space 3D position.
80
- * @param {Entity} params.origin.entity Origin Entity.
81
- * @param {Number[]} params.target.worldPos Target World-space 3D position.
82
- * @param {Entity} params.target.entity Target Entity.
83
- * @param {Boolean} [params.visible=true] Whether to initially show the {@link DistanceMeasurement}.
84
- * @param {Boolean} [params.originVisible=true] Whether to initially show the {@link DistanceMeasurement} origin.
85
- * @param {Boolean} [params.targetVisible=true] Whether to initially show the {@link DistanceMeasurement} target.
86
- * @param {Boolean} [params.wireVisible=true] Whether to initially show the direct point-to-point wire between {@link DistanceMeasurement.origin} and {@link DistanceMeasurement.target}.
87
- * @param {Boolean} [params.axisVisible=true] Whether to initially show the axis-aligned wires between {@link DistanceMeasurement.origin} and {@link DistanceMeasurement.target}.
88
- * @param {string} [params.color] The color of the length dot, wire and label.
89
- * @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
90
- */
91
- createMeasurement(params?: {
92
- id: string;
93
- origin: {
94
- entity: Entity;
95
- worldPos: number[];
96
- };
97
- target: {
98
- entity: Entity;
99
- worldPos: number[];
100
- };
101
- visible?: boolean;
102
- originVisible?: boolean;
103
- targetVisible?: boolean;
104
- wireVisible?: boolean;
105
- axisVisible?: boolean;
106
- color?: string;
107
- }): DistanceMeasurement;
108
-
109
- /**
110
- * Destroys a {@link DistanceMeasurement}.
111
- *
112
- * @param {String} id ID of DistanceMeasurement to destroy.
113
- */
114
- destroyMeasurement(id: string): void;
58
+ /**
59
+ * Gets the {@link DistanceMeasurementsControl}, which creates {@link DistanceMeasurement}s from user input.
60
+ *
61
+ * @type {DistanceMeasurementsControl}
62
+ */
63
+ get control(): DistanceMeasurementsControl;
115
64
 
116
- /**
117
- * Destroys all {@link DistanceMeasurement}s.
118
- */
119
- clear(): void;
65
+ /**
66
+ * Gets the existing {@link DistanceMeasurement}s, each mapped to its {@link DistanceMeasurement.id}.
67
+ *
68
+ * @type {{String:DistanceMeasurement}}
69
+ */
70
+ get measurements(): { [key: string]: DistanceMeasurement };
120
71
 
121
- /**
122
- * Fires when a measurement is created.
123
- * @param {String} event The measurementCreated event
124
- * @param {Function} callback Callback fired on the event
125
- */
126
- on(event: "measurementCreated", callback: (measurement: DistanceMeasurement)=> void): string;
72
+ /**
73
+ * Creates a {@link DistanceMeasurement}.
74
+ *
75
+ * The DistanceMeasurement is then registered by {@link DistanceMeasurement.id} in {@link DistanceMeasurementsPlugin.measurements}.
76
+ *
77
+ * @param {Object} params {@link DistanceMeasurement} configuration.
78
+ * @param {String} params.id Unique ID to assign to {@link DistanceMeasurement.id}. The DistanceMeasurement will be registered by this in {@link DistanceMeasurementsPlugin.measurements} and {@link Scene.components}. Must be unique among all components in the {@link Viewer}.
79
+ * @param {Number[]} params.origin.worldPos Origin World-space 3D position.
80
+ * @param {Entity} params.origin.entity Origin Entity.
81
+ * @param {Number[]} params.target.worldPos Target World-space 3D position.
82
+ * @param {Entity} params.target.entity Target Entity.
83
+ * @param {Boolean} [params.visible=true] Whether to initially show the {@link DistanceMeasurement}.
84
+ * @param {Boolean} [params.originVisible=true] Whether to initially show the {@link DistanceMeasurement} origin.
85
+ * @param {Boolean} [params.targetVisible=true] Whether to initially show the {@link DistanceMeasurement} target.
86
+ * @param {Boolean} [params.wireVisible=true] Whether to initially show the direct point-to-point wire between {@link DistanceMeasurement.origin} and {@link DistanceMeasurement.target}.
87
+ * @param {Boolean} [params.axisVisible=true] Whether to initially show the axis-aligned wires between {@link DistanceMeasurement.origin} and {@link DistanceMeasurement.target}.
88
+ * @param {string} [params.color] The color of the length dot, wire and label.
89
+ * @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
90
+ */
91
+ createMeasurement(params?: {
92
+ id: string;
93
+ origin: {
94
+ entity: Entity;
95
+ worldPos: number[];
96
+ };
97
+ target: {
98
+ entity: Entity;
99
+ worldPos: number[];
100
+ };
101
+ visible?: boolean;
102
+ originVisible?: boolean;
103
+ targetVisible?: boolean;
104
+ wireVisible?: boolean;
105
+ axisVisible?: boolean;
106
+ color?: string;
107
+ }): DistanceMeasurement;
127
108
 
128
- /**
129
- * Fires when a measurement is completed.
130
- * @param {String} event The measurementEnd event
131
- * @param {Function} callback Callback fired on the event
132
- */
133
- on(event: "measurementEnd", callback: (measurement: DistanceMeasurement)=> void): string;
109
+ /**
110
+ * Destroys a {@link DistanceMeasurement}.
111
+ *
112
+ * @param {String} id ID of DistanceMeasurement to destroy.
113
+ */
114
+ destroyMeasurement(id: string): void;
134
115
 
135
- /**
136
- * Fires when a measurement is cancelled.
137
- * @param {String} event The measurementCancel event
138
- * @param {Function} callback Callback fired on the event
139
- */
140
- on(event: "measurementCancel", callback: (measurement: DistanceMeasurement)=> void): string;
116
+ /**
117
+ * Destroys all {@link DistanceMeasurement}s.
118
+ */
119
+ clear(): void;
141
120
 
142
- /**
143
- * Fires when a measurement is destroyed.
144
- * @param {String} event The measurementDestroyed event
145
- * @param {Function} callback Callback fired on the event
146
- */
147
- on(event: "measurementDestroyed", callback: (measurement: DistanceMeasurement)=> void): string;
148
-
121
+ /**
122
+ * Fires when a measurement is created.
123
+ * @param {String} event The measurementCreated event
124
+ * @param {Function} callback Callback fired on the event
125
+ */
126
+ on(event: "measurementCreated", callback: (measurement: DistanceMeasurement) => void): string;
127
+
128
+ /**
129
+ * Fires when a measurement is completed.
130
+ * @param {String} event The measurementEnd event
131
+ * @param {Function} callback Callback fired on the event
132
+ */
133
+ on(event: "measurementEnd", callback: (measurement: DistanceMeasurement) => void): string;
134
+
135
+ /**
136
+ * Fires when a measurement is cancelled.
137
+ * @param {String} event The measurementCancel event
138
+ * @param {Function} callback Callback fired on the event
139
+ */
140
+ on(event: "measurementCancel", callback: (measurement: DistanceMeasurement) => void): string;
141
+
142
+ /**
143
+ * Fires when a measurement is destroyed.
144
+ * @param {String} event The measurementDestroyed event
145
+ * @param {Function} callback Callback fired on the event
146
+ */
147
+ on(event: "measurementDestroyed", callback: (measurement: DistanceMeasurement) => void): string;
148
+
149
+ /**
150
+ * trigger when hover measure object
151
+ * @param event
152
+ * @param e
153
+ */
154
+ on(event: "mouseOver", e: any): void;
155
+
156
+ /**
157
+ * trigger when leave measure object
158
+ * @param event
159
+ * @param e
160
+ */
161
+ on(event: "mouseLeave", e: any): void;
149
162
  }
@@ -0,0 +1,96 @@
1
+ import { DistanceMeasurementsControl } from "./DistanceMeasurementsControl.js";
2
+ import { DistanceMeasurementsPlugin } from "./DistanceMeasurementsPlugin.js";
3
+ import { PointerLens } from "../../extras/PointerLens/PointerLens.js";
4
+ import { PointerCircle } from "../../extras/PointerCircle/PointerCircle.js";
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 DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
17
+ /**
18
+ * Creates a DistanceMeasurementsTouchControl bound to the given DistanceMeasurementsPlugin.
19
+ * @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
20
+ * @param {boolean} [cfg.snapToEdge=true] Whether to initially enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsTouchControl.
21
+ * @param {boolean} [cfg.snapToVertex=true] Whether to initially enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsTouchControl.
22
+ * @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
23
+ * @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
24
+ */
25
+ constructor(
26
+ distanceMeasurementsPlugin: DistanceMeasurementsPlugin,
27
+ cfg?: {
28
+ pointerLens?: PointerLens;
29
+ snapToEdge?: boolean;
30
+ snapToVertex?: boolean;
31
+ offsetX?: number;
32
+ offsetY?: number;
33
+ }
34
+ );
35
+
36
+ /**
37
+ * @return {number} mouse offset
38
+ */
39
+ get offsetX(): number;
40
+
41
+ /**
42
+ * @param {number} offsetX
43
+ */
44
+ set offsetX(offsetX: number);
45
+
46
+ /**
47
+ * @return {number} mouse offset
48
+ */
49
+ get offsetY(): number;
50
+
51
+ /**
52
+ * @param {number} offsetY
53
+ */
54
+ set offsetY(offsetY: number);
55
+
56
+ /**
57
+ * Gets whether this DistanceMeasurementsTouchControl is currently active, responding to input.
58
+ *
59
+ * @returns {boolean} True if active, false otherwise.
60
+ */
61
+ get active(): boolean;
62
+
63
+ /**
64
+ * Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
65
+ *
66
+ * @param {boolean} snapping True to enable snap-to-vertex and snap-to-edge, false to disable.
67
+ */
68
+ set snapping(snapping: boolean);
69
+
70
+ /**
71
+ * Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
72
+ *
73
+ * @returns {boolean} True if snap-to-vertex and snap-to-edge are enabled, false otherwise.
74
+ */
75
+ get snapping(): boolean;
76
+
77
+ /**
78
+ * Activates this DistanceMeasurementsTouchControl, making it responsive to input.
79
+ */
80
+ activate(): void;
81
+
82
+ /**
83
+ * Deactivates this DistanceMeasurementsTouchControl, making it unresponsive to input.
84
+ */
85
+ deactivate(): void;
86
+
87
+ /**
88
+ * Resets this DistanceMeasurementsTouchControl, destroying any DistanceMeasurement under construction.
89
+ */
90
+ reset(): void;
91
+
92
+ /**
93
+ * Destroys this DistanceMeasurementsTouchControl.
94
+ */
95
+ destroy(): void;
96
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./DistanceMeasurementsPlugin";
2
2
  export * from "./DistanceMeasurementsControl";
3
3
  export * from "./DistanceMeasurementsMouseControl";
4
+ export * from "./DistanceMeasurementsTouchControl";
@@ -9,45 +9,61 @@ import { Component } from "../Component";
9
9
  * * Located at {@link Scene#input}
10
10
  */
11
11
  export declare class Input extends Component {
12
- readonly KEY_CTRL: number;
13
-
14
- keyDown: boolean[];
15
-
16
- keyboardEnabled: boolean;
17
-
18
- /**
19
- * Sets whether input handlers are enabled.
20
- */
21
- setEnabled(enable: boolean): void;
22
-
23
- /**
24
- * Gets whether input handlers are enabled.
25
- */
26
- getEnabled(): boolean
27
-
28
- /**
29
- * Sets whether or not keyboard input is enabled.
30
- */
31
- setKeyboardEnabled(enable: boolean): void;
32
-
33
- /**
34
- * Gets whether keyboard input is enabled.
35
- */
36
- getKeyboardEnabled(): boolean;
37
-
38
- /**
39
- * Fires on mouse events
40
- * @param event The loaded event
41
- * @param callback Called fired on the event
42
- * @param scope Scope for the callback
43
- */
44
- on(event: "mousedown" | "mouseup" | "mouseclicked" | "dblclick", callback: (canvasCoords: number[]) => void, scope?: any): string;
45
-
46
- /**
47
- * Fires on keyboard events
48
- * @param event The loaded event
49
- * @param callback Called fired on the event
50
- * @param scope Scope for the callback
51
- */
52
- on(event: "keydown" | "keyup", callback: (keyCode: number) => void, scope?: any): string;
53
- }
12
+ readonly KEY_CTRL: number;
13
+
14
+ keyDown: boolean[];
15
+
16
+ keyboardEnabled: boolean;
17
+
18
+ /**
19
+ * Sets whether input handlers are enabled.
20
+ */
21
+ setEnabled(enable: boolean): void;
22
+
23
+ /**
24
+ * Gets whether input handlers are enabled.
25
+ */
26
+ getEnabled(): boolean;
27
+
28
+ /**
29
+ * Sets whether or not keyboard input is enabled.
30
+ */
31
+ setKeyboardEnabled(enable: boolean): void;
32
+
33
+ /**
34
+ * Gets whether keyboard input is enabled.
35
+ */
36
+ getKeyboardEnabled(): boolean;
37
+
38
+ /**
39
+ * Fires on mouse events
40
+ * @param event The loaded event
41
+ * @param callback Called fired on the event
42
+ * @param scope Scope for the callback
43
+ */
44
+ on(
45
+ event: "mousedown" | "mouseup" | "mouseclicked" | "dblclick",
46
+ callback: (canvasCoords: number[]) => void,
47
+ scope?: any
48
+ ): string;
49
+
50
+ /**
51
+ * Fires on touch events
52
+ * @param event The loaded event
53
+ * @param callback Called fired on the event
54
+ * @param scope Scope for the callback
55
+ */
56
+ on(
57
+ event: "touchstart" | "touchend" | "touchclicked",
58
+ callback: (canvasCoords: number[]) => void,
59
+ scope?: any
60
+ ): string;
61
+
62
+ /**
63
+ * Fires on keyboard events
64
+ * @param event The loaded event
65
+ * @param callback Called fired on the event
66
+ * @param scope Scope for the callback
67
+ */
68
+ on(event: "keydown" | "keyup", callback: (keyCode: number) => void, scope?: any): string;
69
+ }