@inweb/client
Version:
JavaScript REST API client for the Open Cloud Server
184 lines (183 loc) • 6.28 kB
TypeScript
import { Endpoint } from "./Endpoint";
import type { File } from "./File";
import type { Assembly } from "./Assembly";
import type { IFileReferences } from "./IFile";
import type { IModelTransformMatrix } from "./IAssembly";
/**
* Provides properties and methods for working with view of the {@link File | file} or
* {@link Assembly| assembly}. For example, for `dwg` it is a `Model` space or layout, and for `rvt` files
* it is a `3D` view.
*/
export declare class Model extends Endpoint {
private _data;
private _file;
/**
* @param data - Raw model data received from the server.
* @param file - The file/assembly instance that owns the model.
*/
constructor(data: any, file: File | Assembly);
/**
* The `Assembly` instance that owns the model.
*
* @readonly
*/
get assembly(): Assembly;
/**
* Raw model data received from the server.
*
* @readonly
*/
get data(): any;
private set data(value);
/**
* Scene description resource file name. Use {@link downloadResource | downloadResource()} to download
* scene description file.
*
* @readonly
*/
get database(): string;
/**
* `true` if this is default model.
*
* @readonly
*/
get default(): boolean;
/**
* The `File` instance that owns the model.
*
* @readonly
*/
get file(): File;
/**
* The ID of the file that owns the model.
*
* @readonly
*/
get fileId(): string;
/**
* The list of geometry data resource files. Use {@link downloadResource | downloadResource()} to
* download geometry data files.
*
* @readonly
*/
get geometry(): string[];
/**
* Unique model ID.
*
* @readonly
*/
get id(): string;
/**
* Model name.
*
* @readonly
*/
get name(): string;
/**
* Model owner type, matches the file extension this is model of the file, or `assembly` for
* assemblies.
*
* @readonly
*/
get type(): string;
get version(): string;
/**
* Returns model list with one item `self`.
*/
getModels(): Promise<Model[]>;
/**
* Returns a model transformation.
*
* @param handle - Model handle.
*/
getModelTransformMatrix(handle: string): IModelTransformMatrix;
/**
* Sets or removes a model transformation.
*
* @param handle - Model handle.
* @param transform - Transformation matrix. Specify `undefined` to remove transformation.
*/
setModelTransformMatrix(handle: string, transform?: IModelTransformMatrix): Promise<this>;
/**
* Returns a list of viewpoints of the owner file/assembly.
*/
getViewpoints(): Promise<any[]>;
/**
* Saves a new model owner file/assembly viewpoint to the server. To create a new viewpoint use
* `Viewer.createViewpoint()`.
*
* @param viewpoint - Viewpoint object.
*/
saveViewpoint(viewpoint: any): Promise<any>;
/**
* Deletes the specified viewpoint from the owner file/assembly.
*
* @param guid - Viewpoint GUID.
* @returns Returns the raw data of a deleted viewpoint.
*/
deleteViewpoint(guid: string): Promise<any>;
/**
* Returns viewpoint snapshot as base64-encoded
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
*
* @param guid - Viewpoint GUID.
*/
getSnapshot(guid: string): Promise<string>;
/**
* Returns viewpoint snapshot data.
*
* @param guid - Viewpoint GUID.
* @param bitmapGuid - Bitmap GUID.
*/
getSnapshotData(guid: string, bitmapGuid: string): Promise<string>;
/**
* Downloads a resource file. Resource files are files that contain model scene descriptions, or
* geometry data.
*
* @param dataId - Resource file name.
* @param onProgress - Download progress callback.
* @param signal - An
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
* to communicate with a fetch request and abort it if desired.
*/
downloadResource(dataId: string, onProgress?: (progress: number, chunk: Uint8Array) => void, signal?: AbortSignal): Promise<ArrayBuffer>;
/**
* Downloads a part of resource file. Resource files are files that contain model scene descriptions,
* or geometry data.
*
* @param dataId - Resource file name.
* @param ranges - A range of resource file contents to download.
* @param requestId - Request ID for download progress callback.
* @param onProgress - Download progress callback.
* @param signal - An
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
* to communicate with a fetch request and abort it if desired.
*/
downloadResourceRange(dataId: string, requestId: number, ranges: Array<{
begin: number;
end: number;
requestId: number;
}>, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, signal?: AbortSignal): Promise<ArrayBuffer>;
/**
* Deprecated since `25.3`. Use {@link downloadResource | downloadResource()} instead.
*
* @deprecated
*/
partialDownloadResource(dataId: string, onProgress?: (progress: number, chunk: Uint8Array) => void, signal?: AbortSignal): Promise<ArrayBuffer>;
/**
* Deprecated since `25.3`. Use {@link downloadResourceRange | downloadResourceRange()} instead.
*
* @deprecated
*/
downloadFileRange(requestId: number, records: any | null, dataId: string, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, signal?: AbortSignal): Promise<void>;
/**
* Returns a list of references of the owner file/assembly.
*
* References are images, fonts, or any other files to correct rendering of the file.
*
* @param signal - An
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal, which
* can be used to abort waiting as desired.
*/
getReferences(signal?: AbortSignal): Promise<IFileReferences>;
}