Jump to content

Is there a way to modify material ID of imported meshes?


 Share

Recommended Posts

While importing meshes designed in software like Autocad and Blender, I noticed that the color of a previously imported mesh is getting applied to many meshes that are later imported. Then I realized that that this is due to conflicting material IDs.

 

Is there a way to modify material ID of an imported mesh or is there any other solution to this problem?

Link to comment
Share on other sites

I need something like this too (removing textures from imported material), the way we do it is

$.json(
  {
    url: "model.babylon",
    success: (rawData) => {
      data.id = "newId";
      data.mesh.material.id = "newId";
      BABYLON.SceneLoader.ImportMesh(
         "",
         "data://" + JSON.stringify(rawData);
         scene,
         (meshes, particles, skeletons) => {
           // success callback 
         }
      )
    }
  }
)

(It's pseudocode, the success callback in the first $.json call is likely to be much more complicated...)

The idea is you first load the .babylon file as a Javascript object, so you may edit it easily.

Once all changes are made, you serialize and re-inject it. 

(It would be better to be able to load a mesh from a Javascript object, but it requires some changes in Babylon code...)

 

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