Level of detail
Similarly, you can load low-poly meshes and low-resolution textures when the user starts playing the game and replace them with higher-detail assets during gameplay, either when the larger assets are loaded or when the user gets close enough to them to see the improved detail. The latter technique is called Level-of-Detail (LOD), and Three.js has built-in support for it using the THREE.LOD
object. For example, we could modify the spinning shape example we built in Chapter 1, Hello, Three.js, to change the detail of our sphere depending on how close to it we are. First we need to change how we add the mesh to the scene:
geometry = [ [new THREE.IcosahedronGeometry(200, 4), 50], [new THREE.IcosahedronGeometry(200, 3), 300], [new THREE.IcosahedronGeometry(200, 2), 1000], [new THREE.IcosahedronGeometry(200, 1), 2000], [new THREE.IcosahedronGeometry(200, 0), 8000], ]; material = new THREE.MeshNormalMaterial(); lod = new THREE.LOD(); for (var i = 0; i < geometry.length...