Dos Posted April 19, 2018 Share Posted April 19, 2018 Hello everybody, I'm currently working on a project implying a serious amount of materials (including textures) and would like to store them as separate files (one per material). So, at first, I decided to store the "material" object as a json file including textures as base64 strings. I simply tried to merge the object from this json file onto the mesh.material with deepmerge resulting in a "RangeError: Maximum call stack size exceeded" (probably due to the base64 textures inside of it) So I was wondering : what would be the best way to store my materials as separate files so I could load them when needed? Sorry if this question looks stupid but I can't manage to find a suitable solution. Thanks in advance Quote Link to comment Share on other sites More sharing options...
babbleon Posted April 19, 2018 Share Posted April 19, 2018 I store mine in a MySQL database, have a PHP script output the json, eg. materials.php?materialid=1 There may well be a better way, but it works well for me. Quote Link to comment Share on other sites More sharing options...
Dos Posted April 19, 2018 Author Share Posted April 19, 2018 Do you have textures in your materials ? How do you apply them to a mesh ? I tried // material is the object from the json file and deepmerge a library I use mesh.material = deepmerge(mesh.material, material) But it throws a "RangeError: Maximum call stack size exceeded" :'( Quote Link to comment Share on other sites More sharing options...
Dos Posted April 20, 2018 Author Share Posted April 20, 2018 OK, I finally found it. No need for deepmerge here (as it throws the error above probably because the material objects are too big to be processed that way) All I needed to do was : mesh.material = BABYLON.Material.Parse(material, this.scene) The UVs and normals aren't fine for now but the materials are loaded correctly ! GameMonetize 1 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.