@itwin/core-common
Version:
iTwin.js components common to frontend and backend
327 lines • 17.1 kB
TypeScript
/** @packageDocumentation
* @module DisplayStyles
*/
import { BeEvent } from "@itwin/core-bentley";
import { FeatureAppearance, FeatureAppearanceProps } from "./FeatureSymbology";
import { PlanarClipMaskProps, PlanarClipMaskSettings } from "./PlanarClipMask";
import { SpatialClassifierProps, SpatialClassifiers, SpatialClassifiersContainer } from "./SpatialClassification";
import { RealityModelDisplayProps, RealityModelDisplaySettings } from "./RealityModelDisplaySettings";
/** JSON representation of the blob properties for an OrbitGt property cloud.
* @alpha
*/
export interface OrbitGtBlobProps {
rdsUrl?: string;
containerName: string;
blobFileName: string;
sasToken: string;
accountName: string;
}
/** Identify the Reality Data service provider
* @beta
*/
export declare enum RealityDataProvider {
/**
* This is the legacy mode where the access to the 3d tiles is hardcoded in ContextRealityModelProps.tilesetUrl property.
* It was used to support RealityMesh3DTiles, Terrain3DTiles, Cesium3DTiles
* You should use other modes when possible
* @see [[RealityDataSource.createKeyFromUrl]] that will try to detect provider from an URL
*/
TilesetUrl = "TilesetUrl",
/**
* This is the legacy mode where the access to the 3d tiles is hardcoded in ContextRealityModelProps.OrbitGtBlob property.
* It was used to support OrbitPointCloud (OPC) from other server than ContextShare
* You should use other modes when possible
* @see [[RealityDataSource.createKeyFromOrbitGtBlobProps]] that will try to detect provider from an URL
*/
OrbitGtBlob = "OrbitGtBlob",
/**
* Will provide access url from realityDataId and iTwinId on contextShare for 3dTile storage format or OPC storage format
* This provider supports all types of 3dTile storage format and OrbitPointCloud: RealityMesh3DTiles, Terrain3DTiles, Cesium3DTiles, OPC
* @see [[RealityDataFormat]].
*/
ContextShare = "ContextShare",
/**
* Will provide Open Street Map Building (OSM) from Cesium Ion (in 3dTile format)
*/
CesiumIonAsset = "CesiumIonAsset"
}
/** Identify the Reality Data storage format
* @beta
*/
export declare enum RealityDataFormat {
/**
* 3dTile supported formats; RealityMesh3DTiles, Terrain3DTiles, Cesium3DTiles
* */
ThreeDTile = "ThreeDTile",
/**
* Orbit Point Cloud (OPC) storage format (RealityDataType.OPC)
*/
OPC = "OPC"
}
/** Utility function for RealityDataFormat
* @beta
*/
export declare namespace RealityDataFormat {
/**
* Try to extract the RealityDataFormat from the url
* @param tilesetUrl the reality data attachment url
* @returns the extracted RealityDataFormat or ThreeDTile by default if not found
*/
function fromUrl(tilesetUrl: string): RealityDataFormat;
}
/**
* Key used by RealityDataSource to identify provider and reality data format
* This key identify one and only one reality data source on the provider
* @beta
*/
export interface RealityDataSourceKey {
/**
* The provider that supplies the access to reality data source for displaying the reality model
* @see [[RealityDataProvider]] for default supported value;
*/
provider: string;
/**
* The format used by the provider to store the reality data
* @see [[RealityDataFormat]] for default supported value;
*/
format: string;
/** The reality data id that identify a reality data for the provider */
id: string;
/** The context id that was used when reality data was attached - if none provided, current session iTwinId will be used */
iTwinId?: string;
}
/**
* RealityDataSourceKey utility functions
* @beta */
export declare namespace RealityDataSourceKey {
/** Utility function to convert a RealityDataSourceKey into its string representation */
function convertToString(rdSourceKey: RealityDataSourceKey): string;
/** Utility function to compare two RealityDataSourceKey, we consider it equal even if itwinId is different */
function isEqual(key1: RealityDataSourceKey, key2: RealityDataSourceKey): boolean;
}
/** JSON representation of the reality data reference attachment properties.
* @beta
*/
export interface RealityDataSourceProps {
/** The source key that identify a reality data for the provider. */
sourceKey: RealityDataSourceKey;
}
/** JSON representation of a [[ContextRealityModel]].
* @public
* @extensions
*/
export interface ContextRealityModelProps {
/** See [[ContextRealityModel.rdSourceKey]].
* @beta
*/
rdSourceKey?: RealityDataSourceKey;
/** The URL that supplies the 3d tiles for displaying the reality model. */
tilesetUrl: string;
/** See [[ContextRealityModel.orbitGtBlob]].
* @alpha
*/
orbitGtBlob?: OrbitGtBlobProps;
/** See [[ContextRealityModel.realityDataId]]. */
realityDataId?: string;
/** An optional, user-friendly name for the reality model suitable for display in a user interface. */
name?: string;
/** An optional, user-friendly description of the reality model suitable for display in a user interface. */
description?: string;
/** See [[ContextRealityModel.classifiers]]. */
classifiers?: SpatialClassifierProps[];
/** See [[ContextRealityModel.planarClipMask]]. */
planarClipMask?: PlanarClipMaskProps;
/** See [[ContextRealityModel.appearanceOverrides]]. */
appearanceOverrides?: FeatureAppearanceProps;
/** See [[ContextRealityModel.displaySettings]].
* @beta
*/
displaySettings?: RealityModelDisplayProps;
/** See [[ContextRealityModel.invisible]].
* @beta
*/
invisible?: boolean;
}
/** @public */
export declare namespace ContextRealityModelProps {
/** Produce a deep copy of `input`. */
function clone(input: ContextRealityModelProps): ContextRealityModelProps;
}
/** A reality model not associated with a [GeometricModel]($backend) but instead defined in a [DisplayStyle]($backend) or [DisplayStyleState]($frontend).
* Such reality models are displayed to provide context to the view and can be freely attached and detached at display time.
* @see [this interactive example](https://www.itwinjs.org/sample-showcase/?group=Viewer&sample=reality-data-sample)
* @see [[DisplayStyleSettings.contextRealityModels]] to define context reality models for a display style.
* @public
*/
export declare class ContextRealityModel {
/** @internal */
protected readonly _props: ContextRealityModelProps;
/**
* The reality data source key identify the reality data provider and storage format.
* It takes precedence over tilesetUrl and orbitGtBlob when present and can be use to actually replace these properties.
* @beta
*/
readonly rdSourceKey?: RealityDataSourceKey;
/** A name suitable for display in a user interface. By default, an empty string. */
readonly name: string;
/** The URL that supplies the 3d tiles for displaying the reality model. */
readonly url: string;
/** A description of the model suitable for display in a user interface. By default, an empty string. */
readonly description: string;
/** An optional identifier that, if present, can be used to elide a request to the reality data service. */
readonly realityDataId?: string;
private _invisible;
private readonly _classifiers;
/** @alpha */
readonly orbitGtBlob?: Readonly<OrbitGtBlobProps>;
protected _appearanceOverrides?: FeatureAppearance;
/** @beta */
protected _displaySettings: RealityModelDisplaySettings;
protected _planarClipMask?: PlanarClipMaskSettings;
/** Event dispatched just before assignment to [[planarClipMaskSettings]]. */
readonly onPlanarClipMaskChanged: BeEvent<(newSettings: PlanarClipMaskSettings | undefined, model: ContextRealityModel) => void>;
/** Event dispatched just before assignment to [[appearanceOverrides]]. */
readonly onAppearanceOverridesChanged: BeEvent<(newOverrides: FeatureAppearance | undefined, model: ContextRealityModel) => void>;
/** Event dispatched just before assignment to [[displaySettings]].
* @beta
*/
readonly onDisplaySettingsChanged: BeEvent<(newSettings: RealityModelDisplaySettings, model: ContextRealityModel) => void>;
/** Event dispatched just before a model become invisible
* @beta
*/
readonly onInvisibleChanged: BeEvent<(invisible: boolean, model: ContextRealityModel) => void>;
/** Construct a new context reality model.
* @param props JSON representation of the reality model, which will be kept in sync with changes made via the ContextRealityModel's methods.
* @param options Options to customize how the reality model is created.
*/
constructor(props: ContextRealityModelProps, options?: {
createClassifiers: (container: SpatialClassifiersContainer) => SpatialClassifiers;
});
/** A set of [[SpatialClassifier]]s, of which one at any given time can be used to classify the reality model. */
get classifiers(): SpatialClassifiers;
/** Optionally describes how the geometry of the reality model can be masked by other models. */
get planarClipMaskSettings(): PlanarClipMaskSettings | undefined;
set planarClipMaskSettings(settings: PlanarClipMaskSettings | undefined);
/** Overrides applied to the appearance of the reality model. Only the rgb, transparency, nonLocatable, and emphasized properties are applicable - the rest are ignored. */
get appearanceOverrides(): FeatureAppearance | undefined;
set appearanceOverrides(overrides: FeatureAppearance | undefined);
/** Settings controlling how this reality model is displayed in a [Viewport]($frontend).
* @beta
*/
get displaySettings(): RealityModelDisplaySettings;
set displaySettings(settings: RealityModelDisplaySettings);
/** If true, reality model is not drawn.
* @beta
*/
get invisible(): boolean;
set invisible(invisible: boolean);
/** Convert this model to its JSON representation. */
toJSON(): ContextRealityModelProps;
/** Returns true if [[name]] and [[url]] match the specified name and url. */
matchesNameAndUrl(name: string, url: string): boolean;
}
/** An object that can store the JSON representation of a list of [[ContextRealityModel]]s.
* @see [[ContextRealityModels]].
* @see [[DisplayStyleSettingsProps.contextRealityModels]].
* @public
* @extensions
*/
export interface ContextRealityModelsContainer {
/** The list of reality models. */
contextRealityModels?: ContextRealityModelProps[];
/** @internal used for type discrimination with ContextRealityModelsArgs. */
container?: never;
}
/** Arguments supplied to the constructor of [[ContextRealityModels]].
* @public
*/
export interface ContextRealityModelsArgs {
/** The object that holds the JSON representation of the list of context reality models. */
container: ContextRealityModelsContainer;
/** Optional function used to instantiate each [[ContextRealityModel]] in the list. */
createContextRealityModel?: (props: ContextRealityModelProps) => ContextRealityModel;
/** If true, the list will not be populated by the constructor. Instead, the caller is responsible for calling [[ContextRealityModels.populate]] exactly once after construction.
* This is chiefly intended for use internally by the [DisplayStyleState]($frontend) constructor.
*/
deferPopulating?: boolean;
}
/** A list of [[ContextRealityModel]]s attached to a [[DisplayStyleSettings]]. The list may be presented to the user with the name and description of each model.
* The list is automatically synchronized with the underlying JSON representation provided by the input [[ContextRealityModelsContainer]].
* @see [this interactive example](https://www.itwinjs.org/sample-showcase/?group=Viewer&sample=reality-data-sample)
* @see [[DisplayStyleSettings.contextRealityModels]].
* @public
*/
export declare class ContextRealityModels {
private readonly _container;
private readonly _createModel;
private readonly _models;
/** Event dispatched just before [[ContextRealityModel.planarClipMaskSettings]] is modified for one of the reality models. */
readonly onPlanarClipMaskChanged: BeEvent<(model: ContextRealityModel, newSettings: PlanarClipMaskSettings | undefined) => void>;
/** Event dispatched just before [[ContextRealityModel.appearanceOverrides]] is modified for one of the reality models. */
readonly onAppearanceOverridesChanged: BeEvent<(model: ContextRealityModel, newOverrides: FeatureAppearance | undefined) => void>;
/** Event dispatched just before [[ContextRealityModel.displaySettings]] is modified for one of the reality models.
* @beta
*/
readonly onDisplaySettingsChanged: BeEvent<(model: ContextRealityModel, newSettings: RealityModelDisplaySettings) => void>;
/** Event dispatched just before [[ContextRealityModel.invisible]] is modified for one of the reality models.
* @beta
*/
readonly onInvisibleChanged: BeEvent<(model: ContextRealityModel, invisible: boolean) => void>;
/** Event dispatched when a model is [[add]]ed, [[delete]]d, [[replace]]d, or [[update]]d. */
readonly onChanged: BeEvent<(previousModel: ContextRealityModel | undefined, newModel: ContextRealityModel | undefined) => void>;
/** Construct a new list of reality models from its JSON representation. The list will be initialized from `container.contextRealityModels` and that JSON representation
* will be kept in sync with changes made to the list. The caller should not directly modify `container.contextRealityModels` or its contents as that will cause the list
* to become out of sync with the JSON representation.
* @param container The object that holds the JSON representation of the list.
* @param createContextRealityModel Optional function used to instantiate each [[ContextRealityModel]] in the list.
*/
constructor(container: ContextRealityModelsContainer, createContextRealityModel?: (props: ContextRealityModelProps) => ContextRealityModel);
/** Construct a new list of reality models from its JSON representation. The list will be initialized from `args.container.contextRealityModels` and that JSON representation
* will be kept in sync with changes made to the list. The caller should not directly modify `container.contextRealityModels` or its contents as that will cause the list
* to become out of sync with the JSON representation.
* @param args Specifies the container and optionally customizes how the list of models is populated.
*/
constructor(args: ContextRealityModelsArgs);
/** @internal needs to be invoked after DisplayStyleSettings constructor by DisplayStyleState constructor.*/
/** Populate the list of [[models]] from the container that was supplied to the constructor.
* This should only be invoked once, and only if [[ContextRealityModelsArgs.deferPopulating]] was specified as `true` when calling the constructor.
* @public
*/
populate(): void;
/** The read-only list of reality models. */
get models(): ReadonlyArray<ContextRealityModel>;
/** Append a new reality model to the list.
* @param The JSON representation of the reality model.
* @returns the newly-added reality model.
*/
add(props: ContextRealityModelProps): ContextRealityModel;
/** Remove the specified reality model from the list.
* @param model The reality model to remove.
* @returns true if the model was removed, or false if the model was not present in the list.
*/
delete(model: ContextRealityModel): boolean;
/** Remove all reality models from the list. */
clear(): void;
/** Replace a reality model in the list.
* @param toReplace The reality model to be replaced.
* @param replaceWith The JSON representation of the replacement reality model.
* @returns the newly-created reality model that replaced `toReplace`.
* @throws Error if `toReplace` is not present in the list
* @note The replacement occupies the same index in the list as `toReplace` did.
*/
replace(toReplace: ContextRealityModel, replaceWith: ContextRealityModelProps): ContextRealityModel;
/** Change selected properties of a reality model.
* @param toUpdate The reality model whose properties are to be modified.
* @param updateProps The properties to change.
* @returns The updated reality model, identical to `toUpdate` except for properties explicitly supplied by `updateProps`.
* @throws Error if `toUpdate` is not present in the list.
*/
update(toUpdate: ContextRealityModel, updateProps: Partial<ContextRealityModelProps>): ContextRealityModel;
private createModel;
private dropEventListeners;
private handlePlanarClipMaskChanged;
private handleAppearanceOverridesChanged;
private handleDisplaySettingsChanged;
private handleInvisibleChanged;
}
//# sourceMappingURL=ContextRealityModel.d.ts.map