@thatopen/components 3.2.6 → 3.3.0

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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import CameraControls from 'camera-controls';
2
2
  import { DataMap as DataMap_2 } from '@thatopen/fragments';
3
+ import { DataSet as DataSet_2 } from '@thatopen/fragments';
3
4
  import * as FRAGS from '@thatopen/fragments';
4
5
  import * as THREE from 'three';
6
+ import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
5
7
  import { Vector2 } from 'three';
6
8
  import * as WEBIFC from 'web-ifc';
7
9
  import { XMLBuilder } from 'fast-xml-parser';
@@ -289,8 +291,8 @@ export declare class BCFTopics extends Component implements Disposable_2, Config
289
291
  static xmlParser: XMLParser;
290
292
  protected _defaultConfig: Required<BCFTopicsConfig>;
291
293
  config: BCFTopicsConfigManager;
292
- readonly list: DataMap<string, Topic>;
293
- readonly documents: DataMap<string, InternalDocumentReference | ExternalDocumentReference>;
294
+ readonly list: DataMap_2<string, Topic>;
295
+ readonly documents: DataMap_2<string, InternalDocumentReference | ExternalDocumentReference>;
294
296
  readonly onSetup: Event_2<unknown>;
295
297
  isSetup: boolean;
296
298
  setup(config?: Partial<BCFTopicsConfig>): void;
@@ -904,6 +906,7 @@ export declare class Clipper extends Component implements Createable, Disposable
904
906
  private _size;
905
907
  private _enabled;
906
908
  private _visible;
909
+ readonly onStateChanged: Event_2<("material" | "enabled" | "size" | "visibility")[]>;
907
910
  /** {@link Component.enabled} */
908
911
  get enabled(): boolean;
909
912
  /** {@link Component.enabled} */
