Magilla

How to change a texture on a part of an object

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

Share this post


Link to post
Share on other sites

I've noticed that the obj loader is looking for a <filename>.ojb.manifest3647834723 file, which wasn't included with the package I was delivered. How important is that file?

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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)"

Share this post


Link to post
Share on other sites

Excellent information, thank you :)

There is only one MTL file being requested and loaded.

scene.meshes has 3 different entries.

Share this post


Link to post
Share on other sites

I'll have to wait until I'm on a more capable machine this evening to try and open the obj file. I think this thing would have a fit if I tried to open a 25MB text file.

Share this post


Link to post
Share on other sites

The names are:

accessories_Circle.010

accessories_Circle.000

_mm1

 

I'm surprised that the model is loading without textures, even though the mtl file is loading...

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.