ViewerUI
Extends:
UI controller for a xeokit Viewer toolbar.
Constructor Summary
| Public Constructor | ||
| public |
constructor(server: Server, cfg: *) Constructs a ViewerUI. |
|
Method Summary
| Public Methods | ||
| public |
De-selects all objects currently in the viewer. |
|
| public |
destroy() Destroys the viewer, freeing all resources. |
|
| 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 |
getProjectInfo(projectId: String, done: Function, error: Function) Gets information on a project. |
|
| public |
getProjectsInfo(done: Function, error: Function) Gets information on all available projects. |
|
| public |
Hides all objects currently in the viewer. |
|
| public |
hideAllObjectsExceptFor(objectIds: String[]) Hides all objects currently in the viewer, except for those with the given IDs. |
|
| public |
hideObject(objectId: String) Hides the object with the given ID. |
|
| 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 |
Selects all objects currently in the viewer. |
|
| public |
selectAllObjectsExceptFor(objectIds: String[]) Selects all objects currently in the viewer, except for those with the given IDs. |
|
| public |
selectObject(objectId: String) Selects the objects with the given ID. |
|
| public |
setControlsEnabled(enabled: Boolean) Enables or disables the various buttons and controls throughout the viewer. |
|
| public |
Shows all objects currently in the viewer. |
|
| public |
showAllObjectsExceptFor(objectIds: String[]) Shows all objects currently in the viewer, except for those with the given IDs. |
|
| public |
showObject(objectId: String) Shows the object with the given ID. |
|
| public |
showObjectInClassesTab(objectId: *) |
|
| public |
showObjectInObjectsTab(objectId: *) |
|
| public |
showObjectInStoreysTab(objectId: *) |
|
| public |
unloadModel(modelId: *) Unloads a model from the viewer. |
|
| public |
Unloads all currently loaded models. |
|
| public |
X-rays all objects currently in the viewer. |
|
| public |
xrayAllObjectsExceptFor(objectIds: String[]) X-rays all objects currently in the viewer, except for those with the given IDs. |
|
| public |
Un-x-rays all objects currently in the viewer. |
|
| public |
xrayObject(objectId: String) X-ray the object with the given ID. |
|
Public Constructors
Public Methods
public getLoadedModelIds(): String[] source
Returns the IDs of the currently loaded models, if any.
Return:
| String[] | The IDs of the currently loaded models, else an empty array if no models are currently loaded. |
public getProjectInfo(projectId: String, done: Function, error: Function) source
Gets information on a project.
Use ViewerUI#getProjects to get information on all available projects.
Example
myViewer.getProjectInfo(("Duplex") => {
console.log(JSON.stringify(projectInfo, null, "\t"));
});
Returns JSON similar to:
{
"id": "Duplex",
"name": "Duplex"
}
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 ViewerUI#getProjects. |
|
| done | Function | Callback fired on success, into which the project information JSON is passed. |
|
| error | Function | Callback fired on failure, into which the error message string is passed. |
public getProjectsInfo(done: Function, error: Function) source
Gets information on all available projects.
Example
myViewer.getProjectsInfo((projectsInfo) => {
console.log(JSON.stringify(projectsInfo, null, "\t"));
});
Returns JSON similar to:
{
"projects": [
{
"id": "Duplex",
"name": "Duplex"
},
{
"id": "Schependomlaan",
"name": "Schependomlaan"
},
{
"id": "WestRiversideHospital",
"name": "West Riverside Hospital"
}
]
}
public hideAllObjectsExceptFor(objectIds: String[]) source
Hides all objects currently in the viewer, except for those with the given IDs.
Params:
| Name | Type | Attribute | Description |
| objectIds | String[] | IDs of objects to not hide. |
public hideObject(objectId: String) source
Hides the object with the given ID.
Params:
| Name | Type | Attribute | Description |
| objectId | String | ID of object to hide. |
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. |
public loadModel(modelId: String, done: Function, error: Function) source
Loads a model into the viewer.
Assumes that the project that contains the model is currently loaded.
public loadProject(projectId: String, done: Function, error: Function) source
Loads a project into the viewer.
Unloads any project and contained models that are already loaded.
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 ViewerUI#getProjects. |
|
| done | Function | Callback fired on success. |
|
| error | Function | Callback fired 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, and
- "storeys" - the Storeys tab, which contains a tree view for each loaded model, with nodes grouped within
IfcBuildingStoreys, sub-grouped by their IFC types.
Params:
| Name | Type | Attribute | Description |
| tabId | String | ID of the tab to open - see method description. |
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 |
Return:
| * | BCF JSON viewpoint object |
Example:
const viewpoint = viewerUI.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 selectAllObjectsExceptFor(objectIds: String[]) source
Selects all objects currently in the viewer, except for those with the given IDs.
Params:
| Name | Type | Attribute | Description |
| objectIds | String[] | IDs of objects to not select. |
public selectObject(objectId: String) source
Selects the objects with the given ID.
Params:
| Name | Type | Attribute | Description |
| objectId | String | ID of object to select. |
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 showAllObjectsExceptFor(objectIds: String[]) source
Shows all objects currently in the viewer, except for those with the given IDs.
Params:
| Name | Type | Attribute | Description |
| objectIds | String[] | IDs of objects to not show. |
public showObject(objectId: String) source
Shows the object with the given ID.
Params:
| Name | Type | Attribute | Description |
| objectId | String | ID of object to show. |
public showObjectInClassesTab(objectId: *) source
Params:
| Name | Type | Attribute | Description |
| objectId | * |
public showObjectInObjectsTab(objectId: *) source
Params:
| Name | Type | Attribute | Description |
| objectId | * |
public showObjectInStoreysTab(objectId: *) source
Params:
| Name | Type | Attribute | Description |
| objectId | * |
public unloadModel(modelId: *) source
Unloads a model from the viewer.
Does nothing if the model is not currently loaded.
Params:
| Name | Type | Attribute | Description |
| modelId | * |
Reference
Source
