Exporting GLB from editor with textures?

editor
gltf-exporter

#1

I have some GLB models that I’d like to make some simple modifications to. I am able to import them into the editor, but when I re-export them, they don’t have any textures. For example, pick a GLB from this repository, download, and import into the editor. Then, just export it right away, start a new project, and import the file you exported. The result is flat black with no texture.

Is this supposed to work? If so, what am I missing? If not, is this documented? (The “Help” menu in the editor is pretty sparse.) Maybe I could save it in another format? I’m trying to load the result in CesiumJS, if that helps.

(I would also be happy to hear about other tools that would make it easy to just rotate an existing model – I’m trying to figure it out in Blender but not really getting anywhere…)


#2

I’ve tested with a318.glb and I can confirm the issue. There are also many warnings in the console.

THREE.ShaderMaterial not supported.

@donmccurdy GLTFLoader creates materials of type ShaderMaterial but GLTFExporter can’t process them. Is this an intended limitation?


#3

glTF has two PBR workflows: metal/rough and spec/gloss. The latter is not supported by three.js builtin materials, so GLTFLoader must use a ShaderMaterial instead. I think support for GLTFExporter could be added (detect material.isGLTFSpecularGlossinessMaterial and go from there) but it isn’t there now, so you’d need to avoid using the KHR_materials_pbrSpecularGlossiness extension to export successfully.


#4

It sounds like the steps I followed should have worked but it would have to be textured using metal/rough reflectivity modeling (?), and the repo I happened upon does not? I’m new at all of this stuff – I just wanted to put a plane on my globe without propellers! – so I’m still getting some of the lingo straight.

Anyway, I should be able to do this in Three if I find a model with the correct lighting model? Is there a simple way to convert the one to the other? You’ll note that that repo also includes Blender source files – maybe I should export from Blender in a different (better-supported) format?


#5

Both of these statements are incorrect.

Click on the blurred text for additional information if interested:

Three.js has a feature called onBeforeCompile. Built-in materials can support anything and have been able to do so for the past few versions of three. Thus, GLTFLoader is not limited to the ShaderMaterial.

This example shows how to modify THREE.MeshNormalMaterial with onBeforeCompile, you can do the same modification on MeshStandardMaterial.

This example shows how to do GLTFLoader with MeshStandardMaterial but uses a proposed alternative to onBeforeCompile (it’s just a preference thing, i like to write less, declarative code, but the same thing can be done with onBeforeCompile, with the proposal, there is no conflict, you can use the method you prefer).

Could this question possible be rephrased as:

Should this be a limitation?

and be asked on github?

Click on the blurred text if interested in additional information

I think there are proposals on github that suggest a workaround for this limitation. Either way, it would be good to establish if this is by design or not, there, so people can make more informed calls when deciding to spend their free time submitting PRs.

I am curious about this designed limitation, and would like if i encountered some breadcrumbs when searching on github, rather than having to look in an additional place. For example, there is already a proposal on github that removes this limitation.

:heart:


#6

I should have looked more carefully at the repo before replying, sorry. The issue mentioned above about spec/gloss PBR materials is not related after all.

All of your models are using glTF 1.0, an older version of the format that is only supported through LegacyGLTFLoader and ShaderMaterial. You will not be able to export that back out in any case, there is no exporter that supports it. Instead, export from Blender with KhronosGroup/glTF-Blender-Exporter and you’ll get glTF 2.0 which should work fine. Exporting that back out with the three.js glTF exporter should be OK as well, although I think modifying in Blender might be easier.