@thatopen/components 2.0.13 → 2.0.15

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.
@@ -1,26 +1,110 @@
1
1
  import * as THREE from "three";
2
- import { Component, Components, Event, World } from "../core";
2
+ import { Component, Components, Disposable, Event, World } from "../core";
3
+ /**
4
+ * Configuration interface for the VertexPicker component.
5
+ */
3
6
  export interface VertexPickerConfig {
7
+ /**
8
+ * If true, only vertices will be picked, not the closest point on the face.
9
+ */
4
10
  showOnlyVertex: boolean;
11
+ /**
12
+ * The maximum distance for snapping to a vertex.
13
+ */
5
14
  snapDistance: number;
15
+ /**
16
+ * The HTML element to use for previewing the picked vertex.
17
+ */
6
18
  previewElement: HTMLElement;
7
19
  }
8
- export declare class VertexPicker extends Component {
9
- onVertexFound: Event<THREE.Vector3>;
10
- onVertexLost: Event<THREE.Vector3>;
20
+ /**
21
+ * A class that provides functionality for picking vertices in a 3D scene.
22
+ */
23
+ export declare class VertexPicker extends Component implements Disposable {
24
+ /** {@link Disposable.onDisposed} */
25
+ readonly onDisposed: Event<unknown>;
26
+ /**
27
+ * An event that is triggered when a vertex is found.
28
+ * The event passes a THREE.Vector3 representing the position of the found vertex.
29
+ */
30
+ readonly onVertexFound: Event<THREE.Vector3>;
31
+ /**
32
+ * An event that is triggered when a vertex is lost.
33
+ * The event passes a THREE.Vector3 representing the position of the lost vertex.
34
+ */
35
+ readonly onVertexLost: Event<THREE.Vector3>;
36
+ /**
37
+ * A reference to the Components instance associated with this VertexPicker.
38
+ */
11
39
  components: Components;
40
+ /**
41
+ * A reference to the working plane used for vertex picking.
42
+ * This plane is used to determine which vertices are considered valid for picking.
43
+ * If this value is null, all vertices are considered valid.
44
+ */
45
+ workingPlane: THREE.Plane | null;
12
46
  private _pickedPoint;
13
47
  private _config;
14
48
  private _enabled;
15
- private _workingPlane;
49
+ /**
50
+ * Sets the enabled state of the VertexPicker.
51
+ * When enabled, the VertexPicker will actively search for vertices in the 3D scene.
52
+ * When disabled, the VertexPicker will stop searching for vertices and reset the picked point.
53
+ *
54
+ * @param value - The new enabled state.
55
+ */
16
56
  set enabled(value: boolean);
57
+ /**
58
+ * Gets the current enabled state of the VertexPicker.
59
+ *
60
+ * @returns The current enabled state.
61
+ */
17
62
  get enabled(): boolean;
18
- constructor(components: Components, config?: Partial<VertexPickerConfig>);
19
- set workingPlane(plane: THREE.Plane | null);
20
- get workingPlane(): THREE.Plane | null;
63
+ /**
64
+ * Sets the configuration for the VertexPicker component.
65
+ *
66
+ * @param value - A Partial object containing the configuration properties to update.
67
+ * The properties not provided in the value object will retain their current values.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * vertexPicker.config = {
72
+ * snapDistance: 0.5,
73
+ * showOnlyVertex: true,
74
+ * };
75
+ * ```
76
+ */
21
77
  set config(value: Partial<VertexPickerConfig>);
78
+ /**
79
+ * Gets the current configuration for the VertexPicker component.
80
+ *
81
+ * @returns A copy of the current VertexPickerConfig object.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const currentConfig = vertexPicker.config;
86
+ * console.log(currentConfig.snapDistance); // Output: 0.25
87
+ * ```
88
+ */
22
89
  get config(): Partial<VertexPickerConfig>;
90
+ constructor(components: Components, config?: Partial<VertexPickerConfig>);
91
+ /** {@link Disposable.dispose} */
23
92
  dispose(): void;
93
+ /**
94
+ * Performs the vertex picking operation based on the current state of the VertexPicker.
95
+ *
96
+ * @param world - The World instance to use for raycasting.
97
+ *
98
+ * @returns The current picked point, or null if no point is picked.
99
+ *
100
+ * @remarks
101
+ * This method checks if the VertexPicker is enabled. If not, it returns the current picked point.
102
+ * If enabled, it performs raycasting to find the closest intersecting object.
103
+ * It then determines the closest vertex or point on the face, based on the configuration settings.
104
+ * If the picked point is on the working plane (if defined), it triggers the `onVertexFound` event and updates the `pickedPoint`.
105
+ * If the picked point is not on the working plane, it resets the `pickedPoint`.
106
+ * If no intersecting object is found, it triggers the `onVertexLost` event and resets the `pickedPoint`.
107
+ */
24
108
  get(world: World): THREE.Vector3 | null;
25
109
  private getClosestVertex;
26
110
  private getVertices;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@thatopen/components",
3
3
  "description": "Collection of core functionalities to author BIM apps.",
4
- "version": "2.0.13",
4
+ "version": "2.0.15",
5
5
  "author": "That Open Company",
6
6
  "contributors": [
7
7
  "Antonio Gonzalez Viegas (https://github.com/agviegas)",
@@ -53,4 +53,4 @@
53
53
  "three": "^0.160.1",
54
54
  "web-ifc": "0.0.53"
55
55
  }
56
- }
56
+ }