Jump to content

The best way to store materials ?


Recommended Posts

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 ;)

Link to post
Share on other sites

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" :'(

Link to post
Share on other sites

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 !

Link to post
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...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...