← Commit history

3d viewer: smooth lift, lower lift height (stays framed), slower reflow/power-on pulses, demo pacing

Ray ·a5c72c3ae9 ·3mo ago ·parent 3d6cf2c
1 file changed +25−23
viewers/3d.html+25−23
@@ -41575,8 +41575,12 @@ function onReady(s){   if((location.hash||'').indexOf('play')>=0) setTimeout(function(){playLifecycle(s);},500);   if((location.hash||'').indexOf('low')>=0){ try{var c=v.getCamera(); if(c){c.beta=1.46; c.radius=c.radius*0.32;}}catch(_){} }   if((location.hash||'').indexOf('demo')>=0){+    try{var c=v.getCamera(); if(c){c.beta=1.05; c.radius=c.radius*1.12;}}catch(_){}+    var reps=6,i=0; (function loop(){ if(i++>=reps)return; playLifecycle(s); setTimeout(loop,9800); })();+  }+  if((location.hash||'').indexOf('vid')>=0){   // single play from a nice angle, delayed so recording can start first     try{var c=v.getCamera(); if(c){c.beta=1.08; c.radius=c.radius*0.9;}}catch(_){}-    var reps=6,i=0; (function loop(){ if(i++>=reps)return; playLifecycle(s); setTimeout(loop,7200); })();+    setTimeout(function(){ playLifecycle(s); }, 3800);   } } @@ -41607,36 +41611,34 @@ function addEtch(s, lines){   if(body){ try{ pl.setParent(body); }catch(_){} } } -// ---- lifecycle animation: pick-and-place -> reflow -> power-on ----+// ---- lifecycle animation: lift -> toggle solder -> place -> reflow -> power-on ---- var animing=false; function setEmis(mm,r,g,b){mm.forEach(function(m){try{if(m.material&&m.material.emissiveColor&&B.Color3)m.material.emissiveColor=new B.Color3(r,g,b);}catch(_){}});}+function tween(dur,upd,done){var t0=performance.now();(function st(now){var t=Math.min(1,(now-t0)/dur);upd(t);if(t<1)requestAnimationFrame(st);else if(done)done();})(t0);}+function easeIO(t){return t<0.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;} function playLifecycle(s){   if(animing||!B.Vector3)return; animing=true;   var pb=document.getElementById('play'); if(pb)pb.disabled=true;-  var chip=byName(s,RE.chip), sol=byName(s,RE.solder);-  var solBtn=document.querySelector('.lyrtog[data-mesh="solder"]');-  var cb=boundsOf(chip); var lift=cb?Math.max(cb.hi.x-cb.lo.x, cb.hi.y-cb.lo.y)*0.9:0.006;  // ~ one chip-width, along +Z+  var chip=byName(s,RE.chip), sol=byName(s,RE.solder), solBtn=document.querySelector('.lyrtog[data-mesh="solder"]');+  var cb=boundsOf(chip); var lift=cb?Math.max(cb.hi.x-cb.lo.x, cb.hi.y-cb.lo.y)*0.55:0.004;   chip.forEach(function(m){ if(!m.__oz){m.computeWorldMatrix(true); m.__op=m.getAbsolutePosition().clone(); m.__oz=1;} });   function place(f){ chip.forEach(function(m){ try{m.setAbsolutePosition(new B.Vector3(m.__op.x, m.__op.y, m.__op.z+lift*f));}catch(_){} }); }   function solOn(on){ sol.forEach(function(m){m.setEnabled(on);}); if(solBtn)solBtn.classList.toggle('on',on); }-  // 1) chip starts lifted (so you can see the pads/solder); solder on-  place(1); solOn(true);-  // 2) show the solder layer: toggle it off, then back on-  setTimeout(function(){ solOn(false); }, 1100);-  setTimeout(function(){ solOn(true); }, 2400);-  // 3) lower the chip onto the solder, then reflow heat-glow + power-on pulse-  setTimeout(function(){-    var t0=performance.now(), DUR=1700;-    (function step(now){-      var t=(now-t0)/DUR; if(t>1)t=1;-      var ease=1-Math.pow(1-t,3);-      place(1-ease);-      if(t>=0.55&&t<0.85){ var g=Math.sin((t-0.55)/0.3*Math.PI); setEmis(sol,0.95*g,0.32*g,0); setEmis(chip,0.35*g,0.1*g,0); }-      else if(t>=0.85){ var p=Math.sin((t-0.85)/0.15*Math.PI); setEmis(chip,0,0.5*p,0.48*p); setEmis(sol,0,0,0); }-      if(t<1) requestAnimationFrame(step);-      else { place(0); setEmis(chip,0,0,0); setEmis(sol,0,0,0); animing=false; if(pb)pb.disabled=false; }-    })(t0);-  }, 3500);+  function fin(){ place(0); setEmis(chip,0,0,0); setEmis(sol,0,0,0); animing=false; if(pb)pb.disabled=false; }+  place(0); solOn(true);+  tween(1000, function(t){ place(easeIO(t)); }, function(){                 // 1) lift the chip up+    setTimeout(function(){ solOn(false);                                     // 2) solder off+      setTimeout(function(){ solOn(true);                                    //    solder back on+        setTimeout(function(){+          tween(1400, function(t){ place(1-easeIO(t)); }, function(){        // 3) lower onto the solder+            tween(1600, function(t){ var g=Math.sin(t*Math.PI); setEmis(sol,0.95*g,0.30*g,0); setEmis(chip,0.26*g,0.08*g,0); }, function(){ setEmis(sol,0,0,0); setEmis(chip,0,0,0);  // 4) slow reflow glow+              tween(1700, function(t){ var p=Math.sin(t*Math.PI); setEmis(chip,0,0.5*p,0.48*p); }, fin);   // 5) slow power-on pulse+            });+          });+        }, 700);+      }, 800);+    }, 700);+  }); }  // cross-highlight bus: 3D joins as a listener (per-lead highlight needs named leads)