@thatopen/components 2.1.0 → 2.1.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.
@@ -1,4 +1,49 @@
1
1
  declare namespace OBC {
2
+ import * as THREE from "three";
3
+ import { Components } from "../Components";
4
+ import { Component } from "../Types";
5
+ /**
6
+ * A tool to safely remove meshes, geometries, materials and other items from memory to [prevent memory leaks](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects).
7
+ */
8
+ export declare class Disposer extends Component {
9
+ private _disposedComponents;
10
+ /** {@link Component.enabled} */
11
+ enabled: boolean;
12
+ /**
13
+ * A unique identifier for the component.
14
+ * This UUID is used to register the component within the Components system.
15
+ */
16
+ static readonly uuid: "76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe";
17
+ constructor(components: Components);
18
+ /**
19
+ * Return the UUIDs of all disposed components.
20
+ */
21
+ get(): Set<string>;
22
+ /**
23
+ * Removes a mesh, its geometry and its materials from memory. If you are
24
+ * using any of these in other parts of the application, make sure that you
25
+ * remove them from the mesh before disposing it.
26
+ *
27
+ * @param object - the [object](https://threejs.org/docs/#api/en/core/Object3D)
28
+ * to remove.
29
+ *
30
+ * @param materials - whether to dispose the materials of the mesh.
31
+ *
32
+ * @param recursive - whether to recursively dispose the children of the mesh.
33
+ */
34
+ destroy(object: THREE.Object3D, materials?: boolean, recursive?: boolean): void;
35
+ /**
36
+ * Disposes a geometry from memory.
37
+ *
38
+ * @param geometry - the
39
+ * [geometry](https://threejs.org/docs/#api/en/core/BufferGeometry)
40
+ * to remove.
41
+ */
42
+ disposeGeometry(geometry: THREE.BufferGeometry): void;
43
+ private disposeGeometryAndMaterials;
44
+ private disposeChildren;
45
+ private static disposeMaterial;
46
+ }
2
47
  import { Component, Disposable, Event } from "../Types";
3
48
  /**
4
49
  * The entry point of the Components library. It can create, delete and access all the components of the library globally, update all the updatable components automatically and dispose all the components, preventing memory leaks.
@@ -7,7 +52,7 @@ export declare class Components implements Disposable {
7
52
  /**
8
53
  * The version of the @thatopen/components library.
9
54
  */
10
- static readonly release = "2.1.0";
55
+ static readonly release = "2.1.1";
11
56
  /** {@link Disposable.onDisposed} */
12
57
  readonly onDisposed: Event<void>;
13
58
  /**
@@ -75,50 +120,72 @@ export declare class Components implements Disposable {
75
120
  private update;
76
121
  private static setupBVH;
77
122
  }
78
- import * as THREE from "three";
123
+ import { Component, Disposable, Updateable, World, Event, BaseScene, BaseCamera, BaseRenderer } from "../Types";
79
124
  import { Components } from "../Components";
80
- import { Component } from "../Types";
125
+ import { SimpleWorld } from "./src";
81
126
  /**
82
- * A tool to safely remove meshes, geometries, materials and other items from memory to [prevent memory leaks](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects).
127
+ * A class representing a collection of worlds within a game engine. It manages the creation, deletion, and update of worlds. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Worlds). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Worlds).
83
128
  */
84
- export declare class Disposer extends Component {
85
- private _disposedComponents;
86
- /** {@link Component.enabled} */
87
- enabled: boolean;
129
+ export declare class Worlds extends Component implements Updateable, Disposable {
88
130
  /**
89
131
  * A unique identifier for the component.
90
132
  * This UUID is used to register the component within the Components system.
91
133
  */
92
- static readonly uuid: "76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe";
134
+ static readonly uuid: "fdb61dc4-2ec1-4966-b83d-54ea795fad4a";
135
+ /** {@link Updateable.onAfterUpdate} */
136
+ readonly onAfterUpdate: Event<unknown>;
137
+ /** {@link Updateable.onBeforeUpdate} */
138
+ readonly onBeforeUpdate: Event<unknown>;
139
+ /** {@link Disposable.onDisposed} */
140
+ readonly onDisposed: Event<unknown>;
141
+ /**
142
+ * An event that is triggered when a new world is created.
143
+ * The event passes the newly created world as a parameter.
144
+ */
145
+ readonly onWorldCreated: Event<World>;
146
+ /**
147
+ * An event that is triggered when a world is deleted.
148
+ * The event passes the UUID of the deleted world as a parameter.
149
+ */
150
+ readonly onWorldDeleted: Event<string>;
151
+ /**
152
+ * A collection of worlds managed by this component.
153
+ * The key is the unique identifier (UUID) of the world, and the value is the World instance.
154
+ */
155
+ list: Map<string, World>;
156
+ /** {@link Component.enabled} */
157
+ enabled: boolean;
93
158
  constructor(components: Components);
94
159
  /**
95
- * Return the UUIDs of all disposed components.
160
+ * Creates a new instance of a SimpleWorld and adds it to the list of worlds.
161
+ *
162
+ * @template T - The type of the scene, extending from BaseScene. Defaults to BaseScene.
163
+ * @template U - The type of the camera, extending from BaseCamera. Defaults to BaseCamera.
164
+ * @template S - The type of the renderer, extending from BaseRenderer. Defaults to BaseRenderer.
165
+ *
166
+ * @throws {Error} - Throws an error if a world with the same UUID already exists in the list.
96
167
  */
97
- get(): Set<string>;
168
+ create<T extends BaseScene = BaseScene, U extends BaseCamera = BaseCamera, S extends BaseRenderer = BaseRenderer>(): SimpleWorld<T, U, S>;
98
169
  /**
99
- * Removes a mesh, its geometry and its materials from memory. If you are
100
- * using any of these in other parts of the application, make sure that you
101
- * remove them from the mesh before disposing it.
170
+ * Deletes a world from the list of worlds.
102
171
  *
103
- * @param object - the [object](https://threejs.org/docs/#api/en/core/Object3D)
104
- * to remove.
172
+ * @param {World} world - The world to be deleted.
105
173
  *
106
- * @param materials - whether to dispose the materials of the mesh.
174
+ * @throws {Error} - Throws an error if the provided world is not found in the list.
107
175
  *
108
- * @param recursive - whether to recursively dispose the children of the mesh.
176
+ * @returns {void}
109
177
  */
110
- destroy(object: THREE.Object3D, materials?: boolean, recursive?: boolean): void;
178
+ delete(world: World): void;
111
179
  /**
112
- * Disposes a geometry from memory.
180
+ * Disposes of the Worlds component and all its managed worlds.
181
+ * This method sets the enabled flag to false, disposes of all worlds, clears the list,
182
+ * and triggers the onDisposed event.
113
183
  *
114
- * @param geometry - the
115
- * [geometry](https://threejs.org/docs/#api/en/core/BufferGeometry)
116
- * to remove.
184
+ * @returns {void}
117
185
  */
118
- disposeGeometry(geometry: THREE.BufferGeometry): void;
119
- private disposeGeometryAndMaterials;
120
- private disposeChildren;
121
- private static disposeMaterial;
186
+ dispose(): void;
187
+ /** {@link Updateable.update} */
188
+ update(delta?: number): void | Promise<void>;
122
189
  }
123
190
  import { Component, Disposable, World, Event } from "../Types";
124
191
  import { SimpleRaycaster } from "./src";
@@ -162,121 +229,100 @@ export declare class Raycasters extends Component implements Disposable {
162
229
  /** {@link Disposable.dispose} */
163
230
  dispose(): void;
164
231
  }
165
- import { Component, Disposable, Updateable, World, Event, BaseScene, BaseCamera, BaseRenderer } from "../Types";
166
232
  import { Components } from "../Components";
167
- import { SimpleWorld } from "./src";
233
+ import { MeshCullerRenderer, CullerRendererSettings } from "./src";
234
+ import { Component, Event, Disposable, World } from "../Types";
168
235
  /**
169
- * A class representing a collection of worlds within a game engine. It manages the creation, deletion, and update of worlds. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Worlds). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Worlds).
236
+ * A component that provides culling functionality for meshes in a 3D scene. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Cullers). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Cullers).
170
237
  */
171
- export declare class Worlds extends Component implements Updateable, Disposable {
238
+ export declare class Cullers extends Component implements Disposable {
172
239
  /**
173
240
  * A unique identifier for the component.
174
241
  * This UUID is used to register the component within the Components system.
175
242
  */
176
- static readonly uuid: "fdb61dc4-2ec1-4966-b83d-54ea795fad4a";
177
- /** {@link Updateable.onAfterUpdate} */
178
- readonly onAfterUpdate: Event<unknown>;
179
- /** {@link Updateable.onBeforeUpdate} */
180
- readonly onBeforeUpdate: Event<unknown>;
181
- /** {@link Disposable.onDisposed} */
182
- readonly onDisposed: Event<unknown>;
183
- /**
184
- * An event that is triggered when a new world is created.
185
- * The event passes the newly created world as a parameter.
186
- */
187
- readonly onWorldCreated: Event<World>;
243
+ static readonly uuid: "69f2a50d-c266-44fc-b1bd-fa4d34be89e6";
188
244
  /**
189
- * An event that is triggered when a world is deleted.
190
- * The event passes the UUID of the deleted world as a parameter.
245
+ * An event that is triggered when the Cullers component is disposed.
191
246
  */
192
- readonly onWorldDeleted: Event<string>;
247
+ readonly onDisposed: Event<unknown>;
248
+ private _enabled;
193
249
  /**
194
- * A collection of worlds managed by this component.
195
- * The key is the unique identifier (UUID) of the world, and the value is the World instance.
250
+ * A map of MeshCullerRenderer instances, keyed by their world UUIDs.
196
251
  */
197
- list: Map<string, World>;
252
+ list: Map<string, MeshCullerRenderer>;
198
253
  /** {@link Component.enabled} */
199
- enabled: boolean;
254
+ get enabled(): boolean;
255
+ /** {@link Component.enabled} */
256
+ set enabled(value: boolean);
200
257
  constructor(components: Components);
201
258
  /**
202
- * Creates a new instance of a SimpleWorld and adds it to the list of worlds.
259
+ * Creates a new MeshCullerRenderer for the given world.
260
+ * If a MeshCullerRenderer already exists for the world, it will return the existing one.
203
261
  *
204
- * @template T - The type of the scene, extending from BaseScene. Defaults to BaseScene.
205
- * @template U - The type of the camera, extending from BaseCamera. Defaults to BaseCamera.
206
- * @template S - The type of the renderer, extending from BaseRenderer. Defaults to BaseRenderer.
262
+ * @param world - The world for which to create the MeshCullerRenderer.
263
+ * @param config - Optional configuration settings for the MeshCullerRenderer.
207
264
  *
208
- * @throws {Error} - Throws an error if a world with the same UUID already exists in the list.
265
+ * @returns The newly created or existing MeshCullerRenderer for the given world.
209
266
  */
210
- create<T extends BaseScene = BaseScene, U extends BaseCamera = BaseCamera, S extends BaseRenderer = BaseRenderer>(): SimpleWorld<T, U, S>;
267
+ create(world: World, config?: Partial<CullerRendererSettings>): MeshCullerRenderer;
211
268
  /**
212
- * Deletes a world from the list of worlds.
213
- *
214
- * @param {World} world - The world to be deleted.
269
+ * Deletes the MeshCullerRenderer associated with the given world.
270
+ * If a MeshCullerRenderer exists for the given world, it will be disposed and removed from the list.
215
271
  *
216
- * @throws {Error} - Throws an error if the provided world is not found in the list.
272
+ * @param world - The world for which to delete the MeshCullerRenderer.
217
273
  *
218
274
  * @returns {void}
219
275
  */
220
276
  delete(world: World): void;
221
- /**
222
- * Disposes of the Worlds component and all its managed worlds.
223
- * This method sets the enabled flag to false, disposes of all worlds, clears the list,
224
- * and triggers the onDisposed event.
225
- *
226
- * @returns {void}
227
- */
277
+ /** {@link Disposable.dispose} */
228
278
  dispose(): void;
229
- /** {@link Updateable.update} */
230
- update(delta?: number): void | Promise<void>;
231
279
  }
232
- import { Component, Disposable, World, Event } from "../Types";
233
- import { GridConfig, SimpleGrid } from "./src";
280
+ import { MiniMap } from "./src";
281
+ import { Component, Updateable, World, Event, Disposable } from "../Types";
234
282
  import { Components } from "../Components";
235
283
  /**
236
- * A component that manages grid instances. Each grid is associated with a unique world. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Grids). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Grids).
284
+ * A component that manages multiple {@link MiniMap} instances, each associated with a unique world ID. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/MiniMap). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/MiniMaps).
237
285
  */
238
- export declare class Grids extends Component implements Disposable {
286
+ export declare class MiniMaps extends Component implements Updateable, Disposable {
239
287
  /**
240
288
  * A unique identifier for the component.
241
289
  * This UUID is used to register the component within the Components system.
242
290
  */
243
- static readonly uuid: "d1e814d5-b81c-4452-87a2-f039375e0489";
244
- /**
245
- * A map of world UUIDs to their corresponding grid instances.
246
- */
247
- list: Map<string, SimpleGrid>;
248
- /**
249
- * The default configuration for grid creation.
250
- */
251
- config: Required<GridConfig>;
291
+ static readonly uuid: "39ad6aad-84c8-4adf-a1e0-7f25313a9e7f";
292
+ /** {@link Updateable.onAfterUpdate} */
293
+ readonly onAfterUpdate: Event<unknown>;
294
+ /** {@link Updateable.onBeforeUpdate} */
295
+ readonly onBeforeUpdate: Event<unknown>;
252
296
  /** {@link Disposable.onDisposed} */
253
297
  readonly onDisposed: Event<unknown>;
254
298
  /** {@link Component.enabled} */
255
299
  enabled: boolean;
300
+ /**
301
+ * A collection of {@link MiniMap} instances, each associated with a unique world ID.
302
+ */
303
+ list: Map<string, MiniMap>;
256
304
  constructor(components: Components);
257
305
  /**
258
- * Creates a new grid for the given world.
259
- * Throws an error if a grid already exists for the world.
260
- *
261
- * @param world - The world to create the grid for.
262
- * @returns The newly created grid.
306
+ * Creates a new {@link MiniMap} instance associated with the given world.
307
+ * If a {@link MiniMap} instance already exists for the given world, an error will be thrown.
263
308
  *
264
- * @throws Will throw an error if a grid already exists for the given world.
309
+ * @param world - The {@link World} for which to create a {@link MiniMap} instance.
310
+ * @returns The newly created {@link MiniMap} instance.
311
+ * @throws Will throw an error if a {@link MiniMap} instance already exists for the given world.
265
312
  */
266
- create(world: World): SimpleGrid;
313
+ create(world: World): MiniMap;
267
314
  /**
268
- * Deletes the grid associated with the given world.
269
- * If a grid does not exist for the given world, this method does nothing.
270
- *
271
- * @param world - The world for which to delete the grid.
315
+ * Deletes a {@link MiniMap} instance associated with the given world ID.
316
+ * If a {@link MiniMap} instance does not exist for the given ID, nothing happens.
272
317
  *
273
- * @remarks
274
- * This method will dispose of the grid and remove it from the internal list.
275
- * If the world is disposed before calling this method, the grid will be automatically deleted.
318
+ * @param id - The unique identifier of the world for which to delete the {@link MiniMap} instance.
319
+ * @returns {void}
276
320
  */
277
- delete(world: World): void;
321
+ delete(id: string): void;
278
322
  /** {@link Disposable.dispose} */
279
323
  dispose(): void;
324
+ /** {@link Updateable.update} */
325
+ update(): void;
280
326
  }
281
327
  import * as THREE from "three";
282
328
  import { Component, Createable, Disposable, Event, Hideable, World } from "../Types";
@@ -405,116 +451,21 @@ export declare class Clipper extends Component implements Createable, Disposable
405
451
  private _onStartDragging;
406
452
  private _onEndDragging;
407
453
  }
454
+ import * as THREE from "three";
408
455
  import { Components } from "../Components";
409
- import { MeshCullerRenderer, CullerRendererSettings } from "./src";
410
- import { Component, Event, Disposable, World } from "../Types";
456
+ import { SimpleCamera } from "..";
457
+ import { NavigationMode, NavModeID, ProjectionManager } from "./src";
411
458
  /**
412
- * A component that provides culling functionality for meshes in a 3D scene. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Cullers). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Cullers).
459
+ * A flexible camera that uses [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls) to control the camera in 2D and 3D. It supports multiple navigation modes, such as 2D floor plan navigation, first person and 3D orbit. This class extends the SimpleCamera class and adds additional functionality for managing different camera projections and navigation modes. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/OrthoPerspectiveCamera). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/OrthoPerspectiveCamera).
413
460
  */
414
- export declare class Cullers extends Component implements Disposable {
461
+ export declare class OrthoPerspectiveCamera extends SimpleCamera {
415
462
  /**
416
- * A unique identifier for the component.
417
- * This UUID is used to register the component within the Components system.
463
+ * A ProjectionManager instance that manages the projection modes of the camera.
418
464
  */
419
- static readonly uuid: "69f2a50d-c266-44fc-b1bd-fa4d34be89e6";
465
+ readonly projection: ProjectionManager;
420
466
  /**
421
- * An event that is triggered when the Cullers component is disposed.
422
- */
423
- readonly onDisposed: Event<unknown>;
424
- private _enabled;
425
- /**
426
- * A map of MeshCullerRenderer instances, keyed by their world UUIDs.
427
- */
428
- list: Map<string, MeshCullerRenderer>;
429
- /** {@link Component.enabled} */
430
- get enabled(): boolean;
431
- /** {@link Component.enabled} */
432
- set enabled(value: boolean);
433
- constructor(components: Components);
434
- /**
435
- * Creates a new MeshCullerRenderer for the given world.
436
- * If a MeshCullerRenderer already exists for the world, it will return the existing one.
437
- *
438
- * @param world - The world for which to create the MeshCullerRenderer.
439
- * @param config - Optional configuration settings for the MeshCullerRenderer.
440
- *
441
- * @returns The newly created or existing MeshCullerRenderer for the given world.
442
- */
443
- create(world: World, config?: Partial<CullerRendererSettings>): MeshCullerRenderer;
444
- /**
445
- * Deletes the MeshCullerRenderer associated with the given world.
446
- * If a MeshCullerRenderer exists for the given world, it will be disposed and removed from the list.
447
- *
448
- * @param world - The world for which to delete the MeshCullerRenderer.
449
- *
450
- * @returns {void}
451
- */
452
- delete(world: World): void;
453
- /** {@link Disposable.dispose} */
454
- dispose(): void;
455
- }
456
- import { MiniMap } from "./src";
457
- import { Component, Updateable, World, Event, Disposable } from "../Types";
458
- import { Components } from "../Components";
459
- /**
460
- * A component that manages multiple {@link MiniMap} instances, each associated with a unique world ID. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/MiniMap). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/MiniMaps).
461
- */
462
- export declare class MiniMaps extends Component implements Updateable, Disposable {
463
- /**
464
- * A unique identifier for the component.
465
- * This UUID is used to register the component within the Components system.
466
- */
467
- static readonly uuid: "39ad6aad-84c8-4adf-a1e0-7f25313a9e7f";
468
- /** {@link Updateable.onAfterUpdate} */
469
- readonly onAfterUpdate: Event<unknown>;
470
- /** {@link Updateable.onBeforeUpdate} */
471
- readonly onBeforeUpdate: Event<unknown>;
472
- /** {@link Disposable.onDisposed} */
473
- readonly onDisposed: Event<unknown>;
474
- /** {@link Component.enabled} */
475
- enabled: boolean;
476
- /**
477
- * A collection of {@link MiniMap} instances, each associated with a unique world ID.
478
- */
479
- list: Map<string, MiniMap>;
480
- constructor(components: Components);
481
- /**
482
- * Creates a new {@link MiniMap} instance associated with the given world.
483
- * If a {@link MiniMap} instance already exists for the given world, an error will be thrown.
484
- *
485
- * @param world - The {@link World} for which to create a {@link MiniMap} instance.
486
- * @returns The newly created {@link MiniMap} instance.
487
- * @throws Will throw an error if a {@link MiniMap} instance already exists for the given world.
488
- */
489
- create(world: World): MiniMap;
490
- /**
491
- * Deletes a {@link MiniMap} instance associated with the given world ID.
492
- * If a {@link MiniMap} instance does not exist for the given ID, nothing happens.
493
- *
494
- * @param id - The unique identifier of the world for which to delete the {@link MiniMap} instance.
495
- * @returns {void}
496
- */
497
- delete(id: string): void;
498
- /** {@link Disposable.dispose} */
499
- dispose(): void;
500
- /** {@link Updateable.update} */
501
- update(): void;
502
- }
503
- import * as THREE from "three";
504
- import { Components } from "../Components";
505
- import { SimpleCamera } from "..";
506
- import { NavigationMode, NavModeID, ProjectionManager } from "./src";
507
- /**
508
- * A flexible camera that uses [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls) to control the camera in 2D and 3D. It supports multiple navigation modes, such as 2D floor plan navigation, first person and 3D orbit. This class extends the SimpleCamera class and adds additional functionality for managing different camera projections and navigation modes. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/OrthoPerspectiveCamera). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/OrthoPerspectiveCamera).
509
- */
510
- export declare class OrthoPerspectiveCamera extends SimpleCamera {
511
- /**
512
- * A ProjectionManager instance that manages the projection modes of the camera.
513
- */
514
- readonly projection: ProjectionManager;
515
- /**
516
- * A THREE.OrthographicCamera instance that represents the orthographic camera.
517
- * This camera is used when the projection mode is set to orthographic.
467
+ * A THREE.OrthographicCamera instance that represents the orthographic camera.
468
+ * This camera is used when the projection mode is set to orthographic.
518
469
  */
519
470
  readonly threeOrtho: THREE.OrthographicCamera;
520
471
  /**
@@ -564,6 +515,55 @@ export declare class OrthoPerspectiveCamera extends SimpleCamera {
564
515
  private newOrthoCamera;
565
516
  private setOrthoPerspCameraAspect;
566
517
  }
518
+ import { Component, Disposable, World, Event } from "../Types";
519
+ import { GridConfig, SimpleGrid } from "./src";
520
+ import { Components } from "../Components";
521
+ /**
522
+ * A component that manages grid instances. Each grid is associated with a unique world. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Grids). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Grids).
523
+ */
524
+ export declare class Grids extends Component implements Disposable {
525
+ /**
526
+ * A unique identifier for the component.
527
+ * This UUID is used to register the component within the Components system.
528
+ */
529
+ static readonly uuid: "d1e814d5-b81c-4452-87a2-f039375e0489";
530
+ /**
531
+ * A map of world UUIDs to their corresponding grid instances.
532
+ */
533
+ list: Map<string, SimpleGrid>;
534
+ /**
535
+ * The default configuration for grid creation.
536
+ */
537
+ config: Required<GridConfig>;
538
+ /** {@link Disposable.onDisposed} */
539
+ readonly onDisposed: Event<unknown>;
540
+ /** {@link Component.enabled} */
541
+ enabled: boolean;
542
+ constructor(components: Components);
543
+ /**
544
+ * Creates a new grid for the given world.
545
+ * Throws an error if a grid already exists for the world.
546
+ *
547
+ * @param world - The world to create the grid for.
548
+ * @returns The newly created grid.
549
+ *
550
+ * @throws Will throw an error if a grid already exists for the given world.
551
+ */
552
+ create(world: World): SimpleGrid;
553
+ /**
554
+ * Deletes the grid associated with the given world.
555
+ * If a grid does not exist for the given world, this method does nothing.
556
+ *
557
+ * @param world - The world for which to delete the grid.
558
+ *
559
+ * @remarks
560
+ * This method will dispose of the grid and remove it from the internal list.
561
+ * If the world is disposed before calling this method, the grid will be automatically deleted.
562
+ */
563
+ delete(world: World): void;
564
+ /** {@link Disposable.dispose} */
565
+ dispose(): void;
566
+ }
567
567
  import * as THREE from "three";
568
568
  import * as FRAGS from "@thatopen/fragments";
569
569
  import { FragmentsGroup } from "@thatopen/fragments";
@@ -772,188 +772,82 @@ export declare class BoundingBoxer extends Component implements Disposable {
772
772
  addFragmentIdMap(fragmentIdMap: FRAGS.FragmentIdMap): void;
773
773
  private static getFragmentBounds;
774
774
  }
775
+ export declare function isPointInFrontOfPlane(point: number[], planePoint: number[], planeNormal: number[]): boolean;
775
776
  import * as THREE from "three";
776
- import * as FRAGS from "@thatopen/fragments";
777
- import { Disposable, Component, Event, Components } from "../../core";
778
- /**
779
- * Interface representing a classification system. The classification is organized by system and class name, and each class contains a map of fragment IDs to their respective express IDs.
780
- */
781
- export interface Classification {
782
- /**
783
- * A system within the classification.
784
- * The key is the system name, and the value is an object representing the classes within the system.
785
- */
786
- [system: string]: {
787
- /**
788
- * A class within the system.
789
- * The key is the class name, and the value is a map of fragment IDs to their respective express IDs.
790
- */
791
- [className: string]: FRAGS.FragmentIdMap;
792
- };
793
- }
777
+ export declare function obbFromPoints(vertices: ArrayLike<number>): {
778
+ center: THREE.Vector3;
779
+ halfSizes: THREE.Vector3;
780
+ rotation: THREE.Matrix3;
781
+ transformation: THREE.Matrix4;
782
+ };
783
+ import { Component, Disposable, Event, Components } from "../../core";
794
784
  /**
795
- * 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).
785
+ * The Exploder component is responsible for managing the explosion of 3D model fragments (generally by floor). 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Exploder). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Exploder).
796
786
  */
797
- export declare class Classifier extends Component implements Disposable {
787
+ export declare class Exploder extends Component implements Disposable {
798
788
  /**
799
789
  * A unique identifier for the component.
800
790
  * This UUID is used to register the component within the Components system.
801
791
  */
802
- static readonly uuid: "e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7";
792
+ static readonly uuid: "d260618b-ce88-4c7d-826c-6debb91de3e2";
793
+ /** {@link Disposable.onDisposed} */
794
+ readonly onDisposed: Event<unknown>;
803
795
  /** {@link Component.enabled} */
804
796
  enabled: boolean;
805
797
  /**
806
- * A map representing the classification systems.
807
- * The key is the system name, and the value is an object representing the classes within the system.
798
+ * The height of the explosion animation.
799
+ * This property determines the vertical distance by which fragments are moved during the explosion.
800
+ * Default value is 10.
808
801
  */
809
- list: Classification;
810
- /** {@link Disposable.onDisposed} */
811
- readonly onDisposed: Event<unknown>;
802
+ height: number;
803
+ /**
804
+ * The group name used for the explosion animation.
805
+ * This property specifies the group of fragments that will be affected by the explosion.
806
+ * Default value is "storeys".
807
+ */
808
+ groupName: string;
809
+ /**
810
+ * A set of strings representing the exploded items.
811
+ * This set is used to keep track of which items have been exploded.
812
+ */
813
+ list: Set<string>;
812
814
  constructor(components: Components);
813
- private onFragmentsDisposed;
814
815
  /** {@link Disposable.dispose} */
815
816
  dispose(): void;
816
817
  /**
817
- * Removes a fragment from the classification based on its unique identifier (guid).
818
- * This method iterates through all classification systems and classes, and deletes the fragment with the specified guid from the respective group.
818
+ * Sets the explosion state of the fragments.
819
819
  *
820
- * @param guid - The unique identifier of the fragment to be removed.
821
- */
822
- remove(guid: string): void;
823
- /**
824
- * Finds and returns fragments based on the provided filter criteria.
825
- * If no filter is provided, it returns all fragments.
820
+ * @param active - A boolean indicating whether to activate or deactivate the explosion.
826
821
  *
827
- * @param filter - An optional object containing filter criteria.
828
- * The keys of the object represent the classification system names,
829
- * and the values are arrays of class names to match.
822
+ * @remarks
823
+ * This method applies a vertical transformation to the fragments based on the 'active' parameter.
824
+ * If 'active' is true, the fragments are moved upwards by a distance determined by the 'height' property.
825
+ * If 'active' is false, the fragments are moved back to their original position.
830
826
  *
831
- * @returns A map of fragment GUIDs to their respective express IDs,
832
- * where the express IDs are filtered based on the provided filter criteria.
827
+ * The method also keeps track of the exploded items using the 'list' set.
833
828
  *
834
- * @throws Will throw an error if the fragments map is malformed.
829
+ * @throws Will throw an error if the 'Classifier' or 'FragmentsManager' components are not found in the 'components' system.
835
830
  */
836
- find(filter?: {
837
- [name: string]: string[];
838
- }): FRAGS.FragmentIdMap;
831
+ set(active: boolean): void;
832
+ }
833
+ import * as FRAGS from "@thatopen/fragments";
834
+ import { Components, Component } from "../../core";
835
+ /**
836
+ * A component that hides or isolates fragments within a 3D scene. It extends the base Component class and provides methods to control fragment visibility and isolation. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Hider). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Hider).
837
+ */
838
+ export declare class Hider extends Component {
839
839
  /**
840
- * Classifies fragments based on their modelID.
841
- *
842
- * @param modelID - The unique identifier of the model to classify fragments by.
843
- * @param group - The FragmentsGroup containing the fragments to be classified.
844
- *
845
- * @remarks
846
- * This method iterates through the fragments in the provided group,
847
- * and classifies them based on their modelID.
848
- * The classification is stored in the 'list.models' property,
849
- * with the modelID as the key and a map of fragment IDs to their respective express IDs as the value.
850
- *
840
+ * A unique identifier for the component.
841
+ * This UUID is used to register the component within the Components system.
851
842
  */
852
- byModel(modelID: string, group: FRAGS.FragmentsGroup): void;
843
+ static readonly uuid: "dd9ccf2d-8a21-4821-b7f6-2949add16a29";
844
+ /** {@link Component.enabled} */
845
+ enabled: boolean;
846
+ constructor(components: Components);
853
847
  /**
854
- * Classifies fragments based on their PredefinedType property.
855
- *
856
- * @param group - The FragmentsGroup containing the fragments to be classified.
857
- *
858
- * @remarks
859
- * This method iterates through the properties of the fragments in the provided group,
860
- * and classifies them based on their PredefinedType property.
861
- * The classification is stored in the 'list.predefinedTypes' property,
862
- * with the PredefinedType as the key and a map of fragment IDs to their respective express IDs as the value.
863
- *
864
- * @throws Will throw an error if the fragment ID is not found.
865
- */
866
- byPredefinedType(group: FRAGS.FragmentsGroup): Promise<void>;
867
- /**
868
- * Classifies fragments based on their entity type.
869
- *
870
- * @param group - The FragmentsGroup containing the fragments to be classified.
871
- *
872
- * @remarks
873
- * This method iterates through the relations of the fragments in the provided group,
874
- * and classifies them based on their entity type.
875
- * The classification is stored in the 'list.entities' property,
876
- * with the entity type as the key and a map of fragment IDs to their respective express IDs as the value.
877
- *
878
- * @throws Will throw an error if the fragment ID is not found.
879
- */
880
- byEntity(group: FRAGS.FragmentsGroup): void;
881
- /**
882
- * Classifies fragments based on a specific IFC relationship.
883
- *
884
- * @param group - The FragmentsGroup containing the fragments to be classified.
885
- * @param ifcRel - The IFC relationship number to classify fragments by.
886
- * @param systemName - The name of the classification system to store the classification.
887
- *
888
- * @remarks
889
- * This method iterates through the relations of the fragments in the provided group,
890
- * and classifies them based on the specified IFC relationship.
891
- * The classification is stored in the 'list' property under the specified system name,
892
- * with the relationship name as the class name and a map of fragment IDs to their respective express IDs as the value.
893
- *
894
- * @throws Will throw an error if the fragment ID is not found or if the IFC relationship is not valid.
895
- */
896
- byIfcRel(group: FRAGS.FragmentsGroup, ifcRel: number, systemName: string): Promise<void>;
897
- /**
898
- * Classifies fragments based on their spatial structure in the IFC model.
899
- *
900
- * @param model - The FragmentsGroup containing the fragments to be classified.
901
- *
902
- * @remarks
903
- * This method iterates through the relations of the fragments in the provided group,
904
- * and classifies them based on their spatial structure in the IFC model.
905
- * The classification is stored in the 'list' property under the system name "spatialStructures",
906
- * with the relationship name as the class name and a map of fragment IDs to their respective express IDs as the value.
907
- *
908
- * @throws Will throw an error if the fragment ID is not found or if the model relations do not exist.
909
- */
910
- bySpatialStructure(model: FRAGS.FragmentsGroup): Promise<void>;
911
- /**
912
- * Sets the color of the specified fragments.
913
- *
914
- * @param items - A map of fragment IDs to their respective express IDs.
915
- * @param color - The color to set for the fragments.
916
- * @param override - A boolean indicating whether to override the existing color of the fragments.
917
- *
918
- * @remarks
919
- * This method iterates through the provided fragment IDs, retrieves the corresponding fragments,
920
- * and sets their color using the 'setColor' method of the FragmentsGroup class.
921
- *
922
- * @throws Will throw an error if the fragment with the specified ID is not found.
923
- */
924
- setColor(items: FRAGS.FragmentIdMap, color: THREE.Color, override?: boolean): void;
925
- /**
926
- * Resets the color of the specified fragments to their original color.
927
- *
928
- * @param items - A map of fragment IDs to their respective express IDs.
929
- *
930
- * @remarks
931
- * This method iterates through the provided fragment IDs, retrieves the corresponding fragments,
932
- * and resets their color using the 'resetColor' method of the FragmentsGroup class.
933
- *
934
- * @throws Will throw an error if the fragment with the specified ID is not found.
935
- */
936
- resetColor(items: FRAGS.FragmentIdMap): void;
937
- protected saveItem(group: FRAGS.FragmentsGroup, systemName: string, className: string, expressID: number): void;
938
- }
939
- import * as FRAGS from "@thatopen/fragments";
940
- import { Components, Component } from "../../core";
941
- /**
942
- * A component that hides or isolates fragments within a 3D scene. It extends the base Component class and provides methods to control fragment visibility and isolation. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Hider). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Hider).
943
- */
944
- export declare class Hider extends Component {
945
- /**
946
- * A unique identifier for the component.
947
- * This UUID is used to register the component within the Components system.
948
- */
949
- static readonly uuid: "dd9ccf2d-8a21-4821-b7f6-2949add16a29";
950
- /** {@link Component.enabled} */
951
- enabled: boolean;
952
- constructor(components: Components);
953
- /**
954
- * Sets the visibility of fragments within the 3D scene.
955
- * If no 'items' parameter is provided, all fragments will be set to the specified visibility.
956
- * If 'items' is provided, only the specified fragments will be affected.
848
+ * Sets the visibility of fragments within the 3D scene.
849
+ * If no 'items' parameter is provided, all fragments will be set to the specified visibility.
850
+ * If 'items' is provided, only the specified fragments will be affected.
957
851
  *
958
852
  * @param visible - The visibility state to set for the fragments.
959
853
  * @param items - An optional map of fragment IDs and their corresponding sub-fragment IDs to be affected.
@@ -974,55 +868,9 @@ export declare class Hider extends Component {
974
868
  isolate(items: FRAGS.FragmentIdMap): void;
975
869
  private updateCulledVisibility;
976
870
  }
977
- import { Component, Disposable, Event, Components } from "../../core";
978
- /**
979
- * The Exploder component is responsible for managing the explosion of 3D model fragments (generally by floor). 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/Exploder). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/Exploder).
980
- */
981
- export declare class Exploder extends Component implements Disposable {
982
- /**
983
- * A unique identifier for the component.
984
- * This UUID is used to register the component within the Components system.
985
- */
986
- static readonly uuid: "d260618b-ce88-4c7d-826c-6debb91de3e2";
987
- /** {@link Disposable.onDisposed} */
988
- readonly onDisposed: Event<unknown>;
989
- /** {@link Component.enabled} */
990
- enabled: boolean;
991
- /**
992
- * The height of the explosion animation.
993
- * This property determines the vertical distance by which fragments are moved during the explosion.
994
- * Default value is 10.
995
- */
996
- height: number;
997
- /**
998
- * The group name used for the explosion animation.
999
- * This property specifies the group of fragments that will be affected by the explosion.
1000
- * Default value is "storeys".
1001
- */
1002
- groupName: string;
1003
- /**
1004
- * A set of strings representing the exploded items.
1005
- * This set is used to keep track of which items have been exploded.
1006
- */
1007
- list: Set<string>;
1008
- constructor(components: Components);
1009
- /** {@link Disposable.dispose} */
1010
- dispose(): void;
1011
- /**
1012
- * Sets the explosion state of the fragments.
1013
- *
1014
- * @param active - A boolean indicating whether to activate or deactivate the explosion.
1015
- *
1016
- * @remarks
1017
- * This method applies a vertical transformation to the fragments based on the 'active' parameter.
1018
- * If 'active' is true, the fragments are moved upwards by a distance determined by the 'height' property.
1019
- * If 'active' is false, the fragments are moved back to their original position.
1020
- *
1021
- * The method also keeps track of the exploded items using the 'list' set.
1022
- *
1023
- * @throws Will throw an error if the 'Classifier' or 'FragmentsManager' components are not found in the 'components' system.
1024
- */
1025
- set(active: boolean): void;
871
+ import * as THREE from "three";
872
+ export declare class MaterialsUtils {
873
+ static isTransparent(material: THREE.Material): boolean;
1026
874
  }
1027
875
  import * as WEBIFC from "web-ifc";
1028
876
  import * as FRAGS from "@thatopen/fragments";
@@ -1139,215 +987,208 @@ export declare class IfcLoader extends Component implements Disposable {
1139
987
  private getGeometry;
1140
988
  private autoSetWasm;
1141
989
  }
1142
- import { Fragment, FragmentsGroup } from "@thatopen/fragments";
1143
- import * as THREE from "three";
1144
- import * as FRAGS from "@thatopen/fragments";
1145
- import { Component, Components, Event, Disposable } from "../../core";
1146
- import { RelationsMap } from "../../ifc/IfcRelationsIndexer/src/types";
990
+ import * as WEBIFC from "web-ifc";
991
+ import { Components, Disposable, Event, Component } from "../../core";
992
+ import { IfcStreamingSettings, StreamedGeometries, StreamedAsset } from "./src";
1147
993
  /**
1148
- * Component to load, delete and manage [fragments](https://github.com/ThatOpen/engine_fragment) efficiently. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/FragmentsManager). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/FragmentsManager).
994
+ * A component that handles the tiling of IFC geometries for efficient streaming. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/IfcGeometryTiler). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/IfcGeometryTiler).
1149
995
  */
1150
- export declare class FragmentsManager extends Component implements Disposable {
996
+ export declare class IfcGeometryTiler extends Component implements Disposable {
1151
997
  /**
1152
998
  * A unique identifier for the component.
1153
999
  * This UUID is used to register the component within the Components system.
1154
1000
  */
1155
- static readonly uuid: "fef46874-46a3-461b-8c44-2922ab77c806";
1156
- /** {@link Disposable.onDisposed} */
1157
- readonly onDisposed: Event<unknown>;
1001
+ static readonly uuid: "d9999a00-e1f5-4d3f-8cfe-c56e08609764";
1158
1002
  /**
1159
- * Event triggered when fragments are loaded.
1003
+ * Event triggered when geometry is streamed.
1004
+ * Contains the streamed geometry data and its buffer.
1160
1005
  */
1161
- readonly onFragmentsLoaded: Event<FragmentsGroup>;
1006
+ readonly onGeometryStreamed: Event<{
1007
+ buffer: Uint8Array;
1008
+ data: StreamedGeometries;
1009
+ }>;
1162
1010
  /**
1163
- * Event triggered when fragments are disposed.
1011
+ * Event triggered when assets are streamed.
1012
+ * Contains the streamed assets.
1164
1013
  */
1165
- readonly onFragmentsDisposed: Event<{
1166
- groupID: string;
1167
- fragmentIDs: string[];
1168
- }>;
1014
+ readonly onAssetStreamed: Event<StreamedAsset[]>;
1169
1015
  /**
1170
- * Map containing all loaded fragments.
1171
- * The key is the fragment's unique identifier, and the value is the fragment itself.
1016
+ * Event triggered to indicate the progress of the streaming process.
1017
+ * Contains the progress percentage.
1172
1018
  */
1173
- readonly list: Map<string, Fragment>;
1019
+ readonly onProgress: Event<number>;
1174
1020
  /**
1175
- * Map containing all loaded fragment groups.
1176
- * The key is the group's unique identifier, and the value is the group itself.
1021
+ * Event triggered when the IFC file is loaded.
1022
+ * Contains the loaded IFC file data.
1177
1023
  */
1178
- readonly groups: Map<string, FragmentsGroup>;
1179
- baseCoordinationModel: string;
1024
+ readonly onIfcLoaded: Event<Uint8Array>;
1025
+ /** {@link Disposable.onDisposed} */
1026
+ readonly onDisposed: Event<unknown>;
1027
+ /**
1028
+ * Settings for the IfcGeometryTiler.
1029
+ */
1030
+ settings: IfcStreamingSettings;
1180
1031
  /** {@link Component.enabled} */
1181
1032
  enabled: boolean;
1182
- private _loader;
1183
1033
  /**
1184
- * Getter for the meshes of all fragments in the FragmentsManager.
1185
- * It iterates over the fragments in the list and pushes their meshes into an array.
1186
- * @returns {THREE.Mesh[]} An array of THREE.Mesh objects representing the fragments.
1034
+ * The WebIFC API instance used for IFC file processing.
1187
1035
  */
1188
- get meshes(): THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>[];
1036
+ webIfc: WEBIFC.IfcAPI;
1037
+ private _spatialTree;
1038
+ private _metaData;
1039
+ private _visitedGeometries;
1040
+ private _streamSerializer;
1041
+ private _geometries;
1042
+ private _geometryCount;
1043
+ private _civil;
1044
+ private _groupSerializer;
1045
+ private _assets;
1046
+ private _meshesWithHoles;
1189
1047
  constructor(components: Components);
1190
1048
  /** {@link Disposable.dispose} */
1191
1049
  dispose(): void;
1192
1050
  /**
1193
- * Dispose of a specific fragment group.
1194
- * This method removes the group from the groups map, deletes all fragments within the group from the list,
1195
- * disposes of the group, and triggers the onFragmentsDisposed event.
1051
+ * This method streams the IFC file from a given buffer.
1196
1052
  *
1197
- * @param group - The fragment group to be disposed.
1053
+ * @param data - The Uint8Array containing the IFC file data.
1054
+ * @returns A Promise that resolves when the streaming process is complete.
1055
+ *
1056
+ * @remarks
1057
+ * This method cleans up any resources after the streaming process is complete.
1058
+ *
1059
+ * @example
1060
+ * '''typescript
1061
+ * const ifcData = await fetch('path/to/ifc/file.ifc');
1062
+ * const rawBuffer = await response.arrayBuffer();
1063
+ * const ifcBuffer = new Uint8Array(rawBuffer);
1064
+ * await ifcGeometryTiler.streamFromBuffer(ifcBuffer);
1065
+ * '''
1198
1066
  */
1199
- disposeGroup(group: FragmentsGroup): void;
1067
+ streamFromBuffer(data: Uint8Array): Promise<void>;
1200
1068
  /**
1201
- * Loads a binary file that contain fragment geometry.
1202
- * @param data - The binary data to load.
1203
- * @param config - Optional configuration for loading.
1204
- * @param config.coordinate - Whether to apply coordinate transformation. Default is true.
1205
- * @param config.properties - Ifc properties to set on the loaded fragments. Not to be used when streaming.
1206
- * @returns The loaded FragmentsGroup.
1069
+ * This method streams the IFC file from a given callback.
1070
+ *
1071
+ * @param loadCallback - The callback function that will be used to load the IFC file.
1072
+ * @returns A Promise that resolves when the streaming process is complete.
1073
+ *
1074
+ * @remarks
1075
+ * This method cleans up any resources after the streaming process is complete.
1076
+ *
1207
1077
  */
1208
- load(data: Uint8Array, config?: Partial<{
1209
- coordinate: boolean;
1210
- name: string;
1211
- properties: FRAGS.IfcProperties;
1212
- relationsMap: RelationsMap;
1213
- }>): FragmentsGroup;
1214
- /**
1215
- * Export the specified fragmentsgroup to binary data.
1216
- * @param group - the fragments group to be exported.
1217
- * @returns the exported data as binary buffer.
1218
- */
1219
- export(group: FragmentsGroup): Uint8Array;
1220
- /**
1221
- * Gets a map of model IDs to sets of express IDs for the given fragment ID map.
1222
- * @param fragmentIdMap - A map of fragment IDs to their corresponding express IDs.
1223
- * @returns A map of model IDs to sets of express IDs.
1224
- */
1225
- getModelIdMap(fragmentIdMap: FRAGS.FragmentIdMap): {
1226
- [modelID: string]: Set<number>;
1227
- };
1078
+ streamFromCallBack(loadCallback: WEBIFC.ModelLoadCallback): Promise<void>;
1079
+ private readIfcFile;
1080
+ private streamIfcFile;
1081
+ private streamAllGeometries;
1082
+ private cleanUp;
1083
+ private getMesh;
1084
+ private getGeometry;
1085
+ private streamAssets;
1086
+ private streamGeometries;
1087
+ }
1088
+ import * as THREE from "three";
1089
+ import * as FRAGS from "@thatopen/fragments";
1090
+ import { Component, Components } from "../../core";
1091
+ /**
1092
+ * Represents an edge measurement result.
1093
+ */
1094
+ export interface MeasureEdge {
1228
1095
  /**
1229
- * Converts a map of model IDs to sets of express IDs to a fragment ID map.
1230
- * @param modelIdMap - A map of model IDs to their corresponding express IDs.
1231
- * @returns A fragment ID map.
1232
- * @remarks
1233
- * This method iterates through the provided model ID map, retrieves the corresponding model from the 'groups' map,
1234
- * and then calls the 'getFragmentMap' method of the model to obtain a fragment ID map for the given express IDs.
1235
- * The fragment ID maps are then merged into a single map and returned.
1236
- * If a model with a given ID is not found in the 'groups' map, the method skips that model and continues with the next one.
1096
+ * The distance between the two points of the edge.
1237
1097
  */
1238
- modelIdToFragmentIdMap(modelIdMap: {
1239
- [modelID: string]: Set<number>;
1240
- }): FRAGS.FragmentIdMap;
1098
+ distance: number;
1241
1099
  /**
1242
- * Applies coordinate transformation to the provided models.
1243
- * If no models are provided, all groups are used.
1244
- * The first model in the list becomes the base model for coordinate transformation.
1245
- * All other models are then transformed to match the base model's coordinate system.
1246
- *
1247
- * @param models - The models to apply coordinate transformation to.
1248
- * If not provided, all groups are used.
1249
- *
1250
- * @returns {void}
1100
+ * The two points that define the edge.
1251
1101
  */
1252
- coordinate(models?: FragmentsGroup[]): void;
1102
+ points: THREE.Vector3[];
1253
1103
  }
1254
- import * as WEBIFC from "web-ifc";
1255
- import { Components, Disposable, Event, Component } from "../../core";
1256
- import { IfcStreamingSettings, StreamedGeometries, StreamedAsset } from "./src";
1257
1104
  /**
1258
- * A component that handles the tiling of IFC geometries for efficient streaming. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/IfcGeometryTiler). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/IfcGeometryTiler).
1105
+ * Utility component for performing measurements on 3D meshes by providing methods for measuring distances between edges and faces. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/MeasurementUtils). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/MeasurementUtils).
1259
1106
  */
1260
- export declare class IfcGeometryTiler extends Component implements Disposable {
1107
+ export declare class MeasurementUtils extends Component {
1261
1108
  /**
1262
1109
  * A unique identifier for the component.
1263
1110
  * This UUID is used to register the component within the Components system.
1264
1111
  */
1265
- static readonly uuid: "d9999a00-e1f5-4d3f-8cfe-c56e08609764";
1266
- /**
1267
- * Event triggered when geometry is streamed.
1268
- * Contains the streamed geometry data and its buffer.
1269
- */
1270
- readonly onGeometryStreamed: Event<{
1271
- buffer: Uint8Array;
1272
- data: StreamedGeometries;
1273
- }>;
1274
- /**
1275
- * Event triggered when assets are streamed.
1276
- * Contains the streamed assets.
1277
- */
1278
- readonly onAssetStreamed: Event<StreamedAsset[]>;
1112
+ static uuid: string;
1113
+ /** {@link Component.enabled} */
1114
+ enabled: boolean;
1115
+ constructor(components: Components);
1279
1116
  /**
1280
- * Event triggered to indicate the progress of the streaming process.
1281
- * Contains the progress percentage.
1117
+ * Utility method to calculate the distance from a point to a line segment.
1118
+ *
1119
+ * @param point - The point from which to calculate the distance.
1120
+ * @param lineStart - The start point of the line segment.
1121
+ * @param lineEnd - The end point of the line segment.
1122
+ * @param clamp - If true, the distance will be clamped to the line segment's length.
1123
+ * @returns The distance from the point to the line segment.
1282
1124
  */
1283
- readonly onProgress: Event<number>;
1125
+ static distanceFromPointToLine(point: THREE.Vector3, lineStart: THREE.Vector3, lineEnd: THREE.Vector3, clamp?: boolean): number;
1284
1126
  /**
1285
- * Event triggered when the IFC file is loaded.
1286
- * Contains the loaded IFC file data.
1127
+ * Method to get the face of a mesh that contains a given triangle index.
1128
+ * It also returns the edges of the found face and their indices.
1129
+ *
1130
+ * @param mesh - The mesh to get the face from. It must be indexed.
1131
+ * @param triangleIndex - The index of the triangle within the mesh.
1132
+ * @param instance - The instance of the mesh (optional).
1133
+ * @returns An object containing the edges of the found face and their indices, or null if no face was found.
1287
1134
  */
1288
- readonly onIfcLoaded: Event<Uint8Array>;
1289
- /** {@link Disposable.onDisposed} */
1290
- readonly onDisposed: Event<unknown>;
1135
+ getFace(mesh: THREE.InstancedMesh | THREE.Mesh, triangleIndex: number, instance?: number): {
1136
+ edges: MeasureEdge[];
1137
+ indices: Set<number>;
1138
+ } | null;
1291
1139
  /**
1292
- * Settings for the IfcGeometryTiler.
1140
+ * Method to get the vertices and normal of a mesh face at a given index.
1141
+ * It also applies instance transformation if provided.
1142
+ *
1143
+ * @param mesh - The mesh to get the face from. It must be indexed.
1144
+ * @param faceIndex - The index of the face within the mesh.
1145
+ * @param instance - The instance of the mesh (optional).
1146
+ * @returns An object containing the vertices and normal of the face.
1147
+ * @throws Will throw an error if the geometry is not indexed.
1293
1148
  */
1294
- settings: IfcStreamingSettings;
1295
- /** {@link Component.enabled} */
1296
- enabled: boolean;
1149
+ getVerticesAndNormal(mesh: THREE.Mesh | THREE.InstancedMesh, faceIndex: number, instance: number | undefined): {
1150
+ p1: THREE.Vector3;
1151
+ p2: THREE.Vector3;
1152
+ p3: THREE.Vector3;
1153
+ faceNormal: THREE.Vector3;
1154
+ };
1297
1155
  /**
1298
- * The WebIFC API instance used for IFC file processing.
1156
+ * Method to round the vector's components to a specified number of decimal places.
1157
+ * This is used to ensure numerical precision in edge detection.
1158
+ *
1159
+ * @param vector - The vector to round.
1160
+ * @returns The vector with rounded components.
1299
1161
  */
1300
- webIfc: WEBIFC.IfcAPI;
1301
- private _spatialTree;
1302
- private _metaData;
1303
- private _visitedGeometries;
1304
- private _streamSerializer;
1305
- private _geometries;
1306
- private _geometryCount;
1307
- private _civil;
1308
- private _groupSerializer;
1309
- private _assets;
1310
- private _meshesWithHoles;
1311
- constructor(components: Components);
1312
- /** {@link Disposable.dispose} */
1313
- dispose(): void;
1162
+ round(vector: THREE.Vector3): void;
1314
1163
  /**
1315
- * This method streams the IFC file from a given buffer.
1164
+ * Calculates the volume of a set of fragments.
1316
1165
  *
1317
- * @param data - The Uint8Array containing the IFC file data.
1318
- * @returns A Promise that resolves when the streaming process is complete.
1166
+ * @param frags - A map of fragment IDs to their corresponding item IDs.
1167
+ * @returns The total volume of the fragments and the bounding sphere.
1319
1168
  *
1320
1169
  * @remarks
1321
- * This method cleans up any resources after the streaming process is complete.
1170
+ * This method creates a set of instanced meshes from the given fragments and item IDs.
1171
+ * It then calculates the volume of each mesh and returns the total volume and its bounding sphere.
1322
1172
  *
1323
- * @example
1324
- * '''typescript
1325
- * const ifcData = await fetch('path/to/ifc/file.ifc');
1326
- * const rawBuffer = await response.arrayBuffer();
1327
- * const ifcBuffer = new Uint8Array(rawBuffer);
1328
- * await ifcGeometryTiler.streamFromBuffer(ifcBuffer);
1329
- * '''
1173
+ * @throws Will throw an error if the geometry of the meshes is not indexed.
1174
+ * @throws Will throw an error if the fragment manager is not available.
1330
1175
  */
1331
- streamFromBuffer(data: Uint8Array): Promise<void>;
1176
+ getVolumeFromFragments(frags: FRAGS.FragmentIdMap): number;
1332
1177
  /**
1333
- * This method streams the IFC file from a given callback.
1178
+ * Calculates the total volume of a set of meshes.
1334
1179
  *
1335
- * @param loadCallback - The callback function that will be used to load the IFC file.
1336
- * @returns A Promise that resolves when the streaming process is complete.
1180
+ * @param meshes - An array of meshes or instanced meshes to calculate the volume from.
1181
+ * @returns The total volume of the meshes and the bounding sphere.
1337
1182
  *
1338
1183
  * @remarks
1339
- * This method cleans up any resources after the streaming process is complete.
1184
+ * This method calculates the volume of each mesh in the provided array and returns the total volume
1185
+ * and its bounding sphere.
1340
1186
  *
1341
1187
  */
1342
- streamFromCallBack(loadCallback: WEBIFC.ModelLoadCallback): Promise<void>;
1343
- private readIfcFile;
1344
- private streamIfcFile;
1345
- private streamAllGeometries;
1346
- private cleanUp;
1347
- private getMesh;
1348
- private getGeometry;
1349
- private streamAssets;
1350
- private streamGeometries;
1188
+ getVolumeFromMeshes(meshes: THREE.InstancedMesh[] | THREE.Mesh[]): number;
1189
+ private getFaceData;
1190
+ private getVolumeOfMesh;
1191
+ private getSignedVolumeOfTriangle;
1351
1192
  }
1352
1193
  import * as WEBIFC from "web-ifc";
1353
1194
  import { AsyncEvent, Component, Disposable, Event } from "../../core";
@@ -1414,590 +1255,753 @@ export declare class IfcPropertiesTiler extends Component implements Disposable
1414
1255
  private streamAllProperties;
1415
1256
  private cleanUp;
1416
1257
  }
1417
- import * as WEBIFC from "web-ifc";
1418
- import * as FRAG from "@thatopen/fragments";
1419
- import { Component, Components } from "../../core";
1258
+ import { Fragment, FragmentsGroup } from "@thatopen/fragments";
1259
+ import * as THREE from "three";
1260
+ import * as FRAGS from "@thatopen/fragments";
1261
+ import { Component, Components, Event, Disposable } from "../../core";
1262
+ import { RelationsMap } from "../../ifc/IfcRelationsIndexer/src/types";
1420
1263
  /**
1421
- * Component to export all the properties from an IFC to a JS object. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/IfcJsonExporter). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/IfcJsonExporter).
1264
+ * Component to load, delete and manage [fragments](https://github.com/ThatOpen/engine_fragment) efficiently. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/FragmentsManager). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/FragmentsManager).
1422
1265
  */
1423
- export declare class IfcJsonExporter extends Component {
1266
+ export declare class FragmentsManager extends Component implements Disposable {
1424
1267
  /**
1425
1268
  * A unique identifier for the component.
1426
1269
  * This UUID is used to register the component within the Components system.
1427
1270
  */
1428
- static readonly uuid: "b32c4332-cd67-436e-ba7f-196646c7a635";
1429
- /** {@link Component.enabled} */
1430
- enabled: boolean;
1431
- constructor(components: Components);
1271
+ static readonly uuid: "fef46874-46a3-461b-8c44-2922ab77c806";
1272
+ /** {@link Disposable.onDisposed} */
1273
+ readonly onDisposed: Event<unknown>;
1432
1274
  /**
1433
- * Exports all the properties of an IFC into an array of JS objects.
1434
- * @param webIfc The instance of [web-ifc](https://github.com/ThatOpen/engine_web-ifc) to use.
1435
- * @param modelID ID of the IFC model whose properties to extract.
1436
- * @param indirect whether to get the indirect relationships as well.
1437
- * @param recursiveSpatial whether to get the properties of spatial items recursively
1438
- * to make the location data available (e.g. absolute position of building).
1275
+ * Event triggered when fragments are loaded.
1439
1276
  */
1440
- export(webIfc: WEBIFC.IfcAPI, modelID: number, indirect?: boolean, recursiveSpatial?: boolean): Promise<FRAG.IfcProperties>;
1441
- }
1442
- import * as WEBIFC from "web-ifc";
1443
- import { FragmentsGroup } from "@thatopen/fragments";
1444
- import { Disposable, Event, Component, Components } from "../../core";
1445
- import { RelationsMap, ModelsRelationMap, InverseAttribute } from "./src/types";
1446
- export type { InverseAttribute, RelationsMap } from "./src/types";
1447
- /**
1448
- * Indexer component for IFC entities, facilitating the indexing and retrieval of IFC entity relationships. It is designed to process models properties by indexing their IFC entities' relations based on predefined inverse attributes, and provides methods to query these relations. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/IfcRelationsIndexer). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/IfcRelationsIndexer).
1449
- */
1450
- export declare class IfcRelationsIndexer extends Component implements Disposable {
1277
+ readonly onFragmentsLoaded: Event<FragmentsGroup>;
1451
1278
  /**
1452
- * A unique identifier for the component.
1453
- * This UUID is used to register the component within the Components system.
1279
+ * Event triggered when fragments are disposed.
1454
1280
  */
1455
- static readonly uuid: "23a889ab-83b3-44a4-8bee-ead83438370b";
1456
- /** {@link Disposable.onDisposed} */
1457
- readonly onDisposed: Event<string>;
1281
+ readonly onFragmentsDisposed: Event<{
1282
+ groupID: string;
1283
+ fragmentIDs: string[];
1284
+ }>;
1458
1285
  /**
1459
- * Event triggered when relations for a model have been indexed.
1460
- * This event provides the model's UUID and the relations map generated for that model.
1461
- *
1462
- * @property {string} modelID - The UUID of the model for which relations have been indexed.
1463
- * @property {RelationsMap} relationsMap - The relations map generated for the specified model.
1464
- * The map keys are expressIDs of entities, and the values are maps where each key is a relation type ID and its value is an array of expressIDs of entities related through that relation type.
1286
+ * Map containing all loaded fragments.
1287
+ * The key is the fragment's unique identifier, and the value is the fragment itself.
1465
1288
  */
1466
- readonly onRelationsIndexed: Event<{
1467
- modelID: string;
1468
- relationsMap: RelationsMap;
1469
- }>;
1289
+ readonly list: Map<string, Fragment>;
1470
1290
  /**
1471
- * Holds the relationship mappings for each model processed by the indexer.
1472
- * The structure is a map where each key is a model's UUID, and the value is another map.
1473
- * This inner map's keys are entity expressIDs, and its values are maps where each key is an index
1474
- * representing a specific relation type, and the value is an array of expressIDs of entities
1475
- * that are related through that relation type. This structure allows for efficient querying
1476
- * of entity relationships within a model.
1291
+ * Map containing all loaded fragment groups.
1292
+ * The key is the group's unique identifier, and the value is the group itself.
1477
1293
  */
1478
- readonly relationMaps: ModelsRelationMap;
1294
+ readonly groups: Map<string, FragmentsGroup>;
1295
+ baseCoordinationModel: string;
1479
1296
  /** {@link Component.enabled} */
1480
1297
  enabled: boolean;
1481
- private _relToAttributesMap;
1482
- private _inverseAttributes;
1483
- private _ifcRels;
1484
- constructor(components: Components);
1485
- private onFragmentsDisposed;
1486
- private indexRelations;
1298
+ private _loader;
1487
1299
  /**
1488
- * Adds a relation map to the model's relations map.
1489
- *
1490
- * @param model - The 'FragmentsGroup' model to which the relation map will be added.
1491
- * @param relationMap - The 'RelationsMap' to be added to the model's relations map.
1492
- *
1493
- * @fires onRelationsIndexed - Triggers an event with the model's UUID and the added relation map.
1300
+ * Getter for the meshes of all fragments in the FragmentsManager.
1301
+ * It iterates over the fragments in the list and pushes their meshes into an array.
1302
+ * @returns {THREE.Mesh[]} An array of THREE.Mesh objects representing the fragments.
1494
1303
  */
1495
- setRelationMap(model: FragmentsGroup, relationMap: RelationsMap): void;
1304
+ get meshes(): THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>[];
1305
+ constructor(components: Components);
1306
+ /** {@link Disposable.dispose} */
1307
+ dispose(): void;
1496
1308
  /**
1497
- * Processes a given model to index its IFC entities relations based on predefined inverse attributes.
1498
- * This method iterates through each specified inverse attribute, retrieves the corresponding relations,
1499
- * and maps them in a structured way to facilitate quick access to related entities.
1500
- *
1501
- * The process involves querying the model for each relation type associated with the inverse attributes
1502
- * and updating the internal relationMaps with the relationships found. This map is keyed by the model's UUID
1503
- * and contains a nested map where each key is an entity's expressID and its value is another map.
1504
- * This inner map's keys are the indices of the inverse attributes, and its values are arrays of expressIDs
1505
- * of entities that are related through that attribute.
1309
+ * Dispose of a specific fragment group.
1310
+ * This method removes the group from the groups map, deletes all fragments within the group from the list,
1311
+ * disposes of the group, and triggers the onFragmentsDisposed event.
1506
1312
  *
1507
- * @param model The 'FragmentsGroup' model to be processed. It must have properties loaded.
1508
- * @returns A promise that resolves to the relations map for the processed model. This map is a detailed
1509
- * representation of the relations indexed by entity expressIDs and relation types.
1510
- * @throws An error if the model does not have properties loaded.
1313
+ * @param group - The fragment group to be disposed.
1511
1314
  */
1512
- process(model: FragmentsGroup): Promise<RelationsMap>;
1315
+ disposeGroup(group: FragmentsGroup): void;
1513
1316
  /**
1514
- * Processes a given model from a WebIfc API to index its IFC entities relations.
1515
- *
1516
- * @param ifcApi - The WebIfc API instance from which to retrieve the model's properties.
1517
- * @param modelID - The unique identifier of the model within the WebIfc API.
1518
- * @returns A promise that resolves to the relations map for the processed model.
1519
- * This map is a detailed representation of the relations indexed by entity expressIDs and relation types.
1317
+ * Loads a binary file that contain fragment geometry.
1318
+ * @param data - The binary data to load.
1319
+ * @param config - Optional configuration for loading.
1320
+ * @param config.coordinate - Whether to apply coordinate transformation. Default is true.
1321
+ * @param config.properties - Ifc properties to set on the loaded fragments. Not to be used when streaming.
1322
+ * @returns The loaded FragmentsGroup.
1520
1323
  */
1521
- processFromWebIfc(ifcApi: WEBIFC.IfcAPI, modelID: number): Promise<RelationsMap>;
1324
+ load(data: Uint8Array, config?: Partial<{
1325
+ coordinate: boolean;
1326
+ name: string;
1327
+ properties: FRAGS.IfcProperties;
1328
+ relationsMap: RelationsMap;
1329
+ }>): FragmentsGroup;
1522
1330
  /**
1523
- * Retrieves the relations of a specific entity within a model based on the given relation name.
1524
- * This method searches the indexed relation maps for the specified model and entity,
1525
- * returning the IDs of related entities if a match is found.
1526
- *
1527
- * @param model The 'FragmentsGroup' model containing the entity.
1528
- * @param expressID The unique identifier of the entity within the model.
1529
- * @param relationName The IFC schema inverse attribute of the relation to search for (e.g., "IsDefinedBy", "ContainsElements").
1530
- * @returns An array of express IDs representing the related entities, or 'null' if no relations are found
1531
- * or the specified relation name is not indexed.
1331
+ * Export the specified fragmentsgroup to binary data.
1332
+ * @param group - the fragments group to be exported.
1333
+ * @returns the exported data as binary buffer.
1532
1334
  */
1533
- getEntityRelations(model: FragmentsGroup, expressID: number, relationName: InverseAttribute): number[] | null;
1335
+ export(group: FragmentsGroup): Uint8Array;
1534
1336
  /**
1535
- * Serializes the relations of a given relation map into a JSON string.
1536
- * This method iterates through the relations in the given map, organizing them into a structured object where each key is an expressID of an entity,
1537
- * and its value is another object mapping relation indices to arrays of related entity expressIDs.
1538
- * The resulting object is then serialized into a JSON string.
1539
- *
1540
- * @param relationMap - The map of relations to be serialized. The map keys are expressIDs of entities, and the values are maps where each key is a relation type ID and its value is an array of expressIDs of entities related through that relation type.
1541
- * @returns A JSON string representing the serialized relations of the given relation map.
1337
+ * Gets a map of model IDs to sets of express IDs for the given fragment ID map.
1338
+ * @param fragmentIdMap - A map of fragment IDs to their corresponding express IDs.
1339
+ * @returns A map of model IDs to sets of express IDs.
1542
1340
  */
1543
- serializeRelations(relationMap: RelationsMap): string;
1341
+ getModelIdMap(fragmentIdMap: FRAGS.FragmentIdMap): {
1342
+ [modelID: string]: Set<number>;
1343
+ };
1544
1344
  /**
1545
- * Serializes the relations of a specific model into a JSON string.
1546
- * This method iterates through the relations indexed for the given model,
1547
- * organizing them into a structured object where each key is an expressID of an entity,
1548
- * and its value is another object mapping relation indices to arrays of related entity expressIDs.
1549
- * The resulting object is then serialized into a JSON string.
1550
- *
1551
- * @param model The 'FragmentsGroup' model whose relations are to be serialized.
1552
- * @returns A JSON string representing the serialized relations of the specified model.
1553
- * If the model has no indexed relations, 'null' is returned.
1345
+ * Converts a map of model IDs to sets of express IDs to a fragment ID map.
1346
+ * @param modelIdMap - A map of model IDs to their corresponding express IDs.
1347
+ * @returns A fragment ID map.
1348
+ * @remarks
1349
+ * This method iterates through the provided model ID map, retrieves the corresponding model from the 'groups' map,
1350
+ * and then calls the 'getFragmentMap' method of the model to obtain a fragment ID map for the given express IDs.
1351
+ * The fragment ID maps are then merged into a single map and returned.
1352
+ * If a model with a given ID is not found in the 'groups' map, the method skips that model and continues with the next one.
1554
1353
  */
1555
- serializeModelRelations(model: FragmentsGroup): string | null;
1354
+ modelIdToFragmentIdMap(modelIdMap: {
1355
+ [modelID: string]: Set<number>;
1356
+ }): FRAGS.FragmentIdMap;
1556
1357
  /**
1557
- * Serializes all relations of every model processed by the indexer into a JSON string.
1558
- * This method iterates through each model's relations indexed in 'relationMaps', organizing them
1559
- * into a structured JSON object. Each top-level key in this object corresponds to a model's UUID,
1560
- * and its value is another object mapping entity expressIDs to their related entities, categorized
1561
- * by relation types. The structure facilitates easy access to any entity's relations across all models.
1358
+ * Applies coordinate transformation to the provided models.
1359
+ * If no models are provided, all groups are used.
1360
+ * The first model in the list becomes the base model for coordinate transformation.
1361
+ * All other models are then transformed to match the base model's coordinate system.
1562
1362
  *
1563
- * @returns A JSON string representing the serialized relations of all models processed by the indexer.
1564
- * If no relations have been indexed, an empty object is returned as a JSON string.
1565
- */
1566
- serializeAllRelations(): string;
1567
- /**
1568
- * Converts a JSON string representing relations between entities into a structured map.
1569
- * This method parses the JSON string to reconstruct the relations map that indexes
1570
- * entity relations by their express IDs. The outer map keys are the express IDs of entities,
1571
- * and the values are maps where each key is a relation type ID and its value is an array
1572
- * of express IDs of entities related through that relation type.
1363
+ * @param models - The models to apply coordinate transformation to.
1364
+ * If not provided, all groups are used.
1573
1365
  *
1574
- * @param json The JSON string to be parsed into the relations map.
1575
- * @returns A 'Map' where the key is the express ID of an entity as a number, and the value
1576
- * is another 'Map'. This inner map's key is the relation type ID as a number, and its value
1577
- * is an array of express IDs (as numbers) of entities related through that relation type.
1366
+ * @returns {void}
1578
1367
  */
1579
- getRelationsMapFromJSON(json: string): RelationsMap;
1580
- /** {@link Disposable.dispose} */
1581
- dispose(): void;
1582
- }
1583
- import * as WEBIFC from "web-ifc";
1584
- import { FragmentsGroup } from "@thatopen/fragments";
1585
- import { Component, Disposable, Event, Components } from "../../core";
1586
- /**
1587
- * Types for boolean properties in IFC schema.
1588
- */
1589
- export type BooleanPropTypes = "IfcBoolean" | "IfcLogical";
1590
- /**
1591
- * Types for string properties in IFC schema.
1592
- */
1593
- export type StringPropTypes = "IfcText" | "IfcLabel" | "IfcIdentifier";
1594
- /**
1595
- * Types for numeric properties in IFC schema.
1596
- */
1597
- export type NumericPropTypes = "IfcInteger" | "IfcReal";
1598
- /**
1599
- * Interface representing a map of changed entities in a model. The keys are model UUIDs, and the values are sets of express IDs of changed entities.
1600
- */
1601
- export interface ChangeMap {
1602
- [modelID: string]: Set<number>;
1368
+ coordinate(models?: FragmentsGroup[]): void;
1603
1369
  }
1370
+ import * as THREE from "three";
1371
+ import * as FRAGS from "@thatopen/fragments";
1372
+ import { Disposable, Component, Event, Components } from "../../core";
1604
1373
  /**
1605
- * Interface representing a map of attribute listeners. The keys are model UUIDs, and the values are objects with express IDs as keys, and objects with attribute names as keys, and Event objects as values.
1374
+ * Interface representing a classification system. The classification is organized by system and class name, and each class contains a map of fragment IDs to their respective express IDs.
1606
1375
  */
1607
- export interface AttributeListener {
1608
- [modelID: string]: {
1609
- [expressID: number]: {
1610
- [attributeName: string]: Event<String | Boolean | Number>;
1611
- };
1376
+ export interface Classification {
1377
+ /**
1378
+ * A system within the classification.
1379
+ * The key is the system name, and the value is an object representing the classes within the system.
1380
+ */
1381
+ [system: string]: {
1382
+ /**
1383
+ * A class within the system.
1384
+ * The key is the class name, and the value is a map of fragment IDs to their respective express IDs.
1385
+ */
1386
+ [className: string]: FRAGS.FragmentIdMap;
1612
1387
  };
1613
1388
  }
1614
1389
  /**
1615
- * Component to manage and edit properties and Psets in IFC files.
1390
+ * 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).
1616
1391
  */
1617
- export declare class IfcPropertiesManager extends Component implements Disposable {
1392
+ export declare class Classifier extends Component implements Disposable {
1618
1393
  /**
1619
1394
  * A unique identifier for the component.
1620
1395
  * This UUID is used to register the component within the Components system.
1621
1396
  */
1622
- static readonly uuid: "58c2d9f0-183c-48d6-a402-dfcf5b9a34df";
1623
- /** {@link Disposable.onDisposed} */
1624
- readonly onDisposed: Event<string>;
1397
+ static readonly uuid: "e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7";
1398
+ /** {@link Component.enabled} */
1399
+ enabled: boolean;
1625
1400
  /**
1626
- * Event triggered when a file is requested for export.
1401
+ * A map representing the classification systems.
1402
+ * The key is the system name, and the value is an object representing the classes within the system.
1627
1403
  */
1628
- readonly onRequestFile: Event<unknown>;
1404
+ list: Classification;
1405
+ /** {@link Disposable.onDisposed} */
1406
+ readonly onDisposed: Event<unknown>;
1407
+ constructor(components: Components);
1408
+ private onFragmentsDisposed;
1409
+ /** {@link Disposable.dispose} */
1410
+ dispose(): void;
1629
1411
  /**
1630
- * ArrayBuffer containing the IFC data to be exported.
1412
+ * Removes a fragment from the classification based on its unique identifier (guid).
1413
+ * This method iterates through all classification systems and classes, and deletes the fragment with the specified guid from the respective group.
1414
+ *
1415
+ * @param guid - The unique identifier of the fragment to be removed.
1631
1416
  */
1632
- ifcToExport: ArrayBuffer | null;
1417
+ remove(guid: string): void;
1633
1418
  /**
1634
- * Event triggered when an element is added to a Pset.
1419
+ * Finds and returns fragments based on the provided filter criteria.
1420
+ * If no filter is provided, it returns all fragments.
1421
+ *
1422
+ * @param filter - An optional object containing filter criteria.
1423
+ * The keys of the object represent the classification system names,
1424
+ * and the values are arrays of class names to match.
1425
+ *
1426
+ * @returns A map of fragment GUIDs to their respective express IDs,
1427
+ * where the express IDs are filtered based on the provided filter criteria.
1428
+ *
1429
+ * @throws Will throw an error if the fragments map is malformed.
1635
1430
  */
1636
- readonly onElementToPset: Event<{
1637
- model: FragmentsGroup;
1638
- psetID: number;
1639
- elementID: number;
1640
- }>;
1431
+ find(filter?: {
1432
+ [name: string]: string[];
1433
+ }): FRAGS.FragmentIdMap;
1641
1434
  /**
1642
- * Event triggered when a property is added to a Pset.
1435
+ * Classifies fragments based on their modelID.
1436
+ *
1437
+ * @param modelID - The unique identifier of the model to classify fragments by.
1438
+ * @param group - The FragmentsGroup containing the fragments to be classified.
1439
+ *
1440
+ * @remarks
1441
+ * This method iterates through the fragments in the provided group,
1442
+ * and classifies them based on their modelID.
1443
+ * The classification is stored in the 'list.models' property,
1444
+ * with the modelID as the key and a map of fragment IDs to their respective express IDs as the value.
1445
+ *
1643
1446
  */
1644
- readonly onPropToPset: Event<{
1645
- model: FragmentsGroup;
1646
- psetID: number;
1647
- propID: number;
1648
- }>;
1447
+ byModel(modelID: string, group: FRAGS.FragmentsGroup): void;
1649
1448
  /**
1650
- * Event triggered when a Pset is removed.
1651
- */
1652
- readonly onPsetRemoved: Event<{
1653
- model: FragmentsGroup;
1654
- psetID: number;
1655
- }>;
1656
- /**
1657
- * Event triggered when data in the model changes.
1658
- */
1659
- readonly onDataChanged: Event<{
1660
- model: FragmentsGroup;
1661
- expressID: number;
1662
- }>;
1663
- /**
1664
- * Configuration for the WebAssembly module.
1665
- */
1666
- wasm: {
1667
- path: string;
1668
- absolute: boolean;
1669
- };
1670
- /** {@link Component.enabled} */
1671
- enabled: boolean;
1672
- /**
1673
- * Map of attribute listeners.
1674
- */
1675
- attributeListeners: AttributeListener;
1676
- /**
1677
- * The currently selected model.
1678
- */
1679
- selectedModel?: FragmentsGroup;
1680
- /**
1681
- * Map of changed entities in the model.
1682
- */
1683
- changeMap: ChangeMap;
1684
- constructor(components: Components);
1685
- /** {@link Disposable.dispose} */
1686
- dispose(): void;
1687
- /**
1688
- * Static method to retrieve the IFC schema from a given model.
1689
- *
1690
- * @param model - The FragmentsGroup model from which to retrieve the IFC schema.
1691
- * @throws Will throw an error if the IFC schema is not found in the model.
1692
- * @returns The IFC schema associated with the given model.
1693
- */
1694
- static getIFCSchema(model: FragmentsGroup): import("@thatopen/fragments").IfcSchema;
1695
- /**
1696
- * Method to set properties data in the model.
1697
- *
1698
- * @param model - The FragmentsGroup model in which to set the properties.
1699
- * @param dataToSave - An array of objects representing the properties to be saved.
1700
- * Each object must have an 'expressID' property, which is the express ID of the entity in the model.
1701
- * The rest of the properties will be set as the properties of the entity.
1702
- *
1703
- * @returns {Promise<void>} A promise that resolves when all the properties have been set.
1704
- *
1705
- * @throws Will throw an error if any of the 'expressID' properties are missing in the 'dataToSave' array.
1706
- */
1707
- setData(model: FragmentsGroup, ...dataToSave: Record<string, any>[]): Promise<void>;
1708
- /**
1709
- * Creates a new Property Set (Pset) in the given model.
1710
- *
1711
- * @param model - The FragmentsGroup model in which to create the Pset.
1712
- * @param name - The name of the Pset.
1713
- * @param description - (Optional) The description of the Pset.
1714
- *
1715
- * @returns A promise that resolves with an object containing the newly created Pset and its relation.
1716
- *
1717
- * @throws Will throw an error if the IFC schema is not found in the model.
1718
- * @throws Will throw an error if no OwnerHistory is found in the model.
1719
- */
1720
- newPset(model: FragmentsGroup, name: string, description?: string): Promise<{
1721
- pset: WEBIFC.IFC2X3.IfcPropertySet | WEBIFC.IFC4.IfcPropertySet | WEBIFC.IFC4X3.IfcPropertySet;
1722
- rel: WEBIFC.IFC4X3.IfcRelDefinesByProperties | WEBIFC.IFC4.IfcRelDefinesByProperties | WEBIFC.IFC2X3.IfcRelDefinesByProperties;
1723
- }>;
1724
- /**
1725
- * Removes a Property Set (Pset) from the given model.
1726
- *
1727
- * @param model - The FragmentsGroup model from which to remove the Pset.
1728
- * @param psetID - The express IDs of the Psets to be removed.
1729
- *
1730
- * @returns {Promise<void>} A promise that resolves when all the Psets have been removed.
1731
- *
1732
- * @throws Will throw an error if any of the 'expressID' properties are missing in the 'psetID' array.
1733
- * @throws Will throw an error if the Pset to be removed is not of type 'IFCPROPERTYSET'.
1734
- * @throws Will throw an error if no relation is found between the Pset and the model.
1735
- */
1736
- removePset(model: FragmentsGroup, ...psetID: number[]): Promise<void>;
1737
- /**
1738
- * Creates a new single-value property of type string in the given model.
1739
- *
1740
- * @param model - The FragmentsGroup model in which to create the property.
1741
- * @param type - The type of the property value. Must be a string property type.
1742
- * @param name - The name of the property.
1743
- * @param value - The value of the property. Must be a string.
1744
- *
1745
- * @returns The newly created single-value property.
1746
- *
1747
- * @throws Will throw an error if the IFC schema is not found in the model.
1748
- * @throws Will throw an error if no OwnerHistory is found in the model.
1749
- */
1750
- newSingleStringProperty(model: FragmentsGroup, type: StringPropTypes, name: string, value: string): Promise<WEBIFC.IFC2X3.IfcPropertySingleValue | WEBIFC.IFC4.IfcPropertySingleValue | WEBIFC.IFC4X3.IfcPropertySingleValue>;
1751
- /**
1752
- * Creates a new single-value property of type numeric in the given model.
1449
+ * Classifies fragments based on their PredefinedType property.
1753
1450
  *
1754
- * @param model - The FragmentsGroup model in which to create the property.
1755
- * @param type - The type of the property value. Must be a numeric property type.
1756
- * @param name - The name of the property.
1757
- * @param value - The value of the property. Must be a number.
1451
+ * @param group - The FragmentsGroup containing the fragments to be classified.
1758
1452
  *
1759
- * @returns The newly created single-value property.
1453
+ * @remarks
1454
+ * This method iterates through the properties of the fragments in the provided group,
1455
+ * and classifies them based on their PredefinedType property.
1456
+ * The classification is stored in the 'list.predefinedTypes' property,
1457
+ * with the PredefinedType as the key and a map of fragment IDs to their respective express IDs as the value.
1760
1458
  *
1761
- * @throws Will throw an error if the IFC schema is not found in the model.
1762
- * @throws Will throw an error if no OwnerHistory is found in the model.
1459
+ * @throws Will throw an error if the fragment ID is not found.
1763
1460
  */
1764
- newSingleNumericProperty(model: FragmentsGroup, type: NumericPropTypes, name: string, value: number): Promise<WEBIFC.IFC2X3.IfcPropertySingleValue | WEBIFC.IFC4.IfcPropertySingleValue | WEBIFC.IFC4X3.IfcPropertySingleValue>;
1461
+ byPredefinedType(group: FRAGS.FragmentsGroup): Promise<void>;
1765
1462
  /**
1766
- * Creates a new single-value property of type boolean in the given model.
1463
+ * Classifies fragments based on their entity type.
1767
1464
  *
1768
- * @param model - The FragmentsGroup model in which to create the property.
1769
- * @param type - The type of the property value. Must be a boolean property type.
1770
- * @param name - The name of the property.
1771
- * @param value - The value of the property. Must be a boolean.
1465
+ * @param group - The FragmentsGroup containing the fragments to be classified.
1772
1466
  *
1773
- * @returns The newly created single-value property.
1467
+ * @remarks
1468
+ * This method iterates through the relations of the fragments in the provided group,
1469
+ * and classifies them based on their entity type.
1470
+ * The classification is stored in the 'list.entities' property,
1471
+ * with the entity type as the key and a map of fragment IDs to their respective express IDs as the value.
1774
1472
  *
1775
- * @throws Will throw an error if the IFC schema is not found in the model.
1776
- * @throws Will throw an error if no OwnerHistory is found in the model.
1473
+ * @throws Will throw an error if the fragment ID is not found.
1777
1474
  */
1778
- newSingleBooleanProperty(model: FragmentsGroup, type: BooleanPropTypes, name: string, value: boolean): Promise<WEBIFC.IFC2X3.IfcPropertySingleValue | WEBIFC.IFC4.IfcPropertySingleValue | WEBIFC.IFC4X3.IfcPropertySingleValue>;
1475
+ byEntity(group: FRAGS.FragmentsGroup): void;
1779
1476
  /**
1780
- * Removes a property from a Property Set (Pset) in the given model.
1477
+ * Classifies fragments based on a specific IFC relationship.
1781
1478
  *
1782
- * @param model - The FragmentsGroup model from which to remove the property.
1783
- * @param psetID - The express ID of the Pset from which to remove the property.
1784
- * @param propID - The express ID of the property to be removed.
1479
+ * @param group - The FragmentsGroup containing the fragments to be classified.
1480
+ * @param ifcRel - The IFC relationship number to classify fragments by.
1481
+ * @param systemName - The name of the classification system to store the classification.
1785
1482
  *
1786
- * @returns {Promise<void>} A promise that resolves when the property has been removed.
1483
+ * @remarks
1484
+ * This method iterates through the relations of the fragments in the provided group,
1485
+ * and classifies them based on the specified IFC relationship.
1486
+ * The classification is stored in the 'list' property under the specified system name,
1487
+ * with the relationship name as the class name and a map of fragment IDs to their respective express IDs as the value.
1787
1488
  *
1788
- * @throws Will throw an error if the Pset or the property to be removed are not found in the model.
1789
- * @throws Will throw an error if the Pset to be removed is not of type 'IFCPROPERTYSET'.
1489
+ * @throws Will throw an error if the fragment ID is not found or if the IFC relationship is not valid.
1790
1490
  */
1791
- removePsetProp(model: FragmentsGroup, psetID: number, propID: number): Promise<void>;
1792
- addElementToPset(model: FragmentsGroup, psetID: number, ...elementID: number[]): Promise<void>;
1491
+ byIfcRel(group: FRAGS.FragmentsGroup, ifcRel: number, systemName: string): Promise<void>;
1793
1492
  /**
1794
- * Adds elements to a Property Set (Pset) in the given model.
1493
+ * Classifies fragments based on their spatial structure in the IFC model.
1795
1494
  *
1796
- * @param model - The FragmentsGroup model in which to add the elements.
1797
- * @param psetID - The express ID of the Pset to which to add the elements.
1798
- * @param elementID - The express IDs of the elements to be added.
1495
+ * @param model - The FragmentsGroup containing the fragments to be classified.
1799
1496
  *
1800
- * @returns {Promise<void>} A promise that resolves when all the elements have been added.
1497
+ * @remarks
1498
+ * This method iterates through the relations of the fragments in the provided group,
1499
+ * and classifies them based on their spatial structure in the IFC model.
1500
+ * The classification is stored in the 'list' property under the system name "spatialStructures",
1501
+ * with the relationship name as the class name and a map of fragment IDs to their respective express IDs as the value.
1801
1502
  *
1802
- * @throws Will throw an error if the Pset or the elements to be added are not found in the model.
1803
- * @throws Will throw an error if the Pset to be added to is not of type 'IFCPROPERTYSET'.
1804
- * @throws Will throw an error if no relation is found between the Pset and the model.
1503
+ * @throws Will throw an error if the fragment ID is not found or if the model relations do not exist.
1805
1504
  */
1806
- addPropToPset(model: FragmentsGroup, psetID: number, ...propID: number[]): Promise<void>;
1505
+ bySpatialStructure(model: FRAGS.FragmentsGroup): Promise<void>;
1807
1506
  /**
1808
- * Saves the changes made to the model to a new IFC file.
1507
+ * Sets the color of the specified fragments.
1809
1508
  *
1810
- * @param model - The FragmentsGroup model from which to save the changes.
1811
- * @param ifcToSaveOn - The Uint8Array representing the original IFC file.
1509
+ * @param items - A map of fragment IDs to their respective express IDs.
1510
+ * @param color - The color to set for the fragments.
1511
+ * @param override - A boolean indicating whether to override the existing color of the fragments.
1812
1512
  *
1813
- * @returns A promise that resolves with the modified IFC data as a Uint8Array.
1513
+ * @remarks
1514
+ * This method iterates through the provided fragment IDs, retrieves the corresponding fragments,
1515
+ * and sets their color using the 'setColor' method of the FragmentsGroup class.
1814
1516
  *
1815
- * @throws Will throw an error if any issues occur during the saving process.
1517
+ * @throws Will throw an error if the fragment with the specified ID is not found.
1816
1518
  */
1817
- saveToIfc(model: FragmentsGroup, ifcToSaveOn: Uint8Array): Promise<Uint8Array>;
1519
+ setColor(items: FRAGS.FragmentIdMap, color: THREE.Color, override?: boolean): void;
1818
1520
  /**
1819
- * Sets an attribute listener for a specific attribute of an entity in the model.
1820
- * The listener will trigger an event whenever the attribute's value changes.
1521
+ * Resets the color of the specified fragments to their original color.
1821
1522
  *
1822
- * @param model - The FragmentsGroup model in which to set the attribute listener.
1823
- * @param expressID - The express ID of the entity for which to set the listener.
1824
- * @param attributeName - The name of the attribute for which to set the listener.
1523
+ * @param items - A map of fragment IDs to their respective express IDs.
1825
1524
  *
1826
- * @returns The event that will be triggered when the attribute's value changes.
1525
+ * @remarks
1526
+ * This method iterates through the provided fragment IDs, retrieves the corresponding fragments,
1527
+ * and resets their color using the 'resetColor' method of the FragmentsGroup class.
1827
1528
  *
1828
- * @throws Will throw an error if the entity with the given expressID doesn't exist.
1829
- * @throws Will throw an error if the attribute is an array or null, and it can't have a listener.
1830
- * @throws Will throw an error if the attribute has a badly defined handle.
1529
+ * @throws Will throw an error if the fragment with the specified ID is not found.
1831
1530
  */
1832
- setAttributeListener(model: FragmentsGroup, expressID: number, attributeName: string): Promise<Event<String | Number | Boolean>>;
1833
- private increaseMaxID;
1834
- private newGUID;
1835
- private getOwnerHistory;
1836
- private registerChange;
1837
- private newSingleProperty;
1531
+ resetColor(items: FRAGS.FragmentIdMap): void;
1532
+ protected saveItem(group: FRAGS.FragmentsGroup, systemName: string, className: string, expressID: number): void;
1838
1533
  }
1839
- import * as THREE from "three";
1840
- import * as FRAGS from "@thatopen/fragments";
1534
+ import * as WEBIFC from "web-ifc";
1535
+ import * as FRAG from "@thatopen/fragments";
1841
1536
  import { Component, Components } from "../../core";
1842
1537
  /**
1843
- * Represents an edge measurement result.
1538
+ * Component to export all the properties from an IFC to a JS object. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/IfcJsonExporter). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/IfcJsonExporter).
1844
1539
  */
1845
- export interface MeasureEdge {
1540
+ export declare class IfcJsonExporter extends Component {
1846
1541
  /**
1847
- * The distance between the two points of the edge.
1542
+ * A unique identifier for the component.
1543
+ * This UUID is used to register the component within the Components system.
1848
1544
  */
1849
- distance: number;
1545
+ static readonly uuid: "b32c4332-cd67-436e-ba7f-196646c7a635";
1546
+ /** {@link Component.enabled} */
1547
+ enabled: boolean;
1548
+ constructor(components: Components);
1850
1549
  /**
1851
- * The two points that define the edge.
1550
+ * Exports all the properties of an IFC into an array of JS objects.
1551
+ * @param webIfc The instance of [web-ifc](https://github.com/ThatOpen/engine_web-ifc) to use.
1552
+ * @param modelID ID of the IFC model whose properties to extract.
1553
+ * @param indirect whether to get the indirect relationships as well.
1554
+ * @param recursiveSpatial whether to get the properties of spatial items recursively
1555
+ * to make the location data available (e.g. absolute position of building).
1852
1556
  */
1853
- points: THREE.Vector3[];
1557
+ export(webIfc: WEBIFC.IfcAPI, modelID: number, indirect?: boolean, recursiveSpatial?: boolean): Promise<FRAG.IfcProperties>;
1854
1558
  }
1559
+ import * as WEBIFC from "web-ifc";
1560
+ import { FragmentsGroup } from "@thatopen/fragments";
1561
+ import { Disposable, Event, Component, Components } from "../../core";
1562
+ import { RelationsMap, ModelsRelationMap, InverseAttribute } from "./src/types";
1563
+ export type { InverseAttribute, RelationsMap } from "./src/types";
1855
1564
  /**
1856
- * Utility component for performing measurements on 3D meshes by providing methods for measuring distances between edges and faces. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/MeasurementUtils). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/MeasurementUtils).
1565
+ * Indexer component for IFC entities, facilitating the indexing and retrieval of IFC entity relationships. It is designed to process models properties by indexing their IFC entities' relations based on predefined inverse attributes, and provides methods to query these relations. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/IfcRelationsIndexer). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/IfcRelationsIndexer).
1857
1566
  */
1858
- export declare class MeasurementUtils extends Component {
1567
+ export declare class IfcRelationsIndexer extends Component implements Disposable {
1859
1568
  /**
1860
1569
  * A unique identifier for the component.
1861
1570
  * This UUID is used to register the component within the Components system.
1862
1571
  */
1863
- static uuid: string;
1864
- /** {@link Component.enabled} */
1865
- enabled: boolean;
1866
- constructor(components: Components);
1572
+ static readonly uuid: "23a889ab-83b3-44a4-8bee-ead83438370b";
1573
+ /** {@link Disposable.onDisposed} */
1574
+ readonly onDisposed: Event<string>;
1867
1575
  /**
1868
- * Utility method to calculate the distance from a point to a line segment.
1869
- *
1870
- * @param point - The point from which to calculate the distance.
1871
- * @param lineStart - The start point of the line segment.
1872
- * @param lineEnd - The end point of the line segment.
1873
- * @param clamp - If true, the distance will be clamped to the line segment's length.
1874
- * @returns The distance from the point to the line segment.
1576
+ * Event triggered when relations for a model have been indexed.
1577
+ * This event provides the model's UUID and the relations map generated for that model.
1578
+ *
1579
+ * @property {string} modelID - The UUID of the model for which relations have been indexed.
1580
+ * @property {RelationsMap} relationsMap - The relations map generated for the specified model.
1581
+ * The map keys are expressIDs of entities, and the values are maps where each key is a relation type ID and its value is an array of expressIDs of entities related through that relation type.
1875
1582
  */
1876
- static distanceFromPointToLine(point: THREE.Vector3, lineStart: THREE.Vector3, lineEnd: THREE.Vector3, clamp?: boolean): number;
1583
+ readonly onRelationsIndexed: Event<{
1584
+ modelID: string;
1585
+ relationsMap: RelationsMap;
1586
+ }>;
1877
1587
  /**
1878
- * Method to get the face of a mesh that contains a given triangle index.
1879
- * It also returns the edges of the found face and their indices.
1880
- *
1881
- * @param mesh - The mesh to get the face from. It must be indexed.
1882
- * @param triangleIndex - The index of the triangle within the mesh.
1883
- * @param instance - The instance of the mesh (optional).
1884
- * @returns An object containing the edges of the found face and their indices, or null if no face was found.
1588
+ * Holds the relationship mappings for each model processed by the indexer.
1589
+ * The structure is a map where each key is a model's UUID, and the value is another map.
1590
+ * This inner map's keys are entity expressIDs, and its values are maps where each key is an index
1591
+ * representing a specific relation type, and the value is an array of expressIDs of entities
1592
+ * that are related through that relation type. This structure allows for efficient querying
1593
+ * of entity relationships within a model.
1885
1594
  */
1886
- getFace(mesh: THREE.InstancedMesh | THREE.Mesh, triangleIndex: number, instance?: number): {
1887
- edges: MeasureEdge[];
1888
- indices: Set<number>;
1889
- } | null;
1595
+ readonly relationMaps: ModelsRelationMap;
1596
+ /** {@link Component.enabled} */
1597
+ enabled: boolean;
1598
+ private _relToAttributesMap;
1599
+ private _inverseAttributes;
1600
+ private _ifcRels;
1601
+ constructor(components: Components);
1602
+ private onFragmentsDisposed;
1603
+ private indexRelations;
1890
1604
  /**
1891
- * Method to get the vertices and normal of a mesh face at a given index.
1892
- * It also applies instance transformation if provided.
1605
+ * Adds a relation map to the model's relations map.
1893
1606
  *
1894
- * @param mesh - The mesh to get the face from. It must be indexed.
1895
- * @param faceIndex - The index of the face within the mesh.
1896
- * @param instance - The instance of the mesh (optional).
1897
- * @returns An object containing the vertices and normal of the face.
1898
- * @throws Will throw an error if the geometry is not indexed.
1607
+ * @param model - The 'FragmentsGroup' model to which the relation map will be added.
1608
+ * @param relationMap - The 'RelationsMap' to be added to the model's relations map.
1609
+ *
1610
+ * @fires onRelationsIndexed - Triggers an event with the model's UUID and the added relation map.
1899
1611
  */
1900
- getVerticesAndNormal(mesh: THREE.Mesh | THREE.InstancedMesh, faceIndex: number, instance: number | undefined): {
1901
- p1: THREE.Vector3;
1902
- p2: THREE.Vector3;
1903
- p3: THREE.Vector3;
1904
- faceNormal: THREE.Vector3;
1905
- };
1612
+ setRelationMap(model: FragmentsGroup, relationMap: RelationsMap): void;
1906
1613
  /**
1907
- * Method to round the vector's components to a specified number of decimal places.
1908
- * This is used to ensure numerical precision in edge detection.
1614
+ * Processes a given model to index its IFC entities relations based on predefined inverse attributes.
1615
+ * This method iterates through each specified inverse attribute, retrieves the corresponding relations,
1616
+ * and maps them in a structured way to facilitate quick access to related entities.
1909
1617
  *
1910
- * @param vector - The vector to round.
1911
- * @returns The vector with rounded components.
1618
+ * The process involves querying the model for each relation type associated with the inverse attributes
1619
+ * and updating the internal relationMaps with the relationships found. This map is keyed by the model's UUID
1620
+ * and contains a nested map where each key is an entity's expressID and its value is another map.
1621
+ * This inner map's keys are the indices of the inverse attributes, and its values are arrays of expressIDs
1622
+ * of entities that are related through that attribute.
1623
+ *
1624
+ * @param model The 'FragmentsGroup' model to be processed. It must have properties loaded.
1625
+ * @returns A promise that resolves to the relations map for the processed model. This map is a detailed
1626
+ * representation of the relations indexed by entity expressIDs and relation types.
1627
+ * @throws An error if the model does not have properties loaded.
1912
1628
  */
1913
- round(vector: THREE.Vector3): void;
1629
+ process(model: FragmentsGroup): Promise<RelationsMap>;
1914
1630
  /**
1915
- * Calculates the volume of a set of fragments.
1631
+ * Processes a given model from a WebIfc API to index its IFC entities relations.
1916
1632
  *
1917
- * @param frags - A map of fragment IDs to their corresponding item IDs.
1918
- * @returns The total volume of the fragments and the bounding sphere.
1633
+ * @param ifcApi - The WebIfc API instance from which to retrieve the model's properties.
1634
+ * @param modelID - The unique identifier of the model within the WebIfc API.
1635
+ * @returns A promise that resolves to the relations map for the processed model.
1636
+ * This map is a detailed representation of the relations indexed by entity expressIDs and relation types.
1637
+ */
1638
+ processFromWebIfc(ifcApi: WEBIFC.IfcAPI, modelID: number): Promise<RelationsMap>;
1639
+ /**
1640
+ * Retrieves the relations of a specific entity within a model based on the given relation name.
1641
+ * This method searches the indexed relation maps for the specified model and entity,
1642
+ * returning the IDs of related entities if a match is found.
1919
1643
  *
1920
- * @remarks
1921
- * This method creates a set of instanced meshes from the given fragments and item IDs.
1922
- * It then calculates the volume of each mesh and returns the total volume and its bounding sphere.
1644
+ * @param model The 'FragmentsGroup' model containing the entity.
1645
+ * @param expressID The unique identifier of the entity within the model.
1646
+ * @param relationName The IFC schema inverse attribute of the relation to search for (e.g., "IsDefinedBy", "ContainsElements").
1647
+ * @returns An array of express IDs representing the related entities, or 'null' if no relations are found
1648
+ * or the specified relation name is not indexed.
1649
+ */
1650
+ getEntityRelations(model: FragmentsGroup, expressID: number, relationName: InverseAttribute): number[] | null;
1651
+ /**
1652
+ * Serializes the relations of a given relation map into a JSON string.
1653
+ * This method iterates through the relations in the given map, organizing them into a structured object where each key is an expressID of an entity,
1654
+ * and its value is another object mapping relation indices to arrays of related entity expressIDs.
1655
+ * The resulting object is then serialized into a JSON string.
1923
1656
  *
1924
- * @throws Will throw an error if the geometry of the meshes is not indexed.
1925
- * @throws Will throw an error if the fragment manager is not available.
1657
+ * @param relationMap - The map of relations to be serialized. The map keys are expressIDs of entities, and the values are maps where each key is a relation type ID and its value is an array of expressIDs of entities related through that relation type.
1658
+ * @returns A JSON string representing the serialized relations of the given relation map.
1926
1659
  */
1927
- getVolumeFromFragments(frags: FRAGS.FragmentIdMap): number;
1660
+ serializeRelations(relationMap: RelationsMap): string;
1928
1661
  /**
1929
- * Calculates the total volume of a set of meshes.
1662
+ * Serializes the relations of a specific model into a JSON string.
1663
+ * This method iterates through the relations indexed for the given model,
1664
+ * organizing them into a structured object where each key is an expressID of an entity,
1665
+ * and its value is another object mapping relation indices to arrays of related entity expressIDs.
1666
+ * The resulting object is then serialized into a JSON string.
1930
1667
  *
1931
- * @param meshes - An array of meshes or instanced meshes to calculate the volume from.
1932
- * @returns The total volume of the meshes and the bounding sphere.
1668
+ * @param model The 'FragmentsGroup' model whose relations are to be serialized.
1669
+ * @returns A JSON string representing the serialized relations of the specified model.
1670
+ * If the model has no indexed relations, 'null' is returned.
1671
+ */
1672
+ serializeModelRelations(model: FragmentsGroup): string | null;
1673
+ /**
1674
+ * Serializes all relations of every model processed by the indexer into a JSON string.
1675
+ * This method iterates through each model's relations indexed in 'relationMaps', organizing them
1676
+ * into a structured JSON object. Each top-level key in this object corresponds to a model's UUID,
1677
+ * and its value is another object mapping entity expressIDs to their related entities, categorized
1678
+ * by relation types. The structure facilitates easy access to any entity's relations across all models.
1933
1679
  *
1934
- * @remarks
1935
- * This method calculates the volume of each mesh in the provided array and returns the total volume
1936
- * and its bounding sphere.
1680
+ * @returns A JSON string representing the serialized relations of all models processed by the indexer.
1681
+ * If no relations have been indexed, an empty object is returned as a JSON string.
1682
+ */
1683
+ serializeAllRelations(): string;
1684
+ /**
1685
+ * Converts a JSON string representing relations between entities into a structured map.
1686
+ * This method parses the JSON string to reconstruct the relations map that indexes
1687
+ * entity relations by their express IDs. The outer map keys are the express IDs of entities,
1688
+ * and the values are maps where each key is a relation type ID and its value is an array
1689
+ * of express IDs of entities related through that relation type.
1937
1690
  *
1691
+ * @param json The JSON string to be parsed into the relations map.
1692
+ * @returns A 'Map' where the key is the express ID of an entity as a number, and the value
1693
+ * is another 'Map'. This inner map's key is the relation type ID as a number, and its value
1694
+ * is an array of express IDs (as numbers) of entities related through that relation type.
1938
1695
  */
1939
- getVolumeFromMeshes(meshes: THREE.InstancedMesh[] | THREE.Mesh[]): number;
1940
- private getFaceData;
1941
- private getVolumeOfMesh;
1942
- private getSignedVolumeOfTriangle;
1696
+ getRelationsMapFromJSON(json: string): RelationsMap;
1697
+ /** {@link Disposable.dispose} */
1698
+ dispose(): void;
1943
1699
  }
1944
- import * as THREE from "three";
1945
- export declare function obbFromPoints(vertices: ArrayLike<number>): {
1946
- center: THREE.Vector3;
1947
- halfSizes: THREE.Vector3;
1948
- rotation: THREE.Matrix3;
1949
- transformation: THREE.Matrix4;
1950
- };
1951
- export declare function isPointInFrontOfPlane(point: number[], planePoint: number[], planeNormal: number[]): boolean;
1952
- import * as THREE from "three";
1953
- export declare class MaterialsUtils {
1954
- static isTransparent(material: THREE.Material): boolean;
1700
+ import * as WEBIFC from "web-ifc";
1701
+ import { FragmentsGroup } from "@thatopen/fragments";
1702
+ import { Component, Disposable, Event, Components } from "../../core";
1703
+ /**
1704
+ * Types for boolean properties in IFC schema.
1705
+ */
1706
+ export type BooleanPropTypes = "IfcBoolean" | "IfcLogical";
1707
+ /**
1708
+ * Types for string properties in IFC schema.
1709
+ */
1710
+ export type StringPropTypes = "IfcText" | "IfcLabel" | "IfcIdentifier";
1711
+ /**
1712
+ * Types for numeric properties in IFC schema.
1713
+ */
1714
+ export type NumericPropTypes = "IfcInteger" | "IfcReal";
1715
+ /**
1716
+ * Interface representing a map of changed entities in a model. The keys are model UUIDs, and the values are sets of express IDs of changed entities.
1717
+ */
1718
+ export interface ChangeMap {
1719
+ [modelID: string]: Set<number>;
1955
1720
  }
1956
- export declare class UUID {
1957
- private static _pattern;
1958
- private static _lut;
1959
- static create(): string;
1960
- static validate(uuid: string): void;
1721
+ /**
1722
+ * Interface representing a map of attribute listeners. The keys are model UUIDs, and the values are objects with express IDs as keys, and objects with attribute names as keys, and Event objects as values.
1723
+ */
1724
+ export interface AttributeListener {
1725
+ [modelID: string]: {
1726
+ [expressID: number]: {
1727
+ [attributeName: string]: Event<String | Boolean | Number>;
1728
+ };
1729
+ };
1961
1730
  }
1962
- import * as THREE from "three";
1963
- import { Component, Components, Disposable, Event, World } from "../core";
1964
1731
  /**
1965
- * Configuration interface for the VertexPicker component.
1732
+ * Component to manage and edit properties and Psets in IFC files.
1966
1733
  */
1967
- export interface VertexPickerConfig {
1734
+ export declare class IfcPropertiesManager extends Component implements Disposable {
1968
1735
  /**
1969
- * If true, only vertices will be picked, not the closest point on the face.
1736
+ * A unique identifier for the component.
1737
+ * This UUID is used to register the component within the Components system.
1970
1738
  */
1971
- showOnlyVertex: boolean;
1739
+ static readonly uuid: "58c2d9f0-183c-48d6-a402-dfcf5b9a34df";
1740
+ /** {@link Disposable.onDisposed} */
1741
+ readonly onDisposed: Event<string>;
1972
1742
  /**
1973
- * The maximum distance for snapping to a vertex.
1743
+ * Event triggered when a file is requested for export.
1974
1744
  */
1975
- snapDistance: number;
1745
+ readonly onRequestFile: Event<unknown>;
1976
1746
  /**
1977
- * The HTML element to use for previewing the picked vertex.
1747
+ * ArrayBuffer containing the IFC data to be exported.
1978
1748
  */
1979
- previewElement: HTMLElement;
1980
- }
1981
- /**
1982
- * A class that provides functionality for picking vertices in a 3D scene.
1983
- */
1984
- export declare class VertexPicker extends Component implements Disposable {
1985
- /** {@link Disposable.onDisposed} */
1986
- readonly onDisposed: Event<unknown>;
1749
+ ifcToExport: ArrayBuffer | null;
1987
1750
  /**
1988
- * An event that is triggered when a vertex is found.
1989
- * The event passes a THREE.Vector3 representing the position of the found vertex.
1751
+ * Event triggered when an element is added to a Pset.
1990
1752
  */
1991
- readonly onVertexFound: Event<THREE.Vector3>;
1753
+ readonly onElementToPset: Event<{
1754
+ model: FragmentsGroup;
1755
+ psetID: number;
1756
+ elementID: number;
1757
+ }>;
1992
1758
  /**
1993
- * An event that is triggered when a vertex is lost.
1994
- * The event passes a THREE.Vector3 representing the position of the lost vertex.
1759
+ * Event triggered when a property is added to a Pset.
1995
1760
  */
1996
- readonly onVertexLost: Event<THREE.Vector3>;
1761
+ readonly onPropToPset: Event<{
1762
+ model: FragmentsGroup;
1763
+ psetID: number;
1764
+ propID: number;
1765
+ }>;
1997
1766
  /**
1998
- * A reference to the Components instance associated with this VertexPicker.
1767
+ * Event triggered when a Pset is removed.
1999
1768
  */
2000
- components: Components;
1769
+ readonly onPsetRemoved: Event<{
1770
+ model: FragmentsGroup;
1771
+ psetID: number;
1772
+ }>;
1773
+ /**
1774
+ * Event triggered when data in the model changes.
1775
+ */
1776
+ readonly onDataChanged: Event<{
1777
+ model: FragmentsGroup;
1778
+ expressID: number;
1779
+ }>;
1780
+ /**
1781
+ * Configuration for the WebAssembly module.
1782
+ */
1783
+ wasm: {
1784
+ path: string;
1785
+ absolute: boolean;
1786
+ };
1787
+ /** {@link Component.enabled} */
1788
+ enabled: boolean;
1789
+ /**
1790
+ * Map of attribute listeners.
1791
+ */
1792
+ attributeListeners: AttributeListener;
1793
+ /**
1794
+ * The currently selected model.
1795
+ */
1796
+ selectedModel?: FragmentsGroup;
1797
+ /**
1798
+ * Map of changed entities in the model.
1799
+ */
1800
+ changeMap: ChangeMap;
1801
+ constructor(components: Components);
1802
+ /** {@link Disposable.dispose} */
1803
+ dispose(): void;
1804
+ /**
1805
+ * Static method to retrieve the IFC schema from a given model.
1806
+ *
1807
+ * @param model - The FragmentsGroup model from which to retrieve the IFC schema.
1808
+ * @throws Will throw an error if the IFC schema is not found in the model.
1809
+ * @returns The IFC schema associated with the given model.
1810
+ */
1811
+ static getIFCSchema(model: FragmentsGroup): import("@thatopen/fragments").IfcSchema;
1812
+ /**
1813
+ * Method to set properties data in the model.
1814
+ *
1815
+ * @param model - The FragmentsGroup model in which to set the properties.
1816
+ * @param dataToSave - An array of objects representing the properties to be saved.
1817
+ * Each object must have an 'expressID' property, which is the express ID of the entity in the model.
1818
+ * The rest of the properties will be set as the properties of the entity.
1819
+ *
1820
+ * @returns {Promise<void>} A promise that resolves when all the properties have been set.
1821
+ *
1822
+ * @throws Will throw an error if any of the 'expressID' properties are missing in the 'dataToSave' array.
1823
+ */
1824
+ setData(model: FragmentsGroup, ...dataToSave: Record<string, any>[]): Promise<void>;
1825
+ /**
1826
+ * Creates a new Property Set (Pset) in the given model.
1827
+ *
1828
+ * @param model - The FragmentsGroup model in which to create the Pset.
1829
+ * @param name - The name of the Pset.
1830
+ * @param description - (Optional) The description of the Pset.
1831
+ *
1832
+ * @returns A promise that resolves with an object containing the newly created Pset and its relation.
1833
+ *
1834
+ * @throws Will throw an error if the IFC schema is not found in the model.
1835
+ * @throws Will throw an error if no OwnerHistory is found in the model.
1836
+ */
1837
+ newPset(model: FragmentsGroup, name: string, description?: string): Promise<{
1838
+ pset: WEBIFC.IFC2X3.IfcPropertySet | WEBIFC.IFC4.IfcPropertySet | WEBIFC.IFC4X3.IfcPropertySet;
1839
+ rel: WEBIFC.IFC4X3.IfcRelDefinesByProperties | WEBIFC.IFC4.IfcRelDefinesByProperties | WEBIFC.IFC2X3.IfcRelDefinesByProperties;
1840
+ }>;
1841
+ /**
1842
+ * Removes a Property Set (Pset) from the given model.
1843
+ *
1844
+ * @param model - The FragmentsGroup model from which to remove the Pset.
1845
+ * @param psetID - The express IDs of the Psets to be removed.
1846
+ *
1847
+ * @returns {Promise<void>} A promise that resolves when all the Psets have been removed.
1848
+ *
1849
+ * @throws Will throw an error if any of the 'expressID' properties are missing in the 'psetID' array.
1850
+ * @throws Will throw an error if the Pset to be removed is not of type 'IFCPROPERTYSET'.
1851
+ * @throws Will throw an error if no relation is found between the Pset and the model.
1852
+ */
1853
+ removePset(model: FragmentsGroup, ...psetID: number[]): Promise<void>;
1854
+ /**
1855
+ * Creates a new single-value property of type string in the given model.
1856
+ *
1857
+ * @param model - The FragmentsGroup model in which to create the property.
1858
+ * @param type - The type of the property value. Must be a string property type.
1859
+ * @param name - The name of the property.
1860
+ * @param value - The value of the property. Must be a string.
1861
+ *
1862
+ * @returns The newly created single-value property.
1863
+ *
1864
+ * @throws Will throw an error if the IFC schema is not found in the model.
1865
+ * @throws Will throw an error if no OwnerHistory is found in the model.
1866
+ */
1867
+ newSingleStringProperty(model: FragmentsGroup, type: StringPropTypes, name: string, value: string): Promise<WEBIFC.IFC2X3.IfcPropertySingleValue | WEBIFC.IFC4.IfcPropertySingleValue | WEBIFC.IFC4X3.IfcPropertySingleValue>;
1868
+ /**
1869
+ * Creates a new single-value property of type numeric in the given model.
1870
+ *
1871
+ * @param model - The FragmentsGroup model in which to create the property.
1872
+ * @param type - The type of the property value. Must be a numeric property type.
1873
+ * @param name - The name of the property.
1874
+ * @param value - The value of the property. Must be a number.
1875
+ *
1876
+ * @returns The newly created single-value property.
1877
+ *
1878
+ * @throws Will throw an error if the IFC schema is not found in the model.
1879
+ * @throws Will throw an error if no OwnerHistory is found in the model.
1880
+ */
1881
+ newSingleNumericProperty(model: FragmentsGroup, type: NumericPropTypes, name: string, value: number): Promise<WEBIFC.IFC2X3.IfcPropertySingleValue | WEBIFC.IFC4.IfcPropertySingleValue | WEBIFC.IFC4X3.IfcPropertySingleValue>;
1882
+ /**
1883
+ * Creates a new single-value property of type boolean in the given model.
1884
+ *
1885
+ * @param model - The FragmentsGroup model in which to create the property.
1886
+ * @param type - The type of the property value. Must be a boolean property type.
1887
+ * @param name - The name of the property.
1888
+ * @param value - The value of the property. Must be a boolean.
1889
+ *
1890
+ * @returns The newly created single-value property.
1891
+ *
1892
+ * @throws Will throw an error if the IFC schema is not found in the model.
1893
+ * @throws Will throw an error if no OwnerHistory is found in the model.
1894
+ */
1895
+ newSingleBooleanProperty(model: FragmentsGroup, type: BooleanPropTypes, name: string, value: boolean): Promise<WEBIFC.IFC2X3.IfcPropertySingleValue | WEBIFC.IFC4.IfcPropertySingleValue | WEBIFC.IFC4X3.IfcPropertySingleValue>;
1896
+ /**
1897
+ * Removes a property from a Property Set (Pset) in the given model.
1898
+ *
1899
+ * @param model - The FragmentsGroup model from which to remove the property.
1900
+ * @param psetID - The express ID of the Pset from which to remove the property.
1901
+ * @param propID - The express ID of the property to be removed.
1902
+ *
1903
+ * @returns {Promise<void>} A promise that resolves when the property has been removed.
1904
+ *
1905
+ * @throws Will throw an error if the Pset or the property to be removed are not found in the model.
1906
+ * @throws Will throw an error if the Pset to be removed is not of type 'IFCPROPERTYSET'.
1907
+ */
1908
+ removePsetProp(model: FragmentsGroup, psetID: number, propID: number): Promise<void>;
1909
+ addElementToPset(model: FragmentsGroup, psetID: number, ...elementID: number[]): Promise<void>;
1910
+ /**
1911
+ * Adds elements to a Property Set (Pset) in the given model.
1912
+ *
1913
+ * @param model - The FragmentsGroup model in which to add the elements.
1914
+ * @param psetID - The express ID of the Pset to which to add the elements.
1915
+ * @param elementID - The express IDs of the elements to be added.
1916
+ *
1917
+ * @returns {Promise<void>} A promise that resolves when all the elements have been added.
1918
+ *
1919
+ * @throws Will throw an error if the Pset or the elements to be added are not found in the model.
1920
+ * @throws Will throw an error if the Pset to be added to is not of type 'IFCPROPERTYSET'.
1921
+ * @throws Will throw an error if no relation is found between the Pset and the model.
1922
+ */
1923
+ addPropToPset(model: FragmentsGroup, psetID: number, ...propID: number[]): Promise<void>;
1924
+ /**
1925
+ * Saves the changes made to the model to a new IFC file.
1926
+ *
1927
+ * @param model - The FragmentsGroup model from which to save the changes.
1928
+ * @param ifcToSaveOn - The Uint8Array representing the original IFC file.
1929
+ *
1930
+ * @returns A promise that resolves with the modified IFC data as a Uint8Array.
1931
+ *
1932
+ * @throws Will throw an error if any issues occur during the saving process.
1933
+ */
1934
+ saveToIfc(model: FragmentsGroup, ifcToSaveOn: Uint8Array): Promise<Uint8Array>;
1935
+ /**
1936
+ * Sets an attribute listener for a specific attribute of an entity in the model.
1937
+ * The listener will trigger an event whenever the attribute's value changes.
1938
+ *
1939
+ * @param model - The FragmentsGroup model in which to set the attribute listener.
1940
+ * @param expressID - The express ID of the entity for which to set the listener.
1941
+ * @param attributeName - The name of the attribute for which to set the listener.
1942
+ *
1943
+ * @returns The event that will be triggered when the attribute's value changes.
1944
+ *
1945
+ * @throws Will throw an error if the entity with the given expressID doesn't exist.
1946
+ * @throws Will throw an error if the attribute is an array or null, and it can't have a listener.
1947
+ * @throws Will throw an error if the attribute has a badly defined handle.
1948
+ */
1949
+ setAttributeListener(model: FragmentsGroup, expressID: number, attributeName: string): Promise<Event<String | Number | Boolean>>;
1950
+ private increaseMaxID;
1951
+ private newGUID;
1952
+ private getOwnerHistory;
1953
+ private registerChange;
1954
+ private newSingleProperty;
1955
+ }
1956
+ export declare class UUID {
1957
+ private static _pattern;
1958
+ private static _lut;
1959
+ static create(): string;
1960
+ static validate(uuid: string): void;
1961
+ }
1962
+ import * as THREE from "three";
1963
+ import { Component, Components, Disposable, Event, World } from "../core";
1964
+ /**
1965
+ * Configuration interface for the VertexPicker component.
1966
+ */
1967
+ export interface VertexPickerConfig {
1968
+ /**
1969
+ * If true, only vertices will be picked, not the closest point on the face.
1970
+ */
1971
+ showOnlyVertex: boolean;
1972
+ /**
1973
+ * The maximum distance for snapping to a vertex.
1974
+ */
1975
+ snapDistance: number;
1976
+ /**
1977
+ * The HTML element to use for previewing the picked vertex.
1978
+ */
1979
+ previewElement: HTMLElement;
1980
+ }
1981
+ /**
1982
+ * A class that provides functionality for picking vertices in a 3D scene.
1983
+ */
1984
+ export declare class VertexPicker extends Component implements Disposable {
1985
+ /** {@link Disposable.onDisposed} */
1986
+ readonly onDisposed: Event<unknown>;
1987
+ /**
1988
+ * An event that is triggered when a vertex is found.
1989
+ * The event passes a THREE.Vector3 representing the position of the found vertex.
1990
+ */
1991
+ readonly onVertexFound: Event<THREE.Vector3>;
1992
+ /**
1993
+ * An event that is triggered when a vertex is lost.
1994
+ * The event passes a THREE.Vector3 representing the position of the lost vertex.
1995
+ */
1996
+ readonly onVertexLost: Event<THREE.Vector3>;
1997
+ /**
1998
+ * An event that is triggered when the picker is enabled or disabled
1999
+ */
2000
+ readonly onEnabled: Event<boolean>;
2001
+ /**
2002
+ * A reference to the Components instance associated with this VertexPicker.
2003
+ */
2004
+ components: Components;
2001
2005
  /**
2002
2006
  * A reference to the working plane used for vertex picking.
2003
2007
  * This plane is used to determine which vertices are considered valid for picking.
@@ -2071,27 +2075,68 @@ export declare class VertexPicker extends Component implements Disposable {
2071
2075
  private getVertices;
2072
2076
  private getVertex;
2073
2077
  }
2074
- import * as THREE from "three";
2075
- import { Resizeable, Updateable, World, Event, Disposable } from "../../Types";
2076
- /**
2077
- * A class representing a 2D minimap of a 3D world.
2078
- */
2079
- export declare class MiniMap implements Resizeable, Updateable, Disposable {
2080
- /** {@link Disposable.onDisposed} */
2081
- readonly onDisposed: Event<unknown>;
2082
- /** {@link Updateable.onAfterUpdate} */
2083
- readonly onAfterUpdate: Event<unknown>;
2084
- /** {@link Updateable.onBeforeUpdate} */
2085
- readonly onBeforeUpdate: Event<unknown>;
2086
- /** {@link Resizeable.onResize} */
2087
- readonly onResize: Event<THREE.Vector2>;
2078
+ import * as WEBIFC from "web-ifc";
2079
+ /** Configuration of the IFC-fragment conversion. */
2080
+ export declare class IfcFragmentSettings {
2081
+ /** Whether to extract the IFC properties into a JSON. */
2082
+ includeProperties: boolean;
2088
2083
  /**
2089
- * The front offset of the minimap.
2090
- * It determines how much the minimap's view is offset from the camera's view.
2091
- * By pushing the map to the front, what the user sees on screen corresponds with what they see on the map
2084
+ * Generate the geometry for categories that are not included by default,
2085
+ * like IFCSPACE.
2092
2086
  */
2093
- frontOffset: number;
2094
- /**
2087
+ optionalCategories: number[];
2088
+ /** Whether to use the coordination data coming from the IFC files. */
2089
+ coordinate: boolean;
2090
+ /** Path of the WASM for [web-ifc](https://github.com/ThatOpen/engine_web-ifc). */
2091
+ wasm: {
2092
+ path: string;
2093
+ absolute: boolean;
2094
+ logLevel?: WEBIFC.LogLevel;
2095
+ };
2096
+ /** List of categories that won't be converted to fragments. */
2097
+ excludedCategories: Set<number>;
2098
+ /** Whether to save the absolute location of all IFC items. */
2099
+ saveLocations: boolean;
2100
+ /** Loader settings for [web-ifc](https://github.com/ThatOpen/engine_web-ifc). */
2101
+ webIfc: WEBIFC.LoaderSettings;
2102
+ /**
2103
+ * Whether to automatically set the path to the WASM file for [web-ifc](https://github.com/ThatOpen/engine_web-ifc).
2104
+ * If set to true, the path will be set to the default path of the WASM file.
2105
+ * If set to false, the path must be provided manually in the 'wasm.path' property.
2106
+ * Default value is true.
2107
+ */
2108
+ autoSetWasm: boolean;
2109
+ /**
2110
+ * Custom function to handle the file location for [web-ifc](https://github.com/ThatOpen/engine_web-ifc).
2111
+ * This function will be called when [web-ifc](https://github.com/ThatOpen/engine_web-ifc) needs to locate a file.
2112
+ * If set to null, the default file location handler will be used.
2113
+ *
2114
+ * @param url - The URL of the file to locate.
2115
+ * @returns The absolute path of the file.
2116
+ */
2117
+ customLocateFileHandler: WEBIFC.LocateFileHandlerFn | null;
2118
+ }
2119
+ import * as THREE from "three";
2120
+ import { Resizeable, Updateable, World, Event, Disposable } from "../../Types";
2121
+ /**
2122
+ * A class representing a 2D minimap of a 3D world.
2123
+ */
2124
+ export declare class MiniMap implements Resizeable, Updateable, Disposable {
2125
+ /** {@link Disposable.onDisposed} */
2126
+ readonly onDisposed: Event<unknown>;
2127
+ /** {@link Updateable.onAfterUpdate} */
2128
+ readonly onAfterUpdate: Event<unknown>;
2129
+ /** {@link Updateable.onBeforeUpdate} */
2130
+ readonly onBeforeUpdate: Event<unknown>;
2131
+ /** {@link Resizeable.onResize} */
2132
+ readonly onResize: Event<THREE.Vector2>;
2133
+ /**
2134
+ * The front offset of the minimap.
2135
+ * It determines how much the minimap's view is offset from the camera's view.
2136
+ * By pushing the map to the front, what the user sees on screen corresponds with what they see on the map
2137
+ */
2138
+ frontOffset: number;
2139
+ /**
2095
2140
  * The override material for the minimap.
2096
2141
  * It is used to render the depth information of the world onto the minimap.
2097
2142
  */
@@ -2164,11 +2209,6 @@ export declare class MiniMap implements Resizeable, Updateable, Disposable {
2164
2209
  * A Set of unique numbers representing different types of IFC geometries.
2165
2210
  */
2166
2211
  export declare const GeometryTypes: Set<number>;
2167
- import { InverseAttribute } from "./types";
2168
- export declare const relToAttributesMap: Map<number, {
2169
- forRelating: InverseAttribute;
2170
- forRelated: InverseAttribute;
2171
- }>;
2172
2212
  import * as WEBIFC from "web-ifc";
2173
2213
  import { IfcItemsCategories } from "../../../ifc";
2174
2214
  export declare class SpatialStructure {
@@ -2178,53 +2218,18 @@ export declare class SpatialStructure {
2178
2218
  cleanUp(): void;
2179
2219
  }
2180
2220
  import * as WEBIFC from "web-ifc";
2181
- /** Configuration of the IFC-fragment conversion. */
2182
- export declare class IfcFragmentSettings {
2183
- /** Whether to extract the IFC properties into a JSON. */
2184
- includeProperties: boolean;
2185
- /**
2186
- * Generate the geometry for categories that are not included by default,
2187
- * like IFCSPACE.
2188
- */
2189
- optionalCategories: number[];
2190
- /** Whether to use the coordination data coming from the IFC files. */
2191
- coordinate: boolean;
2192
- /** Path of the WASM for [web-ifc](https://github.com/ThatOpen/engine_web-ifc). */
2193
- wasm: {
2194
- path: string;
2195
- absolute: boolean;
2196
- logLevel?: WEBIFC.LogLevel;
2197
- };
2198
- /** List of categories that won't be converted to fragments. */
2199
- excludedCategories: Set<number>;
2200
- /** Whether to save the absolute location of all IFC items. */
2201
- saveLocations: boolean;
2202
- /** Loader settings for [web-ifc](https://github.com/ThatOpen/engine_web-ifc). */
2203
- webIfc: WEBIFC.LoaderSettings;
2204
- /**
2205
- * Whether to automatically set the path to the WASM file for [web-ifc](https://github.com/ThatOpen/engine_web-ifc).
2206
- * If set to true, the path will be set to the default path of the WASM file.
2207
- * If set to false, the path must be provided manually in the 'wasm.path' property.
2208
- * Default value is true.
2209
- */
2210
- autoSetWasm: boolean;
2211
- /**
2212
- * Custom function to handle the file location for [web-ifc](https://github.com/ThatOpen/engine_web-ifc).
2213
- * This function will be called when [web-ifc](https://github.com/ThatOpen/engine_web-ifc) needs to locate a file.
2214
- * If set to null, the default file location handler will be used.
2215
- *
2216
- * @param url - The URL of the file to locate.
2217
- * @returns The absolute path of the file.
2218
- */
2219
- customLocateFileHandler: WEBIFC.LocateFileHandlerFn | null;
2220
- }
2221
- import * as WEBIFC from "web-ifc";
2222
2221
  export interface IfcItemsCategories {
2223
2222
  [itemID: number]: number;
2224
2223
  }
2225
2224
  export declare class IfcCategories {
2226
2225
  getAll(webIfc: WEBIFC.IfcAPI, modelID: number): IfcItemsCategories;
2227
2226
  }
2227
+ /**
2228
+ * A map that associates each unique integer identifier (IFC Entity ID) with its corresponding category name. This map is used to map IFC entities to their respective categories for easier identification and processing.
2229
+ */
2230
+ export declare const IfcCategoryMap: {
2231
+ [key: number]: string;
2232
+ };
2228
2233
  /**
2229
2234
  * A map of IFC element types to their corresponding names. The keys are the IFC entity type numbers, and the values are the names of the IFC entities.
2230
2235
  *
@@ -2236,12 +2241,6 @@ export declare class IfcCategories {
2236
2241
  export declare const IfcElements: {
2237
2242
  [key: number]: string;
2238
2243
  };
2239
- /**
2240
- * A map that associates each unique integer identifier (IFC Entity ID) with its corresponding category name. This map is used to map IFC entities to their respective categories for easier identification and processing.
2241
- */
2242
- export declare const IfcCategoryMap: {
2243
- [key: number]: string;
2244
- };
2245
2244
  import * as FRAGS from "@thatopen/fragments";
2246
2245
  export declare class IfcPropertiesUtils {
2247
2246
  static getUnits(group: FRAGS.FragmentsGroup): Promise<number>;
@@ -2267,446 +2266,244 @@ export declare class IfcPropertiesUtils {
2267
2266
  static attributeExists(model: FRAGS.FragmentsGroup, expressID: number, attribute: string): Promise<boolean>;
2268
2267
  static groupEntitiesByType(model: FRAGS.FragmentsGroup, expressIDs: Set<number> | number[]): Promise<Map<number, Set<number>>>;
2269
2268
  }
2269
+ import { InverseAttribute } from "./types";
2270
+ export declare const relToAttributesMap: Map<number, {
2271
+ forRelating: InverseAttribute;
2272
+ forRelated: InverseAttribute;
2273
+ }>;
2270
2274
  import * as THREE from "three";
2271
- import { Disposable, Event } from "../../Types";
2272
- /**
2273
- * A helper to easily get the real position of the mouse in the Three.js canvas to work with tools like the [raycaster](https://threejs.org/docs/#api/en/core/Raycaster), even if it has been transformed through CSS or doesn't occupy the whole screen.
2274
- */
2275
- export declare class Mouse implements Disposable {
2276
- dom: HTMLCanvasElement;
2277
- private _event?;
2278
- private _position;
2279
- /** {@link Disposable.onDisposed} */
2280
- readonly onDisposed: Event<unknown>;
2281
- constructor(dom: HTMLCanvasElement);
2282
- /**
2283
- * The real position of the mouse of the Three.js canvas.
2284
- */
2285
- get position(): THREE.Vector2;
2286
- /** {@link Disposable.dispose} */
2287
- dispose(): void;
2288
- private getPositionY;
2289
- private getPositionX;
2290
- private updateMouseInfo;
2291
- private setupEvents;
2292
- }
2293
- import * as THREE from "three";
2275
+ import { BaseScene, Configurable, Event } from "../../Types";
2294
2276
  import { Components } from "../../Components";
2295
- import { Event, World, Disposable } from "../../Types";
2296
- import { Mouse } from "./mouse";
2297
- /**
2298
- * A simple [raycaster](https://threejs.org/docs/#api/en/core/Raycaster) that allows to easily get items from the scene using the mouse and touch events.
2299
- */
2300
- export declare class SimpleRaycaster implements Disposable {
2301
- /** {@link Component.enabled} */
2302
- enabled: boolean;
2303
- /** The components instance to which this Raycaster belongs. */
2304
- components: Components;
2305
- /** {@link Disposable.onDisposed} */
2306
- readonly onDisposed: Event<unknown>;
2307
- /** The position of the mouse in the screen. */
2308
- readonly mouse: Mouse;
2309
- /**
2310
- * A reference to the Three.js Raycaster instance.
2311
- * This is used for raycasting operations.
2312
- */
2313
- readonly three: THREE.Raycaster;
2314
- /**
2315
- * A reference to the world instance to which this Raycaster belongs.
2316
- * This is used to access the camera and meshes.
2317
- */
2318
- world: World;
2319
- constructor(components: Components, world: World);
2320
- /** {@link Disposable.dispose} */
2321
- dispose(): void;
2322
- /**
2323
- * Throws a ray from the camera to the mouse or touch event point and returns
2324
- * the first item found. This also takes into account the clipping planes
2325
- * used by the renderer.
2326
- *
2327
- * @param items - the [meshes](https://threejs.org/docs/#api/en/objects/Mesh)
2328
- * to query. If not provided, it will query all the meshes stored in
2329
- * {@link Components.meshes}.
2330
- */
2331
- castRay(items?: THREE.Object3D[]): THREE.Intersection | null;
2332
- /**
2333
- * Casts a ray from a given origin in a given direction and returns the first item found.
2334
- * This method also takes into account the clipping planes used by the renderer.
2335
- *
2336
- * @param origin - The origin of the ray.
2337
- * @param direction - The direction of the ray.
2338
- * @param items - The meshes to query. If not provided, it will query all the meshes stored in {@link World.meshes}.
2339
- * @returns The first intersection found or 'null' if no intersection was found.
2340
- */
2341
- castRayFromVector(origin: THREE.Vector3, direction: THREE.Vector3, items?: THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>[]): THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>> | null;
2342
- private intersect;
2343
- private filterClippingPlanes;
2344
- }
2345
- /**
2346
- * 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.
2347
- */
2348
- export declare class Event<T> {
2349
- /**
2350
- * Add a callback to this event instance.
2351
- * @param handler - the callback to be added to this event.
2352
- */
2353
- add(handler: T extends void ? {
2354
- (): void;
2355
- } : {
2356
- (data: T): void;
2357
- }): void;
2358
- /**
2359
- * Removes a callback from this event instance.
2360
- * @param handler - the callback to be removed from this event.
2361
- */
2362
- remove(handler: T extends void ? {
2363
- (): void;
2364
- } : {
2365
- (data: T): void;
2366
- }): void;
2367
- /** Triggers all the callbacks assigned to this event. */
2368
- trigger: (data?: T) => void;
2369
- /** Gets rid of all the suscribed events. */
2370
- reset(): void;
2371
- private handlers;
2372
- }
2373
- /**
2374
- * 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.
2375
- */
2376
- export declare class AsyncEvent<T> {
2377
- /**
2378
- * Add a callback to this event instance.
2379
- * @param handler - the callback to be added to this event.
2380
- */
2381
- add(handler: T extends void ? {
2382
- (): Promise<void>;
2383
- } : {
2384
- (data: T): Promise<void>;
2385
- }): void;
2386
- /**
2387
- * Removes a callback from this event instance.
2388
- * @param handler - the callback to be removed from this event.
2389
- */
2390
- remove(handler: T extends void ? {
2391
- (): Promise<void>;
2392
- } : {
2393
- (data: T): Promise<void>;
2394
- }): void;
2395
- /** Triggers all the callbacks assigned to this event. */
2396
- trigger: (data?: T) => Promise<void>;
2397
- /** Gets rid of all the suscribed events. */
2398
- reset(): void;
2399
- private handlers;
2400
- }
2401
- import * as THREE from "three";
2402
- import CameraControls from "camera-controls";
2403
- import { Event } from "./event";
2404
- /**
2405
- * 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.
2406
- */
2407
- export interface Disposable {
2408
- /**
2409
- * Destroys the object from memory to prevent a
2410
- * [memory leak](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects).
2411
- */
2412
- dispose: () => void | Promise<void>;
2413
- /** Fired after the tool has been disposed. */
2414
- readonly onDisposed: Event<any>;
2415
- }
2416
- /**
2417
- * Whether the geometric representation of this component can be hidden or shown in the [Three.js scene](https://threejs.org/docs/#api/en/scenes/Scene).
2418
- */
2419
- export interface Hideable {
2420
- /**
2421
- * Whether the geometric representation of this component is
2422
- * currently visible or not in the
2423
- * [Three.js scene](https://threejs.org/docs/#api/en/scenes/Scene).
2424
- */
2425
- visible: boolean;
2426
- }
2427
- /**
2428
- * Whether this component can be resized. The meaning of this can vary depending on the component: resizing a [Renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer) component could mean changing its resolution, whereas resizing a [Mesh](https://threejs.org/docs/#api/en/objects/Mesh) would change its scale.
2429
- */
2430
- export interface Resizeable {
2431
- /**
2432
- * Sets size of this component (e.g. the resolution of a
2433
- * [Renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer)
2434
- * component.
2435
- */
2436
- resize: (size?: THREE.Vector2) => void;
2437
- /** Event that fires when the component has been resized. */
2438
- onResize: Event<THREE.Vector2>;
2439
- /**
2440
- * Gets the current size of this component (e.g. the resolution of a
2441
- * [Renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer)
2442
- * component.
2443
- */
2444
- getSize: () => THREE.Vector2;
2445
- }
2446
- /** Whether this component should be updated each frame. */
2447
- export interface Updateable {
2448
- /** Actions that should be executed after updating the component. */
2449
- onAfterUpdate: Event<any>;
2450
- /** Actions that should be executed before updating the component. */
2451
- onBeforeUpdate: Event<any>;
2452
- /**
2453
- * Function used to update the state of this component each frame. For
2454
- * instance, a renderer component will make a render each frame.
2455
- */
2456
- update(delta?: number): void;
2457
- }
2458
- /** Basic type to describe the progress of any kind of process. */
2459
- export interface Progress {
2460
- /** The amount of things that have been done already. */
2461
- current: number;
2462
- /** The total amount of things to be done by the process. */
2463
- total: number;
2464
- }
2465
2277
  /**
2466
- * Whether this component supports create and destroy operations. This generally applies for components that work with instances, such as clipping planes or dimensions.
2278
+ * Configuration interface for the {@link SimpleScene}. Defines properties for directional and ambient lights.
2467
2279
  */
2468
- export interface Createable {
2469
- /** Creates a new instance of an element (e.g. a new Dimension). */
2470
- create: (data: any) => void;
2471
- /**
2472
- * Finish the creation process of the component, successfully creating an
2473
- * instance of whatever the component creates.
2474
- */
2475
- endCreation?: (data: any) => void;
2476
- /**
2477
- * Cancels the creation process of the component, going back to the state
2478
- * before starting to create.
2479
- */
2480
- cancelCreation?: (data: any) => void;
2481
- /** Deletes an existing instance of an element (e.g. a Dimension). */
2482
- delete: (data: any) => void;
2280
+ export interface SimpleSceneConfig {
2281
+ directionalLight: {
2282
+ color: THREE.Color;
2283
+ intensity: number;
2284
+ position: THREE.Vector3;
2285
+ };
2286
+ ambientLight: {
2287
+ color: THREE.Color;
2288
+ intensity: number;
2289
+ };
2483
2290
  }
2484
2291
  /**
2485
- * Whether this component supports to be configured.
2292
+ * A basic 3D [scene](https://threejs.org/docs/#api/en/scenes/Scene) to add objects hierarchically, and easily dispose them when you are finished with it.
2486
2293
  */
2487
- export interface Configurable<T extends Record<string, any>> {
2488
- /** Wether this components has been already configured. */
2294
+ export declare class SimpleScene extends BaseScene implements Configurable<{}> {
2295
+ /** {@link Configurable.isSetup} */
2489
2296
  isSetup: boolean;
2490
- /** Use the provided configuration to setup the tool. */
2491
- setup: (config?: Partial<T>) => void | Promise<void>;
2492
- /** Fired after successfully calling {@link Configurable.setup()} */
2493
- readonly onSetup: Event<any>;
2494
- /** Object holding the tool configuration. Is not meant to be edited directly, if you need
2495
- * to make changes to this object, use {@link Configurable.setup()} just after the tool is instantiated.
2496
- */
2497
- config: Required<T>;
2498
- }
2499
- /**
2500
- * Whether a camera uses the Camera Controls library.
2501
- */
2502
- export interface CameraControllable {
2503
2297
  /**
2504
- * An instance of CameraControls that provides camera control functionalities.
2505
- * This instance is used to manipulate the camera.
2298
+ * The underlying Three.js scene object.
2299
+ * It is used to define the 3D space containing objects, lights, and cameras.
2506
2300
  */
2507
- controls: CameraControls;
2508
- }
2509
- import { Base } from "./base";
2510
- /**
2511
- * Components are the building blocks of this library. Components are singleton elements that contain specific functionality. For instance, the Clipper Component can create, delete and handle 3D clipping planes. Components must be unique (they can't be instanced more than once per Components instance), and have a static UUID that identifies them uniquely. The can be accessed globally using the {@link Components} instance.
2512
- */
2513
- export declare abstract class Component extends Base {
2301
+ three: THREE.Scene;
2302
+ /** {@link Configurable.onSetup} */
2303
+ readonly onSetup: Event<SimpleScene>;
2514
2304
  /**
2515
- * Whether this component is active or not. The behaviour can vary depending
2516
- * on the type of component. E.g. a disabled dimension tool will stop creating
2517
- * dimensions, while a disabled camera will stop moving. A disabled component
2518
- * will not be updated automatically each frame.
2305
+ * Configuration interface for the {@link SimpleScene}.
2306
+ * Defines properties for directional and ambient lights.
2519
2307
  */
2520
- abstract enabled: boolean;
2521
- }
2522
- import { Disposable, Hideable, Resizeable, Updateable, Configurable } from "./interfaces";
2523
- import { Components } from "../../Components";
2524
- /**
2525
- * Base class of the library. Useful for finding out the interfaces something implements.
2526
- */
2527
- export declare abstract class Base {
2528
- components: Components;
2308
+ config: Required<SimpleSceneConfig>;
2529
2309
  constructor(components: Components);
2530
- /** Whether is component is {@link Disposable}. */
2531
- isDisposeable: () => this is Disposable;
2532
- /** Whether is component is {@link Resizeable}. */
2533
- isResizeable: () => this is Resizeable;
2534
- /** Whether is component is {@link Updateable}. */
2535
- isUpdateable: () => this is Updateable;
2536
- /** Whether is component is {@link Hideable}. */
2537
- isHideable: () => this is Hideable;
2538
- /** Whether is component is {@link Configurable}. */
2539
- isConfigurable: () => this is Configurable<any>;
2310
+ /** {@link Configurable.setup} */
2311
+ setup(config?: Partial<SimpleSceneConfig>): void;
2540
2312
  }
2541
2313
  import * as THREE from "three";
2542
- import CameraControls from "camera-controls";
2543
- import { BaseWorldItem } from "./base-world-item";
2544
- import { CameraControllable } from "./interfaces";
2314
+ import { Event, Base, World, BaseScene, BaseCamera, BaseRenderer, Disposable, Updateable } from "../../Types";
2545
2315
  /**
2546
- * Abstract class representing a camera in a 3D world. All cameras should use this class as a base.
2316
+ * A class representing a simple world in a 3D environment. It extends the Base class and implements the World interface.
2317
+ *
2318
+ * @template T - The type of the scene. Default is BaseScene.
2319
+ * @template U - The type of the camera. Default is BaseCamera.
2320
+ * @template S - The type of the renderer. Default is BaseRenderer.
2547
2321
  */
2548
- export declare abstract class BaseCamera extends BaseWorldItem {
2322
+ export declare class SimpleWorld<T extends BaseScene = BaseScene, U extends BaseCamera = BaseCamera, S extends BaseRenderer = BaseRenderer> extends Base implements World, Disposable, Updateable {
2549
2323
  /**
2550
- * Whether the camera is enabled or not.
2324
+ * All the loaded [meshes](https://threejs.org/docs/#api/en/objects/Mesh). These meshes will be taken into account in operations like raycasting.
2551
2325
  */
2552
- abstract enabled: boolean;
2326
+ readonly meshes: Set<THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>>;
2327
+ /** {@link Updateable.onAfterUpdate} */
2328
+ readonly onAfterUpdate: Event<unknown>;
2329
+ /** {@link Updateable.onBeforeUpdate} */
2330
+ readonly onBeforeUpdate: Event<unknown>;
2331
+ /** {@link Disposable.onDisposed} */
2332
+ readonly onDisposed: Event<unknown>;
2553
2333
  /**
2554
- * The Three.js camera instance.
2334
+ * Indicates whether the world is currently being disposed. This is useful to prevent trying to access world's elements when it's being disposed, which could cause errors when you dispose a world.
2555
2335
  */
2556
- abstract three: THREE.Camera;
2336
+ isDisposing: boolean;
2557
2337
  /**
2558
- * Optional CameraControls instance for controlling the camera.
2559
- * This property is only available if the camera is controllable.
2338
+ * Indicates whether the world is currently enabled.
2339
+ * When disabled, the world will not be updated.
2560
2340
  */
2561
- abstract controls?: CameraControls;
2341
+ enabled: boolean;
2562
2342
  /**
2563
- * Checks whether the instance is {@link CameraControllable}.
2564
- *
2565
- * @returns True if the instance is controllable, false otherwise.
2343
+ * A unique identifier for the world.
2566
2344
  */
2567
- hasCameraControls: () => this is CameraControllable;
2568
- }
2569
- import { Base } from "./base";
2570
- import { World } from "./world";
2571
- import { Event } from "./event";
2572
- import { Components } from "../../Components";
2573
- /**
2574
- * One of the elements that make a world. It can be either a scene, a camera or a renderer.
2575
- */
2576
- export declare abstract class BaseWorldItem extends Base {
2577
- readonly worlds: Map<string, World>;
2345
+ uuid: string;
2578
2346
  /**
2579
- * Event that is triggered when a world is added or removed from the 'worlds' map.
2580
- * The event payload contains the world instance and the action ("added" or "removed").
2347
+ * An optional name for the world.
2581
2348
  */
2582
- readonly onWorldChanged: Event<{
2583
- world: World;
2584
- action: "added" | "removed";
2585
- }>;
2349
+ name?: string;
2350
+ private _scene?;
2351
+ private _camera?;
2352
+ private _renderer;
2586
2353
  /**
2587
- * The current world this item is associated with. It can be null if no world is currently active.
2354
+ * Getter for the scene. If no scene is initialized, it throws an error.
2355
+ * @returns The current scene.
2588
2356
  */
2589
- currentWorld: World | null;
2590
- protected constructor(components: Components);
2591
- }
2592
- import * as THREE from "three";
2593
- import { Vector2 } from "three";
2594
- import { Event } from "./event";
2595
- import { BaseWorldItem } from "./base-world-item";
2596
- import { Disposable, Resizeable, Updateable } from "./interfaces";
2597
- /**
2598
- * Abstract class representing a renderer for a 3D world. All renderers should use this class as a base.
2599
- */
2600
- export declare abstract class BaseRenderer extends BaseWorldItem implements Updateable, Disposable, Resizeable {
2357
+ get scene(): T;
2601
2358
  /**
2602
- * The three.js WebGLRenderer instance associated with this renderer.
2603
- *
2604
- * @abstract
2605
- * @type {THREE.WebGLRenderer}
2359
+ * Setter for the scene. It sets the current scene, adds the world to the scene's worlds set,
2360
+ * sets the current world in the scene, and triggers the scene's onWorldChanged event with the added action.
2361
+ * @param scene - The new scene to be set.
2606
2362
  */
2607
- abstract three: THREE.WebGLRenderer;
2608
- /** {@link Updateable.onBeforeUpdate} */
2609
- onAfterUpdate: Event<unknown>;
2610
- /** {@link Updateable.onAfterUpdate} */
2611
- onBeforeUpdate: Event<unknown>;
2612
- /** {@link Disposable.onDisposed} */
2613
- readonly onDisposed: Event<undefined>;
2614
- /** {@link Resizeable.onResize} */
2615
- readonly onResize: Event<THREE.Vector2>;
2363
+ set scene(scene: T);
2616
2364
  /**
2617
- * Event that fires when there has been a change to the list of clipping
2618
- * planes used by the active renderer.
2365
+ * Getter for the camera. If no camera is initialized, it throws an error.
2366
+ * @returns The current camera.
2619
2367
  */
2620
- readonly onClippingPlanesUpdated: Event<unknown>;
2621
- /** {@link Updateable.update} */
2622
- abstract update(delta?: number): void | Promise<void>;
2623
- /** {@link Disposable.dispose} */
2624
- abstract dispose(): void;
2625
- /** {@link Resizeable.getSize} */
2626
- abstract getSize(): Vector2;
2627
- /** {@link Resizeable.resize} */
2628
- abstract resize(size: Vector2 | undefined): void;
2368
+ get camera(): U;
2629
2369
  /**
2630
- * The list of [clipping planes](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.clippingPlanes) used by this instance of the renderer.
2370
+ * Setter for the camera. It sets the current camera, adds the world to the camera's worlds set,
2371
+ * sets the current world in the camera, and triggers the camera's onWorldChanged event with the added action.
2372
+ * @param camera - The new camera to be set.
2631
2373
  */
2632
- clippingPlanes: THREE.Plane[];
2374
+ set camera(camera: U);
2633
2375
  /**
2634
- * Updates the clipping planes and triggers the 'onClippingPlanesUpdated' event.
2635
- *
2636
- * @remarks
2637
- * This method is typically called when there is a change to the list of clipping planes
2638
- * used by the active renderer.
2376
+ * Getter for the renderer.
2377
+ * @returns The current renderer or null if no renderer is set. Some worlds don't need a renderer to work (when your mail goal is not to display a 3D viewport to the user).
2639
2378
  */
2640
- updateClippingPlanes(): void;
2379
+ get renderer(): S | null;
2641
2380
  /**
2642
- * Sets or removes a clipping plane from the renderer.
2643
- *
2644
- * @param active - A boolean indicating whether the clipping plane should be active or not.
2645
- * @param plane - The clipping plane to be added or removed.
2646
- * @param isLocal - An optional boolean indicating whether the clipping plane is local to the object. If not provided, it defaults to 'false'.
2647
- *
2648
- * @remarks
2649
- * This method adds or removes a clipping plane from the 'clippingPlanes' array.
2650
- * If 'active' is 'true' and the plane is not already in the array, it is added.
2651
- * If 'active' is 'false' and the plane is in the array, it is removed.
2652
- * The 'three.clippingPlanes' property is then updated to reflect the current state of the 'clippingPlanes' array,
2653
- * excluding any planes marked as local.
2381
+ * Setter for the renderer. It sets the current renderer, adds the world to the renderer's worlds set,
2382
+ * sets the current world in the renderer, and triggers the renderer's onWorldChanged event with the added action.
2383
+ * If a new renderer is set, it also triggers the onWorldChanged event with the removed action for the old renderer.
2384
+ * @param renderer - The new renderer to be set or null to remove the current renderer.
2654
2385
  */
2655
- setPlane(active: boolean, plane: THREE.Plane, isLocal?: boolean): void;
2386
+ set renderer(renderer: S | null);
2387
+ /** {@link Updateable.update} */
2388
+ update(delta?: number): void;
2389
+ /** {@link Disposable.dispose} */
2390
+ dispose(disposeResources?: boolean): void;
2656
2391
  }
2657
2392
  import * as THREE from "three";
2658
- import { Disposable } from "./interfaces";
2659
- import { Event } from "./event";
2393
+ import { BaseRenderer, Event } from "../../Types";
2660
2394
  import { Components } from "../../Components";
2661
- import { BaseWorldItem } from "./base-world-item";
2662
2395
  /**
2663
- * Abstract class representing a base scene in the application. All scenes should use this class as a base.
2396
+ * A basic renderer capable of rendering [Objec3Ds](https://threejs.org/docs/#api/en/core/Object3D).
2664
2397
  */
2665
- export declare abstract class BaseScene extends BaseWorldItem implements Disposable {
2666
- /** {@link Disposable.onDisposed} */
2667
- readonly onDisposed: Event<unknown>;
2398
+ export declare class SimpleRenderer extends BaseRenderer {
2668
2399
  /**
2669
- * Abstract property representing the three.js object associated with this scene.
2670
- * It should be implemented by subclasses.
2400
+ * Indicates whether the renderer is enabled. If it's not, it won't be updated.
2401
+ * Default is 'true'.
2671
2402
  */
2672
- abstract three: THREE.Object3D;
2673
- protected constructor(components: Components);
2403
+ enabled: boolean;
2404
+ /**
2405
+ * The HTML container of the THREE.js canvas where the scene is rendered.
2406
+ */
2407
+ container: HTMLElement;
2408
+ /**
2409
+ * The THREE.js WebGLRenderer instance.
2410
+ */
2411
+ three: THREE.WebGLRenderer;
2412
+ protected _canvas: HTMLCanvasElement;
2413
+ protected _parameters?: Partial<THREE.WebGLRendererParameters>;
2414
+ protected _resizeObserver: ResizeObserver | null;
2415
+ protected onContainerUpdated: Event<unknown>;
2416
+ private _resizing;
2417
+ /**
2418
+ * Constructor for the SimpleRenderer class.
2419
+ *
2420
+ * @param components - The components instance.
2421
+ * @param container - The HTML container where the THREE.js canvas will be rendered.
2422
+ * @param parameters - Optional parameters for the THREE.js WebGLRenderer.
2423
+ */
2424
+ constructor(components: Components, container: HTMLElement, parameters?: Partial<THREE.WebGLRendererParameters>);
2425
+ /** {@link Updateable.update} */
2426
+ update(): void;
2674
2427
  /** {@link Disposable.dispose} */
2675
2428
  dispose(): void;
2429
+ /** {@link Resizeable.getSize}. */
2430
+ getSize(): THREE.Vector2;
2431
+ /** {@link Resizeable.resize} */
2432
+ resize: (size?: THREE.Vector2) => void;
2433
+ /**
2434
+ * Sets up and manages the event listeners for the renderer.
2435
+ *
2436
+ * @param active - A boolean indicating whether to activate or deactivate the event listeners.
2437
+ *
2438
+ * @throws Will throw an error if the renderer does not have an HTML container.
2439
+ */
2440
+ setupEvents(active: boolean): void;
2441
+ private resizeEvent;
2442
+ private setupRenderer;
2443
+ private onContextLost;
2444
+ private onContextBack;
2676
2445
  }
2677
2446
  import * as THREE from "three";
2678
- import { BaseScene } from "./base-scene";
2679
- import { BaseCamera } from "./base-camera";
2680
- import { BaseRenderer } from "./base-renderer";
2681
- import { Updateable, Disposable } from "./interfaces";
2447
+ import CameraControls from "camera-controls";
2448
+ import { Disposable, Updateable, Event, BaseCamera } from "../../Types";
2449
+ import { Components } from "../../Components";
2682
2450
  /**
2683
- * Represents a 3D world with meshes, scene, camera, renderer, and other properties.
2451
+ * A basic camera that uses [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls) to control the camera in 2D and 3D. Check out it's API to find out what features it offers.
2684
2452
  */
2685
- export interface World extends Disposable, Updateable {
2453
+ export declare class SimpleCamera extends BaseCamera implements Updateable, Disposable {
2454
+ /** {@link Updateable.onBeforeUpdate} */
2455
+ readonly onBeforeUpdate: Event<SimpleCamera>;
2456
+ /** {@link Updateable.onAfterUpdate} */
2457
+ readonly onAfterUpdate: Event<SimpleCamera>;
2686
2458
  /**
2687
- * A set of meshes present in the world. This is taken into account for operations like raycasting.
2459
+ * Event that is triggered when the aspect of the camera has been updated.
2460
+ * This event is useful when you need to perform actions after the aspect of the camera has been changed.
2688
2461
  */
2689
- meshes: Set<THREE.Mesh>;
2462
+ readonly onAspectUpdated: Event<unknown>;
2463
+ /** {@link Disposable.onDisposed} */
2464
+ readonly onDisposed: Event<string>;
2690
2465
  /**
2691
- * The base scene of the world.
2466
+ * A three.js PerspectiveCamera or OrthographicCamera instance.
2467
+ * This camera is used for rendering the scene.
2692
2468
  */
2693
- scene: BaseScene;
2469
+ three: THREE.PerspectiveCamera | THREE.OrthographicCamera;
2470
+ private _allControls;
2694
2471
  /**
2695
- * The base camera of the world.
2472
+ * The object that controls the camera. An instance of
2473
+ * [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls).
2474
+ * Transforming the camera directly will have no effect: you need to use this
2475
+ * object to move, rotate, look at objects, etc.
2696
2476
  */
2697
- camera: BaseCamera;
2477
+ get controls(): CameraControls;
2698
2478
  /**
2699
- * The base renderer of the world. Can be null if this world doesn't use a renderer (e.g. in a backend environment).
2479
+ * Getter for the enabled state of the camera controls.
2480
+ * If the current world is null, it returns false.
2481
+ * Otherwise, it returns the enabled state of the camera controls.
2482
+ *
2483
+ * @returns {boolean} The enabled state of the camera controls.
2700
2484
  */
2701
- renderer: BaseRenderer | null;
2485
+ get enabled(): boolean;
2702
2486
  /**
2703
- * A unique identifier for the world.
2487
+ * Setter for the enabled state of the camera controls.
2488
+ * If the current world is not null, it sets the enabled state of the camera controls to the provided value.
2489
+ *
2490
+ * @param {boolean} enabled - The new enabled state of the camera controls.
2704
2491
  */
2705
- uuid: string;
2492
+ set enabled(enabled: boolean);
2493
+ constructor(components: Components);
2494
+ /** {@link Disposable.dispose} */
2495
+ dispose(): void;
2496
+ /** {@link Updateable.update} */
2497
+ update(_delta: number): void;
2706
2498
  /**
2707
- * Indicates whether the world is currently disposing. This is useful for cancelling logic that access the elements of a world (which are also disposed).
2499
+ * Updates the aspect of the camera to match the size of the
2500
+ * {@link Components.renderer}.
2708
2501
  */
2709
- isDisposing: boolean;
2502
+ updateAspect: () => void;
2503
+ private setupCamera;
2504
+ private newCameraControls;
2505
+ private setupEvents;
2506
+ private static getSubsetOfThree;
2710
2507
  }
2711
2508
  import * as THREE from "three";
2712
2509
  import { Components } from "../../Components";
@@ -2800,410 +2597,658 @@ export declare class CullerRenderer {
2800
2597
  private applySettings;
2801
2598
  }
2802
2599
  import * as THREE from "three";
2803
- import { Hideable, Event, World, Disposable } from "../../Types";
2804
- import { Components } from "../../Components";
2600
+ import { Disposable, Event } from "../../Types";
2601
+ /**
2602
+ * A helper to easily get the real position of the mouse in the Three.js canvas to work with tools like the [raycaster](https://threejs.org/docs/#api/en/core/Raycaster), even if it has been transformed through CSS or doesn't occupy the whole screen.
2603
+ */
2604
+ export declare class Mouse implements Disposable {
2605
+ dom: HTMLCanvasElement;
2606
+ private _event?;
2607
+ private _position;
2608
+ /** {@link Disposable.onDisposed} */
2609
+ readonly onDisposed: Event<unknown>;
2610
+ constructor(dom: HTMLCanvasElement);
2611
+ /**
2612
+ * The real position of the mouse of the Three.js canvas.
2613
+ */
2614
+ get position(): THREE.Vector2;
2615
+ /** {@link Disposable.dispose} */
2616
+ dispose(): void;
2617
+ private getPositionY;
2618
+ private getPositionX;
2619
+ private updateMouseInfo;
2620
+ private setupEvents;
2621
+ }
2622
+ import * as THREE from "three";
2623
+ import { CullerRenderer, CullerRendererSettings } from "./culler-renderer";
2624
+ import { Components } from "../../Components";
2625
+ import { Event, World, Disposable } from "../../Types";
2626
+ /**
2627
+ * A renderer to hide/show meshes depending on their visibility from the user's point of view.
2628
+ */
2629
+ export declare class MeshCullerRenderer extends CullerRenderer implements Disposable {
2630
+ /**
2631
+ * Event triggered when the visibility of meshes is updated.
2632
+ * Contains two sets: seen and unseen.
2633
+ */
2634
+ readonly onViewUpdated: Event<{
2635
+ seen: Set<THREE.Mesh>;
2636
+ unseen: Set<THREE.Mesh>;
2637
+ }>;
2638
+ /**
2639
+ * Pixels in screen a geometry must occupy to be considered "seen".
2640
+ * Default value is 100.
2641
+ */
2642
+ threshold: number;
2643
+ /**
2644
+ * Map of color code to THREE.InstancedMesh.
2645
+ * Used to keep track of color-coded meshes.
2646
+ */
2647
+ colorMeshes: Map<string, THREE.InstancedMesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[]>>;
2648
+ /**
2649
+ * Flag to indicate if the renderer is currently processing.
2650
+ * Used to prevent concurrent processing.
2651
+ */
2652
+ isProcessing: boolean;
2653
+ private _colorCodeMeshMap;
2654
+ private _meshIDColorCodeMap;
2655
+ private _currentVisibleMeshes;
2656
+ private _recentlyHiddenMeshes;
2657
+ private _intervalID;
2658
+ private readonly _transparentMat;
2659
+ constructor(components: Components, world: World, settings?: CullerRendererSettings);
2660
+ /** {@link Disposable.dispose} */
2661
+ dispose(): void;
2662
+ /**
2663
+ * Adds a mesh to the culler. When the mesh is not visibile anymore, it will be removed from the scene. When it's visible again, it will be added to the scene.
2664
+ * @param mesh - The mesh to add. It can be a regular THREE.Mesh or an instance of THREE.InstancedMesh.
2665
+ * @returns {void}
2666
+ */
2667
+ add(mesh: THREE.Mesh | THREE.InstancedMesh): void;
2668
+ /**
2669
+ * Removes a mesh from the culler, so its visibility is not controlled by the culler anymore.
2670
+ * When the mesh is removed, it will be hidden from the scene and its color-coded mesh will be destroyed.
2671
+ * @param mesh - The mesh to remove. It can be a regular THREE.Mesh or an instance of THREE.InstancedMesh.
2672
+ * @returns {void}
2673
+ */
2674
+ remove(mesh: THREE.Mesh | THREE.InstancedMesh): void;
2675
+ private handleWorkerMessage;
2676
+ private getAvailableMaterial;
2677
+ }
2678
+ export declare function readPixelsAsync(gl: WebGL2RenderingContext, x: number, y: number, w: number, h: number, format: any, type: any, dest: ArrayBufferView): Promise<ArrayBufferView>;
2679
+ import * as THREE from "three";
2680
+ import { Components } from "../../Components";
2681
+ import { Event, World, Disposable } from "../../Types";
2682
+ import { Mouse } from "./mouse";
2683
+ /**
2684
+ * A simple [raycaster](https://threejs.org/docs/#api/en/core/Raycaster) that allows to easily get items from the scene using the mouse and touch events.
2685
+ */
2686
+ export declare class SimpleRaycaster implements Disposable {
2687
+ /** {@link Component.enabled} */
2688
+ enabled: boolean;
2689
+ /** The components instance to which this Raycaster belongs. */
2690
+ components: Components;
2691
+ /** {@link Disposable.onDisposed} */
2692
+ readonly onDisposed: Event<unknown>;
2693
+ /** The position of the mouse in the screen. */
2694
+ readonly mouse: Mouse;
2695
+ /**
2696
+ * A reference to the Three.js Raycaster instance.
2697
+ * This is used for raycasting operations.
2698
+ */
2699
+ readonly three: THREE.Raycaster;
2700
+ /**
2701
+ * A reference to the world instance to which this Raycaster belongs.
2702
+ * This is used to access the camera and meshes.
2703
+ */
2704
+ world: World;
2705
+ constructor(components: Components, world: World);
2706
+ /** {@link Disposable.dispose} */
2707
+ dispose(): void;
2708
+ /**
2709
+ * Throws a ray from the camera to the mouse or touch event point and returns
2710
+ * the first item found. This also takes into account the clipping planes
2711
+ * used by the renderer.
2712
+ *
2713
+ * @param items - the [meshes](https://threejs.org/docs/#api/en/objects/Mesh)
2714
+ * to query. If not provided, it will query all the meshes stored in
2715
+ * {@link Components.meshes}.
2716
+ */
2717
+ castRay(items?: THREE.Object3D[]): THREE.Intersection | null;
2718
+ /**
2719
+ * Casts a ray from a given origin in a given direction and returns the first item found.
2720
+ * This method also takes into account the clipping planes used by the renderer.
2721
+ *
2722
+ * @param origin - The origin of the ray.
2723
+ * @param direction - The direction of the ray.
2724
+ * @param items - The meshes to query. If not provided, it will query all the meshes stored in {@link World.meshes}.
2725
+ * @returns The first intersection found or 'null' if no intersection was found.
2726
+ */
2727
+ castRayFromVector(origin: THREE.Vector3, direction: THREE.Vector3, items?: THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>[]): THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>> | null;
2728
+ private intersect;
2729
+ private filterClippingPlanes;
2730
+ }
2731
+ import * as THREE from "three";
2732
+ import { Hideable, Event, World, Disposable } from "../../Types";
2733
+ import { Components } from "../../Components";
2734
+ /**
2735
+ * Configuration interface for the {@link SimpleGrid} class.
2736
+ */
2737
+ export interface GridConfig {
2738
+ /**
2739
+ * The color of the grid lines.
2740
+ */
2741
+ color: THREE.Color;
2742
+ /**
2743
+ * The size of the primary grid lines.
2744
+ */
2745
+ size1: number;
2746
+ /**
2747
+ * The size of the secondary grid lines.
2748
+ */
2749
+ size2: number;
2750
+ /**
2751
+ * The distance at which the grid lines start to fade away.
2752
+ */
2753
+ distance: number;
2754
+ }
2755
+ /**
2756
+ * An infinite grid. Created by [fyrestar](https://github.com/Fyrestar/THREE.InfiniteGridHelper) and translated to typescript by [dkaraush](https://github.com/dkaraush/THREE.InfiniteGridHelper/blob/master/InfiniteGridHelper.ts).
2757
+ */
2758
+ export declare class SimpleGrid implements Hideable, Disposable {
2759
+ /** {@link Disposable.onDisposed} */
2760
+ readonly onDisposed: Event<unknown>;
2761
+ /** The world instance to which this Raycaster belongs. */
2762
+ world: World;
2763
+ /** The components instance to which this grid belongs. */
2764
+ components: Components;
2765
+ /** {@link Hideable.visible} */
2766
+ get visible(): boolean;
2767
+ /** {@link Hideable.visible} */
2768
+ set visible(visible: boolean);
2769
+ /** The material of the grid. */
2770
+ get material(): THREE.ShaderMaterial;
2771
+ /**
2772
+ * Whether the grid should fade away with distance. Recommended to be true for
2773
+ * perspective cameras and false for orthographic cameras.
2774
+ */
2775
+ get fade(): boolean;
2776
+ /**
2777
+ * Whether the grid should fade away with distance. Recommended to be true for
2778
+ * perspective cameras and false for orthographic cameras.
2779
+ */
2780
+ set fade(active: boolean);
2781
+ /** The Three.js mesh that contains the infinite grid. */
2782
+ readonly three: THREE.Mesh;
2783
+ private _fade;
2784
+ constructor(components: Components, world: World, config: GridConfig);
2785
+ /** {@link Disposable.dispose} */
2786
+ dispose(): void;
2787
+ private setupEvents;
2788
+ private updateZoom;
2789
+ }
2790
+ /**
2791
+ * 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.
2792
+ */
2793
+ export declare class Event<T> {
2794
+ /**
2795
+ * Add a callback to this event instance.
2796
+ * @param handler - the callback to be added to this event.
2797
+ */
2798
+ add(handler: T extends void ? {
2799
+ (): void;
2800
+ } : {
2801
+ (data: T): void;
2802
+ }): void;
2803
+ /**
2804
+ * Removes a callback from this event instance.
2805
+ * @param handler - the callback to be removed from this event.
2806
+ */
2807
+ remove(handler: T extends void ? {
2808
+ (): void;
2809
+ } : {
2810
+ (data: T): void;
2811
+ }): void;
2812
+ /** Triggers all the callbacks assigned to this event. */
2813
+ trigger: (data?: T) => void;
2814
+ /** Gets rid of all the suscribed events. */
2815
+ reset(): void;
2816
+ private handlers;
2817
+ }
2818
+ /**
2819
+ * 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.
2820
+ */
2821
+ export declare class AsyncEvent<T> {
2822
+ /**
2823
+ * Add a callback to this event instance.
2824
+ * @param handler - the callback to be added to this event.
2825
+ */
2826
+ add(handler: T extends void ? {
2827
+ (): Promise<void>;
2828
+ } : {
2829
+ (data: T): Promise<void>;
2830
+ }): void;
2831
+ /**
2832
+ * Removes a callback from this event instance.
2833
+ * @param handler - the callback to be removed from this event.
2834
+ */
2835
+ remove(handler: T extends void ? {
2836
+ (): Promise<void>;
2837
+ } : {
2838
+ (data: T): Promise<void>;
2839
+ }): void;
2840
+ /** Triggers all the callbacks assigned to this event. */
2841
+ trigger: (data?: T) => Promise<void>;
2842
+ /** Gets rid of all the suscribed events. */
2843
+ reset(): void;
2844
+ private handlers;
2845
+ }
2846
+ import * as THREE from "three";
2847
+ import CameraControls from "camera-controls";
2848
+ import { Event } from "./event";
2805
2849
  /**
2806
- * Configuration interface for the {@link SimpleGrid} class.
2850
+ * 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.
2807
2851
  */
2808
- export interface GridConfig {
2809
- /**
2810
- * The color of the grid lines.
2811
- */
2812
- color: THREE.Color;
2813
- /**
2814
- * The size of the primary grid lines.
2815
- */
2816
- size1: number;
2852
+ export interface Disposable {
2817
2853
  /**
2818
- * The size of the secondary grid lines.
2854
+ * Destroys the object from memory to prevent a
2855
+ * [memory leak](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects).
2819
2856
  */
2820
- size2: number;
2857
+ dispose: () => void | Promise<void>;
2858
+ /** Fired after the tool has been disposed. */
2859
+ readonly onDisposed: Event<any>;
2860
+ }
2861
+ /**
2862
+ * Whether the geometric representation of this component can be hidden or shown in the [Three.js scene](https://threejs.org/docs/#api/en/scenes/Scene).
2863
+ */
2864
+ export interface Hideable {
2821
2865
  /**
2822
- * The distance at which the grid lines start to fade away.
2866
+ * Whether the geometric representation of this component is
2867
+ * currently visible or not in the
2868
+ * [Three.js scene](https://threejs.org/docs/#api/en/scenes/Scene).
2823
2869
  */
2824
- distance: number;
2870
+ visible: boolean;
2825
2871
  }
2826
2872
  /**
2827
- * An infinite grid. Created by [fyrestar](https://github.com/Fyrestar/THREE.InfiniteGridHelper) and translated to typescript by [dkaraush](https://github.com/dkaraush/THREE.InfiniteGridHelper/blob/master/InfiniteGridHelper.ts).
2873
+ * Whether this component can be resized. The meaning of this can vary depending on the component: resizing a [Renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer) component could mean changing its resolution, whereas resizing a [Mesh](https://threejs.org/docs/#api/en/objects/Mesh) would change its scale.
2828
2874
  */
2829
- export declare class SimpleGrid implements Hideable, Disposable {
2830
- /** {@link Disposable.onDisposed} */
2831
- readonly onDisposed: Event<unknown>;
2832
- /** The world instance to which this Raycaster belongs. */
2833
- world: World;
2834
- /** The components instance to which this grid belongs. */
2835
- components: Components;
2836
- /** {@link Hideable.visible} */
2837
- get visible(): boolean;
2838
- /** {@link Hideable.visible} */
2839
- set visible(visible: boolean);
2840
- /** The material of the grid. */
2841
- get material(): THREE.ShaderMaterial;
2875
+ export interface Resizeable {
2842
2876
  /**
2843
- * Whether the grid should fade away with distance. Recommended to be true for
2844
- * perspective cameras and false for orthographic cameras.
2877
+ * Sets size of this component (e.g. the resolution of a
2878
+ * [Renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer)
2879
+ * component.
2845
2880
  */
2846
- get fade(): boolean;
2881
+ resize: (size?: THREE.Vector2) => void;
2882
+ /** Event that fires when the component has been resized. */
2883
+ onResize: Event<THREE.Vector2>;
2847
2884
  /**
2848
- * Whether the grid should fade away with distance. Recommended to be true for
2849
- * perspective cameras and false for orthographic cameras.
2885
+ * Gets the current size of this component (e.g. the resolution of a
2886
+ * [Renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer)
2887
+ * component.
2850
2888
  */
2851
- set fade(active: boolean);
2852
- /** The Three.js mesh that contains the infinite grid. */
2853
- readonly three: THREE.Mesh;
2854
- private _fade;
2855
- constructor(components: Components, world: World, config: GridConfig);
2856
- /** {@link Disposable.dispose} */
2857
- dispose(): void;
2858
- private setupEvents;
2859
- private updateZoom;
2889
+ getSize: () => THREE.Vector2;
2890
+ }
2891
+ /** Whether this component should be updated each frame. */
2892
+ export interface Updateable {
2893
+ /** Actions that should be executed after updating the component. */
2894
+ onAfterUpdate: Event<any>;
2895
+ /** Actions that should be executed before updating the component. */
2896
+ onBeforeUpdate: Event<any>;
2897
+ /**
2898
+ * Function used to update the state of this component each frame. For
2899
+ * instance, a renderer component will make a render each frame.
2900
+ */
2901
+ update(delta?: number): void;
2902
+ }
2903
+ /** Basic type to describe the progress of any kind of process. */
2904
+ export interface Progress {
2905
+ /** The amount of things that have been done already. */
2906
+ current: number;
2907
+ /** The total amount of things to be done by the process. */
2908
+ total: number;
2860
2909
  }
2861
- import * as THREE from "three";
2862
- import { CullerRenderer, CullerRendererSettings } from "./culler-renderer";
2863
- import { Components } from "../../Components";
2864
- import { Event, World, Disposable } from "../../Types";
2865
2910
  /**
2866
- * A renderer to hide/show meshes depending on their visibility from the user's point of view.
2911
+ * Whether this component supports create and destroy operations. This generally applies for components that work with instances, such as clipping planes or dimensions.
2867
2912
  */
2868
- export declare class MeshCullerRenderer extends CullerRenderer implements Disposable {
2913
+ export interface Createable {
2914
+ /** Creates a new instance of an element (e.g. a new Dimension). */
2915
+ create: (data: any) => void;
2869
2916
  /**
2870
- * Event triggered when the visibility of meshes is updated.
2871
- * Contains two sets: seen and unseen.
2917
+ * Finish the creation process of the component, successfully creating an
2918
+ * instance of whatever the component creates.
2872
2919
  */
2873
- readonly onViewUpdated: Event<{
2874
- seen: Set<THREE.Mesh>;
2875
- unseen: Set<THREE.Mesh>;
2876
- }>;
2920
+ endCreation?: (data: any) => void;
2877
2921
  /**
2878
- * Pixels in screen a geometry must occupy to be considered "seen".
2879
- * Default value is 100.
2922
+ * Cancels the creation process of the component, going back to the state
2923
+ * before starting to create.
2880
2924
  */
2881
- threshold: number;
2882
- /**
2883
- * Map of color code to THREE.InstancedMesh.
2884
- * Used to keep track of color-coded meshes.
2925
+ cancelCreation?: (data: any) => void;
2926
+ /** Deletes an existing instance of an element (e.g. a Dimension). */
2927
+ delete: (data: any) => void;
2928
+ }
2929
+ /**
2930
+ * Whether this component supports to be configured.
2931
+ */
2932
+ export interface Configurable<T extends Record<string, any>> {
2933
+ /** Wether this components has been already configured. */
2934
+ isSetup: boolean;
2935
+ /** Use the provided configuration to setup the tool. */
2936
+ setup: (config?: Partial<T>) => void | Promise<void>;
2937
+ /** Fired after successfully calling {@link Configurable.setup()} */
2938
+ readonly onSetup: Event<any>;
2939
+ /** Object holding the tool configuration. Is not meant to be edited directly, if you need
2940
+ * to make changes to this object, use {@link Configurable.setup()} just after the tool is instantiated.
2885
2941
  */
2886
- colorMeshes: Map<string, THREE.InstancedMesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[]>>;
2942
+ config: Required<T>;
2943
+ }
2944
+ /**
2945
+ * Whether a camera uses the Camera Controls library.
2946
+ */
2947
+ export interface CameraControllable {
2887
2948
  /**
2888
- * Flag to indicate if the renderer is currently processing.
2889
- * Used to prevent concurrent processing.
2949
+ * An instance of CameraControls that provides camera control functionalities.
2950
+ * This instance is used to manipulate the camera.
2890
2951
  */
2891
- isProcessing: boolean;
2892
- private _colorCodeMeshMap;
2893
- private _meshIDColorCodeMap;
2894
- private _currentVisibleMeshes;
2895
- private _recentlyHiddenMeshes;
2896
- private _intervalID;
2897
- private readonly _transparentMat;
2898
- constructor(components: Components, world: World, settings?: CullerRendererSettings);
2899
- /** {@link Disposable.dispose} */
2900
- dispose(): void;
2952
+ controls: CameraControls;
2953
+ }
2954
+ import { Base } from "./base";
2955
+ import { World } from "./world";
2956
+ import { Event } from "./event";
2957
+ import { Components } from "../../Components";
2958
+ /**
2959
+ * One of the elements that make a world. It can be either a scene, a camera or a renderer.
2960
+ */
2961
+ export declare abstract class BaseWorldItem extends Base {
2962
+ readonly worlds: Map<string, World>;
2901
2963
  /**
2902
- * Adds a mesh to the culler. When the mesh is not visibile anymore, it will be removed from the scene. When it's visible again, it will be added to the scene.
2903
- * @param mesh - The mesh to add. It can be a regular THREE.Mesh or an instance of THREE.InstancedMesh.
2904
- * @returns {void}
2964
+ * Event that is triggered when a world is added or removed from the 'worlds' map.
2965
+ * The event payload contains the world instance and the action ("added" or "removed").
2905
2966
  */
2906
- add(mesh: THREE.Mesh | THREE.InstancedMesh): void;
2967
+ readonly onWorldChanged: Event<{
2968
+ world: World;
2969
+ action: "added" | "removed";
2970
+ }>;
2907
2971
  /**
2908
- * Removes a mesh from the culler, so its visibility is not controlled by the culler anymore.
2909
- * When the mesh is removed, it will be hidden from the scene and its color-coded mesh will be destroyed.
2910
- * @param mesh - The mesh to remove. It can be a regular THREE.Mesh or an instance of THREE.InstancedMesh.
2911
- * @returns {void}
2972
+ * The current world this item is associated with. It can be null if no world is currently active.
2912
2973
  */
2913
- remove(mesh: THREE.Mesh | THREE.InstancedMesh): void;
2914
- private handleWorkerMessage;
2915
- private getAvailableMaterial;
2974
+ currentWorld: World | null;
2975
+ protected constructor(components: Components);
2916
2976
  }
2917
- export declare function readPixelsAsync(gl: WebGL2RenderingContext, x: number, y: number, w: number, h: number, format: any, type: any, dest: ArrayBufferView): Promise<ArrayBufferView>;
2918
- import { IfcFragmentSettings } from "../../IfcLoader/src";
2977
+ import { Base } from "./base";
2919
2978
  /**
2920
- * Settings for streaming properties. Extends {@link IfcFragmentSettings} to inherit common settings.
2979
+ * Components are the building blocks of this library. Components are singleton elements that contain specific functionality. For instance, the Clipper Component can create, delete and handle 3D clipping planes. Components must be unique (they can't be instanced more than once per Components instance), and have a static UUID that identifies them uniquely. The can be accessed globally using the {@link Components} instance.
2921
2980
  */
2922
- export declare class PropertiesStreamingSettings extends IfcFragmentSettings {
2981
+ export declare abstract class Component extends Base {
2923
2982
  /**
2924
- * Amount of properties to be streamed.
2925
- * Defaults to 100 properties.
2983
+ * Whether this component is active or not. The behaviour can vary depending
2984
+ * on the type of component. E.g. a disabled dimension tool will stop creating
2985
+ * dimensions, while a disabled camera will stop moving. A disabled component
2986
+ * will not be updated automatically each frame.
2926
2987
  */
2927
- propertiesSize: number;
2988
+ abstract enabled: boolean;
2989
+ }
2990
+ import { Disposable, Hideable, Resizeable, Updateable, Configurable } from "./interfaces";
2991
+ import { Components } from "../../Components";
2992
+ /**
2993
+ * Base class of the library. Useful for finding out the interfaces something implements.
2994
+ */
2995
+ export declare abstract class Base {
2996
+ components: Components;
2997
+ constructor(components: Components);
2998
+ /** Whether is component is {@link Disposable}. */
2999
+ isDisposeable: () => this is Disposable;
3000
+ /** Whether is component is {@link Resizeable}. */
3001
+ isResizeable: () => this is Resizeable;
3002
+ /** Whether is component is {@link Updateable}. */
3003
+ isUpdateable: () => this is Updateable;
3004
+ /** Whether is component is {@link Hideable}. */
3005
+ isHideable: () => this is Hideable;
3006
+ /** Whether is component is {@link Configurable}. */
3007
+ isConfigurable: () => this is Configurable<any>;
2928
3008
  }
2929
3009
  import * as THREE from "three";
2930
- import { Event, Base, World, BaseScene, BaseCamera, BaseRenderer, Disposable, Updateable } from "../../Types";
3010
+ import { Vector2 } from "three";
3011
+ import { Event } from "./event";
3012
+ import { BaseWorldItem } from "./base-world-item";
3013
+ import { Disposable, Resizeable, Updateable } from "./interfaces";
2931
3014
  /**
2932
- * A class representing a simple world in a 3D environment. It extends the Base class and implements the World interface.
2933
- *
2934
- * @template T - The type of the scene. Default is BaseScene.
2935
- * @template U - The type of the camera. Default is BaseCamera.
2936
- * @template S - The type of the renderer. Default is BaseRenderer.
3015
+ * Abstract class representing a renderer for a 3D world. All renderers should use this class as a base.
2937
3016
  */
2938
- export declare class SimpleWorld<T extends BaseScene = BaseScene, U extends BaseCamera = BaseCamera, S extends BaseRenderer = BaseRenderer> extends Base implements World, Disposable, Updateable {
3017
+ export declare abstract class BaseRenderer extends BaseWorldItem implements Updateable, Disposable, Resizeable {
2939
3018
  /**
2940
- * All the loaded [meshes](https://threejs.org/docs/#api/en/objects/Mesh). These meshes will be taken into account in operations like raycasting.
3019
+ * The three.js WebGLRenderer instance associated with this renderer.
3020
+ *
3021
+ * @abstract
3022
+ * @type {THREE.WebGLRenderer}
2941
3023
  */
2942
- readonly meshes: Set<THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>>;
2943
- /** {@link Updateable.onAfterUpdate} */
2944
- readonly onAfterUpdate: Event<unknown>;
3024
+ abstract three: THREE.WebGLRenderer;
2945
3025
  /** {@link Updateable.onBeforeUpdate} */
2946
- readonly onBeforeUpdate: Event<unknown>;
2947
- /** {@link Disposable.onDisposed} */
2948
- readonly onDisposed: Event<unknown>;
2949
- /**
2950
- * Indicates whether the world is currently being disposed. This is useful to prevent trying to access world's elements when it's being disposed, which could cause errors when you dispose a world.
2951
- */
2952
- isDisposing: boolean;
2953
- /**
2954
- * Indicates whether the world is currently enabled.
2955
- * When disabled, the world will not be updated.
2956
- */
2957
- enabled: boolean;
3026
+ onAfterUpdate: Event<unknown>;
3027
+ /** {@link Updateable.onAfterUpdate} */
3028
+ onBeforeUpdate: Event<unknown>;
3029
+ /** {@link Disposable.onDisposed} */
3030
+ readonly onDisposed: Event<undefined>;
3031
+ /** {@link Resizeable.onResize} */
3032
+ readonly onResize: Event<THREE.Vector2>;
2958
3033
  /**
2959
- * A unique identifier for the world.
3034
+ * Event that fires when there has been a change to the list of clipping
3035
+ * planes used by the active renderer.
2960
3036
  */
2961
- uuid: string;
3037
+ readonly onClippingPlanesUpdated: Event<unknown>;
3038
+ /** {@link Updateable.update} */
3039
+ abstract update(delta?: number): void | Promise<void>;
3040
+ /** {@link Disposable.dispose} */
3041
+ abstract dispose(): void;
3042
+ /** {@link Resizeable.getSize} */
3043
+ abstract getSize(): Vector2;
3044
+ /** {@link Resizeable.resize} */
3045
+ abstract resize(size: Vector2 | undefined): void;
2962
3046
  /**
2963
- * An optional name for the world.
3047
+ * The list of [clipping planes](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.clippingPlanes) used by this instance of the renderer.
2964
3048
  */
2965
- name?: string;
2966
- private _scene?;
2967
- private _camera?;
2968
- private _renderer;
3049
+ clippingPlanes: THREE.Plane[];
2969
3050
  /**
2970
- * Getter for the scene. If no scene is initialized, it throws an error.
2971
- * @returns The current scene.
3051
+ * Updates the clipping planes and triggers the 'onClippingPlanesUpdated' event.
3052
+ *
3053
+ * @remarks
3054
+ * This method is typically called when there is a change to the list of clipping planes
3055
+ * used by the active renderer.
2972
3056
  */
2973
- get scene(): T;
3057
+ updateClippingPlanes(): void;
2974
3058
  /**
2975
- * Setter for the scene. It sets the current scene, adds the world to the scene's worlds set,
2976
- * sets the current world in the scene, and triggers the scene's onWorldChanged event with the added action.
2977
- * @param scene - The new scene to be set.
3059
+ * Sets or removes a clipping plane from the renderer.
3060
+ *
3061
+ * @param active - A boolean indicating whether the clipping plane should be active or not.
3062
+ * @param plane - The clipping plane to be added or removed.
3063
+ * @param isLocal - An optional boolean indicating whether the clipping plane is local to the object. If not provided, it defaults to 'false'.
3064
+ *
3065
+ * @remarks
3066
+ * This method adds or removes a clipping plane from the 'clippingPlanes' array.
3067
+ * If 'active' is 'true' and the plane is not already in the array, it is added.
3068
+ * If 'active' is 'false' and the plane is in the array, it is removed.
3069
+ * The 'three.clippingPlanes' property is then updated to reflect the current state of the 'clippingPlanes' array,
3070
+ * excluding any planes marked as local.
2978
3071
  */
2979
- set scene(scene: T);
3072
+ setPlane(active: boolean, plane: THREE.Plane, isLocal?: boolean): void;
3073
+ }
3074
+ import * as THREE from "three";
3075
+ import CameraControls from "camera-controls";
3076
+ import { BaseWorldItem } from "./base-world-item";
3077
+ import { CameraControllable } from "./interfaces";
3078
+ /**
3079
+ * Abstract class representing a camera in a 3D world. All cameras should use this class as a base.
3080
+ */
3081
+ export declare abstract class BaseCamera extends BaseWorldItem {
2980
3082
  /**
2981
- * Getter for the camera. If no camera is initialized, it throws an error.
2982
- * @returns The current camera.
3083
+ * Whether the camera is enabled or not.
2983
3084
  */
2984
- get camera(): U;
3085
+ abstract enabled: boolean;
2985
3086
  /**
2986
- * Setter for the camera. It sets the current camera, adds the world to the camera's worlds set,
2987
- * sets the current world in the camera, and triggers the camera's onWorldChanged event with the added action.
2988
- * @param camera - The new camera to be set.
3087
+ * The Three.js camera instance.
2989
3088
  */
2990
- set camera(camera: U);
3089
+ abstract three: THREE.Camera;
2991
3090
  /**
2992
- * Getter for the renderer.
2993
- * @returns The current renderer or null if no renderer is set. Some worlds don't need a renderer to work (when your mail goal is not to display a 3D viewport to the user).
3091
+ * Optional CameraControls instance for controlling the camera.
3092
+ * This property is only available if the camera is controllable.
2994
3093
  */
2995
- get renderer(): S | null;
3094
+ abstract controls?: CameraControls;
2996
3095
  /**
2997
- * Setter for the renderer. It sets the current renderer, adds the world to the renderer's worlds set,
2998
- * sets the current world in the renderer, and triggers the renderer's onWorldChanged event with the added action.
2999
- * If a new renderer is set, it also triggers the onWorldChanged event with the removed action for the old renderer.
3000
- * @param renderer - The new renderer to be set or null to remove the current renderer.
3096
+ * Checks whether the instance is {@link CameraControllable}.
3097
+ *
3098
+ * @returns True if the instance is controllable, false otherwise.
3001
3099
  */
3002
- set renderer(renderer: S | null);
3003
- /** {@link Updateable.update} */
3004
- update(delta?: number): void;
3005
- /** {@link Disposable.dispose} */
3006
- dispose(disposeResources?: boolean): void;
3100
+ hasCameraControls: () => this is CameraControllable;
3007
3101
  }
3008
3102
  import * as THREE from "three";
3009
- import { BaseScene, Configurable, Event } from "../../Types";
3103
+ import { Disposable } from "./interfaces";
3104
+ import { Event } from "./event";
3010
3105
  import { Components } from "../../Components";
3106
+ import { BaseWorldItem } from "./base-world-item";
3011
3107
  /**
3012
- * Configuration interface for the {@link SimpleScene}. Defines properties for directional and ambient lights.
3013
- */
3014
- export interface SimpleSceneConfig {
3015
- directionalLight: {
3016
- color: THREE.Color;
3017
- intensity: number;
3018
- position: THREE.Vector3;
3019
- };
3020
- ambientLight: {
3021
- color: THREE.Color;
3022
- intensity: number;
3023
- };
3024
- }
3025
- /**
3026
- * A basic 3D [scene](https://threejs.org/docs/#api/en/scenes/Scene) to add objects hierarchically, and easily dispose them when you are finished with it.
3108
+ * Abstract class representing a base scene in the application. All scenes should use this class as a base.
3027
3109
  */
3028
- export declare class SimpleScene extends BaseScene implements Configurable<{}> {
3029
- /** {@link Configurable.isSetup} */
3030
- isSetup: boolean;
3031
- /**
3032
- * The underlying Three.js scene object.
3033
- * It is used to define the 3D space containing objects, lights, and cameras.
3034
- */
3035
- three: THREE.Scene;
3036
- /** {@link Configurable.onSetup} */
3037
- readonly onSetup: Event<SimpleScene>;
3110
+ export declare abstract class BaseScene extends BaseWorldItem implements Disposable {
3111
+ /** {@link Disposable.onDisposed} */
3112
+ readonly onDisposed: Event<unknown>;
3038
3113
  /**
3039
- * Configuration interface for the {@link SimpleScene}.
3040
- * Defines properties for directional and ambient lights.
3114
+ * Abstract property representing the three.js object associated with this scene.
3115
+ * It should be implemented by subclasses.
3041
3116
  */
3042
- config: Required<SimpleSceneConfig>;
3043
- constructor(components: Components);
3044
- /** {@link Configurable.setup} */
3045
- setup(config?: Partial<SimpleSceneConfig>): void;
3117
+ abstract three: THREE.Object3D;
3118
+ protected constructor(components: Components);
3119
+ /** {@link Disposable.dispose} */
3120
+ dispose(): void;
3046
3121
  }
3047
3122
  import * as THREE from "three";
3048
- import { BaseRenderer, Event } from "../../Types";
3049
- import { Components } from "../../Components";
3123
+ import { BaseScene } from "./base-scene";
3124
+ import { BaseCamera } from "./base-camera";
3125
+ import { BaseRenderer } from "./base-renderer";
3126
+ import { Updateable, Disposable } from "./interfaces";
3050
3127
  /**
3051
- * A basic renderer capable of rendering [Objec3Ds](https://threejs.org/docs/#api/en/core/Object3D).
3128
+ * Represents a 3D world with meshes, scene, camera, renderer, and other properties.
3052
3129
  */
3053
- export declare class SimpleRenderer extends BaseRenderer {
3130
+ export interface World extends Disposable, Updateable {
3054
3131
  /**
3055
- * Indicates whether the renderer is enabled. If it's not, it won't be updated.
3056
- * Default is 'true'.
3132
+ * A set of meshes present in the world. This is taken into account for operations like raycasting.
3057
3133
  */
3058
- enabled: boolean;
3134
+ meshes: Set<THREE.Mesh>;
3059
3135
  /**
3060
- * The HTML container of the THREE.js canvas where the scene is rendered.
3136
+ * The base scene of the world.
3061
3137
  */
3062
- container: HTMLElement;
3138
+ scene: BaseScene;
3063
3139
  /**
3064
- * The THREE.js WebGLRenderer instance.
3140
+ * The base camera of the world.
3065
3141
  */
3066
- three: THREE.WebGLRenderer;
3067
- protected _canvas: HTMLCanvasElement;
3068
- protected _parameters?: Partial<THREE.WebGLRendererParameters>;
3069
- protected _resizeObserver: ResizeObserver | null;
3070
- protected onContainerUpdated: Event<unknown>;
3071
- private _resizing;
3142
+ camera: BaseCamera;
3072
3143
  /**
3073
- * Constructor for the SimpleRenderer class.
3074
- *
3075
- * @param components - The components instance.
3076
- * @param container - The HTML container where the THREE.js canvas will be rendered.
3077
- * @param parameters - Optional parameters for the THREE.js WebGLRenderer.
3144
+ * The base renderer of the world. Can be null if this world doesn't use a renderer (e.g. in a backend environment).
3078
3145
  */
3079
- constructor(components: Components, container: HTMLElement, parameters?: Partial<THREE.WebGLRendererParameters>);
3080
- /** {@link Updateable.update} */
3081
- update(): void;
3082
- /** {@link Disposable.dispose} */
3083
- dispose(): void;
3084
- /** {@link Resizeable.getSize}. */
3085
- getSize(): THREE.Vector2;
3086
- /** {@link Resizeable.resize} */
3087
- resize: (size?: THREE.Vector2) => void;
3146
+ renderer: BaseRenderer | null;
3088
3147
  /**
3089
- * Sets up and manages the event listeners for the renderer.
3090
- *
3091
- * @param active - A boolean indicating whether to activate or deactivate the event listeners.
3092
- *
3093
- * @throws Will throw an error if the renderer does not have an HTML container.
3148
+ * A unique identifier for the world.
3094
3149
  */
3095
- setupEvents(active: boolean): void;
3096
- private resizeEvent;
3097
- private setupRenderer;
3098
- private onContextLost;
3099
- private onContextBack;
3150
+ uuid: string;
3151
+ /**
3152
+ * Indicates whether the world is currently disposing. This is useful for cancelling logic that access the elements of a world (which are also disposed).
3153
+ */
3154
+ isDisposing: boolean;
3100
3155
  }
3101
3156
  import * as THREE from "three";
3102
- import CameraControls from "camera-controls";
3103
- import { Disposable, Updateable, Event, BaseCamera } from "../../Types";
3157
+ import { Hideable, Disposable, Event, World } from "../../Types";
3104
3158
  import { Components } from "../../Components";
3105
3159
  /**
3106
- * A basic camera that uses [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls) to control the camera in 2D and 3D. Check out it's API to find out what features it offers.
3160
+ * Each of the clipping planes created by the clipper.
3107
3161
  */
3108
- export declare class SimpleCamera extends BaseCamera implements Updateable, Disposable {
3109
- /** {@link Updateable.onBeforeUpdate} */
3110
- readonly onBeforeUpdate: Event<SimpleCamera>;
3111
- /** {@link Updateable.onAfterUpdate} */
3112
- readonly onAfterUpdate: Event<SimpleCamera>;
3162
+ export declare class SimplePlane implements Disposable, Hideable {
3163
+ /** Event that fires when the user starts dragging a clipping plane. */
3164
+ readonly onDraggingStarted: Event<unknown>;
3165
+ /** Event that fires when the user stops dragging a clipping plane. */
3166
+ readonly onDraggingEnded: Event<unknown>;
3167
+ /** {@link Disposable.onDisposed} */
3168
+ readonly onDisposed: Event<unknown>;
3113
3169
  /**
3114
- * Event that is triggered when the aspect of the camera has been updated.
3115
- * This event is useful when you need to perform actions after the aspect of the camera has been changed.
3170
+ * The normal vector of the clipping plane.
3116
3171
  */
3117
- readonly onAspectUpdated: Event<unknown>;
3118
- /** {@link Disposable.onDisposed} */
3119
- readonly onDisposed: Event<string>;
3172
+ readonly normal: THREE.Vector3;
3120
3173
  /**
3121
- * A three.js PerspectiveCamera or OrthographicCamera instance.
3122
- * This camera is used for rendering the scene.
3174
+ * The origin point of the clipping plane.
3123
3175
  */
3124
- three: THREE.PerspectiveCamera | THREE.OrthographicCamera;
3125
- private _allControls;
3176
+ readonly origin: THREE.Vector3;
3126
3177
  /**
3127
- * The object that controls the camera. An instance of
3128
- * [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls).
3129
- * Transforming the camera directly will have no effect: you need to use this
3130
- * object to move, rotate, look at objects, etc.
3178
+ * The THREE.js Plane object representing the clipping plane.
3131
3179
  */
3132
- get controls(): CameraControls;
3180
+ readonly three: THREE.Plane;
3181
+ /** The components instance to which this plane belongs. */
3182
+ components: Components;
3183
+ /** The world instance to which this plane belongs. */
3184
+ world: World;
3185
+ protected readonly _helper: THREE.Object3D;
3186
+ protected _visible: boolean;
3187
+ protected _enabled: boolean;
3188
+ private _controlsActive;
3189
+ private readonly _arrowBoundBox;
3190
+ private readonly _planeMesh;
3191
+ private readonly _controls;
3192
+ private readonly _hiddenMaterial;
3193
+ /**
3194
+ * Getter for the enabled state of the clipping plane.
3195
+ * @returns {boolean} The current enabled state.
3196
+ */
3197
+ get enabled(): boolean;
3198
+ /**
3199
+ * Setter for the enabled state of the clipping plane.
3200
+ * Updates the clipping plane state in the renderer and throws an error if no renderer is found.
3201
+ * @param {boolean} state - The new enabled state.
3202
+ */
3203
+ set enabled(state: boolean);
3204
+ /** {@link Hideable.visible } */
3205
+ get visible(): boolean;
3206
+ /** {@link Hideable.visible } */
3207
+ set visible(state: boolean);
3208
+ /** The meshes used for raycasting */
3209
+ get meshes(): THREE.Mesh[];
3210
+ /** The material of the clipping plane representation. */
3211
+ get planeMaterial(): THREE.Material | THREE.Material[];
3212
+ /** The material of the clipping plane representation. */
3213
+ set planeMaterial(material: THREE.Material | THREE.Material[]);
3214
+ /** The size of the clipping plane representation. */
3215
+ get size(): number;
3216
+ /** Sets the size of the clipping plane representation. */
3217
+ set size(size: number);
3133
3218
  /**
3134
- * Getter for the enabled state of the camera controls.
3135
- * If the current world is null, it returns false.
3136
- * Otherwise, it returns the enabled state of the camera controls.
3219
+ * Getter for the helper object of the clipping plane.
3220
+ * The helper object is a THREE.Object3D that contains the clipping plane mesh and other related objects.
3221
+ * It is used for positioning, rotating, and scaling the clipping plane in the 3D scene.
3137
3222
  *
3138
- * @returns {boolean} The enabled state of the camera controls.
3223
+ * @returns {THREE.Object3D} The helper object of the clipping plane.
3139
3224
  */
3140
- get enabled(): boolean;
3225
+ get helper(): THREE.Object3D<THREE.Object3DEventMap>;
3226
+ constructor(components: Components, world: World, origin: THREE.Vector3, normal: THREE.Vector3, material: THREE.Material, size?: number, activateControls?: boolean);
3141
3227
  /**
3142
- * Setter for the enabled state of the camera controls.
3143
- * If the current world is not null, it sets the enabled state of the camera controls to the provided value.
3228
+ * Sets the clipping plane's normal and origin from the given normal and point.
3229
+ * This method resets the clipping plane's state, updates the normal and origin,
3230
+ * and positions the helper object accordingly.
3144
3231
  *
3145
- * @param {boolean} enabled - The new enabled state of the camera controls.
3232
+ * @param normal - The new normal vector for the clipping plane.
3233
+ * @param point - The new origin point for the clipping plane.
3234
+ *
3235
+ * @returns {void}
3146
3236
  */
3147
- set enabled(enabled: boolean);
3148
- constructor(components: Components);
3237
+ setFromNormalAndCoplanarPoint(normal: THREE.Vector3, point: THREE.Vector3): void;
3238
+ /** {@link Updateable.update} */
3239
+ update: () => void;
3149
3240
  /** {@link Disposable.dispose} */
3150
3241
  dispose(): void;
3151
- /** {@link Updateable.update} */
3152
- update(_delta: number): void;
3153
- /**
3154
- * Updates the aspect of the camera to match the size of the
3155
- * {@link Components.renderer}.
3156
- */
3157
- updateAspect: () => void;
3158
- private setupCamera;
3159
- private newCameraControls;
3160
- private setupEvents;
3161
- private static getSubsetOfThree;
3162
- }
3163
- import { IfcFragmentSettings } from "../../IfcLoader/src";
3164
- /**
3165
- * Settings for streaming IFC geometry and assets. Extends {@link IfcFragmentSettings} to inherit common settings.
3166
- */
3167
- export declare class IfcStreamingSettings extends IfcFragmentSettings {
3168
- /**
3169
- * Minimum number of geometries to be streamed.
3170
- * Defaults to 10 geometries.
3171
- */
3172
- minGeometrySize: number;
3173
- /**
3174
- * Minimum amount of assets to be streamed.
3175
- * Defaults to 1000 assets.
3176
- */
3177
- minAssetsSize: number;
3178
- }
3179
- /**
3180
- * A dictionary of geometries streamed from a server. Each geometry is identified by a unique number (id), and contains information about its bounding box, whether it has holes, and an optional file path for the geometry data.
3181
- */
3182
- export interface StreamedGeometries {
3183
- [id: number]: {
3184
- /** The bounding box of the geometry as a Float32Array. */
3185
- boundingBox: Float32Array;
3186
- /** A boolean indicating whether the geometry has holes. */
3187
- hasHoles: boolean;
3188
- /** An optional file path for the geometry data. */
3189
- geometryFile?: string;
3190
- };
3191
- }
3192
- /**
3193
- * A streamed asset, which consists of multiple geometries. Each geometry in the asset is identified by a unique number (geometryID), and contains information about its transformation and color.
3194
- */
3195
- export interface StreamedAsset {
3196
- /** The unique identifier of the asset. */
3197
- id: number;
3198
- /** An array of geometries associated with the asset. */
3199
- geometries: {
3200
- /** The unique identifier of the geometry. */
3201
- geometryID: number;
3202
- /** The transformation matrix of the geometry as a number array. */
3203
- transformation: number[];
3204
- /** The color of the geometry as a number array. */
3205
- color: number[];
3206
- }[];
3242
+ private reset;
3243
+ protected toggleControls(state: boolean): void;
3244
+ private newTransformControls;
3245
+ private initializeControls;
3246
+ private createArrowBoundingBox;
3247
+ private changeDrag;
3248
+ private notifyDraggingChanged;
3249
+ private preventCameraMovement;
3250
+ private newHelper;
3251
+ private static newPlaneMesh;
3207
3252
  }
3208
3253
  import { NavigationMode } from "./types";
3209
3254
  import { OrthoPerspectiveCamera } from "../index";
@@ -3257,6 +3302,17 @@ export declare class PlanMode implements NavigationMode {
3257
3302
  /** {@link NavigationMode.set} */
3258
3303
  set(active: boolean): void;
3259
3304
  }
3305
+ import { IfcFragmentSettings } from "../../IfcLoader/src";
3306
+ /**
3307
+ * Settings for streaming properties. Extends {@link IfcFragmentSettings} to inherit common settings.
3308
+ */
3309
+ export declare class PropertiesStreamingSettings extends IfcFragmentSettings {
3310
+ /**
3311
+ * Amount of properties to be streamed.
3312
+ * Defaults to 100 properties.
3313
+ */
3314
+ propertiesSize: number;
3315
+ }
3260
3316
  import * as THREE from "three";
3261
3317
  import { CameraProjection } from "./types";
3262
3318
  import { Event } from "../../Types";
@@ -3328,6 +3384,11 @@ export interface NavigationMode {
3328
3384
  /** Whether this navigation mode is active or not. */
3329
3385
  enabled: boolean;
3330
3386
  }
3387
+ import * as WEBIFC from "web-ifc";
3388
+ export declare class IfcMetadataReader {
3389
+ getNameInfo(webIfc: WEBIFC.IfcAPI): Record<string, any>;
3390
+ getDescriptionInfo(webIfc: WEBIFC.IfcAPI): Record<string, any>;
3391
+ }
3331
3392
  import * as THREE from "three";
3332
3393
  import * as WEBIFC from "web-ifc";
3333
3394
  import * as FRAGS from "@thatopen/fragments";
@@ -3343,107 +3404,21 @@ export declare class CivilReader {
3343
3404
  } | undefined;
3344
3405
  private getCurves;
3345
3406
  }
3346
- import * as WEBIFC from "web-ifc";
3347
- export declare class IfcMetadataReader {
3348
- getNameInfo(webIfc: WEBIFC.IfcAPI): Record<string, any>;
3349
- getDescriptionInfo(webIfc: WEBIFC.IfcAPI): Record<string, any>;
3350
- }
3351
- import * as THREE from "three";
3352
- import { Hideable, Disposable, Event, World } from "../../Types";
3353
- import { Components } from "../../Components";
3407
+ import { IfcFragmentSettings } from "../../IfcLoader/src";
3354
3408
  /**
3355
- * Each of the clipping planes created by the clipper.
3409
+ * Settings for streaming IFC geometry and assets. Extends {@link IfcFragmentSettings} to inherit common settings.
3356
3410
  */
3357
- export declare class SimplePlane implements Disposable, Hideable {
3358
- /** Event that fires when the user starts dragging a clipping plane. */
3359
- readonly onDraggingStarted: Event<unknown>;
3360
- /** Event that fires when the user stops dragging a clipping plane. */
3361
- readonly onDraggingEnded: Event<unknown>;
3362
- /** {@link Disposable.onDisposed} */
3363
- readonly onDisposed: Event<unknown>;
3364
- /**
3365
- * The normal vector of the clipping plane.
3366
- */
3367
- readonly normal: THREE.Vector3;
3368
- /**
3369
- * The origin point of the clipping plane.
3370
- */
3371
- readonly origin: THREE.Vector3;
3372
- /**
3373
- * The THREE.js Plane object representing the clipping plane.
3374
- */
3375
- readonly three: THREE.Plane;
3376
- /** The components instance to which this plane belongs. */
3377
- components: Components;
3378
- /** The world instance to which this plane belongs. */
3379
- world: World;
3380
- protected readonly _helper: THREE.Object3D;
3381
- protected _visible: boolean;
3382
- protected _enabled: boolean;
3383
- private _controlsActive;
3384
- private readonly _arrowBoundBox;
3385
- private readonly _planeMesh;
3386
- private readonly _controls;
3387
- private readonly _hiddenMaterial;
3388
- /**
3389
- * Getter for the enabled state of the clipping plane.
3390
- * @returns {boolean} The current enabled state.
3391
- */
3392
- get enabled(): boolean;
3393
- /**
3394
- * Setter for the enabled state of the clipping plane.
3395
- * Updates the clipping plane state in the renderer and throws an error if no renderer is found.
3396
- * @param {boolean} state - The new enabled state.
3397
- */
3398
- set enabled(state: boolean);
3399
- /** {@link Hideable.visible } */
3400
- get visible(): boolean;
3401
- /** {@link Hideable.visible } */
3402
- set visible(state: boolean);
3403
- /** The meshes used for raycasting */
3404
- get meshes(): THREE.Mesh[];
3405
- /** The material of the clipping plane representation. */
3406
- get planeMaterial(): THREE.Material | THREE.Material[];
3407
- /** The material of the clipping plane representation. */
3408
- set planeMaterial(material: THREE.Material | THREE.Material[]);
3409
- /** The size of the clipping plane representation. */
3410
- get size(): number;
3411
- /** Sets the size of the clipping plane representation. */
3412
- set size(size: number);
3411
+ export declare class IfcStreamingSettings extends IfcFragmentSettings {
3413
3412
  /**
3414
- * Getter for the helper object of the clipping plane.
3415
- * The helper object is a THREE.Object3D that contains the clipping plane mesh and other related objects.
3416
- * It is used for positioning, rotating, and scaling the clipping plane in the 3D scene.
3417
- *
3418
- * @returns {THREE.Object3D} The helper object of the clipping plane.
3413
+ * Minimum number of geometries to be streamed.
3414
+ * Defaults to 10 geometries.
3419
3415
  */
3420
- get helper(): THREE.Object3D<THREE.Object3DEventMap>;
3421
- constructor(components: Components, world: World, origin: THREE.Vector3, normal: THREE.Vector3, material: THREE.Material, size?: number, activateControls?: boolean);
3416
+ minGeometrySize: number;
3422
3417
  /**
3423
- * Sets the clipping plane's normal and origin from the given normal and point.
3424
- * This method resets the clipping plane's state, updates the normal and origin,
3425
- * and positions the helper object accordingly.
3426
- *
3427
- * @param normal - The new normal vector for the clipping plane.
3428
- * @param point - The new origin point for the clipping plane.
3429
- *
3430
- * @returns {void}
3418
+ * Minimum amount of assets to be streamed.
3419
+ * Defaults to 1000 assets.
3431
3420
  */
3432
- setFromNormalAndCoplanarPoint(normal: THREE.Vector3, point: THREE.Vector3): void;
3433
- /** {@link Updateable.update} */
3434
- update: () => void;
3435
- /** {@link Disposable.dispose} */
3436
- dispose(): void;
3437
- private reset;
3438
- protected toggleControls(state: boolean): void;
3439
- private newTransformControls;
3440
- private initializeControls;
3441
- private createArrowBoundingBox;
3442
- private changeDrag;
3443
- private notifyDraggingChanged;
3444
- private preventCameraMovement;
3445
- private newHelper;
3446
- private static newPlaneMesh;
3421
+ minAssetsSize: number;
3447
3422
  }
3448
3423
  import * as WEBIFC from "web-ifc";
3449
3424
  import * as THREE from "three";
@@ -3455,6 +3430,35 @@ export declare class Units {
3455
3430
  private getLengthUnits;
3456
3431
  private getScaleMatrix;
3457
3432
  }
3433
+ /**
3434
+ * A dictionary of geometries streamed from a server. Each geometry is identified by a unique number (id), and contains information about its bounding box, whether it has holes, and an optional file path for the geometry data.
3435
+ */
3436
+ export interface StreamedGeometries {
3437
+ [id: number]: {
3438
+ /** The bounding box of the geometry as a Float32Array. */
3439
+ boundingBox: Float32Array;
3440
+ /** A boolean indicating whether the geometry has holes. */
3441
+ hasHoles: boolean;
3442
+ /** An optional file path for the geometry data. */
3443
+ geometryFile?: string;
3444
+ };
3445
+ }
3446
+ /**
3447
+ * A streamed asset, which consists of multiple geometries. Each geometry in the asset is identified by a unique number (geometryID), and contains information about its transformation and color.
3448
+ */
3449
+ export interface StreamedAsset {
3450
+ /** The unique identifier of the asset. */
3451
+ id: number;
3452
+ /** An array of geometries associated with the asset. */
3453
+ geometries: {
3454
+ /** The unique identifier of the geometry. */
3455
+ geometryID: number;
3456
+ /** The transformation matrix of the geometry as a number array. */
3457
+ transformation: number[];
3458
+ /** The color of the geometry as a number array. */
3459
+ color: number[];
3460
+ }[];
3461
+ }
3458
3462
  export type RelationsMap = Map<number, Map<number, number[]>>;
3459
3463
  export interface ModelsRelationMap {
3460
3464
  [modelID: string]: RelationsMap;