Dispose things correctly in three.js

Reusing materials and textures greatly seems to reduce the memory footprint as well.

Eg. in @revyTH’s code, doing:

function addMeshes (e) {
    let boxGeometry = new THREE.BoxGeometry(1, 1, 1);
    let material = new THREE.MeshBasicMaterial({color: 0xff0000});
    for (let i = 0; i < 100; ++i) {
		let mesh = new THREE.Mesh(
			boxGeometry,
			material)
		mesh.position.set(Math.random() * 100, 0.5, Math.random() * 100)
		scene.add(mesh)		
    }
    boxGeometry.dispose();
    material.dispose();
}

instead of:

function addMeshes (e) {		
	for (let i = 0; i < 100; ++i) {
		let mesh = new THREE.Mesh(
			new THREE.BoxGeometry(1, 1, 1),
			new THREE.MeshBasicMaterial({color: 0xff0000}))
		mesh.position.set(Math.random() * 100, 0.5, Math.random() * 100)
		scene.add(mesh)				
	}			
}		

Also seem to reduce the memory footprint.