glTF Exporter

glTF Exporter

The glTF Exporter allows BabylonJS models to be exported to the glTF 2.0 format.

Exporting a Scene to glTF

The exporter expects the scene to be ready before exporting, so it is best called by the scene's executeWhenReady function:

scene.executeWhenReady(function() {
    let gltf = BABYLON.GLTF2Export.GLTF(scene, "fileName");

To download to glb format, simply replace the GLTF static function with GLB:

scene.executeWhenReady(function() {
    let gltf = BABYLON.GLTF2Export.GLB(scene, "fileName");

Export options

glTF Exporter accepts an optional options parameter with certain functions and properties defined.

Excluding geometry

Sometimes you may need to exclude geometry from export, such as the skybox. You can define a boolean callback called shouldExportMesh which accepts a BabylonJS mesh as an argument and returns a boolean, specifying if the mesh should be exported or not:

// Initializer code...
let skybox = scene.createDefaultSkybox(hdrTexture, true, 100, 0.3);
// scene setup code...
scene.executeWhenReady(function() {
    let options = {
        shouldExportMesh: function(mesh) {
            return mesh !== skybox;

    let gltf = BABYLON.GLTF2Export.GLB(scene, "fileName", options);

Supported features

  • Currently the following material types are supported:
    • PBRMaterial
      • Not all Babylon PBRMaterial features are supported in glTF.
    • MetallicRoughnessMaterial
    • StandardMaterial
      • A conversion from StandardMaterial to MetallicRoughness has been implemented to try to match as close as visibly possible, though not all BabylonJS features are supported in glTF.
    • SpecularGlossinessMaterial
      • glTF Exporter converts SpecularGlossiness materials to MetallicRoughness to match core glTF 2.0 specification.
  • Node-based TRS animation

Coming soon

  • Skinning animation
  • Morph Targets