Jump to content

Imported assets from glTF and UV mapping after scene serialization


matdav
 Share

Recommended Posts

Hi guys!
 
I'm relatively new to both Babylon JS and 3D world and I'm trying to understand how things work in order to use Babylon JS in my current project. So please forgive me if I'll say nonsense.

What I would like to do is import assets in my scene from external files, for example from a glTF or obj file, manipulate objects and then save the final 3D scene in .babylon format in order to read it back later.
I'm getting problems when I import objects from glTF files and in particular for the textures.
 
First of all, when I import the glTF file, for each texture a new blob in memory is created and the temporary object url (created with URL.createObjectURL()) is set to the texture url, losing the original file name.
Secondly and more problematic, the UV mappings does not seem to work anymore when reading the serialized babylon json file.
To explain better I created a playground sample.
 
 
The sample loads objects from two files: the original avocado.gltf file (shown on the left in the scene) and the serialized baylon file (on the right).
To get the babylon js file I just serialized the scene with the object obtained from the glTF file and I replaced in the resulting json the blob object urls with the file names of the textures, saved to the same path as the babylon file.

As you can see, in the object on the right the texture coordinates are not mapped well anymore to the mesh vertices.
However, if you look at the console, you can see that the uv data seem to be there and are the same in both cases. So what could be the problem? Am I doing something wrong?
 
I hope I've explained myself well,
 
Thanks,
Matteo
 
Link to comment
Share on other sites

@matdav The blob url thing is something we need to address and is a separate problem. 

The textures are upside down. If you look at the material's albedoTexture between glTF and Babylon, the _invertY property is false and true respectively. It looks like the serialization code is not taking some texture flags into account.

/cc @Deltakosh

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...