@thatopen/components 2.2.4 → 2.3.0-alpha.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.
@@ -6,7 +6,7 @@ export declare class Components implements Disposable {
6
6
  /**
7
7
  * The version of the @thatopen/components library.
8
8
  */
9
- static readonly release = "2.2.4";
9
+ static readonly release = "2.3.0-alpha.1";
10
10
  /** {@link Disposable.onDisposed} */
11
11
  readonly onDisposed: Event<void>;
12
12
  /**
@@ -1,6 +1,6 @@
1
- import { SimpleScene, SimpleSceneConfig } from "../Worlds";
1
+ import { SimpleScene, SimpleSceneConfig, SimpleSceneConfigManager } from "../Worlds";
2
2
  import { DistanceRenderer } from "./src";
3
- import { Disposable } from "../Types";
3
+ import { Configurable, Disposable } from "../Types";
4
4
  /**
5
5
  * Configuration interface for the {@link ShadowedScene}. Defines properties for directional and ambient lights,
6
6
  * as well as shadows.
@@ -14,17 +14,16 @@ export interface ShadowedSceneConfig extends SimpleSceneConfig {
14
14
  /**
15
15
  * A scene that supports efficient cast shadows. 📕 [Tutorial](https://docs.thatopen.com/Tutorials/Components/Core/ShadowedScene). 📘 [API](https://docs.thatopen.com/api/@thatopen/components/classes/ShadowedScene).
16
16
  */
17
- export declare class ShadowedScene extends SimpleScene implements Disposable {
17
+ export declare class ShadowedScene extends SimpleScene implements Disposable, Configurable<SimpleSceneConfigManager, ShadowedSceneConfig> {
18
18
  private _distanceRenderer?;
19
19
  /**
20
20
  * Whether the bias property should be set automatically depending on the shadow distance.
21
21
  */
22
22
  autoBias: boolean;
23
- /**
24
- * Configuration interface for the {@link ShadowedScene}.
25
- * Defines properties for directional and ambient lights, as well as shadows.
26
- */
27
- config: Required<ShadowedSceneConfig>;
23
+ protected _defaultShadowConfig: {
24
+ cascade: number;
25
+ resolution: number;
26
+ };
28
27
  private _lightsWithShadow;
29
28
  private _isComputingShadows;
30
29
  private _shadowsEnabled;
@@ -21,4 +21,5 @@ export declare abstract class BaseScene extends BaseWorldItem implements Disposa
21
21
  protected constructor(components: Components);
22
22
  /** {@link Disposable.dispose} */
23
23
  dispose(): void;
24
+ deleteAllLights(): void;
24
25
  }
@@ -15,5 +15,5 @@ export declare abstract class Base {
15
15
  /** Whether is component is {@link Hideable}. */
16
16
  isHideable: () => this is Hideable;
17
17
  /** Whether is component is {@link Configurable}. */
18
- isConfigurable: () => this is Configurable<any>;
18
+ isConfigurable: () => this is Configurable<any, any>;
19
19
  }
@@ -0,0 +1,13 @@
1
+ import { Component } from "./component";
2
+ export type ComponentUIElement = {
3
+ name: string;
4
+ componentID: string;
5
+ attributes: {
6
+ [name: string]: string;
7
+ };
8
+ get: () => HTMLElement;
9
+ };
10
+ export declare abstract class ComponentWithUI extends Component {
11
+ abstract name: string;
12
+ abstract getUI(): ComponentUIElement[];
13
+ }
@@ -0,0 +1,50 @@
1
+ import * as THREE from "three";
2
+ export interface BooleanSettingsControl {
3
+ type: "Boolean";
4
+ value: boolean;
5
+ }
6
+ export interface ColorSettingsControl {
7
+ type: "Color";
8
+ opacity: number;
9
+ value: THREE.Color;
10
+ }
11
+ export interface TextSettingsControl {
12
+ type: "Text";
13
+ value: string;
14
+ }
15
+ export interface NumberSettingControl {
16
+ type: "Number";
17
+ interpolable: boolean;
18
+ min?: number;
19
+ max?: number;
20
+ value: number;
21
+ }
22
+ export interface SelectSettingControl {
23
+ type: "Select";
24
+ options: Set<string>;
25
+ value: string;
26
+ }
27
+ export interface MultiSelectSettingControl {
28
+ type: "MultiSelect";
29
+ options: Set<string>;
30
+ value: Set<string>;
31
+ }
32
+ export interface Vector3SettingControl {
33
+ type: "Vector";
34
+ value: THREE.Vector3;
35
+ }
36
+ export interface TextSetSettingControl {
37
+ type: "TextSet";
38
+ value: Set<string>;
39
+ }
40
+ type ControlEntry = BooleanSettingsControl | ColorSettingsControl | TextSettingsControl | NumberSettingControl | SelectSettingControl | Vector3SettingControl | TextSetSettingControl | MultiSelectSettingControl;
41
+ interface ControlsSchema {
42
+ [name: string]: ControlEntry | ControlsSchema;
43
+ }
44
+ export declare abstract class ConfigManager<T, U extends ControlsSchema> {
45
+ protected abstract _list: U;
46
+ protected _component: T;
47
+ get controls(): any;
48
+ constructor(component: T);
49
+ }
50
+ export {};
@@ -10,3 +10,5 @@ export * from "./base-scene";
10
10
  export * from "./world";
11
11
  export * from "./data-set";
12
12
  export * from "./data-map";
13
+ export * from "./component-with-ui";
14
+ export * from "./config-manager";
@@ -84,15 +84,14 @@ export interface Createable {
84
84
  /**
85
85
  * Whether this component supports to be configured.
86
86
  */
87
- export interface Configurable<T extends Record<string, any>> {
87
+ export interface Configurable<T, U> {
88
88
  /** Wether this components has been already configured. */
89
89
  isSetup: boolean;
90
- /** Use the provided configuration to setup the tool. */
91
- setup: (config?: Partial<T>) => void | Promise<void>;
90
+ /** Use the provided configuration to set up the tool. */
91
+ setup: (config?: Partial<U>) => void | Promise<void>;
92
92
  /** Fired after successfully calling {@link Configurable.setup()} */
93
93
  readonly onSetup: Event<any>;
94
- /** Object holding the tool configuration. Is not meant to be edited directly, if you need
95
- * to make changes to this object, use {@link Configurable.setup()} just after the tool is instantiated.
94
+ /** Object holding the tool configuration. You can edit this directly to change the object.
96
95
  */
97
96
  config: Required<T>;
98
97
  }
@@ -1,18 +1,9 @@
1
1
  import { World, Component, Disposable, Event, DataMap, Configurable } from "../Types";
2
2
  import { Components } from "../Components";
3
3
  import { BCFViewpoint, Viewpoint } from "./src";
4
- /**
5
- * Configuration interface for the Viewpoints general behavior.
6
- */
7
- interface ViewpointsConfig {
8
- /**
9
- * Indicates whether to overwrite the fragments colors when applying viewpoints.
10
- * @remarks BCF Viewpoints comes with information to indicate the colors to be applied to components, if any.
11
- * @default false
12
- */
13
- overwriteColors: boolean;
14
- }
15
- export declare class Viewpoints extends Component implements Disposable, Configurable<ViewpointsConfig> {
4
+ import { ViewpointsConfigManger, ViewpointsConfig } from "./src/viewpoints-config";
5
+ export * from "./src";
6
+ export declare class Viewpoints extends Component implements Disposable, Configurable<ViewpointsConfigManger, ViewpointsConfig> {
16
7
  static readonly uuid: "ee867824-a796-408d-8aa0-4e5962a83c66";
17
8
  enabled: boolean;
18
9
  /**
@@ -33,7 +24,7 @@ export declare class Viewpoints extends Component implements Disposable, Configu
33
24
  isSetup: boolean;
34
25
  setup(): void;
35
26
  onSetup: Event<unknown>;
36
- config: Required<ViewpointsConfig>;
27
+ config: ViewpointsConfigManger;
37
28
  readonly onDisposed: Event<unknown>;
38
29
  /**
39
30
  * Disposes of the Viewpoints component and its associated resources.
@@ -44,4 +35,3 @@ export declare class Viewpoints extends Component implements Disposable, Configu
44
35
  */
45
36
  dispose(): void;
46
37
  }
47
- export * from "./src";
@@ -1,2 +1,2 @@
1
1
  export * from "./types";
2
- export * from "./Viewpoint";
2
+ export * from "./viewpoint";
@@ -186,5 +186,5 @@ export declare class Viewpoint implements BCFViewpoint {
186
186
  * @throws An error if the world's camera does not have camera controls.
187
187
  * @throws An error if the world's renderer is not available.
188
188
  */
189
- serialize(version?: import("../../../openbim/BCFTopics").BCFVersion): Promise<string>;
189
+ serialize(version?: string): Promise<string>;
190
190
  }
@@ -0,0 +1,28 @@
1
+ import { BooleanSettingsControl, ConfigManager } from "../../Types";
2
+ import { Viewpoints } from "../index";
3
+ /**
4
+ * Configuration interface for the Viewpoints general behavior.
5
+ */
6
+ export interface ViewpointsConfig {
7
+ /**
8
+ * Indicates whether to overwrite the fragments colors when applying viewpoints.
9
+ * @remarks BCF Viewpoints comes with information to indicate the colors to be applied to components, if any.
10
+ * @default false
11
+ */
12
+ overwriteColors: boolean;
13
+ }
14
+ type ViewpointsConfigType = {
15
+ overwriteColors: BooleanSettingsControl;
16
+ };
17
+ export declare class ViewpointsConfigManger extends ConfigManager<Viewpoints, ViewpointsConfigType> {
18
+ protected _list: {
19
+ overwriteColors: {
20
+ value: boolean;
21
+ opacity: number;
22
+ type: "Boolean";
23
+ };
24
+ };
25
+ get overwriteColors(): boolean;
26
+ set overwriteColors(value: boolean);
27
+ }
28
+ export {};
@@ -2,3 +2,4 @@ export * from "./simple-world";
2
2
  export * from "./simple-scene";
3
3
  export * from "./simple-renderer";
4
4
  export * from "./simple-camera";
5
+ export * from "./simple-scene-config";
@@ -0,0 +1,92 @@
1
+ import * as THREE from "three";
2
+ import { SimpleScene } from "./simple-scene";
3
+ import { ColorSettingsControl, ConfigManager, NumberSettingControl, Vector3SettingControl } from "../../Types";
4
+ type SimpleSceneConfigType = {
5
+ backgroundColor: ColorSettingsControl;
6
+ ambientLight: {
7
+ color: ColorSettingsControl;
8
+ intensity: NumberSettingControl;
9
+ };
10
+ directionalLight: {
11
+ color: ColorSettingsControl;
12
+ intensity: NumberSettingControl;
13
+ position: Vector3SettingControl;
14
+ };
15
+ };
16
+ declare class DirectionalLightConfig {
17
+ private _list;
18
+ private _scene;
19
+ constructor(list: SimpleSceneConfigType, scene: SimpleScene);
20
+ get color(): THREE.Color;
21
+ set color(value: THREE.Color);
22
+ get intensity(): number;
23
+ set intensity(value: number);
24
+ get position(): THREE.Vector3;
25
+ set position(value: THREE.Vector3);
26
+ }
27
+ declare class AmbientLightConfig {
28
+ private _list;
29
+ private _scene;
30
+ constructor(list: SimpleSceneConfigType, scene: SimpleScene);
31
+ get color(): THREE.Color;
32
+ set color(value: THREE.Color);
33
+ get intensity(): number;
34
+ set intensity(value: number);
35
+ }
36
+ /**
37
+ * Configuration interface for the {@link SimpleScene}.
38
+ */
39
+ export interface SimpleSceneConfig {
40
+ backgroundColor: THREE.Color;
41
+ directionalLight: {
42
+ color: THREE.Color;
43
+ intensity: number;
44
+ position: THREE.Vector3;
45
+ };
46
+ ambientLight: {
47
+ color: THREE.Color;
48
+ intensity: number;
49
+ };
50
+ }
51
+ export declare class SimpleSceneConfigManager extends ConfigManager<SimpleScene, SimpleSceneConfigType> {
52
+ protected _list: {
53
+ backgroundColor: {
54
+ value: THREE.Color;
55
+ opacity: number;
56
+ type: "Color";
57
+ };
58
+ ambientLight: {
59
+ color: {
60
+ type: "Color";
61
+ opacity: number;
62
+ value: THREE.Color;
63
+ };
64
+ intensity: {
65
+ type: "Number";
66
+ interpolable: boolean;
67
+ value: number;
68
+ };
69
+ };
70
+ directionalLight: {
71
+ color: {
72
+ type: "Color";
73
+ opacity: number;
74
+ value: THREE.Color;
75
+ };
76
+ intensity: {
77
+ type: "Number";
78
+ interpolable: boolean;
79
+ value: number;
80
+ };
81
+ position: {
82
+ type: "Vector";
83
+ value: THREE.Vector3;
84
+ };
85
+ };
86
+ };
87
+ ambientLight: AmbientLightConfig;
88
+ directionalLight: DirectionalLightConfig;
89
+ get backgroundColor(): THREE.Color;
90
+ set backgroundColor(value: THREE.Color);
91
+ }
92
+ export {};
@@ -1,24 +1,11 @@
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
- */
7
- export interface SimpleSceneConfig {
8
- directionalLight: {
9
- color: THREE.Color;
10
- intensity: number;
11
- position: THREE.Vector3;
12
- };
13
- ambientLight: {
14
- color: THREE.Color;
15
- intensity: number;
16
- };
17
- }
4
+ import { SimpleSceneConfig, SimpleSceneConfigManager } from "./simple-scene-config";
18
5
  /**
19
6
  * 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.
20
7
  */
21
- export declare class SimpleScene extends BaseScene implements Configurable<{}> {
8
+ export declare class SimpleScene extends BaseScene implements Configurable<SimpleSceneConfigManager, SimpleSceneConfig> {
22
9
  /** {@link Configurable.isSetup} */
23
10
  isSetup: boolean;
24
11
  /**
@@ -28,11 +15,9 @@ export declare class SimpleScene extends BaseScene implements Configurable<{}> {
28
15
  three: THREE.Scene;
29
16
  /** {@link Configurable.onSetup} */
30
17
  readonly onSetup: Event<SimpleScene>;
31
- /**
32
- * Configuration interface for the {@link SimpleScene}.
33
- * Defines properties for directional and ambient lights.
34
- */
35
- config: Required<SimpleSceneConfig>;
18
+ /** {@link Configurable.config} */
19
+ config: SimpleSceneConfigManager;
20
+ protected _defaultConfig: SimpleSceneConfig;
36
21
  constructor(components: Components);
37
22
  /** {@link Configurable.setup} */
38
23
  setup(config?: Partial<SimpleSceneConfig>): void;