-
Notifications
You must be signed in to change notification settings - Fork 294
Creating Files for Offline BIM
See also:
- xeokit-bim-viewer - xeokit's bundled BIM viewer, the fastest way to deploy your BIM models to the Web
- Viewing BIM Models Offline - a quick guide to building your own custom BIM viewer
In this tutorial you'll learn how to convert your model from an IFC STEP file (either IFC2x3 or IFC4) to geometry and metadata files that can be efficiently loaded into xeokit, straight off the file system, without relying on cloud storage or a BIM model server.
To view your model, you can then use xeokit-bim-viewer, which is the fastest way to get your model on the Web. To use that option, you just need to fork that repository, drop in your model, add some JSON to register it, and you're good to go.
Or, if you're building your custom viewer, you can plug it together yourself from xeokit SDK components and plugins, as described in Viewing BIM Models Offline.
We'll use an IFC2x3 model from the OTC Conference Center dataset. Note that we could also use IFC4.
Note that, for this tutorial, we've renamed our IFC file to OTCConferenceCenter.ifc
, just to strip out the spaces in the filename and make it more readable.
We'll use these CLI tools to transform the IFC file into an .XKT
file:
- ifcConvert (v0.6.0 or later) to convert IFC files to DAE
- COLLADA2GLTF to convert DAE to glTF
- xokit-gktf-to-xkt to convert glTF into XKT
We'll assume that these are installed relative to the current working directory.
Convert the IFC file into a COLLADA file:
./IfcConvert --use-element-guids OTCConferenceCenter.ifc OTCConferenceCenter.dae
Note the use-element-guids
option, which ensures that the IFC product IDs are preserved in the glTF.
Sometimes the coordinates within an IFC model are translated far from the origin, which can cause the model to become distorted when later converted into XKT
format (see Step 5 below).
If that happens, try adding the --center-model
option, which makes IfcConvert
center the model at [0,0,0]
:
./IfcConvert --use-element-guids --center-model OTCConferenceCenter.ifc OTCConferenceCenter.dae
Sometimes IfcSpace
elements may be missing in your converted model.
IfcConvert
will exclude IfcSpace
elements by default. Try running it with an --exclude=entities
argument, to explicitly override that exclusion. Make sure that argument is the last argument on the command.
ifcconvert --use-element-guids OTCConferenceCenter.ifc OTCConferenceCenter.dae --exclude=entities IfcOpeningElement
Then convert the COLLADA into a glTF 2.0 file:
./COLLADA2GLTF/build/COLLADA2GLTF-bin -i OTCConferenceCenter.dae -o OTCConferenceCenter.gltf
The glTF file will be a single text file with its geometry data embedded within it.
Now convert the glTF into an XKT
file:
gltf2xkt.js -s OTCConferenceCenter.gltf -o OTCConferenceCenter.xkt
or
node gltf2xkt.js -s OTCConferenceCenter.gltf -o OTCConferenceCenter.xkt
Now we have the model geometry in a compact format that can be loaded efficiently into xeokit. Next, we'll create the JSON metadata file that we'll be loading alongside the XKT file.
Download and install xeokit-metadata, which we'll use to extract the structural hierarchy of the building elements within an IFC
file into xeokit's metadata format.
xeokit-metadata OTCConferenceCenter.ifc OTCConferenceCenter.json
Now we have an XKT
file that describes the model geometry, along with a JSON file that specifies
metadata for it.
At this point, as mentioned, we have two options for getting our BIM model on the Web:
- deploy the model in a fork of xeokit-bim-viewer, xeokit's bundled IFC viewer, or
- create our own viewer using xeokit components, as described in Viewing BIM Models Offline.
Everything here is well-tested and used in production by a bunch of xeokit users, so we're confident that this process can work well for you.
Sometimes, however, users have benefited from a short consultation to get them started.
xeolabs can help you with:
- Identifying issues in your IFC models
- Optimizing your models for fast loading and rendering
- Setting up the model conversion tools
- Setting up a xeokit-bim-viewer with your models
- Pointers on using the xeokit SDK to build your custom solution
Get in touch if you could use a little help getting started.