0
votes

I'm using three.js to load an obj file, a ring with some pearls. I haven't got an mtl file, as the software we use to export the obj (rhinoceros(?)) won't generate it with an obj file (this is what I was told by the graphic designer).

I need to set a metallic material ONLY for the ring, and glass material ONLY for the stone/pearls.

This is a link to the test page where I actually load the file: jaaxlab.com/test_youring

...for the rest I don't know how to set a single material and also multiple.

Link to obj file jaaxlab.com/test_youring/obj/prova1.obj

1
There is no code to post, i have to understand if is possible to do one thing or not... and how, i can show how i'm loading the obj file but i don't think it is needed - gattass69
Could you share a link for downloading of you obj file? - prisoner849
I edited the question with some minor grammatical changes, added the link from the comments, and removed the intro/closing paragraphs, to keep the question succinct. Good luck! - Dan Eastwell
I see the following error: (index):139 Uncaught ReferenceError: rObj is not defined at OBJLoader2Example.initGL ((index):139) at (index):274 in the console. Maybe that's a starting point for helping to debug :) - Dan Eastwell

1 Answers

0
votes

Your object has several children. The child with index 0 is the ring. Also, its name is sezione_B_misura13_Riviera_mix_full anello_sezione_B_misura13.

So, you can access it like:

obj.children[0].material = new THREE.MeshStandardMaterial(...);

or

obj.getObjectByName('sezione_B_misura13_Riviera_mix_full anello_sezione_B_misura13').material = new THREE.MeshStandardMaterial(...);

Given that obj is the object, loaded with you loader.

Take a look at this jsfiddle. Load your file, then check the console log. You can also click any part of the object and see its id and name in the console.