Adrian3D

BABYLON.GLTF2Export with texture issue <- Feature or Bug?

Recommended Posts

Hello Babylon community,

I have been working with the BABYLON.GLTF2Export feature (which is by the way great to have!!!), and noticed an odd behavior of which I am not sure if it is intended.

Check out this playground: http://www.babylonjs-playground.com/#1GXSPK#16

It will create a simple scene with a texture and download the following 3 files to your computer:

  1. MyFile.gltf

  2. MyFile.bin

  3. _textures_BJS-logo_v3.png.png

So texture image files are renamed during export by their folder path and file extension (in our example from "./textures/BJS-logo_v3.png" to _textures_BJS-logo_v3.png.png ")

 

If I then try to open / drag and drop these in the sandbox https://sandbox.babylonjs.com, I get the following error message:

#/images/0/uri: Failed to load './textures/BJS-logo_v3.png.png': 0

Changing line 169 in the file "MyFile.gltf"

  • From: "uri": "./textures/BJS-logo_v3.png.png"

  • To: "uri": "_textures_BJS-logo_v3.png.png"

makes it work again in the sandbox and other software.

 

Maybe the intention here is to indicate with "_textures_" that the image texture was originally in the sub-folder texture, but you cannot open the gltf-file any more like that.

In my opinion the BABYLON.GLTF2Export should either

  • Leave the texture file names as is (e.g. "./textures/BJS-logo_v3.png") so that as a user I have to save the gltf in the correct folder (typically relative to the Babylon HTML-app) and NOT include them in the export (i.e. only two files are downloaded), or

  • Include the textures in the export but fix the uri to the correct relative value.

Just a proposal to save others the time I spent figuring this out.

Share this post


Link to post
Share on other sites

Hi @Adrian3D.  Thanks for flagging this issue!  This is definitely a bug and the intention is for your second proposal to be the expected behavior, where the file name is corrected in the glTF file.  I will work on a fix and update when completed.

Share this post


Link to post
Share on other sites

Hi @Adrian3D, the change has been merged to master.  It turned out to be a behavior with the browsers, where Chrome replaced the slashes with underscores, whereas Edge tried to keep the original slashes but had issues actually downloading the textures.  To make the export behavior consistent, I changed all slashes and dots to underscores.

Share this post


Link to post
Share on other sites

 

> To make the export behavior consistent, I changed all slashes and dots to underscores.
Great. Tested with http://www.babylonjs-playground.com/#1GXSPK%2316 and it's working now.

Thank you so much for your help.

Marked topic as solved.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.