Hiding some objects depending on distance from camera

In my scene I have several hundreds of static cubes. Next to each cube I show a THREE.Sprite that shows their name. (the textures for the sprites are generated once at initial loading)

I only want to render the sprites that are close to the camera.
The FAR-property of the camera is not the right solution for me, because I still want to render the cubes.
As far as I can see the LOD is also the wrong approach, because the sprite has already very primitive geometry.

So my approach would be to calculate it by myself.
I would calculate the distance to the camera for each sprite and then just set the visible property to false.
Is this the right way to do that?


scene.traverse( function(child) {
                if(child instanceof THREE.Sprite) {
                    if(camera.position.distanceToSquared(child.position) < 100){
                        child.visible = true;
                    } else {
                        child.visible = false;

I think your approach should work well for a manageable amount of sprites.

If there are much more objects (more than just a few hundred) and if you start perceiving performance problems, you might want to use some kind of spatial query mechanism. One basic approach is e.g. grid space partitioning.