Is there a way to transform a cube geometry into a terrain based on latitude and longitude data? I have an array of objects with latitude, longitude, and deformation values for specific coordinates.
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;
}
}
}
}
This code currently raises the vertices closest to the latitude and longitude coordinates. How can I smooth the terrain around each location to create a more realistic terrain instead of spikes?