<!-- SAGA3 · part 41 -->
r lake = new THREE.Mesh(new THREE.PlaneGeometry(width*0.3, len*0.6), waterMat);
      lake.rotation.x = -Math.PI/2;
      lake.position.set((x1+x2)/2, 0.35, (z1+z2)/2);
      lake.rotation.z = angle;
      scene.add(lake);
    }

    uValley(-3500, -3500, -2500, -2500, 200, 80);
    uValley(3000, 3000, 4000, 2500, 180, 70);

  }catch(e){}
}
if(typeof buildUValleys === 'function'){ try{ buildUValleys(); }catch(e){} }

/* PEOPLE — simple figures walking the streets. For the children. 2026-10-04. */
function buildPeople(){
  try{
    window._dynamics = window._dynamics || [];
    var skinMat = new THREE.MeshStandardMaterial({color: 0xd4a080, roughness: 0.8});
    var clothColors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff];

    function person(x, z, color){
      var p = new THREE.Group();
      /* Body */
      var body = new THREE.Mesh(new THREE.CylinderGeometry(0.5, 0.7, 2, 8),
        new THREE.MeshStandardMaterial({color: color, roughness: 0.8}));
      body.position.y = 1.5;
      p.add(body);
      /* Head */
      var head = new THREE.Mesh(new THREE.SphereGeometry(0.5, 12, 8), skinMat);
      head.position.y = 3;
      p.add(head);
      /* Legs */
      var legL = new THREE.Mesh(new THREE.CylinderGeometry(0.2, 0.2, 1.5, 6), skinMat);
      legL.position.set(-0.3, 0.75, 0);
      p.add(legL);
      var legR = new THREE.Mesh(new THREE.CylinderGeometry(0.2, 0.2, 1.5, 6), skinMat);
      legR.position.set(0.3, 0.75, 0);
      p.add(legR);
      p.position.set(x, 0.13, z);
      scene.add(p);
      /* Walk animation */
      var walkPh = Math.random() * 10;
      var dir = Math.random() * Math.PI * 2;
      var speed = 0.5 + Math.random() * 0.5;
      var cx = x, cz = z;
      var range = 30;
      window._dynamics.push(function(t){
        walkPh += 0.1 * speed;
        /* Move in circle */
        var nt = t * 0.1 * speed + dir;
        p.position.x = cx + Math.cos(nt) * range;
        p.position.z = cz + Math.sin(nt) * range;
        p.rotation.y = -nt + Math.PI/2;
        /* Leg swing */
        legL.rotation.x = Math.sin(walkPh) * 0.5;
        legR.rotation.x = -Math.sin(walkPh) * 0.5;
        /* Bob */
        p.position.y = 0.13 + Math.abs(Math.sin(walkPh)) * 0.1;
      });
      return p;
    }

    /* People in the city */
    for(var i = 0; i < 15; i++){
      person(100 + (Math.random()-0.5)*80, -100 + (Math.random()-0.5)*80,
        clothColors[i % clothColors.length]);
    }
    /* People in the village */
    for(var j = 0; j < 10; j++){
      person(-80 + (Math.random()-0.5)*50, 180 + (Math.random()-0.5)*50,
        clothColors[(j+3) % clothColors.length]);
    }

  }catch(e){}
}
if(typeof buildPeople === 'function'){ try{ buildPeople(); }catch(e){} }















/* WORLD HEART — the crystal at the center of everything. 2026-10-04. */
function buildWorldHeart(){
  try{
    window._dynamics = window._dynamics || [];
    /* Massive crystal */
    var heart = new THREE.Mesh(new THREE.OctahedronGeometry(15, 0),
      new THREE.MeshStandardMaterial({
        color: 0xffd700, emissive: 0xaa7700, emissiveIntensity: 1,
        transparent: true, opacity: 0.9, roughness: 0.1, metalness: 0.3
      }));
    heart.position.set(0, 40, 0);
    scene.add(heart);
    /* Inner glow */
    var glow = new THREE.Mesh(new THREE.OctahedronGeometry(10, 0),
      new THREE.MeshBasicMaterial({color: 0xfff8dc, transparent: true, opacity: 0.6}));
    glow.position.set(0, 40, 0);
    scene.add(glow);
    /* Floating rings */
    for(var r = 0; r < 3; r++){
      (function(){
        var ring = new THREE.Mesh(new THREE.TorusGeometry(25 + r*10, 1, 8, 32),
          new THREE.MeshBasicMaterial({color: 0xd4a017, transparent: true, opacity: 0.5}));
        ring.position.set(0, 40, 0);
        ring.rotation.x = Math.PI/2 + r*0.3;
        scene.add(ring);
        window._dynamics.push(function(t){
          ring.rotation.z += 0.005 * (r+1);
        });
      })();
    }
    /* Pedestal */
    var ped = new THREE.Mesh(new THREE.CylinderGeometry(20, 25, 10, 8),
      new THREE.MeshStandardMaterial({color: 0x1a1a1a, roughness: 0.8}));
    ped.position.set(0, 5, 0);
    scene.add(ped);
    /* Pulse */
    window._dynamics.push(function(t){
      var pulse = 1 + Math.sin(t*2) * 0.1;
      heart.scale.set(pulse, pulse*1.2, pulse);
      heart.rotation.y += 0.01;
      heart.material.emissiveIntensity = 0.8 + Math.sin(t*2) * 0.4;
      glow.material.opacity = 0.4 + Math.sin(t*2) * 0.2;
    });
    /* Light beam to sky */
    var beam = new THREE.Mesh(new THREE.CylinderGeometry(3, 5, 500, 12),
      new THREE.MeshBasicMaterial({color: 0xffd700, transparent: true, opacity: 0.2, fog: false}));
    beam.position.set(0, 290, 0);
    scene.add(beam);
  }catch(e){}
}
if(typeof buildWorldHeart === 'function'){ try{ buildWorldHeart(); }catch(e){} }

/* DYNAMIC RESOLUTION — adaptive pixel ratio for performance. 2026-10-04. */
(function(){
  var frameTimes = [];
  var lastT = performance.now();