Namespace gltf2xgf

xeokit glTF -> XGF Converter


CLI tools for converting glTF models into xeokit's compact XGF geometry format.


  • Converts glTF files to XGF, xeokit's efficient binary format for large models.
  • Optionally generates a JSON file containing a data model that represents the glTF scene hierarchy.
  • Backward compatibility for all XGF versions.
  • XGF format contains only geometry and color data; textures are not supported.

Installation

Install the xeokit SDK by running:

npm install @xeokit/sdk

Usage

Use the gltf2xgf CLI tool to convert a single glTF file into an XGF file, along with an optional JSON file containing a simple DataModel derived from the glTF scene and node hierarchy.

node gltf2xgf.js -h
Usage: gltf2xgf [options]

CLI tool to convert glTF files into xeokit's compact XGF format.

Options:
-v, --version output the version number
-i, --source [file] path to source glTF file
-s, --scenemodel [file] path to target XGF file
-d, --datamodel [file] path to target JSON data model file, derived from the glTF scene hierarchy (optional)
-f, --format [number] target XGF version (default is 1; supported version is 1)
-h, --help display help for the command

The example below converts a binary glTF file to XGF. The resulting XGF objects will contain geometry and material color data parsed from the glTF file. The XGF file can then be loaded into a xeokit SceneModel using the loadXGF() function. For optimal performance, it is recommended to convert binary glTF files.

node gltf2xgf -i duplex.glb -s duplex.xgf

In the next example, we convert a binary glTF file to XGF, while also generating a JSON file that defines a simple data model expressing the hierarchy of the nodes within the glTF scene. The JSON file can then be loaded into a xeokit DataModel using Data.createModel().

node gltf2xgf -i duplex.glb -s duplex.xgf -d duplex.json

In the previous examples, we converted the glTF file to the latest version of XGF by default. In this example, we convert the binary glTF file to a specific version of XGF. The XGF format is expected to evolve over time, and this feature ensures backward compatibility.

gltf2xgf -i duplex.glb -s duplex.xgf -f 1