@@ -1142,7 +1145,7 @@ export declare class ConfigManager extends Component {
1142
1145
  /**
1143
1146
  * The list of all configurations of this app.
1144
1147
  */
1145
- list: DataMap<string, Configurator<any, any>>;
1148
+ list: DataMap_2<string, Configurator<any, any>>;
1146
1149
  /** {@link Component.enabled} */
1147
1150
  enabled: boolean;
1148
1151
  /**
@@ -1631,10 +1634,174 @@ export declare interface ExternalDocumentReference extends DocumentReference {
1631
1634
  url: string;
1632
1635
  }
1633
1636
 
1637
+ /**
1638
+ * A fast model picker that uses color coding to identify fragment models under the mouse cursor.
1639
+ * This is much faster than raycasting for simple model identification.
1640
+ */
1641
+ export declare class FastModelPicker implements Disposable_2 {
1642
+ /** {@link Component.enabled} */
1643
+ enabled: boolean;
1644
+ /** The components instance to which this FastModelPicker belongs. */
1645
+ components: Components;
1646
+ /** {@link Disposable.onDisposed} */
1647
+ readonly onDisposed: Event_2<unknown>;
1648
+ /** The position of the mouse in the screen. */
1649
+ readonly mouse: Mouse;
1650
+ /**
1651
+ * A reference to the world instance to which this FastModelPicker belongs.
1652
+ * This is used to access the camera and scene.
1653
+ */
1654
+ world: World;
1655
+ /**
1656
+ * Whether debug mode is enabled. When enabled, shows the color-coded canvas.
1657
+ */
1658
+ debugMode: boolean;
1659
+ /**
1660
+ * Map from color (as RGB number) to model ID.
1661
+ * Color is encoded as: (r << 16) | (g << 8) | b
1662
+ */
1663
+ private colorToModelId;
1664
+ /**
1665
+ * Map from model ID to color.
1666
+ */
1667
+ private modelIdToColor;
1668
+ /**
1669
+ * Render target for the color-coded scene.
1670
+ */
1671
+ private renderTarget?;
1672
+ /**
1673
+ * Size of the render target (stored separately since getSize doesn't exist).
1674
+ */
1675
+ private renderTargetSize;
1676
+ /**
1677
+ * Debug canvas element (shown when debugMode is true).
1678
+ */
1679
+ private debugCanvas?;
1680
+ /**
1681
+ * Debug container element.
1682
+ */
1683
+ private debugContainer?;
1684
+ /**
1685
+ * Material used for color-coding models.
1686
+ */
1687
+ private colorMaterials;
1688
+ /**
1689
+ * Original materials cache (to restore after picking).
1690
+ */
1691
+ private originalMaterials;
1692
+ private originalLodColors;
1693
+ /**
1694
+ * Whether colors need to be reassigned (when models change).
1695
+ */
1696
+ private colorsNeedUpdate;
1697
+ constructor(components: Components, world: World);
1698
+ /**
1699
+ * Sets up listeners for fragment model changes.
1700
+ */
1701
+ private setupFragmentListeners;
1702
+ /**
1703
+ * Sets up the render target for color-coded picking.
1704
+ */
1705
+ private setupRenderTarget;
1706
+ /**
1707
+ * Sets up the debug canvas for visualization.
1708
+ */
1709
+ private setupDebugCanvas;
1710
+ /**
1711
+ * Generates a deterministic color for a model based on its ID.
1712
+ * This ensures the same model always gets the same color.
1713
+ */
1714
+ private generateColorForModel;
1715
+ /**
1716
+ * Converts a color to a numeric ID.
1717
+ */
1718
+ private colorToId;
1719
+ /**
1720
+ * Assigns unique colors to all fragment models.
1721
+ * Colors are deterministic based on model ID, so the same model always gets the same color.
1722
+ */
1723
+ private assignColors;
1724
+ /**
1725
+ * Applies color materials to fragment models.
1726
+ */
1727
+ private applyColorMaterials;
1728
+ /**
1729
+ * Restores original materials to fragment models.
1730
+ */
1731
+ private restoreOriginalMaterials;
1732
+ /**
1733
+ * Renders the scene with color-coded models.
1734
+ */
1735
+ private renderColorCoded;
1736
+ /**
1737
+ * Updates the debug canvas with the color-coded render.
1738
+ */
1739
+ private updateDebugCanvas;
1740
+ /**
1741
+ * Gets the model ID at the given screen position.
1742
+ *
1743
+ * @param position - Optional screen position. If not provided, uses current mouse position.
1744
+ * @returns The model ID at the position, or null if no model is found.
1745
+ */
1746
+ getModelAt(position?: THREE.Vector2): Promise<string | null>;
1747
+ /**
1748
+ * Enables or disables debug mode.
1749
+ * When enabled, shows a canvas with the color-coded render.
1750
+ */
1751
+ setDebugMode(enabled: boolean): void;
1752
+ /**
1753
+ * Removes the debug canvas.
1754
+ */
1755
+ private removeDebugCanvas;
1756
+ /** {@link Disposable.dispose} */
1757
+ dispose(): void;
1758
+ }
1759
+
1760
+ /**
1761
+ * A component that manages a FastModelPicker for each world and automatically disposes it when its corresponding world is disposed.
1762
+ */
1763
+ export declare class FastModelPickers extends Component implements Disposable_2 {
1764
+ /**
1765
+ * A unique identifier for the component.
1766
+ * This UUID is used to register the component within the Components system.
1767
+ */
1768
+ static readonly uuid: "4a82430c-7ff2-49ea-9401-60807502dad6";
1769
+ /** {@link Component.enabled} */
1770
+ enabled: boolean;
1771
+ /**
1772
+ * A Map that stores FastModelPicker instances for each world.
1773
+ * The key is the world's UUID, and the value is the corresponding FastModelPicker instance.
1774
+ */
1775
+ list: Map<string, FastModelPicker>;
1776
+ /** {@link Disposable.onDisposed} */
1777
+ onDisposed: Event_2<unknown>;
1778
+ constructor(components: Components);
1779
+ /**
1780
+ * Retrieves a FastModelPicker instance for the given world.
1781
+ * If a FastModelPicker instance already exists for the world, it will be returned.
1782
+ * Otherwise, a new FastModelPicker instance will be created and added to the list.
1783
+ *
1784
+ * @param world - The world for which to retrieve or create a FastModelPicker instance.
1785
+ * @returns The FastModelPicker instance for the given world.
1786
+ */
1787
+ get(world: World): FastModelPicker;
1788
+ /**
1789
+ * Deletes the FastModelPicker instance associated with the given world.
1790
+ * If a FastModelPicker instance exists for the given world, it will be disposed and removed from the list.
1791
+ *
1792
+ * @param world - The world for which to delete the FastModelPicker instance.
1793
+ * @returns {void}
1794
+ */
1795
+ delete(world: World): void;
1796
+ /** {@link Disposable.dispose} */
1797
+ dispose(): void;
1798
+ }
1799
+
1634
1800
  /**
1635
1801
  * Represents a finder query for retrieving items based on specified parameters. This class encapsulates the query logic, caching mechanism, and result management.
1636
1802
  */
1637
1803
  export declare class FinderQuery {
1804
+ name: string;
1638
1805
  customData: Record<string, any>;
1639
1806
  private _components;
1640
1807
  private _queries;
@@ -1689,7 +1856,7 @@ export declare class FinderQuery {
1689
1856
  * @param data - A `SerializedFinderQuery` object representing the serialized query.
1690
1857
  * @returns A `FinderQuery` instance.
1691
1858
  */
1692
- fromJSON(data: Omit<SerializedFinderQuery, "name">): this;
1859
+ fromJSON(data: SerializedFinderQuery): this;
1693
1860
  }
1694
1861
 
1695
1862
  /**
@@ -2155,7 +2322,7 @@ export declare class IDSSpecifications extends Component {
2155
2322
  static xmlParser: XMLParser;
2156
2323
  IDSInfo?: IDSInfo;
2157
2324
  constructor(components: Components);
2158
- readonly list: DataMap<string, IDSSpecification>;
2325
+ readonly list: DataMap_2<string, IDSSpecification>;
2159
2326
  /**
2160
2327
  * Processes the results of an IDS check and categorizes the items into passing and failing.
2161
2328
  *
@@ -2373,6 +2540,7 @@ export declare class ItemsFinder extends Component implements Serializable<Seria
2373
2540
  getItems(queries: FRAGS.ItemsQueryParams[], config?: {
2374
2541
  modelIds?: RegExp[];
2375
2542
  aggregation?: QueryResultAggregation;
2543
+ items?: ModelIdMap;
2376
2544
  }): Promise<ModelIdMap>;
2377
2545
  /**
2378
2546
  * Creates a new FinderQuery instance and adds it to the list of queries.
@@ -2648,7 +2816,7 @@ export declare class OrthoPerspectiveCamera extends SimpleCamera {
2648
2816
  readonly threePersp: THREE.PerspectiveCamera;
2649
2817
  protected readonly _userInputButtons: any;
2650
2818
  protected readonly _frustumSize = 50;
2651
- protected readonly _navigationModes: Map<NavModeID, NavigationMode>;
2819
+ protected readonly _navigationModes: Map<string, NavigationMode>;
2652
2820
  protected _mode: NavigationMode | null;
2653
2821
  private previousSize;
2654
2822
  /**
@@ -2668,7 +2836,7 @@ export declare class OrthoPerspectiveCamera extends SimpleCamera {
2668
2836
  *
2669
2837
  * @param mode - The {@link NavigationMode} to set.
2670
2838
  */
2671
- set(mode: NavModeID): void;
2839
+ set(mode: string): void;
2672
2840
  /**
2673
2841
  * Make the camera view fit all the specified meshes.
2674
2842
  *
@@ -2683,6 +2851,12 @@ export declare class OrthoPerspectiveCamera extends SimpleCamera {
2683
2851
  * @param active - whether to enable or disable user inputs.
2684
2852
  */
2685
2853
  setUserInput(active: boolean): void;
2854
+ /**
2855
+ * Adds a custom {@link NavigationMode} to the camera that can be used using the {@link OrthoPerspectiveCamera.set} method.
2856
+ *
2857
+ * @param mode - The custom {@link NavigationMode} to add.
2858
+ */
2859
+ addCustomNavigationMode(mode: NavigationMode): void;
2686
2860
  private disableUserInput;
2687
2861
  private enableUserInput;
2688
2862
  private newOrthoCamera;
@@ -2880,6 +3054,10 @@ export declare interface SerializationResult<D extends Record<string, any> = Rec
2880
3054
  * Represents a serialized query for an item finder.
2881
3055
  */
2882
3056
  export declare interface SerializedFinderQuery {
3057
+ /**
3058
+ * The ID of the query.
3059
+ */
3060
+ guid: string;
2883
3061
  /**
2884
3062
  * The name of the query.
2885
3063
  */
@@ -3277,6 +3455,13 @@ export declare class SimplePlane implements Disposable_2, Hideable {
3277
3455
  * @returns {THREE.Object3D} The helper object of the clipping plane.
3278
3456
  */
3279
3457
  get helper(): THREE.Object3D<THREE.Object3DEventMap>;
3458
+ /**
3459
+ * Getter for the transform controls of the clipping plane.
3460
+ * The controls allow interactive manipulation (translation, rotation, etc.) of the clipping plane.
3461
+ *
3462
+ * @returns {TransformControls} The transform controls of the clipping plane.
3463
+ */
3464
+ get controls(): TransformControls;
3280
3465
  constructor(components: Components, world: World, origin: THREE.Vector3, normal: THREE.Vector3, material: THREE.Material, size?: number, activateControls?: boolean);
3281
3466
  private notifyManager;
3282
3467
  /**
@@ -3328,6 +3513,13 @@ export declare class SimpleRaycaster implements Disposable_2 {
3328
3513
  * This is used to access the camera and meshes.
3329
3514
  */
3330
3515
  world: World;
3516
+ /**
3517
+ * Whether to use fast model picking to optimize raycasting.
3518
+ * When enabled, the raycaster will first use FastModelPicker to identify
3519
+ * which model is under the mouse, then only raycast that specific model.
3520
+ * This can significantly improve performance when there are many models.
3521
+ */
3522
+ useFastModelPicking: boolean;
3331
3523
  constructor(components: Components, world: World);
3332
3524
  /** {@link Disposable.dispose} */
3333
3525
  dispose(): void;
@@ -3597,10 +3789,10 @@ export declare class Topic implements BCFTopic {
3597
3789
  title: string;
3598
3790
  creationDate: Date;
3599
3791
  creationAuthor: string;
3600
- readonly viewpoints: DataSet<string>;
3601
- readonly relatedTopics: DataSet<string>;
3602
- readonly comments: DataMap<string, Comment_2>;
3603
- readonly documentReferences: DataSet<string>;
3792
+ readonly viewpoints: DataSet_2<string>;
3793
+ readonly relatedTopics: DataSet_2<string>;
3794
+ readonly comments: DataMap_2<string, Comment_2>;
3795
+ readonly documentReferences: DataSet_2<string>;
3604
3796
  customData: Record<string, any>;
3605
3797
  description?: string;
3606
3798
  serverAssignedId?: string;
@@ -3900,6 +4092,7 @@ export declare class Viewpoint {
3900
4092
  */
3901
4093
  readonly clippingPlanes: FRAGS.DataSet<string>;
3902
4094
  camera: ViewpointPerspectiveCamera | ViewpointOrthogonalCamera;
4095
+ customData: Record<string, any>;
3903
4096
  /**
3904
4097
  * A list of components GUIDs to hide when defaultVisibility = true or to show when defaultVisibility = false
3905
4098
  */
@@ -4537,7 +4730,7 @@ export declare class Worlds extends Component implements Updateable, Disposable_
4537
4730
  * A collection of worlds managed by this component.
4538
4731
  * The key is the unique identifier (UUID) of the world, and the value is the World instance.
4539
4732
  */
4540
- list: DataMap<string, World>;
4733
+ list: DataMap_2<string, World>;
4541
4734
  /** {@link Component.enabled} */
4542
4735
  enabled: boolean;
4543
4736
  constructor(components: Components);