import { Color, Matrix4, Plane, Box3, Vector3 } from 'three'; import { CameraConfiguration } from '../../utilities'; import { WellKnownAsprsPointClassCodes } from './types'; import { PointColorType, PointShape, PointSizeType } from '../../rendering'; import { SupportedModelTypes } from '../../model-base'; import { ClassicDataSourceType, DataSourceType, PointCloudObjectMetadata } from '../../data-providers'; import { PointCloudAppearance, StyledPointCloudVolumeCollection } from '../../pointcloud-styling'; /** * Represents a point clouds model loaded from CDF. * @noInheritDoc * @module @cognite/reveal */ export declare class CognitePointCloudModel { readonly type: SupportedModelTypes; /** * The modelId of the point cloud model in Cognite Data Fusion. 0 if not applicable * @deprecated Use modelIdentifier instead */ readonly modelId: number; /** * The revisionId of the specific model revision in Cognite Data Fusion. 0 if not applicable * @deprecated Use modelIdentifier instead */ readonly revisionId: number; /** * The identifier of this model */ readonly modelIdentifier: T['modelIdentifier']; private readonly _styledVolumeCollections; /** * Used to clean up memory. */ dispose(): void; /** * @param outBoundingBox Optional. Used to write result to. * @returns Model's bounding box. * @example * ```js * const boundingBox = new Box3() * model.getModelBoundingBox(boundingBox); * // boundingBox now has the bounding box *``` * ```js * // the following code does the same * const boundingBox = model.getModelBoundingBox(); * ``` */ getModelBoundingBox(outBoundingBox?: Box3): Box3; /** * Retrieves the camera position and target stored for the model. Typically this * is used to store a good starting position for a model. Returns `undefined` if there * isn't any stored camera configuration for the model. */ getCameraConfiguration(): CameraConfiguration | undefined; /** * Sets transformation matrix of the model. This overrides the current transformation. * @param transformationMatrix The new transformation matrix */ setModelTransformation(transformationMatrix: Matrix4): void; /** * Gets transformation matrix that has previously been * set with {@link CognitePointCloudModel.setModelTransformation}. * @param out Preallocated `Matrix4` (optional). */ getModelTransformation(out?: Matrix4): Matrix4; /** * Gets transformation from CDF space to ThreeJS space, * which includes any additional "default" transformations assigned to this model. * Does not include any custom transformations set by {@link CognitePointCloudModel.setModelTransformation} * @param out Preallocated `Matrix4` (optional) */ getCdfToDefaultModelTransformation(out?: Matrix4): Matrix4; /** * Retrieves all points from the point cloud that are contained within the specified bounding box. * @param box The Box3 bounding box used to filter points, defined in local model coordinates. * @returns Array of Vector3 points that are located within the provided bounding box in local model coordinates. * @example * ```js * const boundingBox = new Box3(new Vector3(-10, -10, -10), new Vector3(10, 10, 10)); * const pointsInBox = model.getPointsByBoundingBox(boundingBox); * console.log(`Found ${pointsInBox.length} points in the bounding box`); * ``` */ getPointsByBoundingBox(box: Box3): Vector3[]; /** * Map point from CDF to model space, taking the model's custom transformation into account * @param point Point to compute transformation from * @param out Optional pre-allocated point */ mapPointFromCdfToModelCoordinates(point: Vector3, out?: Vector3): Vector3; /** * Map bounding box from CDF to model space, taking the model's custom transformation into account * @param box Box to compute transformation from * @param out Optional pre-allocated box */ mapBoxFromCdfToModelCoordinates(box: Box3, out?: Box3): Box3; /** * Sets a visible filter on points of a given class. * @param pointClass ASPRS classification class code. Either one of the well known * classes from {@link WellKnownAsprsPointClassCodes} or a number for user defined classes. * @param visible Boolean flag that determines if the point class type should be visible or not. * @throws Error if the model doesn't have the class given. */ setClassVisible(pointClass: number | WellKnownAsprsPointClassCodes, visible: boolean): void; /** * Determines if points from a given class are visible. * @param pointClass ASPRS classification class code. Either one of the well known * classes from {@link WellKnownAsprsPointClassCodes} or a number for user defined classes. * @returns True if points from the given class will be visible. * @throws Error if the model doesn't have the class given. */ isClassVisible(pointClass: number | WellKnownAsprsPointClassCodes): boolean; /** * Returns true if the model has values with the given classification class. * @param pointClass ASPRS classification class code. Either one of the well known * classes from {@link WellKnownAsprsPointClassCodes} or a number for user defined classes. * @returns True if model has values in the class given. */ hasClass(pointClass: number | WellKnownAsprsPointClassCodes): boolean; /** * Returns a list of sorted classification names and codes present in the model. * Names will be the custom names provided by the user, or a default one if none have been provided. * @returns A sorted list of classification codes and names from the model. */ getClasses(): Array<{ name: string; code: number | WellKnownAsprsPointClassCodes; color: Color; }>; /** * Returns the current number of visible/loaded points. */ get visiblePointCount(): number; /** * Determines how points currently are colored. */ get pointColorType(): PointColorType; /** * Specifies how points are colored. * @default PointColorType.Rgb * @example * ```js * model.pointColorType = PointColorType.Rgb * ``` */ set pointColorType(type: PointColorType); /** * Returns the size of each rendered point in the point cloud. */ get pointSize(): number; /** * Sets the size of each rendered point in the point cloud. * @default `2` */ set pointSize(size: number); /** * Get the point size type. */ get pointSizeType(): PointSizeType; /** * Set the point size type for the point cloud. * The point size type can be either Fixed or Adaptive. * @default `PointSizeType.Adaptive` */ set pointSizeType(type: PointSizeType); /** * Sets the point shape of each rendered point in the point cloud. * @default `PointShape.Circle` * @see {@link PointShape}. */ get pointShape(): PointShape; /** * Gets the point shape of each rendered point in the point cloud. * @see {@link PointShape}. */ set pointShape(shape: PointShape); /** * Sets the model visibility. * @example * ```js * model.visible = false * ``` */ set visible(value: boolean); /** * Returns the model visibility. */ get visible(): boolean; /** * Sets the clipping planes for this model. They will be combined with the * global clipping planes. */ setModelClippingPlanes(clippingPlanes: Plane[]): void; /** * Get the clipping planes for this model. */ getModelClippingPlanes(): Plane[]; /** * Gets default point appearance */ getDefaultPointCloudAppearance(): PointCloudAppearance; /** * Sets default apparance for points that are not styled otherwise * @param appearance Appearance to assign as default */ setDefaultPointCloudAppearance(appearance: PointCloudAppearance): void; /** * Gets the object collections that have been assigned a style * @returns All object collections and their associated style */ get styledCollections(): StyledPointCloudVolumeCollection[]; /** * Gets array of stylable objects for the point cloud model. * @returns All stylable objects for this model * * @example * ```js * model.stylableObjects.forEach(pointCloudMetadata => console.log(pointCloudMetadata.annotationId)); * // or * model.stylableObjects.forEach(pointCloudMetadata => { * if (isDMPointCloudVolume(pointCloudMetadata)) * console.log(pointCloudMetadata.volumeInstanceRef); * }); * ``` */ get stylableObjects(): PointCloudObjectMetadata[]; /** * Assign a style to a collection of objects. If the object collection has been assigned * a style previously, the previous style will be replaced by the new one. * @param objectCollection The object collection to assign a style to * @param appearance The style to assign to the object collection * @param importance The importance of the styling, used for ordering styles to apply. Collections with higher importance gets applied later */ assignStyledObjectCollection(objectCollection: T['pointCloudCollectionType'], appearance: PointCloudAppearance, importance?: number): void; /** * Unassign style from an already styled object collection. * @param objectCollection The object collection from which to remove the style */ unassignStyledObjectCollection(objectCollection: T['pointCloudCollectionType']): void; /** * Removes styling on all object collections in this model */ removeAllStyledObjectCollections(): void; /** * @returns The number of stylable objects */ get stylableObjectCount(): number; /** * @deprecated Use {@link CognitePointCloudModel.stylableObjects} * Iterates through all stylable objects for this model * @example * ```js * model.traverseStylableObjects( * annotationMetadata => console.log(annotationMetadata.annotationId) * ); * ``` */ traverseStylableObjects(callback: (annotationMetadata: PointCloudObjectMetadata) => void): void; }