[solved] GLTF exported with latest Blender 2.8.2 gltf2 exporter is not working as expected with threejs (r114)

Today I found out that when exporting a new gltf or glb from the gltf2 exporter in blender 2.8.2 (also 2.8.1a) and import that in threejs, things are starting to get really weird. Materials are having problems (totally different) and they even flash in one project from that weird state to the right state while dragging the OrbitControls. So that’s odd and I would not expect that to happen.

The old gltf exports I made months ago work in these threejs r114 projects as expected, but the new gltf exports don’t. The materials are having issues. I even tried exporting everything with the gltf2 exporter in blender by ticking all the boxes, just to be sure everything is exported, but it didn’t help. I’m using blender 2.8.2 btw (also seen in 2.81a).

@donmccurdy
I know you are very much involved in the GLTFloader and I believe also know a little about the gltf exporter in blender. Do you happen to know if something in the gltf exporter of blender is incompatible with the GLTFloader in threejs or perhaps a known issue I should know about? Or are there perhaps different gltf-versions around? I would expect all gltf files to be having the same structure, but they have not? Is there something I’m missing here?

Can you please be more specific? It would be best to share one of your old glTF exports and the a new one so it’s possible to compare both assets. The respective blend file would also help to investigate the issue.

@Mugen87 I like to be more specific, but it is hard to tell what’s going on. That’s why I asked this questions first here:

My questions are: is there something changed in the gltf spec, is there a known issue in the gltf2 exporter in blender and is there a known issue in the gltfLoader of threejs to import the latest gltf standard / export from Blender 2.8.2. I believe these are pretty straight forward questions.

I did a diff on both gltfs and see some differences. But what can I do with that? The fact that these files are different I already knew by looking at the threejs output which is obviously different.

If I find a little more time I’ll create a demo. Could you please answer the above questions before that? I would say that these results are so different that it’s hard to believe I’m the only one facing these issues. And again, I’m very much surprised that the gltf outputs are so different, so I want to know if threejs is not up to par to the official gltf2 exporter, or that the exporter is changing the gltf2 format over time so we have to adjust our code accordingly.

Thanks in advance.

@Friksel there are no known issues of this sort, either in THREE.GLTFLoader or the Blender addon. Three.js supports nearly the full glTF specification, with a couple limitations documented at https://threejs.org/docs/#examples/en/loaders/GLTFLoader, which haven’t changed.

Materials flashing (disappearing/appearing?) when the camera moves sounds like it could be related to transparency, or to having materials marked as transparent when they should not be. This happens occasionally in models from catalogs like TurboSquid and Sketchfab. One change was made in that regard with r114, although I would have expected it to cause less flashing and not more. But I don’t quite know what issue you’re asking about, without more information.

I would recommend the troubleshooting steps here first — if the model works in several viewers, it’s probably an issue in your code and we would need to see your code to help. If the model is broken in viewers, it may be an issue with the exporter or with the model’s creation.

Hm, actually, are these the same issues you mention in What's the right way to import a scene from gltf in r114?, that were fixed by replacing the root Group object?

@donmccurdy Thanks for your answers. This was what I wanted to know first before I dive into this weird issue further.

To answer your question; this is not related to the question about the import. I changed all import routines in my projects to import the gltf.scene as a group and then add the individual group.children to the newly created scene. Exactly as how you described in the other post. And that’s working perfectly fine in even a very complex large project here, so I’m pretty sure that’s doesn’t have anything to do with this issue here.

Think I have to look if this could be a depth issue, as I’ve seen a change on that (as you also pointed out). If I know more or have a demo I get back to you. Thanks for now

For information: I just found the reason of a bad transfer on one of the projects: in the exporter the normals weren’t exported. I was sure I ticked all checkboxes on export as a test before, including normals, but for some reason now it works with just ticking the export normals checkbox, so maybe I am a little confused with another project I tested. So For this project it all works now! Yah! I will now check another project that was also having some issue with materials.

BTW Nice to see also .glb files work! For a large project now half the size! Nice!

1 Like

Unfortunately the other project is still not working. I’m going to debug that one another day.

Alright, the other project now works too. This seemed to be a problem in the Blender file. For some strange reason the material library wasn’t linked anymore (and also not needed anymore in Blender 2.8). So after fixing the materials in the blend file and re-exporting to gltf with materials on everything was fine again.

1 Like