Jump to content

SceneLoader.Append do not load images of models correctly


Dad72
 Share

Recommended Posts

Hi,

When we load a model with ImportMesh on a scene, then we serialize the scene, the images are recorded with a path to find this model (data/meshes/ for exemple).

Once the scene data is serialized, it is saved in a babylon file that I put in the root.

But when I reload this scene file later, with the function SceneLoader.Append() will create me the model (is good), but go look for the image at the root where it finds the scene file instead of looking in data/meshes/ .

In the serialized file at the material level the path of the images is the data/meshes/images.png, but this path is not used because it starts from the root by searching directly for the image.

Basically, there is only the name of the image taken into account and not the path from which it finds the image.

If the images are in the same folder as the models, the serialized scene file can not be in all the models folders (logical), so it is at the root. But Append() and Load() will try to fetch the images from the root of the file what should not be done.

I think it's because it's diffuseTexture.name which is loaded for texture and not diffuseTexture.url :

5a86a181e347d_2018-02-1610_15_16-Greenshot.thumb.jpg.0c6e0070cb167fd1ab58de8d2f2738c4.jpg

Link to comment
Share on other sites

I think I understand why. when importing a model with ImportMesh, the images are at the root of the model, so the path of the image saved in diffuseTexture.name, is at the root of the model and the path in Url by the root of the site.

The image is loaded correctly from a terrain for example, because in diffuseTexture.name, it is the path from the root of the site that is registered at the time of serialization. But with ImportMesh, it does not go that way.

Link to comment
Share on other sites

I do not know how to reproduce that in the PG. I use PHP to save my serialized files and put them in a directory. The PG does not allow me to do that. If I do everything from the PG, I could not reproduce the problem.

The problem is just that when loading a serialized scene, it will look for the images in material.diffuseTexture.name instead of material.diffuseTexture.url (that's a guess, but the url is not taken into account)

I'm thinking about a PG for tomorrow.

 

 

Link to comment
Share on other sites

I tried to make a PG. I load a terrain with a texture and I load a model with ImportMesh. I then serialized the scene that I reload with Append.

We can see the differences in console log at the image path level (name and url) and we can see that when loading with Append, it will not look for the images correctly (on the PG it works because the models is displayed in the same place, ( a cache story I guess), but we can see that we have "404 not found" on all the images of the model :

5a88137699d79_2018-02-1712_34_25-Greenshot.jpg.6e12858326600018b50cbc1dbd168118.jpg

It can be seen on the image the path of of images is search from the root of the playground rather than picking them up from the url of file

http://www.babylonjs-playground.com/#1LNWLE#21

what could be useful would be to have the possibility to load the models of a scene that uses the "url" rather than the "name"

a property like :  BABYLON.SceneLoader.useFullPath = true; for example (which would be false by default so that it works as currently)

Thanks 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...