Constructor Summary
Public Constructor | ||
public |
constructor(server: Server, cfg: *) Constructs a BIMViewer. |
Member Summary
Public Members | ||
public get |
localeService: LocaleService: * Returns the LocaleService that was configured on this Viewer. |
|
public |
|
|
public |
|
|
public |
viewer: Viewer The xeokit Viewer at the core of this BIMViewer. |
Method Summary
Public Methods | ||
public |
addModel() Adds a model. |
|
public |
Clears sections. |
|
public |
deleteModel(modelId: String) Deletes a model. |
|
public |
destroy() Destroys the viewer, freeing all resources. |
|
public |
Disables all sections. |
|
public |
Edits a model. |
|
public |
Enables all sections. |
|
public |
Inverts the direction of sections. |
|
public |
flyToObject(objectId: String, done: Function) Flies the camera to fit the given object in view. |
|
public |
Gets whether the viewer is in 3D or 2D viewing mode. |
|
public |
Gets the value of a viewer configuration. |
|
public |
Gets whether keyboard camera control is enabled. |
|
public |
getLoadedModelIds(): String[] Returns the IDs of the currently loaded models, if any. |
|
public |
Returns the ID of the currently loaded project, if any. |
|
public |
getModelIds(): String[] Returns the IDs of the models in the currently loaded project. |
|
public |
Returns the number of sections that currently exist. |
|
public |
this method was deprecated.
Gets where the colors for model objects will be loaded from. |
|
public |
getObjectInfo(projectId: String, modelId: String, objectId: String, done: Function, error: Function) Gets information on the given object, belonging to the given model, within the given project. |
|
public |
getOpenTab(): string Returns the ID of the currently open viewer tab. |
|
public |
Gets whether the viewer is in orthographic viewing mode. |
|
public |
getProjectInfo(projectId: String, done: Function, error: Function) Gets information on the given project. |
|
public |
getProjectsInfo(done: Function, error: Function) Gets information on all available projects. |
|
public |
Gets whether the viewer allows IFCSpace types to be shown. |
|
public |
Hides the section edition control, if currently shown. |
|
public |
isModelLoaded(modelId: String): Boolean Gets if the given model is loaded. |
|
public |
jumpToObject(objectId: String) Jumps the camera to fit the given object in view. |
|
public |
loadAllModels(done: Function) Load all models in the currently loaded project. |
|
public |
loadBCFViewpoint(bcfViewpoint: *, options: *) Sets viewer state to the given BCF viewpoint. |
|
public |
Loads a model into the viewer. |
|
public |
loadProject(projectId: String, done: Function, error: Function) Loads a project into the viewer. |
|
public |
Opens the specified viewer tab. |
|
public |
Resets the view. |
|
public |
saveBCFViewpoint(options: *): * Saves viewer state to a BCF viewpoint. |
|
public |
selectStorey(storeyObjectId: String, done: Function) Transitions the viewer into an isolated view of the given building storey. |
|
public |
set3DEnabled(enabled: Boolean, done: Function) Switches the viewer between 2D and 3D viewing modes. |
|
public |
setAllObjectsSelected(selected: Boolean) Sets whether or not all objects are selected. |
|
public |
setAllObjectsVisible(visible: Boolean) Sets the visibility of all objects. |
|
public |
setAllObjectsXRayed(xrayed: Boolean) Sets whether or not all objects are X-rayed. |
|
public |
setBackgroundColor(rgbColor: Number[]) Sets the viewer's background color. |
|
public |
Sets the camera to the given position. |
|
public |
Sets a viewer configuration. |
|
public |
setConfigs(viewerConfigs: *) Sets a batch of viewer configurations. |
|
public |
setControlsEnabled(enabled: Boolean) Enables or disables the various buttons and controls throughout the viewer. |
|
public |
setKeyboardEnabled(enabled: Boolean) Sets whether or not keyboard camera control is enabled. |
|
public |
setObjectColorSource(source: String) this method was deprecated.
Sets where the colors for model objects will be loaded from. |
|
public |
setObjectsSelected(objectIds: String[], selected: Boolean) Sets whether or not the given objects are selected. |
|
public |
setObjectsVisible(objectIds: String[], visible: Boolean) Sets whether or not the given objects are visible. |
|
public |
setObjectsXRayed(objectIds: String[], xrayed: Boolean) Sets whether or not the given objects are X-rayed. |
|
public |
setOrthoEnabled(enabled: Boolean, done: Function) Sets whether the viewer is in orthographic viewing mode. |
|
public |
setSpacesShown(shown: Boolean) Sets whether IFCSpace types are ever shown. |
|
public |
setViewerState(viewerState: Object, done: Function) Updates viewer UI state according to the properties in the given object. |
|
public |
showObjectInExplorers(objectId: String) Highlights the given object in the tree views within the Objects, Classes and Storeys tabs. |
|
public |
showObjectProperties(objectId: String) Shows the properties of the given object in the Properties tab. |
|
public |
De-highlights the object previously highlighted with BIMViewer#showObjectInExplorers. |
|
public |
Unloads all currently loaded models. |
|
public |
unloadModel(modelId: String) Unloads a model from the viewer. |
|
public |
Unloads whatever project is currently loaded. |
|
public |
viewFitAll(done: Function) Flies the camera to fit all objects in view. |
|
public |
viewFitModels(modelIds: String[], done: Function) Fits the given models in view. |
|
public |
viewFitObjects(objectIds: String[], done: Function) Flies the camera to fit the given objects in view. |
Public Constructors
public constructor(server: Server, cfg: *) source
Constructs a BIMViewer.
Params:
Name | Type | Attribute | Description |
server | Server | Data access strategy. |
|
cfg | * | Configuration. |
|
cfg.enableEditModels | Boolean |
|
Set |
cfg.keyboardEventsElement | Boolean |
|
Optional reference to HTML element on which key events should be handled. Defaults to the HTML Document. |
Public Members
public get localeService: LocaleService: * source
Returns the LocaleService that was configured on this Viewer.
Return:
LocaleService | The LocaleService. |
public setFirstPersonModeActive: * source
public setThreeDModeActive: * source
Public Methods
public clearSections() source
Clears sections.
Sections are the slicing planes, that we use to section models in order to see interior structures.
public deleteModel(modelId: String) source
Deletes a model.
Assumes that the project containing the model is currently loaded.
Params:
Name | Type | Attribute | Description |
modelId | String | ID of the model to delete. Must be the ID of one of the models in the currently loaded project. |
public editModel(modelId: String) source
Edits a model.
Assumes that the project containing the model is currently loaded.
Params:
Name | Type | Attribute | Description |
modelId | String | ID of the model to edit. Must be the ID of one of the models in the currently loaded project. |
public flyToObject(objectId: String, done: Function) source
Flies the camera to fit the given object in view.
public getConfig(name: String): * source
Gets the value of a viewer configuration.
These are set with BIMViewer#setConfig and BIMViewer#setConfigs.
Params:
Name | Type | Attribute | Description |
name | String | Configuration name. |
Return:
* |
public getKeyboardEnabled(): Boolean source
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
.
public getLoadedModelIds(): String[] source
Returns the IDs of the currently loaded models, if any.
Return:
String[] | The IDs of the currently loaded models, otherwise an empty array if no models are currently loaded. |
public getLoadedProjectId(): String source
Returns the ID of the currently loaded project, if any.
Return:
String | The ID of the currently loaded project, otherwise |
public getModelIds(): String[] source
Returns the IDs of the models in the currently loaded project.
public getNumSections(): Number source
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.
public getObjectColorSource(): String source
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. |
public getObjectInfo(projectId: String, modelId: String, objectId: String, done: Function, error: Function) source
Gets information on the given object, belonging to the given model, within the given project.
See Getting Info on an Object for usage.
Params:
Name | Type | Attribute | Description |
projectId | String | ID of the project to get information on. Must be the ID of one of the projects in the information obtained by BIMViewer#getProjects. |
|
modelId | String | ID of a model within the project. Must be the ID of one of the models in the information obtained by BIMViewer#getProjectInfo. |
|
objectId | String | ID of an object in the model. |
|
done | Function | Callback invoked on success, into which the object information JSON is passed. |
|
error | Function | Callback invoked on failure, into which the error message string is passed. |
public getOpenTab(): string source
Returns the ID of the currently open viewer tab.
The available tabs are:
- "models" - the Models tab, which lists the models available within the currently loaded project,
- "objects" - the Objects tab, which contains a tree view for each loaded model, organized to indicate the containment hierarchy of their objects,
- "classes" - the Classes tab, which contains a tree view for each loaded model, with nodes grouped by IFC types of their objects,
- "storeys" - the Storeys tab, which contains a tree view for each loaded model, with nodes grouped within
IfcBuildingStoreys
, sub-grouped by their IFC types, - "properties" - the Properties tab, which shows property sets for a given object, and
- "none" - no tab is open; this is unlikely, since one of the above tabs should be open at a any time, but here for robustness.
public getOrthoEnabled(): boolean source
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.
public getProjectInfo(projectId: String, done: Function, error: Function) source
Gets information on the given project.
See Getting Info on a Project for usage.
Params:
Name | Type | Attribute | Description |
projectId | String | ID of the project to get information on. Must be the ID of one of the projects in the information obtained by BIMViewer#getProjects. |
|
done | Function | Callback invoked on success, into which the project information JSON is passed. |
|
error | Function | Callback invoked on failure, into which the error message string is passed. |
public getProjectsInfo(done: Function, error: Function) source
Gets information on all available projects. Gets information on all available projects.
See Getting Info on Available Projects for usage.
public isModelLoaded(modelId: String): Boolean source
Gets if the given model is loaded.
Params:
Name | Type | Attribute | Description |
modelId | String | ID of the model to check. Must be the ID of one of the models in the currently loaded project. |
public jumpToObject(objectId: String) source
Jumps the camera to fit the given object in view.
Params:
Name | Type | Attribute | Description |
objectId | String | ID of the object |
public loadAllModels(done: Function) source
Load all models in the currently loaded project.
Doesn't reload any models that are currently loaded.
Params:
Name | Type | Attribute | Description |
done | Function | Callback invoked on successful loading of the models. |
public loadBCFViewpoint(bcfViewpoint: *, options: *) source
Sets viewer state to the given BCF viewpoint.
This assumes that the viewer currently contains the same project and model(s) that were loaded at the time that the viewpoint was originally saved (the BCF viewpoint specification does not contain that information).
Note that xeokit's Camera#look is the point-of-interest, whereas the BCF camera_direction
is a
direction vector. Therefore, when loading a BCF viewpoint, we set Camera#look to the absolute position
obtained by offsetting the BCF camera_view_point
along camera_direction
.
When loading a viewpoint, we also have the option to find Camera#look as the closest point of intersection
(on the surface of any visible and pickable Entity) with a 3D ray fired from camera_view_point
in
the direction of camera_direction
.
Params:
Name | Type | Attribute | Description |
bcfViewpoint | * | BCF JSON viewpoint object or "reset" / "RESET" to reset the viewer, which clears SectionPlanes, shows default visible entities and restores camera to initial default position. |
|
options | * |
|
Options for setting the viewpoint. |
options.rayCast | Boolean |
|
When |
options.immediate | Boolean |
|
When |
options.duration | Boolean |
|
Flight duration in seconds. Overrides CameraFlightAnimation#duration. |
options.reset | Boolean |
|
When |
options.reverseClippingPlanes | Boolean |
|
When |
options.updateCompositeObjects | Boolean |
|
When |
public loadModel(modelId: String, done: Function, error: Function) source
Loads a model into the viewer.
Assumes that the project containing the model is currently loaded.
public loadProject(projectId: String, done: Function, error: Function) source
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.
Params:
Name | Type | Attribute | Description |
projectId | String | ID of the project to load. Must be the ID of one of the projects in the information obtained by BIMViewer#getProjects. |
|
done | Function | Callback invoked on success. |
|
error | Function | Callback invoked on failure, into which the error message string is passed. |
public openTab(tabId: String) source
Opens the specified viewer tab.
The available tabs are:
- "models" - the Models tab, which lists the models available within the currently loaded project,
- "objects" - the Objects tab, which contains a tree view for each loaded model, organized to indicate the containment hierarchy of their objects,
- "classes" - the Classes tab, which contains a tree view for each loaded model, with nodes grouped by IFC types of their objects,
- "storeys" - the Storeys tab, which contains a tree view for each loaded model, with nodes grouped within
IfcBuildingStoreys
, sub-grouped by their IFC types, and - "properties" - the Properties tab, which shows property sets for a given object.
Params:
Name | Type | Attribute | Description |
tabId | String | ID of the tab to open - see method description. |
public resetView() source
Resets the view.
This resets object appearances (visibility, selection, highlight and X-ray), sets camera to default position, and removes section planes.
public saveBCFViewpoint(options: *): * source
Saves viewer state to a BCF viewpoint.
This does not save information about the project and model(s) that are currently loaded. When loading the viewpoint, the viewer will assume that the same project and models will be currently loaded (the BCF viewpoint specification does not contain that information).
Note that xeokit's Camera#look is the point-of-interest, whereas the BCF camera_direction
is a
direction vector. Therefore, we save camera_direction
as the vector from Camera#eye to Camera#look.
Params:
Name | Type | Attribute | Description |
options | * |
|
Options for getting the viewpoint. |
options.spacesVisible | Boolean |
|
Indicates whether |
options.openingsVisible | Boolean |
|
Indicates whether |
options.spaceBoundariesVisible | Boolean |
|
Indicates whether the boundaries of |
options.reverseClippingPlanes | Boolean |
|
When |
options.defaultInvisible | Boolean |
|
When |
Return:
* | BCF JSON viewpoint object |
Example:
const viewpoint = bimViewer.saveBCFViewpoint({
spacesVisible: false, // Default
spaceBoundariesVisible: false, // Default
openingsVisible: false // Default
});
// viewpoint will resemble the following:
{
perspective_camera: {
camera_view_point: {
x: 0.0,
y: 0.0,
z: 0.0
},
camera_direction: {
x: 1.0,
y: 1.0,
z: 2.0
},
camera_up_vector: {
x: 0.0,
y: 0.0,
z: 1.0
},
field_of_view: 90.0
},
lines: [],
clipping_planes: [{
location: {
x: 0.5,
y: 0.5,
z: 0.5
},
direction: {
x: 1.0,
y: 0.0,
z: 0.0
}
}],
bitmaps: [],
snapshot: {
snapshot_type: png,
snapshot_data: "data:image/png;base64,......"
},
components: {
visibility: {
default_visibility: false,
exceptions: [{
ifc_guid: 4$cshxZO9AJBebsni$z9Yk,
originating_system: xeokit.io,
authoring_tool_id: xeokit/v1.0
}]
},
selection: [{
ifc_guid: "4$cshxZO9AJBebsni$z9Yk",
}]
}
}
public selectStorey(storeyObjectId: String, done: Function) source
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
.
Params:
Name | Type | Attribute | Description |
storeyObjectId | String | ID of an |
|
done | Function |
|
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. |
public set3DEnabled(enabled: Boolean, done: Function) source
Switches the viewer between 2D and 3D viewing modes.
public setAllObjectsSelected(selected: Boolean) source
Sets whether or not all objects are selected.
Params:
Name | Type | Attribute | Description |
selected | Boolean | Whether or not to set all objects selected. |
public setAllObjectsVisible(visible: Boolean) source
Sets the visibility of all objects.
Params:
Name | Type | Attribute | Description |
visible | Boolean | True to set objects visible, false to set them invisible. |
public setAllObjectsXRayed(xrayed: Boolean) source
Sets whether or not all objects are X-rayed.
Params:
Name | Type | Attribute | Description |
xrayed | Boolean | Whether or not to set all objects X-rayed. |
public setBackgroundColor(rgbColor: Number[]) source
Sets the viewer's background color.
Params:
Name | Type | Attribute | Description |
rgbColor | Number[] | Three-element array of RGB values, each in range |
public setCamera() source
Sets the camera to the given position.
public setConfig(name: String, value: *) source
Sets a viewer configuration.
See Viewer Configurations for the list of available configurations.
Params:
Name | Type | Attribute | Description |
name | String | Configuration name. |
|
value | * | Configuration value. |
public setConfigs(viewerConfigs: *) source
Sets a batch of viewer configurations.
Note that this method is not to be confused with BIMViewer#setViewerState, which batch-updates various states of the viewer's UI and 3D view.
See Viewer Configurations for the list of available configurations.
Params:
Name | Type | Attribute | Description |
viewerConfigs | * | Map of key-value configuration pairs. |
public setControlsEnabled(enabled: Boolean) source
Enables or disables the various buttons and controls throughout the viewer.
This also makes various buttons appear disabled.
Params:
Name | Type | Attribute | Description |
enabled | Boolean | Whether or not to disable the controls. |
public setKeyboardEnabled(enabled: Boolean) source
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
.
Params:
Name | Type | Attribute | Description |
enabled | Boolean | Set |
public setObjectColorSource(source: String) source
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.
Params:
Name | Type | Attribute | Description |
source | String | Where colors will be loaded from - "model" or "viewer". |
public setObjectsSelected(objectIds: String[], selected: Boolean) source
Sets whether or not the given objects are selected.
public setObjectsVisible(objectIds: String[], visible: Boolean) source
Sets whether or not the given objects are visible.
public setObjectsXRayed(objectIds: String[], xrayed: Boolean) source
Sets whether or not the given objects are X-rayed.
public setOrthoEnabled(enabled: Boolean, done: Function) source
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.
public setSpacesShown(shown: Boolean) source
Sets whether IFCSpace types are ever shown.
Params:
Name | Type | Attribute | Description |
shown | Boolean | Set true to allow IFCSpaces to be shown, else false to always keep them hidden. |
public setViewerState(viewerState: Object, done: Function) source
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 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.
public showObjectInExplorers(objectId: String) source
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.
Params:
Name | Type | Attribute | Description |
objectId | String | ID of the object |
public showObjectProperties(objectId: String) source
Shows the properties of the given object in the Properties tab.
Params:
Name | Type | Attribute | Description |
objectId | String | ID of the object |
public unShowObjectInExplorers() source
De-highlights the object previously highlighted with 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.
public unloadModel(modelId: String) source
Unloads a model from the viewer.
Does nothing if the model is not currently loaded.
Params:
Name | Type | Attribute | Description |
modelId | String | ID of the model to unload. |
public viewFitAll(done: Function) source
Flies the camera to fit all objects in view.
Params:
Name | Type | Attribute | Description |
done | Function | Callback invoked on completion |