<!-- RUBY-BACKUP · part 282 -->
ID, {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({markers:[{x:sx, y:sy, z:sz}]})}); }catch(e){}
      }
    }
    codeStatus('spiral step '+SPIRAL_STEP+': '+sx+', '+sz); return; }
  if(tl==='spiralreset'){ SPIRAL_STEP = 0; codeStatus('spiral reset to center'); return; }
  if(tl==='cleardots'){ SPIRAL_DOTS.forEach(function(d){ if(d && d.parent) d.parent.remove(d); }); SPIRAL_DOTS = []; codeStatus('dots cleared'); return; }
  if(tl==='cammode'){ BUILD_MODE = false; codeStatus('camera mode - markers available'); return; }
  if(tl==='buildmode'){ BUILD_MODE = true; codeStatus('build mode - click stones to build'); return; }
  if(tl==='attach'){ var best = null, bd = 1e9;
    var mx = (typeof solidLocal!=='undefined' && solidLocal) ? solidLocal.x : 0;
    var mz = (typeof solidLocal!=='undefined' && solidLocal) ? solidLocal.z : 0;
    ALL_INVISIBLE.forEach(function(st){
      if(!st) return;
      var key = Math.round(st.position.x)+','+Math.round(st.position.z);
      if(BLOCKED_VIEWS[key]) return; // view obsolete while built upon
      var dx = st.position.x - mx, dz = st.position.z - mz;
      var d = dx*dx + dz*dz;
      if(d < bd){ bd = d; best = st; }
    });
    if(best && typeof solidLocal!=='undefined' && solidLocal){
      solidLocal.x = best.position.x; solidLocal.z = best.position.z; solidLocal.y = best.position.y;
      // Create view stones inside the new area
      if(typeof placeStone==='function'){
        [[2,0],[ -2,0],[0,2],[0,-2]].forEach(function(off){
          var vs = placeStone(best.position.x+off[0], best.position.y, best.position.z+off[1], 'b');
          if(vs){ if(vs.material){ vs.material.transparent = true; vs.material.opacity = 0; } vs.visible = false; ALL_INVISIBLE.push(vs); }
        });
      }
      codeStatus('attached, views created');
    } else { codeStatus('no stone found'); }
    return; }
  if(tl==='links'){ var R = 50;
    var dirs = [[R,0,0],[-R,0,0],[0,0,R],[0,0,-R],[0,30,0],[0,-10,0]];
    dirs.forEach(function(d){
      if(typeof placeStone==='function'){
        var lk = placeStone(d[0], d[1], d[2], 'b');
        if(lk){ if(lk.material){ lk.material.transparent = true; lk.material.opacity = 0; } lk.visible = false; ALL_INVISIBLE.push(lk); }
      }
    });
    codeStatus('6 link stones placed'); return; }
  if(tl.indexOf('merger')===0){ var mgp = tl.split(/\s+/); var mgx = parseFloat(mgp[1])||0, mgz = parseFloat(mgp[2])||0;
    var mcnv = document.createElement('canvas'); mcnv.width = 256; mcnv.height = 256;
    var mctx = mcnv.getContext('2d');
    mctx.fillStyle = '#1a0f0a'; mctx.fillRect(0,0,256,256);
    mctx.strokeStyle = '#d4af37'; mctx.lineWidth = 0.5;
    for(var mi=0; mi<128; mi++){ mctx.beginPath(); mctx.moveTo(mi*2, 0); mctx.lineTo(mi*2, 256); mctx.stroke(); }
    for(var mj=0; mj<128; mj++){ mctx.beginPath(); mctx.moveTo(0, mj*2); mctx.lineTo(256, mj*2); mctx.stroke(); }
    mctx.strokeStyle = '#f4d03f';
    for(var mk=0; mk<32; mk++){ mctx.beginPath(); mctx.arc(128, 128, mk*4, 0, Math.PI*2); mctx.stroke(); }
    var mtex = new THREE.CanvasTexture(mcnv);
    var mgy = (typeof groundY==='function') ? groundY(mgx, mgz) : 0;
    if(typeof placeStone==='function'){
      var mst = placeStone(mgx, mgy, mgz, 'b');
      if(mst && mst.material){ mst.material.map = mtex; mst.material.needsUpdate = true; }
    }
    codeStatus('merger stone placed'); return; }
  if(tl.indexOf('linkstone')===0){ var lsp = tl.split(/\s+/); var lsx = parseFloat(lsp[1])||0, lsz = parseFloat(lsp[2])||0;
    // Ultra-dense intaglio linework texture
    var cnv = document.createElement('canvas'); cnv.width = 256; cnv.height = 256;
    var ctx = cnv.getContext('2d');
    ctx.fillStyle = '#1a0f0a'; ctx.fillRect(0,0,256,256);
    ctx.strokeStyle = '#d4af37'; ctx.lineWidth = 0.5;
    for(var i=0; i<128; i++){ ctx.beginPath(); ctx.moveTo(i*2, 0); ctx.lineTo(i*2, 256); ctx.stroke(); }
    for(var j=0; j<128; j++){ ctx.beginPath(); ctx.moveTo(0, j*2); ctx.lineTo(256, j*2); ctx.stroke(); }
    ctx.strokeStyle = '#f4d03f';
    for(var k=0; k<32; k++){ ctx.beginPath(); ctx.arc(128, 128, k*4, 0, Math.PI*2); ctx.stroke(); }
    var tex = new THREE.CanvasTexture(cnv);
    var lsy = (typeof solidLocal!=='undefined' && solidLocal && solidLocal.y) ? solidLocal.y : 2;
    if(typeof placeStone==='function'){
      var lst = placeStone(lsx, lsy, lsz, 'b');
      if(lst){ if(lst.material){ lst.material.transparent = true; lst.material.opacity = 0; } lst.visible = false; }
    }
    codeStatus('link stone raised'); return; }
  if(tl==='vtoggle'){ VTOG = !VTOG;
    if(VTOG){ var ra8 = (typeof remoteAvatars!=='undefined') ? remoteAvatars['solid-watch'] : null;
      var sx8 = 0, sz8 = 0;
      if(solidLocal){ sx8 = solidLocal.x; sz8 = solidLocal.z; }
      else if(ra8 && ra8.grp){ sx8 = ra8.grp.position.x; sz8 = ra8.grp.position.z; }
      var dx8 = sx8 - mePos.x, dz8 = sz8 - mePos.z;
      camYaw = Math.atan2(dx8, dz8); camPitch = 0.5;