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?
Code:
scene.traverse( function(child) {
if(child instanceof THREE.Sprite) {
if(camera.position.distanceToSquared(child.position) < 100){
child.visible = true;
} else {
child.visible = false;
}
}
});