I need to build terrain using one cube with dimensions 1x1x1, the coordinates are provided in a .txt file and there are about 11M triplets.
The problem is that using my current code I can only draw about 60k of them, then the browser tab is resetted and a prompt to stop an unresponsive script comes out, so I use too much memory and time to generate them.
Here is the chunk of code I use to draw them:
function generateCubes(data) {
var cubeGeometry = new THREE.CubeGeometry(cubeSize, cubeSize, cubeSize);
var material = new THREE.MeshLambertMaterial({color: 0x587058});
var mesh = new THREE.Mesh(cubeGeometry, material);
var mergedGeo = new THREE.Geometry();
var instance;
var line = data[0].split(';');
var translateX = line[0], translateY = line[1], translateZ = line[2];
//var group = new THREE.Object3d();
for(var i = 0; i < 100000; i++) { // should go to data.length
line = data[i].split(';');
//instance = mesh.clone();
//instance.position.set(line[0] - translateX, line[2] - translateZ, line[1] - translateY);
//group.add(instance);
mesh.position.x = Number(line[0]) - translateX;
mesh.position.y = Math.round(Number(line[2]) - translateZ);
mesh.position.z = Number(line[1]) - translateY;
mesh.updateMatrix();
mergedGeo.merge(instance.geometry, instance.matrix);
}
group = new THREE.Mesh(mergedGeo, material);
scene.add(group);
}
The function is called from a success in an $.ajax call.
The commented parts are used without merged geometry, that way I can draw around 100k of the data.