2
votes

I have created a 3d object using blender and exported it as .obj file.

I am trying to load that .obj file using OBJloader in threejs. That is a single object with multiple material in it. It is loaded without any issues.

I am trying to track which material the user has clicked in a 3d object. I am using raycasting for this. Since raycasting works only at object level, I am not able to get which specific material user has clicked.

1
I've made a PR to make this task easier: github.com/mrdoob/three.js/pull/15613. If it gets merged, you can evaluate intersection.face.materialIndex and then retrieve the correct material from your materials array. - Mugen87

1 Answers

0
votes

Starting with three.js R101, you can evaluate intersection.face.materialIndex and then retrieve the correct material from your materials array. This was actually a missing feature in previous three.js revisions.