Game Development Reference
In-Depth Information
floor.rotation.x = -90 * Math.PI / 180;
scene.add(floor);
// Original building
var geometry = new THREE.CubeGeometry(1, 1, 1);
geometry.applyMatrix(new THREE.Matrix4().makeTranslation(0, 0.5,
0));
var material = new THREE.MeshDepthMaterial({overdraw: true});
// Cloned buildings
for (var i = 0; i < 300; i++) {
var building = new THREE.Mesh(geometry.clone(), material.clone());
building.position.x = Math.floor(Math.random() * 200 - 100) * 4;
building.position.z = Math.floor(Math.random() * 200 - 100) * 4;
building.scale.x = Math.random() * 50 + 10;
building.scale.y = Math.random() * building.scale.x * 8 + 8;
building.scale.z = building.scale.x;
scene.add(building);
}
}
// Run it!
setup();
Let's see the result, shown in the next screenshot:
Procedurally generated cityscape
 
Search WWH ::




Custom Search