GLTF Export/Serializer Error

Hey folks,

i am trying to export the babylon scene from my applicationton to GLTF. So i included the serialer js file:
https://preview.babylonjs.com/serializers/babylonjs.serializers.js

Export should happen after pressing a button

document.getElementById("savebtn").addEventListener("click", function(e){
    console.log("save");
    if(scene){
        BABYLON.GLTF2Export.GLTFAsync(scene, "test.gltf").then((gltf) => {
            gltf.downloadFiles();
        });
    }
});

but i only get some errors

babylonjs.serializers.js:416 Uncaught (in promise) TypeError: Cannot read property 'Warn' of undefined
    at babylonjs.serializers.js:416
    at new Promise (<anonymous>)
    at KHR_lights_punctual../glTF/2.0/Extensions/KHR_lights_punctual.ts.KHR_lights_punctual.postExportNodeAsync (babylonjs.serializers.js:386)
    at babylonjs.serializers.js:1434
    at _Exporter../glTF/2.0/glTFExporter.ts._Exporter._applyExtensions (babylonjs.serializers.js:1413)
    at _Exporter../glTF/2.0/glTFExporter.ts._Exporter._extensionsPostExportNodeAsync (babylonjs.serializers.js:1434)
    at babylonjs.serializers.js:2477

Hey! are you using ES6 module import? Or are you referencing everything from preview CDN?

Looks like the Tools module is not imported

iam using this file from the CDN link on the NPM page
https://preview.babylonjs.com/serializers/babylonjs.serializers.js

I meant for Babylon.js itself

i am using the 3.3 version from the version builder
https://www.babylonjs.com/versionbuilder/

Yeah so that’s why. Preview cdn will give you 4.0 code
You need to use 4.0 from version builder

thanks alot!
but now the inspector and the scene explorer are open when a launch my application

You must call scene.debugLayer.show() somewhere ;D

indeed, my bad :smiley:

1 Like