Xray function implementation

"I want to implement an X-ray feature. Currently, I change the color of the selected mesh to red and apply an outline. Other meshes are set to transparent with applied opacity.

When I do this, as shown in the attached image, there are obscured parts. Can you provide example code or reference material for implementing an X-ray feature like this?"

I have no idea how you set the transparency.

You might also want to use depthTest, depthWrite and renderOrder. Here is a demo of a more stable x-ray-ish effect (i.e. elements do not pop-up or sink-down):


can we use Material#opacity – three.js docs (threejs.org) for this so that it can be little bit transparent

thank!! solved