@thatopen/components 3.2.7 → 3.3.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.
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,173 @@ 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. This is much faster than raycasting for simple model identification.
1639
+ */
1640
+ export declare class FastModelPicker implements Disposable_2 {
1641
+ /** {@link Component.enabled} */
1642
+ enabled: boolean;
1643
+ /** The components instance to which this FastModelPicker belongs. */
1644
+ components: Components;
1645
+ /** {@link Disposable.onDisposed} */
1646
+ readonly onDisposed: Event_2<unknown>;
1647
+ /** The position of the mouse in the screen. */
1648
+ readonly mouse: Mouse;
1649
+ /**
1650
+ * A reference to the world instance to which this FastModelPicker belongs.
1651
+ * This is used to access the camera and scene.
1652
+ */
1653
+ world: World;
1654
+ /**
1655
+ * Whether debug mode is enabled. When enabled, shows the color-coded canvas.
1656
+ */
1657
+ debugMode: boolean;
1658
+ /**
1659
+ * Map from color (as RGB number) to model ID.
1660
+ * Color is encoded as: (r << 16) | (g << 8) | b
1661
+ */
1662
+ private colorToModelId;
1663
+ /**
1664
+ * Map from model ID to color.
1665
+ */
1666
+ private modelIdToColor;
1667
+ /**
1668
+ * Render target for the color-coded scene.
1669
+ */
1670
+ private renderTarget?;
1671
+ /**
1672
+ * Size of the render target (stored separately since getSize doesn't exist).
1673
+ */
1674
+ private renderTargetSize;
1675
+ /**
1676
+ * Debug canvas element (shown when debugMode is true).
1677
+ */
1678
+ private debugCanvas?;
1679
+ /**
1680
+ * Debug container element.
1681
+ */
1682
+ private debugContainer?;
1683
+ /**
1684
+ * Material used for color-coding models.
1685
+ */
1686
+ private colorMaterials;
1687
+ /**
1688
+ * Original materials cache (to restore after picking).
1689
+ */
1690
+ private originalMaterials;
1691
+ private originalLodColors;
1692
+ /**
1693
+ * Whether colors need to be reassigned (when models change).
1694
+ */
1695
+ private colorsNeedUpdate;
1696
+ constructor(components: Components, world: World);
1697
+ /**
1698
+ * Sets up listeners for fragment model changes.
1699
+ */
1700
+ private setupFragmentListeners;
1701
+ /**
1702
+ * Sets up the render target for color-coded picking.
1703
+ */
1704
+ private setupRenderTarget;
1705
+ /**
1706
+ * Sets up the debug canvas for visualization.
1707
+ */
1708
+ private setupDebugCanvas;
1709
+ /**
1710
+ * Generates a deterministic color for a model based on its ID.
1711
+ * This ensures the same model always gets the same color.
1712
+ */
1713
+ private generateColorForModel;
1714
+ /**
1715
+ * Converts a color to a numeric ID.
1716
+ */
1717
+ private colorToId;
1718
+ /**
1719
+ * Assigns unique colors to all fragment models.
1720
+ * Colors are deterministic based on model ID, so the same model always gets the same color.
1721
+ */
1722
+ private assignColors;
1723
+ /**
1724
+ * Applies color materials to fragment models.
1725
+ */
1726
+ private applyColorMaterials;
1727
+ /**
1728
+ * Restores original materials to fragment models.
1729
+ */
1730
+ private restoreOriginalMaterials;
1731
+ /**
1732
+ * Renders the scene with color-coded models.
1733
+ */
1734
+ private renderColorCoded;
1735
+ /**
1736
+ * Updates the debug canvas with the color-coded render.
1737
+ */
1738
+ private updateDebugCanvas;
1739
+ /**
1740
+ * Gets the model ID at the given screen position.
1741
+ *
1742
+ * @param position - Optional screen position. If not provided, uses current mouse position.
1743
+ * @returns The model ID at the position, or null if no model is found.
1744
+ */
1745
+ getModelAt(position?: THREE.Vector2): Promise<string | null>;
1746
+ /**
1747
+ * Enables or disables debug mode.
1748
+ * When enabled, shows a canvas with the color-coded render.
1749
+ */
1750
+ setDebugMode(enabled: boolean): void;
1751
+ /**
1752
+ * Removes the debug canvas.
1753
+ */
1754
+ private removeDebugCanvas;
1755
+ /** {@link Disposable.dispose} */
1756
+ dispose(): void;
1757
+ }
1758
+
1759
+ /**
1760
+ * A component that manages a FastModelPicker for each world and automatically disposes it when its corresponding world is disposed.
1761
+ */
1762
+ export declare class FastModelPickers extends Component implements Disposable_2 {
1763
+ /**
1764
+ * A unique identifier for the component.
1765
+ * This UUID is used to register the component within the Components system.
1766
+ */
1767
+ static readonly uuid: "4a82430c-7ff2-49ea-9401-60807502dad6";
1768
+ /** {@link Component.enabled} */
1769
+ enabled: boolean;
1770
+ /**
1771
+ * A Map that stores FastModelPicker instances for each world.
1772
+ * The key is the world's UUID, and the value is the corresponding FastModelPicker instance.
1773
+ */
1774
+ list: Map<string, FastModelPicker>;
1775
+ /** {@link Disposable.onDisposed} */
1776
+ onDisposed: Event_2<unknown>;
1777
+ constructor(components: Components);
1778
+ /**
1779
+ * Retrieves a FastModelPicker instance for the given world.
1780
+ * If a FastModelPicker instance already exists for the world, it will be returned.
1781
+ * Otherwise, a new FastModelPicker instance will be created and added to the list.
1782
+ *
1783
+ * @param world - The world for which to retrieve or create a FastModelPicker instance.
1784
+ * @returns The FastModelPicker instance for the given world.
1785
+ */
1786
+ get(world: World): FastModelPicker;
1787
+ /**
1788
+ * Deletes the FastModelPicker instance associated with the given world.
1789
+ * If a FastModelPicker instance exists for the given world, it will be disposed and removed from the list.
1790
+ *
1791
+ * @param world - The world for which to delete the FastModelPicker instance.
1792
+ * @returns {void}
1793
+ */
1794
+ delete(world: World): void;
1795
+ /** {@link Disposable.dispose} */
1796
+ dispose(): void;
1797
+ }
1798
+
1634
1799
  /**
1635
1800
  * Represents a finder query for retrieving items based on specified parameters. This class encapsulates the query logic, caching mechanism, and result management.
1636
1801
  */
