@thatopen/components 2.4.0-alpha.2 → 2.4.0-alpha.20

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.
@@ -6,7 +6,7 @@ export declare class Components implements Disposable {
6
6
  /**
7
7
  * The version of the @thatopen/components library.
8
8
  */
9
- static readonly release = "2.4.0-alpha.1";
9
+ static readonly release = "2.4.0-alpha.12";
10
10
  /** {@link Disposable.onDisposed} */
11
11
  readonly onDisposed: Event<void>;
12
12
  /**
@@ -35,8 +35,10 @@ export declare class SimpleRaycaster implements Disposable {
35
35
  * @param items - the [meshes](https://threejs.org/docs/#api/en/objects/Mesh)
36
36
  * to query. If not provided, it will query all the meshes stored in
37
37
  * {@link Components.meshes}.
38
+ * @param position - the screen position to use for raycasting. If not provided,
39
+ * the last pointer (mouse/touch) position will be used.
38
40
  */
39
- castRay(items?: THREE.Object3D[]): THREE.Intersection | null;
41
+ castRay(items?: THREE.Object3D[], position?: THREE.Vector2): THREE.Intersection | null;
40
42
  /**
41
43
  * Casts a ray from a given origin in a given direction and returns the first item found.
42
44
  * This method also takes into account the clipping planes used by the renderer.
@@ -2,6 +2,10 @@
2
2
  * Simple event handler by [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540). Keep in mind that if you want to remove it later, you might want to declare the callback as an object. If you want to maintain the reference to `this`, you will need to declare the callback as an arrow function.
3
3
  */
4
4
  export declare class AsyncEvent<T> {
5
+ /**
6
+ * Whether this event is active or not. If not, it won't trigger.
7
+ */
8
+ enabled: boolean;
5
9
  /**
6
10
  * Add a callback to this event instance.
7
11
  * @param handler - the callback to be added to this event.
@@ -1,6 +1,8 @@
1
1
  import { Component } from "./component";
2
2
  export type ComponentUIElement = {
3
3
  name: string;
4
+ id: string;
5
+ icon: string;
4
6
  componentID: string;
5
7
  attributes: {
6
8
  [name: string]: string;
@@ -0,0 +1,30 @@
1
+ import { Event } from "./event";
2
+ import { AsyncEvent } from "./async-event";
3
+ /**
4
+ * Simple class to easily toggle and reset event lists.
5
+ */
6
+ export declare class EventManager {
7
+ /**
8
+ * The list of events managed by this instance.
9
+ */
10
+ list: Set<Event<any> | AsyncEvent<any>>;
11
+ /**
12
+ * Adds events to this manager.
13
+ * @param events the events to add.
14
+ */
15
+ add(events: Iterable<Event<any> | AsyncEvent<any>>): void;
16
+ /**
17
+ * Removes events from this manager.
18
+ * @param events the events to remove.
19
+ */
20
+ remove(events: Iterable<Event<any> | AsyncEvent<any>>): void;
21
+ /**
22
+ * Sets all the events managed by this instance as enabled or disabled.
23
+ * @param active whether to turn on or off the events.
24
+ */
25
+ set(active: boolean): void;
26
+ /**
27
+ * Resets all the events managed by this instance.
28
+ */
29
+ reset(): void;
30
+ }
@@ -2,6 +2,10 @@
2
2
  * Simple event handler by [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540). Keep in mind that if you want to remove it later, you might want to declare the callback as an object. If you want to maintain the reference to `this`, you will need to declare the callback as an arrow function.
3
3
  */
4
4
  export declare class Event<T> {
5
+ /**
6
+ * Whether this event is active or not. If not, it won't trigger.
7
+ */
8
+ enabled: boolean;
5
9
  /**
6
10
  * Add a callback to this event instance.
7
11
  * @param handler - the callback to be added to this event.
@@ -12,3 +12,4 @@ export * from "./data-set";
12
12
  export * from "./data-map";
13
13
  export * from "./component-with-ui";
14
14
  export * from "./config-types";
15
+ export * from "./event-manager";
@@ -1,6 +1,7 @@
1
1
  import * as THREE from "three";
2
2
  import CameraControls from "camera-controls";
3
3
  import { Event } from "./event";
4
+ import { EventManager } from "./event-manager";
4
5
  /**
5
6
  * Whether this component has to be manually destroyed once you are done with it to prevent [memory leaks](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects). This also ensures that the DOM events created by that component will be cleaned up.
6
7
  */
@@ -105,3 +106,12 @@ export interface CameraControllable {
105
106
  */
106
107
  controls: CameraControls;
107
108
  }
109
+ /**
110
+ * Whether it has events or not.
111
+ */
112
+ export interface Eventable {
113
+ /**
114
+ * The object in charge of managing all the events.
115
+ */
116
+ eventManager: EventManager;
117
+ }
@@ -35,7 +35,7 @@ export declare class Viewpoint implements BCFViewpoint {
35
35
  * A map of colors and components GUIDs that should be colorized when displaying a viewpoint.
36
36
  * For this to work, call viewpoint.colorize()
37
37
  */
38
- readonly componentColors: DataMap<string, string[]>;
38
+ readonly componentColors: DataMap<THREE.Color, string[]>;
39
39
  /**
40
40
  * Boolean flags to allow fine control over the visibility of spaces.
41
41
  * A typical use of these flags is when DefaultVisibility=true but spaces should remain hidden.
@@ -163,6 +163,7 @@ export declare class Viewpoint implements BCFViewpoint {
163
163
  * @throws An error if the world's renderer is not available.
164
164
  */
165
165
  updateCamera(): void;
166
+ applyVisibility(): void;
166
167
  /**
167
168
  * Applies color to the components in the viewpoint based on their GUIDs.
168
169
  *
@@ -173,14 +174,13 @@ export declare class Viewpoint implements BCFViewpoint {
173
174
  * The color is applied using the `Classifier.setColor` method, which sets the color of the specified fragments.
174
175
  * The color is provided as a hexadecimal string, prefixed with a '#'.
175
176
  */
176
- colorize(): void;
177
+ applyColors(): void;
177
178
  /**
178
179
  * Resets the colors of all components in the viewpoint to their original color.
179
- * This method iterates through the `componentColors` map, retrieves the fragment IDs
180
- * corresponding to each color, and then uses the `Classifier` to reset the color of those fragments.
181
180
  */
182
181
  resetColors(): void;
183
182
  private createComponentTags;
183
+ private createColorTags;
184
184
  /**
185
185
  * Serializes the viewpoint into a buildingSMART compliant XML string for export.
186
186
  *
@@ -21,6 +21,17 @@ export interface Classification {
21
21
  };
22
22
  };
23
23
  }
24
+ interface ExportedClassification {
25
+ [system: string]: {
26
+ [groupName: string]: {
27
+ map: {
28
+ [name: string]: number[];
29
+ };
30
+ name: string;
31
+ id: number | null;
32
+ };
33
+ };
34
+ }
24
35
  /**
25
36
  * The Classifier component is responsible for classifying and categorizing fragments based on various criteria. It provides methods to add, remove, find, and filter fragments based on their classification. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Classifier). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Classifier).
26
37
  */
@@ -170,5 +181,16 @@ export declare class Classifier extends Component implements Disposable {
170
181
  * @throws Will throw an error if the fragment with the specified ID is not found.
171
182
  */
172
183
  resetColor(items: FRAGS.FragmentIdMap): void;
184
+ /**
185
+ * Exports the computed classification to persists them and import them back
186
+ * later for faster loading.
187
+ */
188
+ export(): ExportedClassification;
189
+ /**
190
+ * Imports a classification previously exported with .export().
191
+ * @param data the serialized classification to import.
192
+ */
193
+ import(data: ExportedClassification): void;
173
194
  protected saveItem(group: FRAGS.FragmentsGroup, systemName: string, className: string, expressID: number, parentID?: number | null): void;
174
195
  }
196
+ export {};
@@ -98,5 +98,6 @@ export declare class IfcGeometryTiler extends Component implements Disposable {
98
98
  private getGeometry;
99
99
  private streamAssets;
100
100
  private streamGeometries;
101
+ private outputGeometries;
101
102
  private registerGeometryData;
102
103
  }