@wdp-api/bim-api
Version:
51WORLD BIM/DCP Api is a JavaScript plugin for WdpApi, It provides a set of APIs for developers to integrate BIM/DCP into their own applications.
252 lines (237 loc) • 8.35 kB
TypeScript
interface ResultType {
success: boolean;
message?: string;
result?: any;
}
type Pagination<T = any> = T & {
pageNumber?: number;
pageSize?: number;
fetchAll?: boolean;
};
type CameraParams = {
distanceFactor?: number;
flyTime?: number;
rotation?: { pitch?: number; yaw?: number };
};
type NodeSearchType = Pagination & { keywordType: 0 | 1 };
type NodeCoordType = 'top' | 'center' | 'bottom';
type NodeInfoType = 'element' | 'space';
declare class BimController {
/** @deprecated */
get IsReady(): boolean;
get isReady(): boolean;
get apiVersion(): string | null;
get sdkVersion(): string | null;
GetVersion(): Promise<ResultType>;
/**
* 获取模型列表
* @param {string}keyword 搜索关键词,默认为空
* @param {Pagination} pager 分页参数
*/
GetModelList(keyword?: string, pager?: Pagination): Promise<ResultType>;
/**
* 获取资产列表
* @param keyword
* @param pager
*/
GetAssetList(keyword?: string, pager?: Pagination): Promise<ResultType>;
/** 获取模型大纲 */
GetOfflineList(): Promise<ResultType>;
/**
* 显隐Gizmo枢轴
* @param {boolean} status true: 显示, false: 隐藏。default: true
*/
SetGizmo(status?: boolean): Promise<ResultType>;
/**
* 模型点击事件: 描边&Gizmo
* @param {boolean} status true: 开启, false: 关闭。default: true
*/
SetDefaultEvent(status?: boolean): Promise<ResultType>;
/**
* 设置构件点击开关
* @param {boolean} status true: 开启, false: 关闭。default: true
*/
SetNodeClickEnable(status?: boolean): Promise<ResultType>;
/**
* 构件点击响应事件
* @param {boolean} highlight 高亮 default: true
* @param {boolean} hidden 显隐 default: false
*/
SetNodeClickEvent(highlight?: boolean, hidden?: boolean): Promise<ResultType>;
/**
* 设置构件高亮默认样式
* @param {string} color 颜色HEX值
* @param {number} opacity 高亮透明度, 取值范围:[0-1]。default: 0.5
*/
SetNodeDefaultHighLightStyle(color: string, opacity?: number): Promise<ResultType>;
/** 获取构件高亮默认样式 */
GetNodeDefaultHighLightStyle(): Promise<ResultType>;
/**
* 清除构件高亮
*/
ClearNodeHighlight(): Promise<ResultType>;
GetModelsByMetadata: (args: { [x: string]: string | string[] }) => Promise<ResultType>;
GetNodesByProperties: (
args: { [x: string]: string | string[] },
type?: NodeInfoType | NodeInfoType[]
) => Promise<ResultType>;
GetRoomsByProperties: (args: { [x: string]: string | string[] }) => Promise<ResultType>;
}
export type SectionType = {
coordZRef: 'ground' | 'surface' | 'altitude';
strokeColor: string;
strokeWeight: number; //被切物体描边宽度[0~1]
invert: boolean; //被切物体(true:内部可见; false:外部可见)
transform: {
location?: [x: number, y: number, z: number];
rotator?: {
pitch: number; //俯仰角, 参考(-180~180)
yaw: number; //偏航角, 参考(0正北, -180~180)
roll: number; //翻滚角, 参考(-180~180)
};
size?: [x: number, y: number, z: number];
};
showLocation: boolean; //true:显示剖切参考顶角location; false:隐藏剖切参考顶角location
status: boolean; //true:开启剖切; false:关闭剖切
};
export type { AssetInfo, ModelInfo, NodeTree } from '@sdk/daas';
export type ModelOption = {
assetId?: string;
entityName?: string;
customId?: string;
customData?: any;
seedId: string;
location?: [x: number, y: number, z: number];
};
export declare class Hierarchy {
constructor(opt: ModelOption);
get eid(): string | null;
get seedId(): string | null;
get assetId(): string | null;
get assetName(): string | null;
get bVisible(): boolean;
get entityName(): string;
get customId(): string;
get customData(): any;
get index(): string;
get isDisassembly(): boolean;
get hideNodeIds(): string[];
get pickNodeId(): string | null;
get rootNodeId(): string | null;
GetLocation(): Promise<ResultType>;
SetLocation(location: [x?: number, y?: number, z?: number]): Promise<ResultType>;
GetRotator(): Promise<ResultType>;
SetRotator(rotator: { pitch?: number; yaw?: number; roll?: number }): Promise<ResultType>;
GetScale3d(): Promise<ResultType>;
SetScale3d(scale3d: [x?: number, y?: number, z?: number]): Promise<ResultType>;
GetVisible(): Promise<ResultType>;
SetVisible(bVisible?: boolean): Promise<ResultType>;
/** 模型卸载 */
Delete(): Promise<ResultType>;
GetSeedId(): Promise<ResultType>;
SetSeedId(seedId: string | null): Promise<ResultType>;
/**
* 模型激活
* @param {boolean} status true: 是, false: 取消。default: true
*/
Active(status?: boolean): Promise<ResultType>;
/** 模型聚焦 */
SetFocus(cameraParams?: CameraParams): Promise<ResultType>;
/** 模型落地 */
SetGround(params?: { type?: 'surface' | 'ground' | 'altitude'; offset?: 0 }): Promise<ResultType>;
/** 设置当前模型的 Gizmo位置 */
SetGizmo(location: [x?: number, y?: number, z?: number] | 'center' | 'reset'): Promise<ResultType>;
/** 开始模型剖切 */
StartModelSection(option: Partial<SectionType>): Promise<ResultType>;
/** 重置模型剖切 */
ResetModelSection(): Promise<ResultType>;
/** 结束模型剖切 */
EndModelSection(): Promise<ResultType>;
/** 模型分层 */
SetDisassembly(): Promise<ResultType>;
// SetBuildLayers(nodeIds: string | string[]): Promise<ResultType>;
/**
* 构件聚焦
* @param {string} nodeId 构件ID
* @param {boolean} highlight 是否同时高亮
* @param opt
*/
SetNodeFocus(
nodeId: string,
opt?: { cameraParams?: CameraParams }
): Promise<ResultType>;
/**
* 设置构件显隐
* @param {string} nodeId 构件ID
* @param {boolean} visible 状态值 true: 显示, false: 隐藏。default: true
*/
SetNodeVisibility(nodeId: string | string[], visible?: boolean): Promise<ResultType>;
/** 显示全部构件 */
SetNodeShowAll(): Promise<ResultType>;
/**
* 构件反选显隐
* @param nodeIds 构件ID
* @param visible 状态 true: 仅显示指定的构件, false: 取消指定构件反向。default: true
*/
SetOtherNodesVisibility(nodeIds: string | string[], visible?: boolean): Promise<ResultType>;
/**
* 构件高亮
* @param {string} nodeId 构件ID
* @param {boolean} status 是否高亮, true: 是, false: 否。default: true
* @param {boolean} unique 是否唯一高亮, true: 是, false: 否。default: true
* @param style
*/
SetNodeHighLight(
nodeId: string,
status?: boolean,
unique?: boolean,
style?: { color: string; opacity?: number }
): Promise<ResultType>;
/**
* 清除构件高亮
*/
ClearNodeHighlight(): Promise<ResultType>;
/** 获取构件坐标 */
GetNodeLocation(nodeId: string, coordType?: NodeCoordType): Promise<ResultType>;
/** 获取构件坐标 */
GetNodeCoord(args: { nodeId: string; coordType?: NodeCoordType }): Promise<ResultType>;
/** @deprecated */
SetNodeDefaultHighLightStyle(color: string, opacity?: number): Promise<ResultType>;
/** @deprecated */
GetNodeDefaultHighLightStyle(): Promise<ResultType>;
/** 获取构件树 */
GetNodeTree(nodeId?: string, pager?: Pagination): Promise<ResultType>;
/** 构件树列表搜索 */
GetNodeListBySearch(keyword: string, args?: NodeSearchType): Promise<ResultType>;
/** 构件树搜索 */
GetNodeTreeBySearch(keyword: string, args?: NodeSearchType): Promise<ResultType>;
/** 通过构件ID获取构件树 */
GetNodeTreeById(nodeId: string): Promise<ResultType>;
/** 获取指定构件ID的父级nodeId */
GetNodeParentId(nodeId: string): Promise<ResultType>;
/**
* @deprecated please use GetNodeInfo instead.
*/
GetNodeAttr(nodeId: string): Promise<ResultType>;
/** 获取指定构件详细信息 */
GetNodeInfo(nodeId: string): Promise<ResultType>;
SetRoomHighLight(args: {
roomIds: string[];
transform?: boolean;
bVisible?: boolean;
colorStyle?: {
color?: string;
opacity?: number;
};
}): Promise<ResultType>;
SetRoomsFocus(
args: {
roomIds: string[];
transform?: boolean;
} & CameraParams
): Promise<ResultType>;
}
export default class BimApi {
DCP: BimController;
Hierarchy: typeof Hierarchy;
}