Skip to content

XKTLoaderPlugin

xeolabs edited this page Jul 17, 2019 · 3 revisions

See also:

Introduction

The XKTLoaderPlugin loads models from xeokit's optimized .xkt format. The .xkt format is a single BLOB, compressed using geometry quantization and zlib. See XKT Format for the format specification.

Use the xeokit-gltf-to-xkt tool to convert your glTF files to .xkt format.

The xeokit-gltf-to-xkt tool and the XKTLoaderPlugin are based on prototypes by Toni Marti at uniZite - find the original discussion around those prototypes here.

Contents

Features

  • Loads models efficiently from a compact format optimized for xeokit.
  • Load multiple models into the same scene.
  • Set the position, scale and rotation of each model as you load it.
  • Optionally load accompanying IFC metadata for each model. [Run example]
  • Filter which IFC types get loaded. [Run example]
  • Configure initial default appearances for IFC types. [Run example]
  • Set a custom data source for .xkt and IFC metadata files. [Run example]

Limitations

  • Does not support textures or physically-based materials.
  • Represents each loaded model model with a PerformanceModel, which does not retain geometry in browser memory (meaning you can't access the geometry data once it's loaded).

Example

XKTLoaderPlugin

import {Viewer} from "../src/viewer/Viewer.js";
import {XKTLoaderPlugin} from "../src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js";

const viewer = new Viewer({
   canvasId: "myCanvas"
});

const xktLoader = new XKTLoaderPlugin(viewer);

const model = xktLoader.load({ 
   id: "myModel",
   src: "./models/xkt/OTCConferenceCenter/OTCConferenceCenter.xkt",
   metaModelSrc: "./metaModels/OTCConferenceCenter/metaModel.json"
});

Creating .xkt Files

To create .xkt files, we transform them from glTF using the Node.js-based xeokit-gltf-to-xkt tool.

This tool currently only works with glTF files with base64-encoded binary data embedded in the JSON.

If the glTF was created from IFC files using the techniques described in Creating Files for Offline BIM, then the IDs of the objects in the .xkt will continue to have the original product IDs from the IFC files.

Performance

File Sizes

The glTF files are not compact, since their geometry is represented as buffers containing uncompressed floating-point values, embedded within the JSON as base-64 strings.

Once converted to .xkt, however, models are much more compact. The geometry positions are quantized to 16-bit integers, the normals are oct-encoded to 8-bit integers, and then all the data is further compressed using pako, which uses the lossless Deflate data compression algorithm.

Model Triangles glTF .xkt
Duplex 66M 1.4 MB 0.4 MB
Schependomlaan 66M 23.1 MB 1.7 MB
OTCConferenceCenter 66M 48.4 MB 8.5 MB

Loading Times

The table below shows comparative loading times for our three test models. Note that these times include the time taken to load the accompanying IFC JSON file for each model.

Note also that in our examples the xeokit JavaScript files are not optimized (not concatenated and minified) and actually take longer to load than the .xkt files themselves.

Model glTF .xkt
Duplex 1.5 Sec 0.34 Sec
Schependomlaan 3.57 Sec 0.79 Sec
OTCConferenceCenter 7.93 Sec 1.55 Sec
Clone this wiki locally