Update app.py
Browse files
app.py
CHANGED
@@ -181,8 +181,8 @@ html_code = """
|
|
181 |
evolve(scene) {
|
182 |
this.generation++;
|
183 |
if (this.blocks.length < 20) {
|
184 |
-
const x = (Math.random() - 0.5) *
|
185 |
-
const z = (Math.random() - 0.5) *
|
186 |
if (!this.isInLake(x, z)) this.addBlock(scene, x, z);
|
187 |
}
|
188 |
this.blocks.forEach(block => this.evolveBlock(scene, block));
|
@@ -220,13 +220,13 @@ html_code = """
|
|
220 |
scene = new THREE.Scene();
|
221 |
scene.background = new THREE.Color(0x87CEEB);
|
222 |
|
223 |
-
// Camera
|
224 |
-
camera = new THREE.PerspectiveCamera(75,
|
225 |
-
camera.position.set(0, 50,
|
226 |
|
227 |
// Renderer
|
228 |
renderer = new THREE.WebGLRenderer({ antialias: true });
|
229 |
-
renderer.setSize(window.innerWidth, window.innerHeight * (
|
230 |
container.appendChild(renderer.domElement);
|
231 |
|
232 |
// Lights
|
@@ -236,8 +236,8 @@ html_code = """
|
|
236 |
sun.position.set(50, 50, 50);
|
237 |
scene.add(sun);
|
238 |
|
239 |
-
// Ground
|
240 |
-
const groundGeo = new THREE.PlaneGeometry(
|
241 |
const groundMat = new THREE.MeshPhongMaterial({ color: 0x4a7043 });
|
242 |
const ground = new THREE.Mesh(groundGeo, groundMat);
|
243 |
ground.rotation.x = -Math.PI / 2;
|
@@ -265,7 +265,7 @@ html_code = """
|
|
265 |
// Controls
|
266 |
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
267 |
controls.enableDamping = true;
|
268 |
-
controls.target.set(0, 0, 0);
|
269 |
|
270 |
// City
|
271 |
city = new CitySimulator();
|
@@ -280,15 +280,15 @@ html_code = """
|
|
280 |
}
|
281 |
|
282 |
function resetView() {
|
283 |
-
camera.position.set(0, 50,
|
284 |
controls.target.set(0, 0, 0);
|
285 |
controls.update();
|
286 |
}
|
287 |
|
288 |
function onWindowResize() {
|
289 |
const width = window.innerWidth;
|
290 |
-
const height = width * (
|
291 |
-
camera.aspect =
|
292 |
camera.updateProjectionMatrix();
|
293 |
renderer.setSize(width, height);
|
294 |
}
|
@@ -322,7 +322,7 @@ Watch a 3D city evolve with lakes, hills, and building blocks.
|
|
322 |
- **Scroll**: Zoom
|
323 |
|
324 |
### Features:
|
325 |
-
-
|
326 |
- Blocks (10x10 units) with up to 5 buildings
|
327 |
- Buildings evolve floor-by-floor using L-systems
|
328 |
- Terrain with hills and lakes
|
|
|
181 |
evolve(scene) {
|
182 |
this.generation++;
|
183 |
if (this.blocks.length < 20) {
|
184 |
+
const x = (Math.random() - 0.5) * 120; // Adjusted for 4:3
|
185 |
+
const z = (Math.random() - 0.5) * 90;
|
186 |
if (!this.isInLake(x, z)) this.addBlock(scene, x, z);
|
187 |
}
|
188 |
this.blocks.forEach(block => this.evolveBlock(scene, block));
|
|
|
220 |
scene = new THREE.Scene();
|
221 |
scene.background = new THREE.Color(0x87CEEB);
|
222 |
|
223 |
+
// Camera with 4:3 aspect ratio
|
224 |
+
camera = new THREE.PerspectiveCamera(75, 4 / 3, 0.1, 1000);
|
225 |
+
camera.position.set(0, 50, 60); // Adjusted to center on city
|
226 |
|
227 |
// Renderer
|
228 |
renderer = new THREE.WebGLRenderer({ antialias: true });
|
229 |
+
renderer.setSize(window.innerWidth, window.innerHeight * (3/4));
|
230 |
container.appendChild(renderer.domElement);
|
231 |
|
232 |
// Lights
|
|
|
236 |
sun.position.set(50, 50, 50);
|
237 |
scene.add(sun);
|
238 |
|
239 |
+
// Ground with 4:3 ratio (120x90)
|
240 |
+
const groundGeo = new THREE.PlaneGeometry(120, 90, 32, 32);
|
241 |
const groundMat = new THREE.MeshPhongMaterial({ color: 0x4a7043 });
|
242 |
const ground = new THREE.Mesh(groundGeo, groundMat);
|
243 |
ground.rotation.x = -Math.PI / 2;
|
|
|
265 |
// Controls
|
266 |
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
267 |
controls.enableDamping = true;
|
268 |
+
controls.target.set(0, 0, 0); // Centered on city origin
|
269 |
|
270 |
// City
|
271 |
city = new CitySimulator();
|
|
|
280 |
}
|
281 |
|
282 |
function resetView() {
|
283 |
+
camera.position.set(0, 50, 60); // Adjusted for 4:3 and centered view
|
284 |
controls.target.set(0, 0, 0);
|
285 |
controls.update();
|
286 |
}
|
287 |
|
288 |
function onWindowResize() {
|
289 |
const width = window.innerWidth;
|
290 |
+
const height = width * (3/4);
|
291 |
+
camera.aspect = 4 / 3;
|
292 |
camera.updateProjectionMatrix();
|
293 |
renderer.setSize(width, height);
|
294 |
}
|
|
|
322 |
- **Scroll**: Zoom
|
323 |
|
324 |
### Features:
|
325 |
+
- 4:3 play area
|
326 |
- Blocks (10x10 units) with up to 5 buildings
|
327 |
- Buildings evolve floor-by-floor using L-systems
|
328 |
- Terrain with hills and lakes
|