How to select surface from a mesh?

Hi,
I’m trying to select a surface and get its details.


the second figure shows the surface after selection. How can I implement this?

for your reference: https://www.3dcontentcentral.com/download-model.aspx?catalogid=12918&id=1585783

Regards,
Binoy

I was tempted to answer just click on it and select “properties”.

Now, seriously, it is hard for me to advice anything, as I know nothing about how your 3D model data is structured, what software tools you use, and so on. A general answer would be: you need to cast a ray from the mouse pointer to the object, get the intersection point, then find what surface contains this point and finally do something with that surface (e.g. change its color, add a border, etc.) If you use some advanced 3D editor, it may have all these things ready. If you have to program the selection process by yourself, you need to have a good understanding of your data and the available 3D API.

I’m sorry I can’t be of any help, and good luck with what you are trying to achieve.

@PavelBoytchev, thanks for the reply. I’m using THREE.GLTFLoader and what I could find in the geometry of the meshes were vertices, normals, and UVs, but there are no surface details. By using raycasting I am only able to change the color of a whole mesh not the color of a particular surface in a mesh.

1 Like

If you need to change the color of part of the object, it should be defined as a separate subobject in the GLTF file. If you are the creator of the GLTF, you can reorganize it as a group of meshes. Each mesh may have its own color. In this case the color is stored in the mesh’s material, not in the geometry. So from the intersecting point you get the object and change its material.

The alternative, which is more complex, is to modify the geometry data to contain vertex colors. In this case you can change the color of individual vertices. But you will also have to color all the vertices of the surface. If you assume a surface is a collection of triangles without edges, you can detect surfaces similar to how EdgesGeometry work.