The user is asking for a single HTML file that uses three.js r160 via an importmap. Procedural low-poly terrain, mountains with snow caps, a lake with animated water, low-poly trees, a sun, fog, gradient background, orbiting camera. Plan: - Importmap for three - Scene with fog, gradient background via a large sphere shader or scene.background color + fog. Use a Canvas texture gradient? No external assets, but a canvas-generated gradient is fine and counts as procedural. Simpler: a big skydome with a vertex color gradient shader. - Terrain: PlaneGeometry with noise-based height (simple value noise with smoothstep interpolation, seeded). Color vertices by height: snow above threshold, rock, grass, sand near water. Flat shading. - Water: plane at water level, animated vertices via sin waves, slightly transparent blue MeshPhongMaterial with flat shading. - Trees: cone + cylinder, instanced or merged; place on terrain based on height, avoiding water/snow. Use InstancedMesh for trunks and leaves. - Sun: emissive sphere + directional light, plus a lens-flare-like glow sprite (procedural canvas radial gradient) — keep it simple: emissive sphere + directional light. - Slowly orbiting camera, lookAt center. - Fog: scene.fog matched to background. Write the code carefully. Use simple hash noise + fbm. Terrain size 200x200, segments around 120. Height function fbm noise; carve out lake basin with radial falloff? Better approach: add a lake where height < waterLevel; naturally occurring low basins form the lake. To guarantee the lake, subtract a smooth depression offset from center. Vertex color per-vertex with flat shading: use non-indexed geometry? For flat shading with per-face colors, use toNonIndexed and set per-face colors. Simpler: set per-vertex color and rely on flatShading true — colors will be interpolated across faces, but that's fine for low-poly. Actually, for a crisp low-poly look, per-face colors are preferable. Use toNonIndexed and compute per-face color from average height, adding slight random variation. Water animation: keep a reference to the position attribute of the water geometry, and animate y with sin functions each frame. Trees: InstancedMesh cones (leaves, maybe 2 stacked cones) and cylinders (trunk). Place at random positions, sample terrain height, require grass-band height between waterLevel+0.5 and snowLine-2. Add random scale/rotation. Sun: place a sphere in the distance, plus a DirectionalLight from the same direction. Also ambient/hemisphere light. Gradient background: a big sphere with ShaderMaterial, BackSide, gradient from horizon color to zenith color. Match fog color to horizon color. Camera orbit: radius ~90, height ~40, angle += dt*0.05, lookAt(0, 5, 0). Snow caps: color vertices above threshold white, with a bit of noise added. Also, higher mountains naturally get snow. Let's write it. Noise: hash(x,y) -> pseudo-random; value noise with smooth interpolation; fbm 4 octaves. Terrain height function: ``` function height(x,z){ let h = fbm(x*0.02, z*0.02) ; // 0..1-ish h = Math.pow(h, 1.6) * 30; // lake depression const d = Math.sqrt(x*x+z*z); ... } ``` Better approach: base fbm creates mountains; a lake depression at some offset location, e.g., center (20,-10), radius 30: h -= 12 * smoothstep falloff. Water level y=0? Set water at y=1.5 and ensure the depression goes below it. Design: height = fbm ridge. Use ridged noise for mountains: r = 1-|2n-1|. h = pow(r,2)*heightScale * mask, mask increases with distance from lake? Keep it simple: h = fbm noise mapped to 0..~28. Then lake: depression = smoothstep(1,0, dist/30) -> h -= 14*depression, clamp lake bed below waterLevel. Water plane covers the lake region — a large plane at waterLevel would intersect terrain everywhere h < waterLevel; other lowlands might also flood, which is fine (a lake where the terrain is low). To keep the lake as the sole water body, raise the minimum terrain outside the lake: h = max(h, 2.5) outside the lake? That kills the beach variation. Simpler: h = 2 + fbm*26 - depression. Water level 3.5. The lake depression lowers terrain to about -4. Other terrain is mostly above 2... some might fall below 3.5 and make ponds — acceptable, or clamp h to minimum 1.5 outside the lake. Clamp: if not inside lake region, h = Math.max(h, waterLevel+0.3)? That creates flat plains — fine for low-poly. Actually, let's compute the lake mask m = smoothstep(1,0.4, dist/lakeR) and h = base - 16*m; base is minimum ~2.5. Then water level 4.0. Base minimum 2.5 < 4 — some areas would flood. Raise base: base = 4 + fbm*24, clamp minimum with waterLevel+0.2 except for lake. Fine: h = Math.max(4.2 + fbm stuff, ...) hmm. Let's just do this: base = fbm^1.5 * 30 + 2. Then lakeMask; h = base - 20*lakeMask. Clamp lake bed: h = Math.max(h, -6). Water at y=2.2. Terrain outside lake: min = 2, mostly above water. Good — only the lake region floods. fbm returns 0..1. base range 2..32. Good. Terrain vertex colors: - Under water: sandy/dark - Low: grass green with variation - Mid: rock gray-green - High: snow white above snowLine (e.g., 18 + noise) Flat shading: geometry.toNonIndexed(), compute per-face color from average height + small random. Tree placement: sample height at random x,z; place if h between waterLevel+1 and snowLine-3 and slope is gentle (approximate with finite differences). Use InstancedMesh: leaves = ConeGeometry(1, 2.5, 5) dark green, trunk = CylinderGeometry(0.15,0.2,1,5) brown. Two leaf cones per tree? Keep with 1 cone + maybe a second smaller cone above. Use two InstancedMeshes for cones (bottom, top) + trunk. Or one leaves geometry merged — can't merge without BufferGeometryUtils (external addon — actually it's part of three's examples; importmap only maps "three". Can also map "three/addons/" to unpkg examples path — no other deps allowed but addons are part of three's package. Safer to avoid and build cones manually). Use 3 InstancedMeshes: trunk, coneLow, coneHigh. Water: PlaneGeometry(60,60,24,24) at lake center, rotated -PI/2, y=waterLevel. MeshPhongMaterial color #3aa, transparent 0.85, shininess, flatShading. Animate vertices: y = sin(x*0.3+t)*0.15 + cos(z*0.25+t*0.8)*0.15; recompute normals each frame (computeVertexNormals) — fine with flatShading. Actually, computeVertexNormals on non-indexed? Plane is indexed; computeVertexNormals works, but flatShading ignores vertex normals? No — flatShading uses face normals computed in the shader via derivatives... In three.js, flatShading:true uses computed face normals (derivatives) in the material, so no need to recompute normals. Good, just update positions. Sun: sphere at directional light position, MeshBasicMaterial #ffdd88, plus a glow sprite via canvas radial gradient texture (procedural, allowed). Add fog:false to sun material so fog doesn't erase it. Fog: scene.fog = new THREE.Fog(horizonColor, 60, 260). Skydome: SphereGeometry(400), ShaderMaterial side BackSide, gradient from horizon (#ffb something) to zenith (blue). Fog false. Lighting: warm directional sun light, low ambient/hemisphere. Renderer: antialias, setPixelRatio, tone mapping ACES, sRGB output. Animation loop with clock. Also a gentle water sparkle: animate water material opacity, or add a second plane? Keep simple. Camera orbit: angle = t*0.06; radius 95; y = 45 + sin(t*0.1)*5; lookAt(0,8,0). Write the final HTML. fbm implementation: ``` function hash(ix, iz){ let n = ix*374761393 + iz*668265263; n = (n ^ (n>>13)) * 1274126177; n = (n ^ (n>>16)) >>> 0; return n / 4294967295; } ``` JS bitwise ops are 32-bit; multiplication overflow — use Math.imul. Let's write: ``` function hash(x, z){ let n = Math.imul(x, 374761393) + Math.imul(z, 668265263); n = Math.imul(n ^ (n >>> 13), 1274126177); return ((n ^ (n >>> 16)) >>> 0) / 4294967296; } function smooth(t){ return t*t*(3-2*t); } function noise2(x, z){ const ix = Math.floor(x), iz = Math.floor(z); const fx = x-ix, fz = z-iz; const a = hash(ix,iz), b=hash(ix+1,iz), c=hash(ix,iz+1), d=hash(ix+1,iz+1); const u = smooth(fx), v = smooth(fz); return a*(1-u)*(1-v)+b*u*(1-v)+c*(1-u)*v+d*u*v; } function fbm(x,z){ let f=0, amp=0.5, freq=1, tot=0; for(let i=0;i<5;i++){ f += noise2(x*freq, z*freq)*amp; tot+=amp; amp*=0.5; freq*=2; } return f/tot; } ``` Height: ``` function terrainHeight(x,z){ const n = fbm(x*0.018+100, z*0.018+100); let h = Math.pow(n, 1.7) * 34; // lake depression const lx = x - 18, lz = z + 12; const d = Math.sqrt(lx*lx+lz*lz)/34; const m = 1 - smooth(clamp(d,0,1)); // 1 at center h -= 22 * m; h = Math.max(h, -8); return h; } ``` Water level 1.2? Base h min is 0 (fbm min ~0). fbm rarely reaches 0; typical value ~0.5^1.7*34 ≈ 10. Min might be ~2. Water level 1.5; lake bed goes down to -8 at center (22*m subtraction). Beach ring where h crosses 1.5. Good. Snowline ~ 20. Terrain size 220, segments 130 => 131^2 vertices, non-indexed 130^2*2 triangles ≈ 34k triangles, fine. Terrain colors: ``` if h < waterLevel+0.6: sand #c2b280 -> underwater darker else if h < 14: grass gradient else blend rock, above snowline snow ``` Compute per face: average height, plus random jitter 0.92..1.05 on color. Trees: iterate random positions over the whole terrain, test height in [waterLevel+1, 16], slope check: compare center height with neighbors, accept if max diff < 2.5. Collect up to ~300 trees. Sun position: (-120, 60, -160)? Directional light color 0xffe0b0 intensity 2 (r160 uses physically-correct lights by default; intensity ~2-3 works with standard materials). Add HemisphereLight(0x88aaff? sky, ground). r160: renderer.useLegacyLights defaults false; directional intensity ~2.5 is fine, ambient 0.5. Water color #2e6fa8, opacity 0.85. Sun glow sprite: canvas 128 radial gradient white->transparent, sprite scale 60. Material with fog:false, depthWrite false, blending additive. Sky shader: ``` varying vec3 vPos; void main(){ vPos = position; gl_Position = ...; } frag: float h = normalize(vPos).y; color = mix(horizon, zenith, max(pow(max(h,0.0),0.6),0.0)); below horizon -> horizon color. ``` Fog color = horizon color. Camera orbit radius 100, but lake is at (18,-12), center is (0,0) — terrain center might be a mountain; lookAt(0, 6, 0). Fine. Write the HTML now. Also handle resize. Add a subtle water sparkle: animate a second wireframe? Skip. Also, maybe add some rocks? Not requested. Keep it clean. Final code below.