{"_rev":"3-541fe2cd206727d849da7911c86f160f","time":{"created":"2022-07-13T15:37:23.713Z","0.0.1":"2022-07-13T10:47:22.492Z","modified":"2022-07-13T15:37:24.174Z","0.0.1-a1":"2022-07-13T15:37:24.013Z"},"_id":"@digital-enabler/bim-viewer-engine","name":"@digital-enabler/bim-viewer-engine","dist-tags":{"latest":"0.0.1-a1"},"versions":{"0.0.1-a1":{"name":"@digital-enabler/bim-viewer-engine","version":"0.0.1-a1","private":false,"description":"BIM viewer built on xeokit","main":"dist/bim-viewer-engine.es.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":" rollup -c","publish":"npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/digital-enabler/BimViewerEngine.git"},"keywords":["OpenProject","webgl","javascript","xeokit","xeolabs","ifc","bim","buildingsmart","openbim","opensource","3d-viewer"],"author":{"name":"Engineering"},"bugs":{"url":"https://github.com/digital-enabler/BimViewerEngine/issues"},"homepage":"https://github.com/digital-enabler/BimViewerEngine#readme","devDependencies":{"autoprefixer":"^9.8.6","esdoc":"^1.1.0","esdoc-standard-plugin":"^1.0.0","rollup":"^1.32.1","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-terser":"^7.0.2"},"dependencies":{"@xeokit/xeokit-sdk":"1.9.0-alpha.1"},"gitHead":"5abaf6cf2314f7717f518256aefb550c1c4b618d","_id":"@digital-enabler/bim-viewer-engine@0.0.1-a1","_nodeVersion":"16.14.0","_npmVersion":"8.13.2","dist":{"integrity":"sha512-sBDTIj7/LWdX8BNpfpmgFImElm/Pm9xqMVyS99QBY3HdkiBQLa1SNxj2MtH5vM+12rcueox9ZSXABkm8z7R8EA==","shasum":"ef3ac3f2582dc35c759618570dfda28b0cd6fb4d","tarball":"https://registry.npmjs.org/@digital-enabler/bim-viewer-engine/-/bim-viewer-engine-0.0.1-a1.tgz","fileCount":4,"unpackedSize":1198393,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFeBSUqdc5Ic6ZpuAdMdIDcRSAyp/68xd1+HK9IdEDeEAiAJjIklT/89OUKRV1Jl3VdoTxbLmMAQdyBX0Db1gtUSDw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJizua0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrA7w/+IBpokmg4UroTmzH69FPBW7iS/PF5bqxwICaZgjyrclxaAodf\r\nbA/CvCcfXirSMpVcwGSo7t+UHIRvfgDm0Hj9IZvXfZrKrZek5eaE/5zxVbaD\r\ngSwA8YPqNyhf1CGID7FtHaXSAJARjimBqR8G6dJo0O8Fg99nJAJxCR7nc+ww\r\nVC6+8hGQhnHvnn1IU2ML+FKXLzvGfEprl+3hqqFfC2lNtc/7COYC12DIV5dx\r\nDSBf4L35bWXi/8TNrIdn2cdcdJb5hvX9Cd85tvvC/d3t5BeWoTW9eTHK7EpU\r\n9j/0vEq3PgLBny0qOuFqFS5UJWU2OXMGmn3+a6qhoHOYK/AbT71vrOCkhjh1\r\nnxr2YYSXK8+ny+ECE3rXV7ZMqNIpyt8qLNlXi1PKazKD61Euw5OpvXmhRBz+\r\nW2UjW2qJijjQtanxMHqPRAqf1aAPwrbnNkV3kbwEELrAnFXZBoZL/qGTfCF8\r\n7wQZoKq/FGK46spqnXrOCCL47VYQflBN3/gDmAqUsUGgO+0ADrjTS4SxA8RS\r\ngSDflEXklV5Yo235USM60+5y/5ibUGAQ4E/+m6sDbq3jzd6BJxV+aWFKDmPM\r\n7pu91GzYzIYIUEWNxMlF0u2F/A/poLib1MyGcS3JMRPN87DwqxadTebrbcmT\r\ne7UffnJBZLRfXA34tkseRgP6QNbZ7MJiGAA=\r\n=rgVS\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"digital-enabler","email":"info-digitalenabler@eng.it"},"directories":{},"maintainers":[{"name":"digital-enabler","email":"info-digitalenabler@eng.it"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bim-viewer-engine_0.0.1-a1_1657726643820_0.2930869345830709"},"_hasShrinkwrap":false}},"maintainers":[{"name":"digital-enabler","email":"info-digitalenabler@eng.it"}],"description":"BIM viewer built on xeokit","homepage":"https://github.com/digital-enabler/BimViewerEngine#readme","keywords":["OpenProject","webgl","javascript","xeokit","xeolabs","ifc","bim","buildingsmart","openbim","opensource","3d-viewer"],"repository":{"type":"git","url":"git+https://github.com/digital-enabler/BimViewerEngine.git"},"author":{"name":"Engineering"},"bugs":{"url":"https://github.com/digital-enabler/BimViewerEngine/issues"},"readme":"# Bim Viewer Engine\r\n\r\nThe Digital Enabler - Bim Viewer Engine is build on **[xeokit-bim-viewer](https://github.com/xeokit/xeokit-bim-viewer)**.\r\n\r\n[![Screenshot](https://github.com/xeokit/xeokit-bim-viewer/raw/master/images/xeokit-bim-viewer.png)](https://xeokit.github.io/xeokit-bim-viewer/app/index.html?projectId=OTCConferenceCenter&tab=storeys)\r\n\r\n---\r\n\r\n**[xeokit-bim-viewer](https://github.com/xeokit/xeokit-bim-viewer)** is an open source 2D/3D BIM viewer that runs in the browser and loads models from your file system.\r\n\r\nThe viewer is built on **[xeokit](http://xeokit.io)**, and is bundled as part of the **[xeokit SDK](http://xeokit.io)**.\r\n\r\nThe viewer is developed by [xeolabs](http://xeolabs.com) and [OpenProject](https://www.openproject.org/), and is integrated within [OpenProject BIM 10.4](https://www.openproject.org/openproject-bim-10-4/) and later.\r\n\r\nThe viewer can be used as a stand-alone JavaScript application. In combination with open source CLI model conversion tools, it represents a low-cost, high-performance way to get your IFC models on the Web, that allows you the freedom to convert and host your models on your own server or GitHub repository.\r\n\r\nTo view your models with this viewer:\r\n\r\n1. Fork the [xeokit-bim-viewer](https://github.com/xeokit/xeokit-bim-viewer) repository on GitHub.\r\n1. Convert your IFC STEP files using [open source CLI tools](https://github.com/xeokit/xeokit-sdk/wiki/Creating-Files-for-Offline-BIM).\r\n1. Add your converted models to your fork's data directory.\r\n1. Serve your fork using [GitHub Pages](https://pages.github.com/).\r\n\r\nThen users can view your models in their browsers, with URLs like this:\r\n\r\n[`https://xeokit.github.io/xeokit-bim-viewer/app/index.html?projectId=OTCConferenceCenter&tab=storeys`](https://xeokit.github.io/xeokit-bim-viewer/app/index.html?projectId=OTCConferenceCenter&tab=storeys)\r\n\r\nRead the documentation below to get started.\r\n\r\n---\r\n\r\n- [Source Code](https://github.com/xeokit/xeokit-bim-viewer)\r\n- [API Docs](https://xeokit.github.io/xeokit-bim-viewer/docs)\r\n- [xeokit SDK](http://xeokit.io)\r\n\r\n---\r\n\r\n## Contents\r\n\r\n- [Features](#features)\r\n- [Demos](#demos)\r\n- [License](#license)\r\n- [The Viewer Application](#the-viewer-application)\r\n- [Model Database](#model-database)\r\n  - [Viewer Configurations](#viewer-configurations)\r\n  - [Viewer States](#viewer-states)\r\n- [Programming API](#programming-api)\r\n  - [Creating a Viewer](#creating-a-viewer)\r\n  - [Configuring the Viewer](#configuring-the-viewer)\r\n  - [Querying Projects, Models and Objects](#querying-projects--models-and-objects)\r\n    - [Getting Info on Available Projects](#getting-info-on-available-projects)\r\n    - [Getting Info on a Project](#getting-info-on-a-project)\r\n    - [Getting Info on an Object](#getting-info-on-an-object)\r\n  - [Loading Projects and Models](#loading-projects-and-models)\r\n    - [Loading a Project](#loading-a-project)\r\n    - [Loading a Model](#loading-a-model)\r\n  - [Controlling Viewer State](#controlling-viewer-state)\r\n  - [Saving and Loading BCF Viewpoints](#saving-and-loading-bcf-viewpoints)\r\n- [Customizing Viewer Style](#customizing-viewer-style)\r\n  - [Modal Busy Dialog](#modal-busy-dialog)\r\n  - [Tooltips](#tooltips)\r\n  - [Customizing Appearances of IFC Types](#customizing-appearances-of-ifc-types)\r\n- [xeokit Components Used in the Viewer](#xeokit-components-used-in-the-viewer)\r\n- [Building the Viewer](#building-the-viewer)\r\n  - [Installing from NPM](#installing-from-npm)\r\n  - [Building the Binary](#building-the-binary)\r\n  - [Building the Documentation](#building-the-documentation)\r\n\r\n---\r\n\r\n## Features\r\n\r\n- Uses [xeokit](https://xeokit.io) for efficient model loading and rendering.\r\n- Works in all major browsers, including mobile.\r\n- Loads models from the file system.\r\n- Loads multiple models.\r\n- Saves and loads BCF viewpoints\r\n- 3D and 2D viewing modes.\r\n- Interactively X-ray, highlight, show, hide and section objects.\r\n- Tree views of structure, layers and storeys.\r\n- Full-precision geometry.\r\n- Point clouds.\r\n- Supports IFC2x3 and IFC4.\r\n- Customize viewer appearance with your own CSS.\r\n- JavaScript programming API for all viewer functions.\r\n  |\r\n\r\n## License\r\n\r\nxeokit-bim-viewer is bundled within the [xeokit SDK](http://xeokit.io). See [Pricing](https://xeokit.io/index.html#pricing) for licensing options.\r\n\r\n## The Viewer Application\r\n\r\nThe [`./app/index.html`](https://github.com/xeokit/xeokit-bim-viewer/tree/master/app/index.html) page provides a ready-to-use instance of xeokit-bim-viewer. We'll just call it _viewer_ from now on.\r\n\r\nThe viewer loads projects and models from the [`./app/data`](https://github.com/xeokit/xeokit-bim-viewer/tree/master/app/data) directory.\r\n\r\nTo view a project, load the viewer with the project's ID on the URL:\r\n\r\n[`https://xeokit.github.io/xeokit-bim-viewer/app/index.html?projectId=WestRiversideHospital`](https://xeokit.github.io/xeokit-bim-viewer/app/index.html?projectId=WestRiversideHospital)\r\n\r\n## Model Database\r\n\r\n**This section aims to show you how how to add your own models to the viewer application.**\r\n\r\nLet's examine the structure of the [`./app/data`](https://github.com/xeokit/xeokit-bim-viewer/tree/master/app/data) directory, where the viewer keeps its projects and models.\r\n\r\nShown below is a portion of the `./app/data` directory. We'll describe it from the root directory downwards.\r\n\r\nWithin the root, we have a directory for each project, along with a manifest of the projects in `index.json`.\r\n\r\nWithin a project directory, we have a directory for each model in the project, along with a manifest of the models in `index.json`.\r\n\r\nWithin a model directory, we have two files that comprise the model itself:\r\n\r\n- `geometry.xkt` - the model's geometry, formatted as `.XKT`, which is xeokit's native binary geometry format, and\r\n- `metadata.json` - the model's structural metadata, a JSON file containing the IFC element hierarchy.\r\n\r\n```\r\n.app/data/\r\n└── projects\r\n    ├── index.json\r\n    ├── Duplex\r\n    │   ├── index.json\r\n    │   └── models\r\n    │       └── design\r\n    │           ├── geometry.xkt\r\n    │           └── metadata.json\r\n    └── WestRiversideHospital\r\n          ├── index.json\r\n          └── models\r\n              ├── architecture\r\n              │   ├── geometry.xkt\r\n              │   └── metadata.json\r\n              ├── structure\r\n              │   ├── geometry.xkt\r\n              │   └── metadata.json\r\n              └── electrical\r\n                  ├── geometry.xkt\r\n                  └── metadata.json\r\n```\r\n\r\nThe `index.json` at the root of `./data` is shown below.\r\n\r\nWithin this file, the `id` of each project matches the name of that project's subdirectory.\r\n\r\n```json\r\n{\r\n  \"projects\": [\r\n    {\r\n      \"id\": \"Duplex\",\r\n      \"name\": \"Duplex\",\r\n      \"position\": [-20, 0.0, -10.0],\r\n      \"scale\": [1.0, 1.0, 1.0],\r\n      \"rotation\": [0.0, 0.0, 0.0]\r\n    },\r\n    {\r\n      \"id\": \"WestRiversideHospital\",\r\n      \"name\": \"West Riverside Hospital\",\r\n      \"position\": [20, 0.0, 0.0],\r\n      \"scale\": [1.0, 1.0, 1.0],\r\n      \"rotation\": [0.0, 0.0, 0.0]\r\n    }\r\n    //...\r\n  ]\r\n}\r\n```\r\n\r\nThe `index.json` for the \"WestRiversideHospital\" project is shown below.\r\n\r\nWithin this file, the `id` of each model matches the name of that model's subdirectory. Each model's `name` is the human-readable name that's displayed in the viewers Models tab.\r\n\r\n```json\r\n{\r\n  \"id\": \"WestRiversideHospital\",\r\n  \"name\": \"West Riverside Hospital\",\r\n  \"models\": [\r\n    {\r\n      \"id\": \"architectural\",\r\n      \"name\": \"Hospital Architecture\"\r\n    },\r\n    {\r\n      \"id\": \"structure\",\r\n      \"name\": \"Hospital Structure\"\r\n    },\r\n    {\r\n      \"id\": \"electrical\",\r\n      \"name\": \"Hospital Electrical\",\r\n      \"saoEnabled\": false\r\n    }\r\n  ],\r\n  \"viewerConfigs\": {\r\n    \"backgroundColor\": [0.9, 0.9, 1.0],\r\n    \"saoEnabled\": true\r\n  },\r\n  \"viewerContent\": {\r\n    \"modelsLoaded\": [\"structure\", \"architectural\"]\r\n  },\r\n  \"viewerState\": {\r\n    \"tabOpen\": \"models\"\r\n  }\r\n}\r\n```\r\n\r\nThe optional `viewerConfigs` section specifies configurations for the viewer to set on itself as it loads the project. See the complete list of available viewer configurations in [Viewer Configurations](#viewer-configurations).\r\n\r\nThe optional `viewerContent` array specifies IDs of models that the viewer will load initially, right after it's applied the configurations.\r\n\r\nThe optional `viewerState` section specifies how the viewer should set up the initial state of its UI, right after its loaded the initial models. See the complete list of available viewer states in [Viewer States](#viewer-states).\r\n\r\nThe `geometry.xkt` and `metadata.json` files for each model are created from an IFC file using open source CLI tools. Learn how to create those files in the [Creating Files for Offline BIM](https://github.com/xeokit/xeokit-sdk/wiki/Creating-Files-for-Offline-BIM) tutorial.\r\n\r\nWhile not essential, you can learn about the format of an `.xkt` geometry file in [XKT Format](https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format) specification.\r\n\r\n### Viewer Configurations\r\n\r\nThe table below lists the complete set of available configurations. Think of these as user preferences. These may be provided to the viewer within project info files, as described in [Model Database](#model-database), or set programmatically on the viewer with [`BIMViewer#setConfigs()`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/BIMViewer.js~BIMViewer.html#instance-method-setConfigs), as described in [Configuring the Viewer](#configuring-the-viewer).\r\n\r\n| Property            | Type    | Range             | Default Value   | Description                                                                                                      |\r\n| :------------------ | :------ | :---------------- | :-------------- | :--------------------------------------------------------------------------------------------------------------- |\r\n| \"backgroundColor\"   | Array   |                   | `[1.0,1.0,1.0]` | Canvas background color                                                                                          |\r\n| \"cameraNear\"        | Number  | `[0.01-0.1]`      | `0.05`          | Distance to the near clipping plane                                                                              |\r\n| \"cameraFar\"         | Number  | `[1-10000]`       | `3000.0`        | Distance to the far clipping plane                                                                               |\r\n| \"smartPivot\"        | Boolean |                   | `true`          | Enables a better pivot-orbiting experience when click-dragging on empty space in camera orbit mode.              |\r\n| \"saoEnabled\"        | Boolean |                   | `false`         | Whether or not to enable Scalable Ambient Obscurance (SAO)                                                       |\r\n| \"saoBias\"           | Number  | `[0.0...10.0]`    | `0.5`           | SAO bias                                                                                                         |\r\n| \"saoIntensity\"      | Number  | `[0.0...200.0]`   | `100.0`         | SAO intensity factor                                                                                             |\r\n| \"saoScale\"          | Number  | `[0.0...1000.0]`  | `500.0`         | SAO scale factor                                                                                                 |\r\n| \"saoKernelRadius\"   | Number  | `[0.0...200.0]`   | `100.0`         | The maximum area that SAO takes into account when checking for possible occlusion                                |\r\n| \"saoBlur\"           | Boolean |                   | `true`          | Whether Guassian blur is enabled for SAO                                                                         |\r\n| \"edgesEnabled\"      | Boolean |                   | `true`          | Whether or not to enhance edges on objects                                                                       |\r\n| \"pbrEnabled\"        | Boolean |                   | `false`         | Whether or not to enable Physically Based rendering (PBR)                                                        |\r\n| \"viewFitFOV\"        | Number  | `[10.0...70.0]`   | `30`            | When fitting objects to view, this is the amount in degrees of how much they should fit the user's field of view |\r\n| \"viewFitDuration\"   | Number  | `[0..5]`          | `0.5`           | When fitting objects to view with an animated transition, this is the duration of the transition in seconds      |\r\n| \"perspectiveFOV\"    | Number  | `[10.0...70.0]`   | `55`            | When in perspective projection, this is the field of view, in degrees, that the user sees                        |\r\n| \"objectColorSource\" | String  | \"model\", \"viewer\" | \"model\"         | Where the colors for model objects will be loaded from                                                           |\r\n\r\n### Viewer States\r\n\r\nIn [Model Database](#model-database) we saw how a project can specify directives for how the viewer should set up the initial state of its UI, right after the project has loaded. The table below lists the available directives. These can also be set on the viewer using [`BIMViewer#setViewerState()`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/BIMViewer.js~BIMViewer.html#instance-method-setViewerState). So far, we have:\r\n\r\n| Property            | Type                                            | Range                             | Default Value | Description                           |\r\n| :------------------ | :---------------------------------------------- | :-------------------------------- | :------------ | :------------------------------------ |\r\n| \"focusObject\"       | String                                          |                                   |               | ID of object to focus on              |\r\n| \"tabOpen\"           | String                                          | \"objects\", \"classes\" or \"storeys\" |               | Which explorer tab to open            |\r\n| \"expandObjectsTree\" | Number                                          | [0..*]                            | 0             | How deep to expand the \"objects\" tree |\r\n| \"expandClassesTree\" | Number                                          | [0..*]                            | 0             | How deep to expand the \"classes\" tree |\r\n| \"expandStoreysTree\" | Number                                          | [0..*]                            | 0             | How deep to expand the \"storeys\" tree |\r\n| \"setCamera\"         | { eye: Number[], look: Number[], up: Number[] } |                                   | 0             | Camera position                       |\r\n\r\n## Programming API\r\n\r\n**This section goes deeper into the viewer, describing how to instantiate a viewer, and how to use its JavaScript programming API.**\r\n\r\nThe viewer is implemented by the JavaScript [`BIMViewer`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/BIMViewer.js~BIMViewer.html) class, which provides a complete set of methods to programmatically control it.\r\n\r\nUsing these methods, we can:\r\n\r\n- create and configure a viewer,\r\n- query what models are available,\r\n- load projects and models,\r\n- interact with the 3D view,\r\n- save and load BCF viewpoints,\r\n- control the various viewer tools, and\r\n- drive the state of the viewer's UI.\r\n\r\n### Creating a Viewer\r\n\r\nIn the example below, we'll create a [`BIMViewer`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/BIMViewer.js~BIMViewer.html), with a [`Server`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/server/Server.js~Server.html) through which it will load projects and models from the file system.\r\n\r\nWe'll configure the `Server` to load that data from the [`./app/data`](https://github.com/xeokit/xeokit-bim-viewer/tree/master/app/data) directory.\r\n\r\nWe'll also configure our `BimViewer` with DOM elements to hold the four parts of its UI, which are:\r\n\r\n1. the 3D canvas,\r\n2. the explorer panel containing the tree views,\r\n3. the toolbar,\r\n4. the NavCube, and\r\n5. the \"backdrop\" element, which covers everything in the UI to prevent interaction whenever the viewer is busy loading a model.\r\n\r\n```javascript\r\nconst server = new Server({\r\n  dataDir: \"./data\",\r\n});\r\n\r\nconst myBIMViewer = new BIMViewer(server, {\r\n  canvasElement: document.getElementById(\"myCanvas\"), // The 3D WebGL canvas\r\n  explorerElement: document.getElementById(\"myExplorer\"), // Container for the explorer panel\r\n  toolbarElement: document.getElementById(\"myToolbar\"), // Container for the toolbar\r\n  navCubeCanvasElement: document.getElementById(\"myNavCubeCanvas\"), // Canvas for the NavCube\r\n  busyModelBackdropElement: document.querySelector(\r\n    \".xeokit-busy-modal-backdrop\"\r\n  ), // Busy modal dialog backdrop element\r\n});\r\n```\r\n\r\nConfiguring the `BIMViewer` with separate places to locate its parts allows us to integrate them more flexibly into our web page.\r\n\r\nIn our [`app/index.html`](https://github.com/xeokit/xeokit-bim-viewer/blob/master/app/index.html) page, the HTML elements look like this:\r\n\r\n```html\r\n<div id=\"myViewer\" class=\"xeokit-busy-modal-backdrop\">\r\n  <div id=\"myExplorer\" class=\"active\"></div>\r\n  <div id=\"myContent\">\r\n    <div id=\"myToolbar\"></div>\r\n    <canvas id=\"myCanvas\"></canvas>\r\n  </div>\r\n</div>\r\n<canvas id=\"myNavCubeCanvas\"></canvas>\r\n```\r\n\r\nSee [`app/css/style.css`](https://github.com/xeokit/xeokit-bim-viewer/blob/master/app/css/style.css) for how we've styled these elements.\r\n\r\nAlso see [`css/BIMViewer.css`](https://github.com/xeokit/xeokit-bim-viewer/blob/master/css/BIMViewer.css) for the CSS styles that BIMViewer applies to the elements it creates internally.\r\n\r\n### Configuring the Viewer\r\n\r\nWith our viewer created, let's use [`BIMViewer#setConfigs()`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/BIMViewer.js~BIMViewer.html#instance-method-setConfigs) to configure it.\r\n\r\nWe'll enable Scalable Ambient Obscurance and set the canvas background color to white:\r\n\r\n```javascript\r\nmyBIMViewer.setConfigs({\r\n  saoEnabled: \"white\",\r\n  backgroundColor: [1.0, 1.0, 1.0],\r\n});\r\n```\r\n\r\nSee [Viewer Configurations](#viewer-configurations) for the list of available configurations.\r\n\r\n### Querying Projects, Models and Objects\r\n\r\nWith our viewer created and configured, let's find out what content is available.\r\n\r\n#### Getting Info on Available Projects\r\n\r\nLet's query what projects are available.\r\n\r\n```javascript\r\nmyBIMViewer.getProjectsInfo((projectsInfo) => {\r\n  console.log(JSON.stringify(projectsInfo, null, \"\\t\"));\r\n});\r\n```\r\n\r\nInternally, the viewer will call [`Server#getProjects()`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/server/Server.js~Server.html#instance-method-getProjects) to get the projects info.\r\n\r\nAs described earlier in [Model Database](#model-database), the projects info is the JSON in [`./app/data/projects/index.json`](https://github.com/xeokit/xeokit-bim-viewer/tree/master/app/data/projects/index.json). We'll just log that info to the console.\r\n\r\nThe projects info will look similar to:\r\n\r\n```json\r\n{\r\n  \"projects\": [\r\n    {\r\n      \"id\": \"Duplex\",\r\n      \"name\": \"Duplex\"\r\n    },\r\n    {\r\n      \"id\": \"Schependomlaan\",\r\n      \"name\": \"Schependomlaan\"\r\n    },\r\n    {\r\n      \"id\": \"WestRiversideHospital\",\r\n      \"name\": \"West Riverside Hospital\"\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n#### Getting Info on a Project\r\n\r\nNow we know what projects are available, we'll get info on one of those projects.\r\n\r\n```javascript\r\nmyBIMViewer.getProjectInfo(\"WestRiversideHospital\", (projectInfo) => {\r\n  console.log(JSON.stringify(projectInfo, null, \"\\t\"));\r\n});\r\n```\r\n\r\nInternally, the viewer will call [`Server#getProject()`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/server/Server.js~Server.html#instance-method-getProject) to get that project info. Like before, we'll just log it to the console.\r\n\r\nThe project info will be the contents of [`./app/data/projects/WestRiversideHospital/index.json`](https://github.com/xeokit/xeokit-bim-viewer/tree/master/app/data/projects/WestRiversideHospital/index.json).\r\n\r\nThe project info will be similar to:\r\n\r\n```json\r\n{\r\n  \"id\": \"WestRiversideHospital\",\r\n  \"name\": \"West Riverside Hospital\",\r\n  \"models\": [\r\n    {\r\n      \"id\": \"architectural\",\r\n      \"name\": \"Hospital Architecture\"\r\n    },\r\n    {\r\n      \"id\": \"structure\",\r\n      \"name\": \"Hospital Structure\"\r\n    },\r\n    {\r\n      \"id\": \"electrical\",\r\n      \"name\": \"Hospital Electrical\",\r\n      \"saoEnabled\": false\r\n    }\r\n  ],\r\n  \"viewerConfigs\": {\r\n    \"backgroundColor\": [0.9, 0.9, 1.0],\r\n    \"saoEnabled\": true\r\n  },\r\n  \"viewerContent\": {\r\n    \"modelsLoaded\": [\"structure\", \"architectural\"]\r\n  },\r\n  \"viewerState\": {\r\n    \"tabOpen\": \"models\"\r\n  }\r\n}\r\n```\r\n\r\nIn this project info, we have:\r\n\r\n- **`id`** - ID of the project,\r\n- **`name`** - human-readable name of the project,\r\n- **`models`** - info on each model in this project,\r\n- **`viewerConfigs`** - configurations for the viewer to apply when loading the project,\r\n- **`viewerContent`** - which models the viewer should immediately load when loading the project, and\r\n- **`viewerState`** - how the viewer should set up its UI after loading the project.\r\n\r\nWhen we later load the project in section [Loading a Project](#loading_a_project), the viewer is going to pass the `viewerConfigs` to [`BIMViewer#setConfigs()`](https://xeokit.github.io/xeokit-sdk/docs/class/src/BIMViewer.js~BIMViewer.html#instance-method-setConfigs), which we described earlier in [Configuring the Viewer](#configuring-the-viewer).\r\n\r\nIn the `viewerConfigs` we're enabling the viewer's Scalable Ambient Obscurance effect, which will create ambient shadows in the crevices of our models. This is an expensive effect for the viewer to render, so we've disabled it for the \"electrical\" model, which contains many long, thin wire objects that don't show the SAO effect well.\r\n\r\n#### Getting Info on an Object\r\n\r\nLet's attempt to get some info on an object within one of our project's models.\r\n\r\nWe say \"attempt\" because it's up to the [`Server`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/server/Server.js~Server.html) to try to find that info for us, which might not exist.\r\n\r\nInternally, the viewer will call [`Server#getObjectInfo()`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/server/Server.js~Server.html#instance-method-getObjectInfo), which will attempt to load that object info from a file.\r\n\r\nIf you were to substitute `Server` with your own implementation, your implementation might get that info from a data store, such as a relational database, populated with metadata for all the objects in your project's models, keyed to their IDs.\r\n\r\nWe'll go ahead and assume that our `Server` has info an an object.\r\n\r\n```javascript\r\nmyViewer.getObjectInfo(\r\n  \"WestRiversideHospital\",\r\n  \"architectural\",\r\n  \"2HaS6zNOX8xOGjmaNi_r6b\",\r\n  (objectInfo) => {\r\n    console.log(JSON.stringify(objectInfo, null, \"\\t\"));\r\n  },\r\n  (errMsg) => {\r\n    console.log(\r\n      \"Oops! There was an error getting info for this object: \" + errMsg\r\n    );\r\n  }\r\n);\r\n```\r\n\r\nIf the object does not exist in the specified project and model, the method will invoke its error callback.\r\n\r\nOur file system database does happen to have info for that object, stored in [`./app/data/projects/WestRiversideHospital/models/architectural/objects/2HaS6zNOX8xOGjmaNi_r6b.json`](https://github.com/xeokit/xeokit-bim-viewer/tree/master/app/data/projects/WestRiversideHospital/models/architectural/objects/2HaS6zNOX8xOGjmaNi_r6b.json).\r\n\r\nSince our object info exists, we'll get a result similar to this:\r\n\r\n```json\r\n{\r\n  \"id\": \"2HaS6zNOX8xOGjmaNi_r6b\",\r\n  \"projectId\": \"WestRiversideHospital\",\r\n  \"modelId\": \"architectural\",\r\n  \"name\": \"Basic Wall:Exterior - Metal Panel on Mtl. Stud:187578\",\r\n  \"type\": \"IfcWall\",\r\n  \"parent\": \"2hExBg8jj4NRG6zzD0RZML\"\r\n}\r\n```\r\n\r\n> By now, you've probably noticed that our file system database is structured to support [RESTful](https://en.wikipedia.org/wiki/Representational_state_transfer) URIs, which our [`Server`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/server/Server.js~Server.html) constructs from the project, model and object IDs we supplied to the viewer's query methods.\r\n\r\n### Loading Projects and Models\r\n\r\nLet's now load some of the projects and models that we queried in the previous section.\r\n\r\n#### Loading a Project\r\n\r\nLet's start by loading the project we just queried info on.\r\n\r\n```javascript\r\nmyBIMViewer.loadProject(\r\n  \"WestRiversideHospital\",\r\n  () => {\r\n    console.log(\"Nice! The project loaded successfully.\");\r\n  },\r\n  (errMsg) => {\r\n    console.log(\"Oops! There was an error loading this project: \" + errMsg);\r\n  }\r\n);\r\n```\r\n\r\nIf that succeeds, the viewer will now have two models loaded, `\"architectural\"` and `\"structure\"`, since those are specified in the project info's `viewerContent`.\r\n\r\nThe viewer will also enable Scalable Ambient Obscurance, since that's specified by the `saoEnabled` property in the `viewerConfigs`. The viewer will also set various other configs on itself, as specified in that section.\r\n\r\nThe viewer will also open its \"Models\" tab, thanks to the `tabOpen` property in the project info's `viewerState` section.\r\n\r\nWe can confirm that the two models are loaded by querying the IDs of the models that are currently loaded in the viewer:\r\n\r\n```javascript\r\nconst modelIds = myBIMViewer.getModelLoadedIds();\r\n\r\nconsole.log(modelIds);\r\n```\r\n\r\nThe result would be:\r\n\r\n```json\r\n[\"architectural\", \"structure\"]\r\n```\r\n\r\n#### Loading a Model\r\n\r\nWith our project loaded, let's load another of its models.\r\n\r\nWe could start by getting the IDs of all the models in our project, just to make sure the model is available:\r\n\r\n```javascript\r\nconst modelIds = myBIMViewer.getModelIds();\r\n\r\nconsole.log(modelIds);\r\n```\r\n\r\nThe result would be:\r\n\r\n```json\r\n[\"architectural\", \"structure\", \"electrical\"]\r\n```\r\n\r\nTo load the model:\r\n\r\n```javascript\r\nmyBIMViewer.loadModel(\r\n  \"electrical\",\r\n  () => {\r\n    console.log(\"Nice! The model loaded successfully.\");\r\n  },\r\n  (errMsg) => {\r\n    console.log(\"Oops! There was an error loading this model: \" + errMsg);\r\n  }\r\n);\r\n```\r\n\r\nIf we no longer need that model, we can unload it again:\r\n\r\n```javascript\r\nmyBIMViewer.unloadModel(\"electrical\");\r\n```\r\n\r\nWhen we no longer need the project, unload like so:\r\n\r\n```javascript\r\nmyBIMViewer.unloadProject();\r\n```\r\n\r\nNote that we can only load one project at a time.\r\n\r\n### Controlling Viewer State\r\n\r\n[`BIMViewer`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/BIMViewer.js~BIMViewer.html) has various methods with which we can programmatically control the state of its UI.\r\n\r\nLet's take a quick look at some of these methods to get an idea of what sort of UI state we can control with them. This won't be an exhaustive guide - see the `BIMViewer` class documentation for the complete list.\r\n\r\nHaving loaded a couple of models in the previous section, let's open the viewer's Objects tab, which contains a tree view of the containment hierarchy of the objects within those models:\r\n\r\n```javascript\r\nmyBIMViewer.openTab(\"objects\");\r\n```\r\n\r\nTo confirm which tab is currently open:\r\n\r\n```javascript\r\nconst tabId = myBIMViewer.getOpenTab();\r\n\r\nconsole.log(\"Currently open tab: '\" + tabId + \"'\"); // \"objects\"\r\n```\r\n\r\nNow let's arrange the camera to fit an object in view:\r\n\r\n```javascript\r\nmyBIMViewer.flyToObject(\"1fOVjSd7T40PyRtVEklS6X\", () => {\r\n  /* Done */\r\n});\r\n```\r\n\r\nTODO: Complete this section once API methods are finalized\r\n\r\n### Saving and Loading BCF Viewpoints\r\n\r\n[Bim Collaborative Format](https://en.wikipedia.org/wiki/BIM_Collaboration_Format) (BCF) is a format for managing issues on a BIM project. A BCF record captures the visual state of a BIM viewer, which includes the camera position, the visibility and selected states of the objects, and any section planes that are currently active.\r\n\r\nA BCF record saved from one BIM viewer can be loaded into another viewer, to synchronize the visual states of both viewers.\r\n\r\nNote that BCF viewpoints do not record which models are currently loaded. It's assumed that both the source and target viewers have the same models loaded.\r\n\r\nUse the [`BIMViewer#saveBCFViewpoint()`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/BIMViewer.js~BIMViewer.html#instance-method-saveBCFViewpoint) to save a JSON BCF record of the current view:\r\n\r\n```javascript\r\nconst viewpoint = bimViewer.saveBCFViewpoint({\r\n  // Options - see BIMViewer#saveBCFViewpoint() documentation for details\r\n});\r\n```\r\n\r\nOur viewpoint JSON will look similar to below. Before saving this viewpoint, we've hidden one object, selected another object, and created section plane to slice our model. The viewpoint also contains a PNG snapshot of the viewer's canvas, which we've truncated here for brevity.\r\n\r\n```\r\n{\r\n    perspective_camera: {\r\n        camera_view_point: { x: 0.0, y: 0.0, z: 0.0 },\r\n        camera_direction: { x: 1.0, y: 1.0, z: 2.0 },\r\n        camera_up_vector: { x: 0.0, y: 0.0, z: 1.0 },\r\n        field_of_view: 90.0\r\n    },\r\n    lines: [],\r\n    clipping_planes: [{\r\n        location: { x: 0.5, y: 0.5, z: 0.5 },\r\n        direction: { x: 1.0, y: 0.0, z: 0.0 }\r\n    }],\r\n    bitmaps: [],\r\n    snapshot: {\r\n        snapshot_type: png,\r\n        snapshot_data: \"data:image/png;base64,......\"\r\n    },\r\n    components: {\r\n        visibility: {\r\n            default_visibility: false,\r\n            exceptions: [{\r\n                ifc_guid: 4$cshxZO9AJBebsni$z9Yk,\r\n                originating_system: xeokit.io,\r\n                authoring_tool_id: xeokit/v1.0\r\n            }]\r\n       },\r\n        selection: [{\r\n           ifc_guid: \"4$cshxZO9AJBebsni$z9Yk\",\r\n        }]\r\n    }\r\n}\r\n```\r\n\r\nUse the [`BIMViewer#loadBCFViewpoint()`](https://xeokit.github.io/xeokit-bim-viewer/docs/class/src/BIMViewer.js~BIMViewer.html#instance-method-loadBCFViewpoint) to load a JSON BCF record:\r\n\r\n```javascript\r\nbimViewer.loadBCFViewpoint(viewpoint, {\r\n  // Options - see BIMViewer#loadBCFViewpoint() documentation for details\r\n});\r\n```\r\n\r\n## Customizing Viewer Style\r\n\r\nThe [`app/index.html`](https://github.com/xeokit/xeokit-bim-viewer/blob/master/app/index.html) file for the standalone viewer contains CSS rules for the various viewer elements, which you can modify as required.\r\n\r\n### Modal Busy Dialog\r\n\r\nThe viewer displays a modal dialog box whenever we load a model. The dialog box has a backdrop element, which overlays the viewer. Whenever the dialog becomes visible, the backdrop will block interaction events on the viewer's UI.\r\n\r\nWithin our [`app/index.html`](https://github.com/xeokit/xeokit-bim-viewer/blob/master/app/index.html) page, the main `<div>` is the backdrop element:\r\n\r\n```html\r\n<div id=\"myBIMViewer\" class=\"xeokit-busy-modal-backdrop\">\r\n  <div id=\"myExplorer\" class=\"active\"></div>\r\n  <div id=\"myContent\">\r\n    <div id=\"myToolbar\"></div>\r\n    <canvas id=\"myCanvas\"></canvas>\r\n  </div>\r\n</div>\r\n<canvas id=\"myNavCubeCanvas\"></canvas>\r\n```\r\n\r\nAs defined in [`css/BIMViewer.css`](https://github.com/xeokit/xeokit-bim-viewer/blob/master/css/BIMViewer.css), the backdrop gets the following style, which allows the dialog to position itself correctly within the backdrop:\r\n\r\n```css\r\n.xeokit-busy-modal-backdrop {\r\n  position: relative;\r\n}\r\n```\r\n\r\nIf you need to tweak CSS relating to the dialog, search for \"xeokit-busy-dialog\" within [`css/BIMViewer.css`](https://github.com/xeokit/xeokit-bim-viewer/blob/master/css/BIMViewer.css).\r\n\r\n### Tooltips\r\n\r\nTooltips are not part of the core JavaScript for the viewer. Instead, viewer HTML elements are marked with `data-tippy-content` attributes that provide strings to show in their tooltips.\r\n\r\nFor example, the _Toggle 2D/3D_ button's element looks like this:\r\n\r\n```html\r\n<button\r\n  type=\"button\"\r\n  class=\"xeokit-threeD xeokit-btn fa fa-cube fa-2x\"\r\n  data-tippy-content=\"Toggle 2D/3D\"\r\n></button>\r\n```\r\n\r\nIn the [app/index.html](https://github.com/xeokit/xeokit-bim-viewer/blob/master/app/index.html) file for the standalone viewer, we're using [tippy.js](https://github.com/atomiks/tippyjs), which automatically creates tooltips for those elements.\r\n\r\n### Customizing Appearances of IFC Types\r\n\r\nTODO: Correct this section - viewer can load from model and viewer\r\n\r\nThe viewer loads colors for the various IFC element types straight from the IFC model, except where overrides are defined in the configuration file [`./src/IFCObjectDefaults/ViewerIFCObjectColors.js`](https://github.com/xeokit/xeokit-bim-viewer/blob/master/src/IFCObjectDefaults/ViewerIFCObjectColors.js).\r\n\r\nYou can add or remove configurations in that file if you need to customize the color and pickability of specific IFC types.\r\n\r\nFor example, to ensure that `IfcWindow` and `IfcSpace` types are initially visible, transparent and pickable (ie. able to be selected by clicking on them), you might configure that file as shown below:\r\n\r\n```javascript\r\nconst IFCObjectDefaults = {\r\n  IfcSpace: {\r\n    visible: true,\r\n    pickable: true,\r\n    opacity: 0.2,\r\n  },\r\n  IfcWindow: {\r\n    visible: true,\r\n    pickable: true,\r\n    opacity: 0.5,\r\n  },\r\n};\r\n\r\nexport { IFCObjectDefaults };\r\n```\r\n\r\nSometimes IFC models have opaque `IfcWindow` and `IfcSpace` elements, so it's a good idea to have configurations in there so that we can see through them.\r\n\r\n## xeokit Components Used in the Viewer\r\n\r\nThe viewer is built on various [xeokit SDK](http://xeokit.io) components and plugins that are designed to accelerate the development of BIM and CAD visualization apps.\r\n\r\nThe table below lists the main ones used in this viewer.\r\n\r\n| Component                                                                                                                                               | Purpose                                                                                                                       |\r\n| :------------------------------------------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------- |\r\n| [`Viewer`](https://xeokit.github.io/xeokit-sdk/docs/class/src/viewer/Viewer.js~Viewer.html)                                                             | The WebGL-based viewer at the heart of `BIMViewer`.                                                                           |\r\n| [`XKTLoaderPlugin`](https://xeokit.github.io/xeokit-sdk/docs/class/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js~XKTLoaderPlugin.html)                 | Loads model geometry and metadata.                                                                                            |\r\n| [`NavCubePlugin`](https://xeokit.github.io/xeokit-sdk/docs/class/src/plugins/NavCubePlugin/NavCubePlugin.js~NavCubePlugin.html)                         | Navigation cube gizmo that allows us to rotate the scene and move the camera to look at it along a selected axis or diagonal. |\r\n| [`TreeViewPlugin`](https://xeokit.github.io/xeokit-sdk/docs/class/src/plugins/TreeViewPlugin/TreeViewPlugin.js~TreeViewPlugin.html)                     | Implements the Objects, Classes and Storeys tree views within the explorer panel.                                             |\r\n| [`SectionPlanesPlugin`](https://xeokit.github.io/xeokit-sdk/docs/class/src/plugins/SectionPlanesPlugin/SectionPlanesPlugin.js~SectionPlanesPlugin.html) | Manages interactive section planes, which are used to slice objects to reveal inner structures.                               |\r\n| [`BCFViewpointsPlugin`](https://xeokit.github.io/xeokit-sdk/docs/class/src/plugins/BCFViewpointsPlugin/BCFViewpointsPlugin.js~BCFViewpointsPlugin.html) | Saves and loads BCF viewpoints.                                                                                               |\r\n| [`ContextMenu`](https://xeokit.github.io/xeokit-sdk/docs/class/src/extras/ContextMenu/ContextMenu.js~ContextMenu.html)                                  | Implements the context menus for the explorer tree views and 3D canvas.                                                       |\r\n\r\n## Building the Viewer\r\n\r\n### Installing from NPM\r\n\r\nTo install the npm package:\r\n\r\n```\r\nnpm i @xeokit/xeokit-bim-viewer\r\n```\r\n\r\n### Building the Binary\r\n\r\nTo build the ES6 module in `/dist/xeokit-bim-viewer.es.js`:\r\n\r\n```\r\nnpm run build\r\n```\r\n\r\n### Building the Documentation\r\n\r\nTo build the API documentation in `/docs/`:\r\n\r\n```\r\nnpm run docs\r\n```\r\n","readmeFilename":"README.md"}