← Commit history

3d viewer: etch sits on chip top + attached to chip; solder dots seated on the pads (no gap)

Ray ·6ed523a6a8 ·3mo ago ·parent 1815e58
1 file changed +17−2
viewers/3d.html+17−2
@@ -41544,7 +41544,17 @@ try{   },200); }catch(err){ var p=document.getElementById('ph'); if(p)p.textContent='3D unavailable: '+err; } +// the GLB places the solder dots with a small gap above the copper pads; seat them+function seatSolder(s){+  try{+    var cop=boundsOf(byName(s,RE.copper)), sol=byName(s,RE.solder), sb=boundsOf(sol);+    if(!cop||!sb)return;+    var gap=sb.lo.z-cop.hi.z;                          // solder bottom minus pad top+    if(gap>0){ sol.forEach(function(m){ try{var p=m.getAbsolutePosition(); m.setAbsolutePosition(new B.Vector3(p.x,p.y,p.z-gap*1.05));}catch(_){} }); }+  }catch(_){}+} function onReady(s){+  seatSolder(s);   try{ if(MARKS && MARKS.length) addEtch(s, MARKS); }catch(_){}   // layer toggles by part name (fr4 / copper / solder_paste / LQFP-chip)   [].slice.call(document.querySelectorAll('.lyrtog')).forEach(function(b){@@ -41561,7 +41571,8 @@ function onReady(s){ // ---- laser-etch the MPN onto the chip top (world up is +Z) ---- function addEtch(s, lines){   if(!B.DynamicTexture || !B.MeshBuilder) return;-  var bnd=boundsOf(byName(s,RE.chip)); if(!bnd) return;+  var chipList=byName(s,RE.chip);+  var bnd=boundsOf(chipList); if(!bnd) return;   var w=bnd.hi.x-bnd.lo.x, h=bnd.hi.y-bnd.lo.y, cx=(bnd.lo.x+bnd.hi.x)/2, cy=(bnd.lo.y+bnd.hi.y)/2, topz=bnd.hi.z;   if(!(w>0&&h>0)) return;   var side=Math.min(w,h)*0.62, W=1024, H=1024;   // sit inside the body, not over the leads@@ -41576,8 +41587,12 @@ function addEtch(s, lines){   mat.diffuseTexture=tex; tex.hasAlpha=true; mat.useAlphaFromDiffuseTexture=true;   mat.emissiveColor=new B.Color3(0.66,0.67,0.69); mat.disableLighting=true; mat.backFaceCulling=false;   var pl=B.MeshBuilder.CreatePlane("laserEtch",{size:side,sideOrientation:2},s);-  pl.position=new B.Vector3(cx, cy, topz+Math.max(w,h)*0.02);  // XY plane faces +Z (up)+  var dz=bnd.hi.z-bnd.lo.z;                                     // chip height+  pl.position=new B.Vector3(cx, cy, topz+dz*0.02);             // just skimming the chip top face   pl.material=mat; pl.isPickable=false;+  // attach the etch to the chip body so it moves with the chip (e.g. during the animation)+  var body=null; chipList.forEach(function(m){ if(!body||m.getTotalVertices()>body.getTotalVertices())body=m; });+  if(body){ try{ pl.setParent(body); }catch(_){} } }  // ---- lifecycle animation: pick-and-place -> reflow -> power-on ----