1637
1802
  export declare class FinderQuery {
1803
+ name: string;
1638
1804
  customData: Record<string, any>;
1639
1805
  private _components;
1640
1806
  private _queries;
@@ -1689,7 +1855,7 @@ export declare class FinderQuery {
1689
1855
  * @param data - A `SerializedFinderQuery` object representing the serialized query.
1690
1856
  * @returns A `FinderQuery` instance.
1691
1857
  */
1692
- fromJSON(data: Omit<SerializedFinderQuery, "name">): this;
1858
+ fromJSON(data: SerializedFinderQuery): this;
1693
1859
  }
1694
1860
 
1695
1861
  /**
@@ -2155,7 +2321,7 @@ export declare class IDSSpecifications extends Component {
2155
2321
  static xmlParser: XMLParser;
2156
2322
  IDSInfo?: IDSInfo;
2157
2323
  constructor(components: Components);
2158
- readonly list: DataMap<string, IDSSpecification>;
2324
+ readonly list: DataMap_2<string, IDSSpecification>;
2159
2325
  /**
2160
2326
  * Processes the results of an IDS check and categorizes the items into passing and failing.
2161
2327
  *
@@ -2373,6 +2539,7 @@ export declare class ItemsFinder extends Component implements Serializable<Seria
2373
2539
  getItems(queries: FRAGS.ItemsQueryParams[], config?: {
2374
2540
  modelIds?: RegExp[];
2375
2541
  aggregation?: QueryResultAggregation;
2542
+ items?: ModelIdMap;
2376
2543
  }): Promise<ModelIdMap>;
2377
2544
  /**
2378
2545
  * Creates a new FinderQuery instance and adds it to the list of queries.
@@ -2886,6 +3053,10 @@ export declare interface SerializationResult<D extends Record<string, any> = Rec
2886
3053
  * Represents a serialized query for an item finder.
2887
3054
  */
2888
3055
  export declare interface SerializedFinderQuery {
3056
+ /**
3057
+ * The ID of the query.
3058
+ */
3059
+ guid: string;
2889
3060
  /**
2890
3061
  * The name of the query.
2891
3062
  */
@@ -3283,6 +3454,13 @@ export declare class SimplePlane implements Disposable_2, Hideable {
3283
3454
  * @returns {THREE.Object3D} The helper object of the clipping plane.
3284
3455
  */
3285
3456
  get helper(): THREE.Object3D<THREE.Object3DEventMap>;
3457
+ /**
3458
+ * Getter for the transform controls of the clipping plane.
3459
+ * The controls allow interactive manipulation (translation, rotation, etc.) of the clipping plane.
3460
+ *
3461
+ * @returns {TransformControls} The transform controls of the clipping plane.
3462
+ */
3463
+ get controls(): TransformControls;
3286
3464
  constructor(components: Components, world: World, origin: THREE.Vector3, normal: THREE.Vector3, material: THREE.Material, size?: number, activateControls?: boolean);
3287
3465
  private notifyManager;
3288
3466
  /**
@@ -3334,6 +3512,13 @@ export declare class SimpleRaycaster implements Disposable_2 {
3334
3512
  * This is used to access the camera and meshes.
3335
3513
  */
3336
3514
  world: World;
3515
+ /**
3516
+ * Whether to use fast model picking to optimize raycasting.
3517
+ * When enabled, the raycaster will first use FastModelPicker to identify
3518
+ * which model is under the mouse, then only raycast that specific model.
3519
+ * This can significantly improve performance when there are many models.
3520
+ */
3521
+ useFastModelPicking: boolean;
3337
3522
  constructor(components: Components, world: World);
3338
3523
  /** {@link Disposable.dispose} */
3339
3524
  dispose(): void;
@@ -3603,10 +3788,10 @@ export declare class Topic implements BCFTopic {
3603
3788
  title: string;
3604
3789
  creationDate: Date;
3605
3790
  creationAuthor: string;
3606
- readonly viewpoints: DataSet<string>;
3607
- readonly relatedTopics: DataSet<string>;
3608
- readonly comments: DataMap<string, Comment_2>;
3609
- readonly documentReferences: DataSet<string>;
3791
+ readonly viewpoints: DataSet_2<string>;
3792
+ readonly relatedTopics: DataSet_2<string>;
3793
+ readonly comments: DataMap_2<string, Comment_2>;
3794
+ readonly documentReferences: DataSet_2<string>;
3610
3795
  customData: Record<string, any>;
3611
3796
  description?: string;
3612
3797
  serverAssignedId?: string;
@@ -3906,6 +4091,7 @@ export declare class Viewpoint {
3906
4091
  */
3907
4092
  readonly clippingPlanes: FRAGS.DataSet<string>;
3908
4093
  camera: ViewpointPerspectiveCamera | ViewpointOrthogonalCamera;
4094
+ customData: Record<string, any>;
3909
4095
  /**
3910
4096
  * A list of components GUIDs to hide when defaultVisibility = true or to show when defaultVisibility = false
3911
4097
  */
@@ -4543,7 +4729,7 @@ export declare class Worlds extends Component implements Updateable, Disposable_
4543
4729
  * A collection of worlds managed by this component.
4544
4730
  * The key is the unique identifier (UUID) of the world, and the value is the World instance.
4545
4731
  */
4546
- list: DataMap<string, World>;
4732
+ list: DataMap_2<string, World>;
4547
4733
  /** {@link Component.enabled} */
4548
4734
  enabled: boolean;
4549
4735
  constructor(components: Components);