This library for THREE.js adds Occlusion Querying to the rendering pipeline.
Simply replace WebGLRenderer with WebGLOcclusionRenderer, and you're all set!
const renderer = new WebGLOcclusionRenderer(myRendererOptions, myScene, myCamera);
renderer.render();
TODO: Transparency
They can be found on CDNs like JSDelivr.