Depth is not correct when rotating the camera in threejs

I’m a newbie in threejs. I have created a sample of the issue so that the issue can be clearly visible.

Click here to load the sample.

In this sample, if you drag the stage horizontally, you’ll see that the cube is rotating and so the capsules. But the red capsule is always on top. When the red capsule is smaller than the yellow one that means the red capsule is behind the yellow one. But still the red one is on the top. May be I’m doing some silly stuff here.

Thanks to Marquizzo. Click here to see the code.


Hi, No answer there. So thought of putting here.

Um, why do you have this line in your code?


Thanks a ton. I was doing R&D and this line left there. Its fixed now.

If you disable depth testing, it’s not surprising that your scene behaves in that way. You normally never want to work with renderer.context anyway.

I will keep that in mind. Thanks :slight_smile:

1 Like