Dad72 Posted February 16, 2018 Share Posted February 16, 2018 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 : Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 16, 2018 Author Share Posted February 16, 2018 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. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 16, 2018 Share Posted February 16, 2018 I think I get what you would like but I may need a tiny repro in the PG to do my testings Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 16, 2018 Author Share Posted February 16, 2018 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 17, 2018 Author Share Posted February 17, 2018 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 : 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 Quote Link to comment Share on other sites More sharing options...
Guest Posted February 20, 2018 Share Posted February 20, 2018 Ok! next commit will introduce a BABYLON.Texture.UseSerializedUrlIfAny = true; Dad72 and satguru 2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 20, 2018 Author Share Posted February 20, 2018 Cool, Thanks DK. I'll tell you when I'll try after this is commit. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 20, 2018 Author Share Posted February 20, 2018 No nothing to change. Sorry Dk. There must be something missing in the SceneLoader I suppose. http://www.babylonjs-playground.com/#1LNWLE#24 Thanks Quote Link to comment Share on other sites More sharing options...
Guest Posted February 21, 2018 Share Posted February 21, 2018 Wait I did not publish yet Should be up in a couple of hours Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 21, 2018 Author Share Posted February 21, 2018 Yes it looks good now. Thank you DK. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.