awacke1 commited on
Commit
ae399c9
Β·
verified Β·
1 Parent(s): 4f867c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
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) * 140;
185
- const z = (Math.random() - 0.5) * 80;
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, 16 / 9, 0.1, 1000);
225
- camera.position.set(0, 50, 80);
226
 
227
  // Renderer
228
  renderer = new THREE.WebGLRenderer({ antialias: true });
229
- renderer.setSize(window.innerWidth, window.innerHeight * (9/16));
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(160, 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,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, 80);
284
  controls.target.set(0, 0, 0);
285
  controls.update();
286
  }
287
 
288
  function onWindowResize() {
289
  const width = window.innerWidth;
290
- const height = width * (9/16);
291
- camera.aspect = 16 / 9;
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
- - 16:9 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
 
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