GLTFExporter not exporting everything

I’ve been working on a project that has user importing models and modifying the scene, and we need to export the entire scene and not just the models. I found a code sandbox to try to get it to export everything with no luck.

This is working for exporting the box and lines, but none of the background color or lights added to the scene. Am I doing something wrong in the code? Can the GLTFExporter not do that? Or is there a different way to go about doing that?

You can’t use glTF to save/restore three.js scenes without losses.

E.g. the KHR_lights_punctual glTF spec only supports directional, point and spot lights but not hemisphere lights. three.js specific entities like the background color or custom materials are also not supported.

You probably have to use the three.js JSON format. You can use scene.toJSON() for serialization and THREE.ObjectLoader for deserialization.

2 Likes