1# Sidi Bou Said — A Procedural 3D Walk Above the Gulf of Tunis
2
3## Overview
4
5Write a complete, production-ready, single-file HTML/JavaScript application that renders a highly detailed, photo-realistic, navigable 3D scene of the iconic cliffside village of **Sidi Bou Said, Tunisia** using Three.js.
6
7## Critical Instructions — No Lazy Code
8
9- **No external asset URLs.** Do not use any external asset URLs (no external `.gltf`, `.obj`, `.jpg`, or `.png` files) as they can break or fail CORS. All textures, heights, and models must be generated dynamically and procedurally within the script — for example, using an HTML canvas to draw textures, procedural noise algorithms for plaster and stone, or mathematical structures for 3D meshes.
10- **No placeholders.** Do not write placeholder comments, truncated code blocks, `// TODO` markers, or "left as an exercise" shorthand. Every single function, shader, loop, and variable must be written out in its entirety.
11- **Single file.** The output must be a single, copy-pasteable HTML file that runs perfectly immediately when opened in a browser.
12
13## Technical Requirements & Features
14
15### 1. Libraries
16
17- Load Three.js and `OrbitControls` via a reliable CDN (cdnjs or unpkg).
18
19### 2. Iconic Architecture (Sidi Bou Said style)
20
21- **White-washed plaster walls**: Buildings with flat roofs, rounded corners, and a couple of traditional domes (*koubba*). Implement a procedural stucco texture (low-frequency noise bump map) applied to a clean matte-white material to mimic hand-plastered walls.
22- **Sidi Bou Said blue accents**: Distinctive vibrant blue doors, arched frames, and window grates.
23- **Ornamental windows & doors**: Procedurally generate arched wooden doors featuring detailed black ornamental stud patterns (drawn using canvas coordinates). Create blue wooden window screens (*mushrabiya*) or curved wrought-iron protective grilles using nested geometries.
24
25### 3. Cliffside Terrain & Cobblestone Alleyway
26
27- Establish a winding, sloped pedestrian alleyway representing the steep streets of the village, ending at a viewpoint overlook.
28- The street must use a procedural cobblestone texture (canvas-generated noise representing individual rounded stones with grey grout) applied as a displacement and roughness map.
29- Add a rustic stone retaining wall / barrier at the edge of the cliff.
30
31### 4. The Mediterranean Overlook (background sea & sky)
32
33- Provide a dramatic view of the Gulf of Tunis below the cliff.
34- **Water**: Use a custom shader (or a deep-blue `MeshStandardMaterial` with layered scrolling normal maps) to simulate calm, glittering sea water reflecting the afternoon sun.
35- **Sky**: A warm, bright Mediterranean sky with subtle atmospheric scattering and a powerful sun source.
36
37### 5. Procedural Flora (vibrant bougainvillea & olive trees)
38
39- **Bougainvillea**: Create climbing vines draped over the white walls. Use instanced meshes for thousands of tiny, vibrant magenta/pink petals (procedural alpha-masked shapes) clustered together.
40- **Potted plants**: Place terracotta pots along the alleyway containing small green plants and flowers.
41
42### 6. Mediterranean Lighting & Shadows
43
44- Set up a high-intensity `DirectionalLight` representing the intense Tunisian sun, casting sharp but soft-edged shadows (`THREE.PCFSoftShadowMap`).
45- Use a `HemisphereLight` with a sky-blue hemisphere color and a warm sandy ground color to emulate realistic bounce light bouncing off the white walls.
46- Configure `ACESFilmicToneMapping` to handle the high contrast between the bright white-washed walls and deep blue shadows without blowing out the highlights.
47
48### 7. Navigation & Exploration
49
50- Implement `OrbitControls` or a first-person WASD / pointer-lock setup. Restrict the camera height and boundary limits to keep the user at human scale (eye level) as they navigate up and down the winding blue-and-white alleyway.
51
52### 8. Optimization
53
54- Maintain 60 fps on standard desktop GPUs by employing instanced geometry for repeating architectural elements (stairs, window frames, flowers) and handling window resizing flawlessly.
55
56---
57
58Generate the full, un-truncated, single-file HTML code now.
59</content>
60</invoke>
61