Jump to content

How to change a texture on a part of an object


Magilla
 Share

Recommended Posts

Super exciting developments for me. @Des3Dteam have finished my first 3D asset :o

I have an obj file, height-maps, textures, and everything. I'm linking a gif of said object below.

Now - what information do I need, and how do I go about changing the texture/image in the circle that says "Des3DTeam"? I need to be able to change it on the fly in the JS code.

 

Thanks :)

1.gif

Link to comment
Share on other sites

1 hour ago, Magilla said:

Where do I go to get the submesh index to target? Or is that trial and error?

I wouldn't go to that trouble - I'm not sure your vertices would be contiguous and also are likely to change if you update your model.  Can you not use objects and groups?  In Blender look for "Objects as OBJ Objects" or switch to  .babylon format!?

edit: don't worry about the manifest - it's for caching/offline usage.

Link to comment
Share on other sites

1 hour ago, brianzinn said:

I wouldn't go to that trouble - I'm not sure your vertices would be contiguous and also are likely to change if you update your model.  Can you not use objects and groups?  In Blender look for "Objects as OBJ Objects" or switch to  .babylon format!?

edit: don't worry about the manifest - it's for caching/offline usage.

TBH, I know absolutely sod-all about Blender, which is why I'm getting someone else to do the assets.

Link to comment
Share on other sites

In the network tab, I am assuming you are only loading one MTL file.  How many meshes are loaded - you can see this in the callback of the loader?  Anyway, you don't need to know about 3D modeling luckily, but the easiest thing is to request assets with the part you want to have a different material as a separate object.

If you are up for a bit of hacking to see yourself -- open up the OBJ file, it is a text file.  You can see if there are named objects or groups "o" and "g", but likely that can be confirmed also with what you have loaded.  If it's a single mesh then I would try to have the asset delivered in an OBJ file with "named objects and polygon groups (o and g in the text file)"

Link to comment
Share on other sites

There was a recent fix for that - where the MTL files were being loaded asynchronously.  I think now the callback isn't called until the textures are loaded.

if (mesh.name === '_mm1') > -1) {
  mesh.showBoundingBox = true;
}

Then just hold a reference to that mesh and you can update the material/mesh.

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