<!-- RUBY-BACKUP · part 191 -->
as */
var SPACESHIPS = [];
var LANDING_PADS = [];
function buildLandingPad(x, z){
  var g = new THREE.Group();
  /* pad — circular */
  var pad = new THREE.Mesh(
    new THREE.CylinderGeometry(2, 2.2, 0.2, 24),
    new THREE.MeshStandardMaterial({color: 0x3a3a4a, metalness: 0.7, roughness: 0.4})
  );
  pad.position.y = 0.1; g.add(pad);
  /* glowing ring */
  var ring = new THREE.Mesh(
    new THREE.TorusGeometry(1.7, 0.08, 8, 32),
    new THREE.MeshStandardMaterial({color: 0x00ffff, emissive: 0x00ffff, emissiveIntensity: 1.5})
  );
  ring.rotation.x = Math.PI/2; ring.position.y = 0.22; g.add(ring);
  /* H marking */
  var hMark = new THREE.Mesh(
    new THREE.PlaneGeometry(0.8, 0.8),
    new THREE.MeshBasicMaterial({color: 0x00ffff, transparent: true, opacity: 0.6})
  );
  hMark.rotation.x = -Math.PI/2; hMark.position.y = 0.21; g.add(hMark);
  /* beacons */
  for(var i=0; i<4; i++){
    var ang = i*Math.PI/2;
    var beacon = new THREE.Mesh(
      new THREE.SphereGeometry(0.08, 10, 10),
      new THREE.MeshStandardMaterial({color: 0xffaa00, emissive: 0xffaa00, emissiveIntensity: 2})
    );
    beacon.position.set(Math.cos(ang)*2, 0.3, Math.sin(ang)*2);
    g.add(beacon);
  }
  g.position.set(x*0.13, 0, z*0.13);
  g.userData.occupied = false;
  return g;
}
function buildSpaceship(){
  var g = new THREE.Group();
  var hull = new THREE.MeshStandardMaterial({color: 0xccccdd, metalness: 0.9, roughness: 0.2});
  var dark = new THREE.MeshStandardMaterial({color: 0x2a2a3a, metalness: 0.8, roughness: 0.3});
  var glow = new THREE.MeshStandardMaterial({color: 0x00ffff, emissive: 0x00ffff, emissiveIntensity: 1.5});
  /* main hull — saucer */
  var saucer = new THREE.Mesh(new THREE.CylinderGeometry(1.2, 0.8, 0.4, 24), hull);
  saucer.position.y = 1.0; g.add(saucer);
  /* dome — cockpit */
  var dome = new THREE.Mesh(new THREE.SphereGeometry(0.4, 20, 20, 0, Math.PI*2, 0, Math.PI/2), dark);
  dome.position.y = 1.2; g.add(dome);
  /* engines — glowing */
  for(var i=0; i<3; i++){
    var ang = i*(Math.PI*2/3);
    var engine = new THREE.Mesh(new THREE.CylinderGeometry(0.15, 0.2, 0.3, 12), dark);
    engine.position.set(Math.cos(ang)*0.9, 0.8, Math.sin(ang)*0.9);
    g.add(engine);
    var flame = new THREE.Mesh(new THREE.ConeGeometry(0.12, 0.4, 10), glow);
    flame.position.set(Math.cos(ang)*0.9, 0.5, Math.sin(ang)*0.9);
    flame.rotation.x = Math.PI;
    g.add(flame);
  }
  /* landing legs */
  for(var j=0; j<3; j++){
    var la = j*(Math.PI*2/3) + Math.PI/3;
    var leg = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.05, 0.8, 8), dark);
    leg.position.set(Math.cos(la)*1.0, 0.4, Math.sin(la)*1.0);
    g.add(leg);
  }
  g.userData.state = 'landed';
  return g;
}

/* THE MOTHER SHIP — HOKULEA */
var MOTHERSHIP = null;
function buildMothership(){
  var g = new THREE.Group();
  var hull = new THREE.MeshStandardMaterial({color: 0xd4d4e4, metalness: 0.95, roughness: 0.15});
  var dark = new THREE.MeshStandardMaterial({color: 0x1a1a2a, metalness: 0.85, roughness: 0.25});
  var glowCyan = new THREE.MeshStandardMaterial({color: 0x00ffff, emissive: 0x00ffff, emissiveIntensity: 2});
  var glowGold = new THREE.MeshStandardMaterial({color: 0xffcc00, emissive: 0xffcc00, emissiveIntensity: 1.5});
  /* massive hull */
  var main = new THREE.Mesh(new THREE.CylinderGeometry(4, 3, 1.5, 32), hull);
  main.position.y = 3; g.add(main);
  /* upper deck */
  var upper = new THREE.Mesh(new THREE.CylinderGeometry(2.5, 3.5, 1.2, 24), hull);
  upper.position.y = 4.2; g.add(upper);
  /* command dome */
  var dome = new THREE.Mesh(new THREE.SphereGeometry(1.2, 24, 24, 0, Math.PI*2, 0, Math.PI/2), dark);
  dome.position.y = 4.8; g.add(dome);
  /* glowing ring — the heart */
  var ring = new THREE.Mesh(new THREE.TorusGeometry(3.5, 0.15, 12, 48), glowCyan);
  ring.rotation.x = Math.PI/2; ring.position.y = 3; g.add(ring);
  /* engines */
  for(var i=0; i<6; i++){
    var ang = i*(Math.PI*2/6);
    var eng = new THREE.Mesh(new THREE.CylinderGeometry(0.4, 0.5, 0.8, 12), dark);
    eng.position.set(Math.cos(ang)*2.8, 2.2, Math.sin(ang)*2.8);
    g.add(eng);
    var flame = new THREE.Mesh(new THREE.ConeGeometry(0.3, 1.0, 10), glowCyan);
    flame.position.set(Math.cos(ang)*2.8, 1.5, Math.sin(ang)*2.8);
    flame.rotation.x = Math.PI;
    g.add(flame);
  }
  /* name — HOKULEA */
  var cv = document.createElement('canvas');
  cv.width = 512; cv.height = 96;
  var ctx = cv.getContext('2d');
  ctx.fillStyle = 'rgba(10,10,20,0.9)';
  ctx.fillRect(0, 0, 512, 96);
  ctx.strokeStyle = '#ffcc00'; ctx.lineWidth = 3;
  ctx.strokeRect(6, 6, 500, 84);
  ctx.fillStyle = '#ffcc00';
  ctx.font = 'bold 52px Georgia, serif';
  ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
  ctx.fillText('HOKULEA', 256, 50);
  var nameTex = new THREE.CanvasTexture(cv);
  var namePlate = new THREE.Mesh(
    new THREE.PlaneGeometry(4, 0.75),
    new THREE.MeshBasicMaterial({map: nameTex, transparent: true})
  );
  namePlate.position.set(0, 3, 3.