Skip to content

Commit a3d0a85

Browse files
committed
2 parents 3de96dd + caeef8a commit a3d0a85

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thatopen/components",
33
"description": "Collection of core functionalities to author BIM apps.",
4-
"version": "2.2.11",
4+
"version": "2.2.12",
55
"author": "That Open Company",
66
"contributors": [
77
"Antonio Gonzalez Viegas (https://github.com/agviegas)",

packages/core/src/core/Components/index.ts

+22-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class Components implements Disposable {
1414
/**
1515
* The version of the @thatopen/components library.
1616
*/
17-
static readonly release = "2.2.11";
17+
static readonly release = "2.2.12";
1818

1919
/** {@link Disposable.onDisposed} */
2020
readonly onDisposed = new Event<void>();
@@ -33,6 +33,26 @@ export class Components implements Disposable {
3333

3434
private _clock: THREE.Clock;
3535

36+
/**
37+
* Event that triggers the Components instance is initialized.
38+
*
39+
* @remarks
40+
* This event is triggered once when the {@link Components.init} method has been called and finish processing.
41+
* This is useful to set configuration placeholders that need to be executed when the components instance is initialized.
42+
* For example, enabling and configuring custom effects in a post-production renderer.
43+
*
44+
* @example
45+
* ```typescript
46+
* const components = new Components();
47+
* components.onInit.add(() => {
48+
* // Enable custom effects in the post-production renderer
49+
* // or any other operation dependant on the component initialization
50+
* });
51+
* components.init();
52+
* ```
53+
*/
54+
readonly onInit = new Event<undefined>();
55+
3656
/**
3757
* Adds a component to the list of components.
3858
* Throws an error if a component with the same UUID already exists.
@@ -88,13 +108,12 @@ export class Components implements Disposable {
88108
* Initializes the Components instance.
89109
* This method starts the animation loop, sets the enabled flag to true,
90110
* and calls the update method.
91-
*
92-
* @returns {void}
93111
*/
94112
init() {
95113
this.enabled = true;
96114
this._clock.start();
97115
this.update();
116+
this.onInit.trigger();
98117
}
99118

100119
/**

0 commit comments

Comments
 (0)