Update app.py
Browse files
app.py
CHANGED
@@ -92,13 +92,14 @@ html_code = """
|
|
92 |
let position = basePos.clone();
|
93 |
let direction = new THREE.Vector3(0, 1, 0);
|
94 |
const structure = new THREE.Group();
|
|
|
95 |
|
96 |
for (let char of this.generate()) {
|
97 |
switch(char) {
|
98 |
case 'F':
|
99 |
if (height < maxHeight) {
|
100 |
-
const width =
|
101 |
-
const floorHeight =
|
102 |
const geo = new THREE.BoxGeometry(width, floorHeight, width);
|
103 |
const mat = new THREE.MeshPhongMaterial({
|
104 |
color: new THREE.Color(0.5 + Math.random() * 0.5,
|
@@ -146,7 +147,7 @@ html_code = """
|
|
146 |
const block = {
|
147 |
position: new THREE.Vector2(x, z),
|
148 |
buildings: [],
|
149 |
-
maxHeight: this.isWaterfront(x, z) ?
|
150 |
};
|
151 |
this.blocks.push(block);
|
152 |
this.evolveBlock(scene, block, true);
|
@@ -181,8 +182,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 +221,13 @@ html_code = """
|
|
220 |
scene = new THREE.Scene();
|
221 |
scene.background = new THREE.Color(0x87CEEB);
|
222 |
|
223 |
-
// Camera with
|
224 |
-
camera = new THREE.PerspectiveCamera(75,
|
225 |
-
camera.position.set(0,
|
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 +237,8 @@ html_code = """
|
|
236 |
sun.position.set(50, 50, 50);
|
237 |
scene.add(sun);
|
238 |
|
239 |
-
// Ground with
|
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 +266,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 +281,15 @@ html_code = """
|
|
280 |
}
|
281 |
|
282 |
function resetView() {
|
283 |
-
camera.position.set(0,
|
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,9 +323,9 @@ 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
|
328 |
- Terrain with hills and lakes
|
329 |
- Waterfront properties grow larger
|
330 |
- Bridges connect land masses
|
|
|
92 |
let position = basePos.clone();
|
93 |
let direction = new THREE.Vector3(0, 1, 0);
|
94 |
const structure = new THREE.Group();
|
95 |
+
let baseWidth = 1.5; // Starting wider base
|
96 |
|
97 |
for (let char of this.generate()) {
|
98 |
switch(char) {
|
99 |
case 'F':
|
100 |
if (height < maxHeight) {
|
101 |
+
const width = baseWidth * (1 - height / maxHeight); // Narrower as it goes up
|
102 |
+
const floorHeight = 2 + Math.random() * 2; // Taller floors
|
103 |
const geo = new THREE.BoxGeometry(width, floorHeight, width);
|
104 |
const mat = new THREE.MeshPhongMaterial({
|
105 |
color: new THREE.Color(0.5 + Math.random() * 0.5,
|
|
|
147 |
const block = {
|
148 |
position: new THREE.Vector2(x, z),
|
149 |
buildings: [],
|
150 |
+
maxHeight: this.isWaterfront(x, z) ? 20 : 12 // Increased max height
|
151 |
};
|
152 |
this.blocks.push(block);
|
153 |
this.evolveBlock(scene, block, true);
|
|
|
182 |
evolve(scene) {
|
183 |
this.generation++;
|
184 |
if (this.blocks.length < 20) {
|
185 |
+
const x = (Math.random() - 0.5) * 80; // Adjusted for 9:16
|
186 |
+
const z = (Math.random() - 0.5) * 140;
|
187 |
if (!this.isInLake(x, z)) this.addBlock(scene, x, z);
|
188 |
}
|
189 |
this.blocks.forEach(block => this.evolveBlock(scene, block));
|
|
|
221 |
scene = new THREE.Scene();
|
222 |
scene.background = new THREE.Color(0x87CEEB);
|
223 |
|
224 |
+
// Camera with 9:16 portrait aspect ratio
|
225 |
+
camera = new THREE.PerspectiveCamera(75, 9 / 16, 0.1, 1000);
|
226 |
+
camera.position.set(0, 80, 40); // Adjusted for portrait view
|
227 |
|
228 |
// Renderer
|
229 |
renderer = new THREE.WebGLRenderer({ antialias: true });
|
230 |
+
renderer.setSize(window.innerWidth, window.innerHeight * (16/9));
|
231 |
container.appendChild(renderer.domElement);
|
232 |
|
233 |
// Lights
|
|
|
237 |
sun.position.set(50, 50, 50);
|
238 |
scene.add(sun);
|
239 |
|
240 |
+
// Ground with 9:16 ratio (90x160)
|
241 |
+
const groundGeo = new THREE.PlaneGeometry(90, 160, 32, 32);
|
242 |
const groundMat = new THREE.MeshPhongMaterial({ color: 0x4a7043 });
|
243 |
const ground = new THREE.Mesh(groundGeo, groundMat);
|
244 |
ground.rotation.x = -Math.PI / 2;
|
|
|
266 |
// Controls
|
267 |
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
268 |
controls.enableDamping = true;
|
269 |
+
controls.target.set(0, 0, 0);
|
270 |
|
271 |
// City
|
272 |
city = new CitySimulator();
|
|
|
281 |
}
|
282 |
|
283 |
function resetView() {
|
284 |
+
camera.position.set(0, 80, 40); // Adjusted for portrait view
|
285 |
controls.target.set(0, 0, 0);
|
286 |
controls.update();
|
287 |
}
|
288 |
|
289 |
function onWindowResize() {
|
290 |
const width = window.innerWidth;
|
291 |
+
const height = width * (16/9); // Portrait orientation
|
292 |
+
camera.aspect = 9 / 16;
|
293 |
camera.updateProjectionMatrix();
|
294 |
renderer.setSize(width, height);
|
295 |
}
|
|
|
323 |
- **Scroll**: Zoom
|
324 |
|
325 |
### Features:
|
326 |
+
- 9:16 portrait play area
|
327 |
- Blocks (10x10 units) with up to 5 buildings
|
328 |
+
- Buildings start wide, grow taller with smaller floors
|
329 |
- Terrain with hills and lakes
|
330 |
- Waterfront properties grow larger
|
331 |
- Bridges connect land masses
|