Magilla Posted July 13, 2018 Share Posted July 13, 2018 Super exciting developments for me. @Des3Dteam have finished my first 3D asset 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 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 13, 2018 Share Posted July 13, 2018 Can you use MultiMaterial? I don't know how to do it in the obj/mtl files: https://doc.babylonjs.com/how_to/multi_materials Magilla 1 Quote Link to comment Share on other sites More sharing options...
Magilla Posted July 13, 2018 Author Share Posted July 13, 2018 My assumption was (maybe naively) that I could treat the obj as a merged mesh and somehow directly target submeshes within it? ALA https://playground.babylonjs.com/#INZ0Z0#6 Am I barking up the wrong tree? Where do I go to get the submesh index to target? Or is that trial and error? Quote Link to comment Share on other sites More sharing options...
Magilla Posted July 13, 2018 Author Share Posted July 13, 2018 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? Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 13, 2018 Share Posted July 13, 2018 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. Magilla 1 Quote Link to comment Share on other sites More sharing options...
Magilla Posted July 13, 2018 Author Share Posted July 13, 2018 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. brianzinn 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 13, 2018 Share Posted July 13, 2018 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)" Magilla 1 Quote Link to comment Share on other sites More sharing options...
Magilla Posted July 13, 2018 Author Share Posted July 13, 2018 Excellent information, thank you :) There is only one MTL file being requested and loaded. scene.meshes has 3 different entries. Quote Link to comment Share on other sites More sharing options...
Magilla Posted July 13, 2018 Author Share Posted July 13, 2018 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. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 13, 2018 Share Posted July 13, 2018 Let's see if all those meshes are from your OBJ file. There is a callback on BABYLON.SceneLoader.ImportMesh(...), so check the console and get the name(s). You can specify different materials at this stage, if you wanted: https://www.babylonjs-playground.com/#4XKSWJ#2 Quote Link to comment Share on other sites More sharing options...
Magilla Posted July 13, 2018 Author Share Posted July 13, 2018 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... Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 13, 2018 Share Posted July 13, 2018 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. 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.