Viewing glTF using xeoconvert and XGFLoader
Introduction
In this tutorial, we'll view a glTF model in the browser using a xeokit Viewer
@xeokit/sdk / viewer / Viewer / Class Viewer 3D model viewer. @xeokit/sdk / data / DataModelParams / Interface DataModelParams Parameters used to define a DataModel.
- Use
xeoconvert
with option--pipeline ifc2xgf
to convert glTF into XGF and JSON DataModelParams files. - Use XGFLoader
@xeokit/sdk / xgf / XGFLoader /
Class XGFLoader
Loads an XGF file into a SceneModel and/or a DataModel.
and DataModelParamsLoader@xeokit/sdk / data / DataModelParamsLoader /
Class DataModelParamsLoader
Reads DataModelParams into a DataModel.
to load the XGF and JSON DataModelParams@xeokit/sdk / data / DataModelParams /
Interface DataModelParams
Parameters used to define a DataModel.
files into a xeokit Viewer in a webpage.
Example glTF Model
For this tutorial, we'll use the Duplex glTF model (source: http://drumbeat.cs.hut.fi/ifc/
).
Below is the final result— the model loaded from XGF and DataModelParams JSON files into a xeokit Viewer. In the following steps, we'll walk through the process of achieving this.

Viewing a glTF Model, Converted to XKF by gltf2xgf
Step 1. Convert glTF into XGF and DataModelParams Files
The first step is to convert our glTF file into an XGF file for geometry and JSON DataModelParams file for the glTF scene metadata. We'll use the xeoconvert CLI tool to do this conversion step:
npm xeoconvert --pipeline gltf2xgf --gltf model.glb --xgf model.xgf --datamodel model.json
The parameters we provided the tool are:
--pipeline
selects the conversion pipeline,gltf2xgf
--gltf
path to source glTF file--xkt
path to target XKT file--datamodel
path to target DataModelParams@xeokit/sdk / data / DataModelParams /
Interface DataModelParams
Parameters used to define a DataModel.
file (optional)
Step 2. View the XGF and DataModelParams Files
Now we'll create a Web page containing a xeokit Viewer
@xeokit/sdk / viewer / Viewer / Class Viewer 3D model viewer.
HTML
Create an HTML page in index.html
that contains a canvas element:
example-html:ifc2xgf_Duplex
JavaScript
Then create JavaScript in @xeokit/sdk / viewer / Viewer / Class Viewer 3D model viewer.index.js
to create the Viewer
The steps in the JavaScript are as follows.
example-javascript:ifc2xgf_Duplex