@thatopen/components 2.0.8 → 2.0.10

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.
Files changed (41) hide show
  1. package/dist/core/Clipper/index.d.ts +34 -6
  2. package/dist/core/Clipper/src/simple-plane.d.ts +40 -4
  3. package/dist/core/Components/index.d.ts +42 -18
  4. package/dist/core/Cullers/index.d.ts +23 -27
  5. package/dist/core/Cullers/src/culler-renderer.d.ts +26 -2
  6. package/dist/core/Cullers/src/mesh-culler-renderer.d.ts +32 -4
  7. package/dist/core/Disposer/index.d.ts +6 -4
  8. package/dist/core/Grids/index.d.ts +35 -1
  9. package/dist/core/Grids/src/simple-grid.d.ts +3 -0
  10. package/dist/core/MiniMap/index.d.ts +31 -0
  11. package/dist/core/MiniMap/src/index.d.ts +55 -0
  12. package/dist/core/OrthoPerspectiveCamera/index.d.ts +19 -6
  13. package/dist/core/OrthoPerspectiveCamera/src/first-person-mode.d.ts +1 -2
  14. package/dist/core/OrthoPerspectiveCamera/src/orbit-mode.d.ts +1 -2
  15. package/dist/core/OrthoPerspectiveCamera/src/plan-mode.d.ts +1 -2
  16. package/dist/core/OrthoPerspectiveCamera/src/projections.d.ts +10 -2
  17. package/dist/core/OrthoPerspectiveCamera/src/types.d.ts +1 -2
  18. package/dist/core/Raycasters/index.d.ts +29 -0
  19. package/dist/core/Raycasters/src/simple-raycaster.d.ts +18 -0
  20. package/dist/core/Types/src/async-event.d.ts +1 -7
  21. package/dist/core/Types/src/base-camera.d.ts +18 -1
  22. package/dist/core/Types/src/base-renderer.d.ts +34 -9
  23. package/dist/core/Types/src/base-scene.d.ts +7 -0
  24. package/dist/core/Types/src/base-world-item.d.ts +8 -2
  25. package/dist/core/Types/src/base.d.ts +1 -1
  26. package/dist/core/Types/src/component.d.ts +1 -6
  27. package/dist/core/Types/src/event.d.ts +1 -7
  28. package/dist/core/Types/src/interfaces.d.ts +9 -24
  29. package/dist/core/Types/src/world.d.ts +21 -0
  30. package/dist/core/Worlds/index.d.ts +31 -15
  31. package/dist/core/Worlds/src/simple-camera.d.ts +22 -6
  32. package/dist/core/Worlds/src/simple-renderer.d.ts +25 -3
  33. package/dist/core/Worlds/src/simple-scene.d.ts +13 -4
  34. package/dist/core/Worlds/src/simple-world.d.ts +57 -6
  35. package/dist/fragments/BoundingBoxer/index.d.ts +1 -2
  36. package/dist/fragments/FragmentsManager/index.d.ts +22 -2
  37. package/dist/ifc/IfcRelationsIndexer/index.d.ts +2 -2
  38. package/dist/index.cjs +5 -5
  39. package/dist/index.mjs +1805 -1325
  40. package/dist/namespace.d.ts +1396 -894
  41. package/package.json +1 -1
@@ -2,19 +2,34 @@ import * as THREE from "three";
2
2
  import { BaseRenderer, Event } from "../../Types";
3
3
  import { Components } from "../../Components";
4
4
  /**
5
- * A basic renderer capable of rendering
6
- * ([Objec3Ds](https://threejs.org/docs/#api/en/core/Object3D).
5
+ * A basic renderer capable of rendering [Objec3Ds](https://threejs.org/docs/#api/en/core/Object3D).
7
6
  */
