import { BCFViewpointsPlugin, LocaleService, Viewer } from "@xtctwins/tctwins-core"; import EventTrigger from "@/EventTrigger"; import Controller from "./Controller"; import ResetAction from "./toolbar/ResetAction"; import FitAction from "./toolbar/FitAction"; import FirstPersonMode from "./toolbar/FirstPersonMode"; import HideTool from "./toolbar/HideTool"; import SelectionTool from "./toolbar/SelectionTool"; import ShowSpacesMode from "./toolbar/ShowSpacesMode"; import QueryTool from "./toolbar/QueryTool"; import SectionTool from "./toolbar/SectionTool"; import NavCubeMode from "./toolbar/NavCubeMode"; import ModelsExplorer from "./explorer/ModelsExplorer"; import ObjectsExplorer from "./explorer/ObjectsExplorer"; import ClassesExplorer from "./explorer/ClassesExplorer"; import StoreysExplorer from "./explorer/StoreysExplorer"; import ThreeDMode from "./toolbar/ThreeDMode"; import OrthoMode from "./toolbar/OrthoMode"; import ObjectsKdTree3 from "./collision/ObjectsKdTree3"; import AnnotationTool from "./toolbar/AnnotationTool"; import MeasureTool from "./toolbar/MeasureTool"; import MeasureDistanceTool from "./toolbar/MeasureTools/MeasureDistanceTool"; import MeasureAngleTool from "./toolbar/MeasureTools/MeasureAngleTool"; import CommentsTool from "./toolbar/CommentsTool"; /** * @desc 引擎入口 * @class */ export default class BIMViewer extends Controller { viewer: Viewer; protected _objectsKdTree3: ObjectsKdTree3; _modelsExplorer: ModelsExplorer; _objectsExplorer: ObjectsExplorer; _classesExplorer: ClassesExplorer; _storeysExplorer: StoreysExplorer; protected _resetAction: ResetAction; protected _fitAction: FitAction; protected _threeDMode: ThreeDMode; protected _hideTool: HideTool; protected _annotationTool: AnnotationTool; protected _orthoMode: OrthoMode; protected _firstPersonMode: FirstPersonMode; protected _measureTool: MeasureTool; _measure_distance_tool: MeasureDistanceTool; _measure_angle_tool: MeasureAngleTool; _sectionTool: SectionTool; _commentsTool: CommentsTool; protected _selectionTool: SelectionTool; protected _showSpacesMode: ShowSpacesMode; protected _queryTool: QueryTool; protected _navCubeMode: NavCubeMode; protected _bcfViewpointsPlugin: BCFViewpointsPlugin; protected _objectColorSource?: string; buttonList: any; protected _eventTrigger: EventTrigger; private navCubeCanvasElement; private viewerElement; private _modelId; private region_url; private bucket_name; protected _configs: any; /** 是否有异常构建 */ private _hasOutlier; /** 异常构建ID */ private _outlierObjectIds; /** 是否是聚焦分布模式 */ private _focusPartial; /** 根据构建检测检测得到的构建分布字符串数组结果 */ private _partialObjectIds; /** 当前聚焦的分布索引 */ private _partialFocusIndex; /** 是否已加载metadata */ private _metaLoaded; /** * Constructs a BIMViewer. * @param {Server} server Data access strategy. * @param {*} cfg Configuration. * @param {Boolean} [cfg.enableEditModels=false] Set ````true```` to show "Add", "Edit" and "Delete" options in the Models tab's context menu. * @param {Boolean} [cfg.keyboardEventsElement] Optional reference to HTML element on which key events should be handled. Defaults to the HTML Document. */ constructor(server: any, cfg?: any); get eventTrigger(): EventTrigger; /** * Returns the LocaleService that was configured on this Viewer. * * @return {LocaleService} The LocaleService. */ get localeService(): LocaleService; /** * 初始化单击事件 */ protected _initSingleClickEvent(): void; /** * 初始化右键事件 */ protected _initRightClickEvent(): void; /** * 初始化双击事件 */ protected _initDoubleClickEvent(): void; protected _customizeViewer(): void; protected _initConfigs(): void; /** * Sets a batch of viewer configurations. * * Note that this method is not to be confused with {@link BIMViewer#setViewerState}, which batch-updates various states of the viewer's UI and 3D view. * * See [Viewer Configurations] for the list of available configurations. * * @param {*} viewerConfigs Map of key-value configuration pairs. */ setConfigs(viewerConfigs: any): void; /** * Sets a viewer configuration. * * See [Viewer Configurations] for the list of available configurations. * * @param {String} name Configuration name. * @param {*} value Configuration value. */ setConfig(name: string, value: any): void; /** * Gets the value of a viewer configuration. * * These are set with {@link BIMViewer#setConfig} and {@link BIMViewer#setConfigs}. * * @param {String} name Configuration name. * @ereturns {*} Configuration value. */ getConfig(name: string): any; /** * Gets information on all available projects. * Gets information on all available projects. * * See [Getting Info on Available Projects] for usage. * * @param {Function} done Callback invoked on success, into which the projects information JSON is passed. * @param {Function} error Callback invoked on failure, into which the error message string is passed. */ getProjectsInfo(done: Function, error: Function): void; /** * Gets information on the given project. * * See [Getting Info on a Project]for usage. * * @param {String} projectId ID of the project to get information on. Must be the ID of one of the projects in the information obtained by {@link BIMViewer#getProjects}. * @param {Function} done Callback invoked on success, into which the project information JSON is passed. * @param {Function} error Callback invoked on failure, into which the error message string is passed. */ getProjectInfo(projectId: string, done: Function, error: Function): void; /** * Gets information on the given object, belonging to the given model, within the given project. * * See [Getting Info on an Object]for usage. * * @param {String} projectId ID of the project to get information on. Must be the ID of one of the projects in the information obtained by {@link BIMViewer#getProjects}. * @param {String} modelId ID of a model within the project. Must be the ID of one of the models in the information obtained by {@link BIMViewer#getProjectInfo}. * @param {String} objectId ID of an object in the model. * @param {Function} done Callback invoked on success, into which the object information JSON is passed. * @param {Function} error Callback invoked on failure, into which the error message string is passed. */ getObjectInfo(projectId: string, modelId: string, objectId: string, done: Function, error: Function): void; /** * Loads a project into the viewer. * * Unloads any currently loaded project and its models first. If the given project is already loaded, will unload that project first. * * @param {String} projectId ID of the project to load. Must be the ID of one of the projects in the information obtained by {@link BIMViewer#getProjects}. * @param {Function} done Callback invoked on success. * @param {Function} error Callback invoked on failure, into which the error message string is passed. */ loadProject(projectId: string, done: Function, error: Function): void; /** * Unloads whatever project is currently loaded. */ unloadProject(): void; /** * Returns the ID of the currently loaded project, if any. * * @returns {String} The ID of the currently loaded project, otherwise ````null```` if no project is currently loaded. */ getLoadedProjectId(): string | null; /** * Returns the IDs of the models in the currently loaded project. * * @returns {String[]} The IDs of the models in the currently loaded project. */ modelId(): string; /** * Loads a model into the viewer. * * Assumes that the project containing the model is currently loaded. * * @param {String} modelId ID of the model to load. Must be the ID of one of the models in the currently loaded project. * @param {Function} done Callback invoked on success. * @param {Function} error Callback invoked on failure, into which the error message string is passed. */ loadModel(modelId: string, done: Function, error: Function): void; /** * 单独加载元数据 * @param deflatedMetadata */ loadMetadata(deflatedMetadata: Buffer, done?: Function): void; /** * Load all models in the currently loaded project. * * Doesn't reload any models that are currently loaded. * * @param {Function} done Callback invoked on successful loading of the models. */ loadAllModels(done?: Function): void; /** * Returns the IDs of the currently loaded models, if any. * * @returns {String[]} The IDs of the currently loaded models, otherwise an empty array if no models are currently loaded. */ getLoadedModelIds(): string[]; /** * Gets if the given model is loaded. * * @param {String} modelId ID of the model to check. Must be the ID of one of the models in the currently loaded project. * @returns {Boolean} True if the given model is loaded. */ isModelLoaded(modelId: string): boolean | undefined; /** * Unloads a model from the viewer. * * Does nothing if the model is not currently loaded. * * @param {String} modelId ID of the model to unload. */ unloadModel(modelId: string): void; /** * Unloads all currently loaded models. */ unloadAllModels(): void; /** * Edits a model. * * Assumes that the project containing the model is currently loaded. * * @param {String} modelId ID of the model to edit. Must be the ID of one of the models in the currently loaded project. */ editModel(modelId: string): void; /** * Deletes a model. * * Assumes that the project containing the model is currently loaded. * * @param {String} modelId ID of the model to delete. Must be the ID of one of the models in the currently loaded project. */ deleteModel(modelId: string): void; /** * Adds a model. * */ addModel(): void; /** * Sets where the colors for model objects will be loaded from. * * Options are: * * * "model" - (default) load colors from models, and * * "viewer" - load colors from the viewer's inbuilt table of colors for IFC types. * * This is "model" by default. * * @param {String} source Where colors will be loaded from - "model" or "viewer". */ setObjectColorSource(source: string): void; /** * Gets where the colors for model objects will be loaded from. * * This is "model" by default. * * @return {String} Where colors will be loaded from - "model" to get colors from the model, or "viewer" to get them from the viewer's built-in table of colors for IFC types. */ getObjectColorSource(): string; /** * Updates viewer UI state according to the properties in the given object. * * Note that, since some updates could be animated (e.g. flying the camera to fit objects to view) this * method optionally takes a callback, which it invokes after updating the UI. * * Also, this method is not to be confused with {@link BIMViewer#setConfigs}, which is used to batch-update various configurations and user preferences on the viewer. * * See [Viewer States] for the list of states that may be batch-updated with this method. * * @param {Object} viewerState Specifies the viewer UI state updates. * @param {Function} done Callback invoked on successful update of the viewer states. */ setViewerState(viewerState: any, done?: Function): void; protected _parseSelectedStorey(viewerState: any, done: Function): void; _parseThreeDMode(viewerState: any, done: Function): void; /** * Highlights the given object in the tree views within the Objects, Classes and Storeys tabs. * * Also scrolls the object's node into view within each tree, then highlights it. * * De-highlights whatever node is currently highlighted in each of those trees. * * @param {String} objectId ID of the object */ showObjectInExplorers(objectId: string): void; /** * De-highlights the object previously highlighted with {@link BIMViewer#showObjectInExplorers}. * * This only de-highlights the node. If the node is currently scrolled into view, then the node will remain in view. * * For each tab, does nothing if a node is currently highlighted. */ unShowObjectInExplorers(): void; /** * 获取构件属性 * @param objectId * @returns */ getObjectProperties(objectId: string): { id: string; name: string; type: string; propertySets: any; } | null; /** * 获取模型信息 * @returns */ getModelInfo(): { id: string | number; createDate: string; author: string; objectCount: string | number; propertySetCount: string | number; }; /** * Sets whether or not the given objects are visible. * * @param {String[]} objectIds IDs of objects. * @param {Boolean} visible True to set objects visible, false to set them invisible. */ setObjectsVisible(objectIds: string[], visible: boolean): void; /** * Sets whether or not the given objects are selected. * * @param {String[]} objectIds IDs of objects. * @param {Boolean} selected Whether or not to set the objects selected. */ setObjectsSelected(objectIds: string[], selected: boolean): void; /** * Sets whether or not the given objects are X-rayed. * * @param {String[]} objectIds IDs of objects. * @param {Boolean} xrayed Whether or not to X-ray the objects. */ setObjectsXRayed(objectIds: string[], xrayed: boolean): void; protected _withObjectsInSubtree(objectIds: string[], callback: Function): void; /** * Flies the camera to fit the given object in view. * * @param {String} objectId ID of the object * @param {Function} done Callback invoked on completion */ flyToObject(objectId: string, done: Function): void; /** * Flies the camera to fit the given objects in view. * * @param {String[]} objectIds IDs of the objects * @param {Function} done Callback invoked on completion */ viewFitObjects(objectIds: string[], done?: Function): void; /** * Jumps the camera to fit the given object in view. * * @param {String} objectId ID of the object */ jumpToObjects(objectIds: string): void; /** * Sets the camera to the given position. * * @param {Number[]} [params.eye] Eye position. * @param {Number[]} [params.look] Point of interest. * @param {Number[]} [params.up] Direction of "up". */ setCamera(params: any): void; /** * Sets the camera to the given position. * * @param {Number[]} [params.eye] Eye position. * @param {Number[]} [params.look] Point of interest. * @param {Number[]} [params.up] Direction of "up". */ flyToNewView(params: any): void; /** * Fits the given models in view. * * @param {String[]} modelIds ID of the models. * @param {Function} [done] Callback invoked on completion. Will be animated if this is given, otherwise will be instantaneous. */ viewFitModels(modelIds: string[], done: Function): void; /** * 切换模型分布 - 根据构建检测结果的模型分布情况聚焦不同分布区域 * * 使用: * bimViewer.viewFitPartial(1, (partNum:number)=>{ * console.log(partNum); //当前聚焦的模型分布索引 * }) * * bimViewer.viewFitPartial((partNum:number)=>{ * console.log(partNum); //当前聚焦的模型分布索引 * }) * * bimViewer.viewFitPartial(1); //无回调方法。自动切换分布视角 * * bimViewer.viewFitPartial(); //无指定索引输入,无回调方法。自动切换分布视角 * * * @param {number} part - 模型分布索引(例如:根据检测结果,当前模型有三块模型分布,则可以输入[0-2]区间的数字) * @param {Function} done - */ viewFitPartial(part?: number | Function, done?: Function): void; /** * 设置模型分布 - 根据构建检测结果设置不同分布位置的模型构建ID数组 * @param {string[][]} partialObjectIds */ setPartialObjectIds(partialObjectIds: string[][]): void; /** * Sets whether IFCSpace types are ever shown. * * @param {Boolean} shown Set true to allow IFCSpaces to be shown, else false to always keep them hidden. */ setSpacesShown(shown: boolean): void; /** * Gets whether the viewer allows IFCSpace types to be shown. * * @returns {boolean} True to allow IFCSpaces to be shown, else false to always keep them hidden. */ getSpacesShown(): boolean; /** * Sets whether the viewer is in orthographic viewing mode. * * The viewer is either in orthographic mode or perspective mode. The viewer is in perspective mode by default. * * @param {Boolean} enabled Set true to switch into ortho mode, else false to switch into perspective mode. * @param {Function} done Callback to invoke when switch complete. Supplying this callback causes an animated transition. Otherwise, the transition will be instant. */ setOrthoEnabled(enabled: boolean, done: Function): void; /** * Gets whether the viewer is in orthographic viewing mode. * * The viewer is either in orthographic mode or perspective mode. The viewer is in perspective mode by default. * * @returns {boolean} True when in ortho mode, else false when in perspective mode. */ getOrthoEnabled(): boolean; /** * Transitions the viewer into an isolated view of the given building storey. * * Does nothing and logs an error if no object of the given ID is in the viewer, or if the object is not an ````IfcBuildingStorey````. * * @param {String} storeyObjectId ID of an ````IfcBuildingStorey```` object. * @param {Function} [done] Optional callback to invoke on completion. When provided, the transition will be animated, with the camera flying into position. Otherwise, the transition will be instant, with the camera jumping into position. */ selectStorey(storeyObjectId: string, done?: Function): void; /** * Sets whether or not keyboard camera control is enabled. * * This is useful when we don't want key events over the canvas to clash with other UI elements outside the canvas. * * Default value is ````true````. * * @param {Boolean} enabled Set ````true```` to enable keyboard input. */ setKeyboardEnabled(enabled: boolean): void; /** * Gets whether keyboard camera control is enabled. * * This is useful when we don't want key events over the canvas to clash with other UI elements outside the canvas. * * Default value is ````true````. * * @returns {Boolean} Returns ````true```` if keyboard input is enabled. */ getKeyboardEnabled(): boolean; /** * Clears sections. * * Sections are the slicing planes, that we use to section models in order to see interior structures. */ clearSections(): void; /** * Disables all sections. */ disableSections(): void; /** * Enables all sections. */ enableSections(): void; /** * Inverts the direction of sections. */ flipSections(): void; /** * Hides the section edition control, if currently shown. */ hideSectionEditControl(): void; /** * spinner显隐设置 * @param show */ showSpinner(show?: boolean): void; /** * Returns the number of sections that currently exist. * * sections are the sliceing planes, that we use to slice models in order to see interior structures. * * @returns {Number} The number of sections. */ getNumSections(): number; /** * 更新包围盒 * @param exceptionIDs - 异常构建ID * @param callback - 回调 */ updateAABB(exceptionIDs: string[], callback: Function): void; /** * 销毁 */ destroy(callback?: Function): void; /** * 设置对象被选中与否 * @param entity * @param selected */ setEntitySelected(entity: any, selected?: boolean): void; /** * 选中其他对象 * @param entity */ setOthersSelected(entity: any): void; /** * Sets whether or not all objects are selected. * * @param {Boolean} selected Whether or not to set all objects selected. */ setAllObjectsSelected(selected: boolean): void; /** * 设置相机适应选中对象 * @param entity */ viewFitEntity(entity: any): void; /** * 相机适应所有选中对象 */ viewFitSelectedObjects(done?: Function): void; /** * Flies the camera to fit all objects in view. * * @param {Function} done Callback invoked on completion */ viewFitAll(done?: Function): void; /** * 设置选中对象隐藏与否 * @param entity */ setEntityHide(entity: any, visible?: boolean): void; /** * 隐藏选中对象以外的其他模型对象 * @param entity * @returns */ setOthersHide(entity: any): void; /** * 显示所有对象 * @param {Boolean} visible True to set objects visible, false to set them invisible. */ setAllObjectsVisible(visible: boolean): void; /** * 设置选中对象透视与否 * @param entity * @param xrayed */ setEntityXRayed(entity: any, xrayed?: boolean): void; /** * 设置其他对象透视 * @param entity * @returns */ setOthersXRayed(entity: any): void; /** * 设置所有对象透视与否 * @param {Boolean} xrayed Whether or not to set all objects X-rayed. */ setAllObjectsXRayed(xrayed: boolean): void; entityVisble(entity: any): any; entityXRayed(entity: any): any; entityChosed(entity: any): any; /** * 判断是否有被隐藏的 * @returns */ hiddenMoreThanOne(): boolean; /** * 判断是否有被透视的 * @returns */ xRayedMoreThanOne(): boolean; /** * 判断是否有被选中的 * @returns */ SelectedMoreThanOne(): boolean; /** * Sets the viewer's background color. * * @param {boolean} */ setBackgroundTransparent(trans?: boolean): void; /** * Sets the viewer's background color. * * @param {Number[]} rgbColor Three-element array of RGB values, each in range ````[0..1]````. */ setBackgroundColor(rgbColor: []): void; /** * 设置导航盒尺寸 * @param {number} size 默认是200 */ setNavCubeSize(size: number): void; /** * 设置导航盒的位置 * @param {string} direction e.g."left","right","top","bottom" * @param {number} pos */ setNavCubePosition(direction: string, pos: number): void; /** * 更新canvas */ updateCanvas(): void; /** * 设置测量鼠标偏移量 * @param offsetX * @param offsetY */ setMouseOffset(offsetX: number, offsetY: number): void; /** * 设置批注鼠标偏移量 * @param offsetX * @param offsetY */ setCommentsOffset(offsetX: number, offsetY: number): void; /** * 设置鼠标吸附点灵敏度 * @param radius */ setSnapRadius(radius: number): void; /** * 设置是否是触屏模式 * @param {boolean} isTouch */ setIsTouch(isTouch: boolean): void; /** * 调整光照强度 0-100 * @param num */ setLightIntensity(num: number): void; /** * 设置空间构建的颜色模式;默认 1 * @param {number} colorState */ setSpaceMaterialColor(colorState: number): void; /** * set edges Enable * @param {boolean} edgesEnabled */ setEdgesEnabled(edgesEnabled?: boolean): void; /** * 是否开启环境光 * @param {boolean} saoEnabled */ setSAOEnabled(saoEnabled?: boolean): void; setDTXEnabled(dtxEnabled?: boolean): void; setPBREnabled(pbrEnabled?: boolean): void; /** * 重置 * */ resetView(callback?: Function): void; /** * 自适应 */ fitView(callback?: Function): void; /** * 标注开关 * @param active * @param callback */ SetAnnotationToolActive(active?: boolean, callback?: Function): void; /** * 批注开关 * @param active * @param callback */ SetCommentsToolActive(active?: boolean, callback?: Function): void; /** * 第一人称视角 * @param active * @param callback */ SetFirstPersonModeActive(active?: boolean, callback?: Function): void; /** * 角度测量开关 * @param active * @param callback */ SetMeasureAngleActive(active?: boolean, callback?: Function): void; /** * 距离测量开关 * @param active * @param callback */ SetMeasureDistanceActive(active?: boolean, callback?: Function): void; /** * 剖切工具开关 * @param active * @param callback */ SetSectionToolActive(active?: boolean, callback?: Function): void; /** * 隐藏工具开关 * @param active * @param callback */ SetHideToolActive(active: boolean, callback?: Function): void; /** * 框选开关 * @param active * @param callback */ SetMarqueeSelectionActive(active: boolean, callback?: Function): void; /** * 相机视角开关 * @param active * @param callback */ SetOrthoModeActive(active: boolean, callback?: Function): void; /** * 选择工具开关 * @param active * @param callback */ SetSelectionToolActive(active: boolean, callback?: Function): void; /** * 显示空间功能开关 * @param active * @param callback */ SetShowSpaceModeActive(active?: boolean, callback?: Function): void; /** * 3d/2d视角开关 * @param active * @param callback */ SetThreeDModeActive(active: boolean, callback?: Function): void; /** * 构建异常值 */ get outlierObjectIds(): string[]; /** * 构建分布 */ get partialObjectIds(): string[][]; /** * 漫游 */ get firstPersonMode(): FirstPersonMode; /** * 角度测量 */ get measureAngleTool(): MeasureAngleTool; /** * 距离测量 */ get measureDistanceTool(): MeasureDistanceTool; /** * 剖切 */ get sectionTool(): SectionTool; /** * 批注 */ get commentTool(): CommentsTool; /** * 标注 */ get annotationTool(): AnnotationTool; /** * 结构树object(对象) */ get objectsExplorer(): ObjectsExplorer; /** * 结构树class(类别) */ get classesExplorer(): ClassesExplorer; /** * 结构树storey(楼层) */ get storeysExplorer(): StoreysExplorer; /** * 模型加载器 */ get modelsExplorer(): ModelsExplorer; /** * 相机视角 */ get orthoMode(): OrthoMode; get navCubeMode(): NavCubeMode; /** * 设置相机方向 * @param {number} dirNum */ setDirection(dirNum: number): void; /** * 单击模型对象 * @param entity */ singleChoseEntity(entity: any): void; /** * 单击点击空白 */ singleChosedSpace(): void; /** * 双击模型对象 * @param entity */ doubleChoseEntity(entity: any): void; /** * 回到正常视图 */ choseSpace(): void; /** * 按照指定角度旋转相机 * @param {number} angleInc * @returns */ orbitYawCamera: (angleInc: number) => Promise; cameraEnable: (pointerEnabled?: boolean) => void; /** * 初始预览环周截图 * @param sizeOrCallback * @param done * @returns */ getPreShot(sizeOrCallback?: number, done?: Function): string; /** * 设置遮挡截图 * @param callback */ setShelterCanvas(callback?: Function): void; /** * 模型截图 * @param width * @param height * @param isDownload * @returns */ shot: (width: number, height: number, isDownload: boolean) => string; }