I would like to create a terrain on top of a cube geometry based on latitude and longitude data. I have an array of objects that contain the latitude, longitude, and amount to deform a specific coordinate.
var geo = new THREE.CubeGeometry( 10, 20, 40, 40, worldWidth, worldDepth);
var worldWidth = 100, worldDepth = 100;
for ( var i = 0; i < worldWidth; i++ ) {
for ( var j = 0; j < worldDepth; j++ ){
for (var k = 0; k < locations.length; k++ ) {
var index = j * worldWidth + i;
var x = worldWidth * (locations[k].lng + 180) / (2 * 180);
var y = worldDepth * (locations[k].lat + 180) / (2 * 180);
var dx = i - x;
var dy = j - y;
var dist = Math.sqrt( dx*dx + dy*dy );
if ( dist < .5 ) {
geo.vertices[index].x += locations[k].count * .05;
}
}
}
}
Right now, this code just pushes up each individual coordinate that is closest to the latitude and longitude. Is there a way I can smooth the area around each locatiuon coordinate so that it looks like a terrain rather than spikes?