8
7
  export declare class SimpleRenderer extends BaseRenderer {
8
+ /**
9
+ * Indicates whether the renderer is enabled. If it's not, it won't be updated.
10
+ * Default is `true`.
11
+ */
9
12
  enabled: boolean;
10
- /** The HTML container of the THREE.js canvas where the scene is rendered. */
13
+ /**
14
+ * The HTML container of the THREE.js canvas where the scene is rendered.
15
+ */
11
16
  container: HTMLElement;
17
+ /**
18
+ * The THREE.js WebGLRenderer instance.
19
+ */
12
20
  three: THREE.WebGLRenderer;
13
21
  protected _canvas: HTMLCanvasElement;
14
22
  protected _parameters?: Partial<THREE.WebGLRendererParameters>;
15
23
  protected _resizeObserver: ResizeObserver | null;
16
24
  protected onContainerUpdated: Event<unknown>;
17
25
  private _resizing;
26
+ /**
27
+ * Constructor for the SimpleRenderer class.
28
+ *
29
+ * @param components - The components instance.
30
+ * @param container - The HTML container where the THREE.js canvas will be rendered.
31
+ * @param parameters - Optional parameters for the THREE.js WebGLRenderer.
32
+ */
18
33
  constructor(components: Components, container: HTMLElement, parameters?: Partial<THREE.WebGLRendererParameters>);
19
34
  /** {@link Updateable.update} */
20
35
  update(): void;
@@ -24,6 +39,13 @@ export declare class SimpleRenderer extends BaseRenderer {
24
39
  getSize(): THREE.Vector2;
25
40
  /** {@link Resizeable.resize} */
26
41
  resize: (size?: THREE.Vector2) => void;
42
+ /**
43
+ * Sets up and manages the event listeners for the renderer.
44
+ *
45
+ * @param active - A boolean indicating whether to activate or deactivate the event listeners.
46
+ *
47
+ * @throws Will throw an error if the renderer does not have an HTML container.
48
+ */
27
49
  setupEvents(active: boolean): void;
28
50
  private resizeEvent;
29
51
  private setupRenderer;
@@ -1,6 +1,9 @@
1
1
  import * as THREE from "three";
2
2
  import { BaseScene, Configurable, Event } from "../../Types";
3
3
  import { Components } from "../../Components";
4
+ /**
5
+ * Configuration interface for the {@link SimpleScene}. Defines properties for directional and ambient lights.
6
+ */
4
7
  export interface SimpleSceneConfig {
5
8
  directionalLight: {
6
9
  color: THREE.Color;
@@ -13,18 +16,24 @@ export interface SimpleSceneConfig {
13
16
  };
14
17
  }
15
18
  /**
16
- * A basic 3D [scene](https://threejs.org/docs/#api/en/scenes/Scene) to add
17
- * objects hierarchically, and easily dispose them when you are finished with it.
18
- * @noInheritDoc
19
+ * 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.
19
20
  */
20
21
  export declare class SimpleScene extends BaseScene implements Configurable<{}> {
21
22
  /** {@link Configurable.isSetup} */
22
23
  isSetup: boolean;
24
+ /**
25
+ * The underlying Three.js scene object.
26
+ * It is used to define the 3D space containing objects, lights, and cameras.
27
+ */
23
28
  three: THREE.Scene;
24
29
  /** {@link Configurable.onSetup} */
25
30
  readonly onSetup: Event<SimpleScene>;
31
+ /**
32
+ * Configuration interface for the {@link SimpleScene}.
33
+ * Defines properties for directional and ambient lights.
34
+ */
26
35
  config: Required<SimpleSceneConfig>;
27
36
  constructor(components: Components);
28
- /** Creates a simple and nice default set up for the scene (e.g. lighting). */
37
+ /** {@link Configurable.setup} */
29
38
  setup(config?: Partial<SimpleSceneConfig>): void;
30
39
  }
@@ -1,28 +1,79 @@
1
1
  import * as THREE from "three";
2
- import { Event, Base, World, BaseScene, BaseCamera, BaseRenderer } from "../../Types";
3
- import { Components } from "../../Components";
4
- export declare class SimpleWorld<T extends BaseScene = BaseScene, U extends BaseCamera = BaseCamera, S extends BaseRenderer = BaseRenderer> extends Base implements World {
2
+ import { Event, Base, World, BaseScene, BaseCamera, BaseRenderer, Disposable, Updateable } from "../../Types";
3
+ /**
4
+ * A class representing a simple world in a 3D environment. It extends the Base class and implements the World interface.
5
+ *
6
+ * @template T - The type of the scene. Default is BaseScene.
7
+ * @template U - The type of the camera. Default is BaseCamera.
8
+ * @template S - The type of the renderer. Default is BaseRenderer.
9
+ */
10
+ export declare class SimpleWorld<T extends BaseScene = BaseScene, U extends BaseCamera = BaseCamera, S extends BaseRenderer = BaseRenderer> extends Base implements World, Disposable, Updateable {
5
11
  /**
6
- * All the loaded [meshes](https://threejs.org/docs/#api/en/objects/Mesh).
12
+ * All the loaded [meshes](https://threejs.org/docs/#api/en/objects/Mesh). These meshes will be taken into account in operations like raycasting.
7
13
  */
8
14
  readonly meshes: Set<THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>>;
15
+ /** {@link Updateable.onAfterUpdate} */
9
16
  readonly onAfterUpdate: Event<unknown>;
17
+ /** {@link Updateable.onBeforeUpdate} */
10
18
  readonly onBeforeUpdate: Event<unknown>;
19
+ /** {@link Disposable.onDisposed} */
20
+ readonly onDisposed: Event<unknown>;
21
+ /**
22
+ * 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.
23
+ */
11
24
  isDisposing: boolean;
25
+ /**
26
+ * Indicates whether the world is currently enabled.
27
+ * When disabled, the world will not be updated.
28
+ */
12
29
  enabled: boolean;
30
+ /**
31
+ * A unique identifier for the world.
32
+ */
13
33
  uuid: string;
34
+ /**
35
+ * An optional name for the world.
36
+ */
14
37
  name?: string;
15
- readonly onDisposed: Event<unknown>;
16
38
  private _scene?;
17
39
  private _camera?;
18
40
  private _renderer;
41
+ /**
42
+ * Getter for the scene. If no scene is initialized, it throws an error.
43
+ * @returns The current scene.
44
+ */
19
45
  get scene(): T;
46
+ /**
47
+ * Setter for the scene. It sets the current scene, adds the world to the scene's worlds set,
48
+ * sets the current world in the scene, and triggers the scene's onWorldChanged event with the added action.
49
+ * @param scene - The new scene to be set.
50
+ */
20
51
  set scene(scene: T);
52
+ /**
53
+ * Getter for the camera. If no camera is initialized, it throws an error.
54
+ * @returns The current camera.
55
+ */
21
56
  get camera(): U;
57
+ /**
58
+ * Setter for the camera. It sets the current camera, adds the world to the camera's worlds set,
59
+ * sets the current world in the camera, and triggers the camera's onWorldChanged event with the added action.
60
+ * @param camera - The new camera to be set.
61
+ */
22
62
  set camera(camera: U);
63
+ /**
64
+ * Getter for the renderer.
65
+ * @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).
66
+ */
23
67
  get renderer(): S | null;
68
+ /**
69
+ * Setter for the renderer. It sets the current renderer, adds the world to the renderer's worlds set,
70
+ * sets the current world in the renderer, and triggers the renderer's onWorldChanged event with the added action.
71
+ * If a new renderer is set, it also triggers the onWorldChanged event with the removed action for the old renderer.
72
+ * @param renderer - The new renderer to be set or null to remove the current renderer.
73
+ */
24
74
  set renderer(renderer: S | null);
25
- constructor(components: Components);
75
+ /** {@link Updateable.update} */
26
76
  update(delta?: number): void;
77
+ /** {@link Disposable.dispose} */
27
78
  dispose(disposeResources?: boolean): void;
28
79
  }
@@ -3,8 +3,7 @@ import * as FRAGS from "@thatopen/fragments";
3
3
  import { FragmentsGroup } from "@thatopen/fragments";
4
4
  import { Component, Components, Disposable, Event } from "../../core";
5
5
  /**
6
- * A simple implementation of bounding box that works for fragments. The resulting bbox is not 100% precise, but
7
- * it's fast, and should suffice for general use cases such as camera zooming or general boundary determination.
6
+ * A simple implementation of bounding box that works for fragments. The resulting bbox is not 100% precise, but it's fast, and should suffice for general use cases such as camera zooming or general boundary determination.
8
7
  */
9
8
  export declare class BoundingBoxer extends Component implements Disposable {
10
9
  static readonly uuid: "d1444724-dba6-4cdd-a0c7-68ee1450d166";
@@ -4,8 +4,7 @@ import * as FRAGS from "@thatopen/fragments";
4
4
  import { Component, Components, Event, Disposable } from "../../core";
5
5
  import { RelationsMap } from "../../ifc/IfcRelationsIndexer/src/types";
6
6
  /**
7
- * Object that can efficiently load binary files that contain
8
- * [fragment geometry](https://github.com/ThatOpen/engine_fragment).
7
+ * Object that can efficiently load binary files that contain [fragment geometry](https://github.com/ThatOpen/engine_fragment).
9
8
  */
10
9
  export declare class FragmentsManager extends Component implements Disposable {
11
10
  static readonly uuid: "fef46874-46a3-461b-8c44-2922ab77c806";
@@ -49,5 +48,26 @@ export declare class FragmentsManager extends Component implements Disposable {
49
48
  * @returns the exported data as binary buffer.
50
49
  */
51
50
  export(group: FragmentsGroup): Uint8Array;
51
+ /**
52
+ * Gets a map of model IDs to sets of express IDs for the given fragment ID map.
53
+ * @param fragmentIdMap - A map of fragment IDs to their corresponding express IDs.
54
+ * @returns A map of model IDs to sets of express IDs.
55
+ */
56
+ getModelIdMap(fragmentIdMap: FRAGS.FragmentIdMap): {
57
+ [modelID: string]: Set<number>;
58
+ };
59
+ /**
60
+ * Converts a map of model IDs to sets of express IDs to a fragment ID map.
61
+ * @param modelIdMap - A map of model IDs to their corresponding express IDs.
62
+ * @returns A fragment ID map.
63
+ * @remarks
64
+ * This method iterates through the provided model ID map, retrieves the corresponding model from the `groups` map,
65
+ * and then calls the `getFragmentMap` method of the model to obtain a fragment ID map for the given express IDs.
66
+ * The fragment ID maps are then merged into a single map and returned.
67
+ * 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.
68
+ */
69
+ modelIdToFragmentIdMap(modelIdMap: {
70
+ [modelID: string]: Set<number>;
71
+ }): FRAGS.FragmentIdMap;
52
72
  coordinate(models?: FragmentsGroup[]): void;
53
73
  }
@@ -3,8 +3,7 @@ import { FragmentsGroup } from "@thatopen/fragments";
3
3
  import { Disposable, Event, Component, Components } from "../../core";
4
4
  import { RelationsMap, ModelsRelationMap, InverseAttribute } from "./src/types";
5
5
  /**
6
- * Indexer for IFC entities, facilitating the indexing and retrieval of IFC entity relationships.
7
- * 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.
6
+ * Indexer 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.
8
7
  */
9
8
  export declare class IfcRelationsIndexer extends Component implements Disposable {
10
9
  static readonly uuid: "23a889ab-83b3-44a4-8bee-ead83438370b";
@@ -29,6 +28,7 @@ export declare class IfcRelationsIndexer extends Component implements Disposable
29
28
  readonly relationMaps: ModelsRelationMap;
30
29
  constructor(components: Components);
31
30
  private onFragmentsDisposed;
31
+ private indexRelations;
32
32
  /**
33
33
  * Adds a relation map to the model's relations map.
34
34
  *