← Commit history

classify whole OCCURRENCES (group leaf meshes by top-level node) so each machine pin is anchored as a unit, not split between layers

John Lauer ·cdf787a894 ·3mo ago ·parent 244e353
3 files changed +26−20
package.json+1−1
@@ -2,7 +2,7 @@   "slug": "bq25792-charger",   "title": "BQ25792 Charger",   "type": "component",-  "version": "0.1.51",+  "version": "0.1.52",   "description": "BQ25792 Charger - buck-boost 1S-4S battery charger board by Adonis, with real 3D copper traces and measured stackup.",   "tags": [     "hardware"
page.json+10−3
@@ -4,9 +4,16 @@   "slug": "bq25792-charger",   "title": "BQ25792 Charger",   "brief": "Buck-boost 1S-4S battery charger board (TI BQ25792) with 14 Adom machine pins, by Adonis",-  "version": "0.1.51",+  "version": "0.1.52",   "tags": [-    "hardware"+    "adom",+    "adom-modular",+    "component",+    "charger",+    "battery",+    "bq25792",+    "power",+    "usb-c"   ],   "license": "proprietary",   "component": {@@ -49,7 +56,7 @@     "email": "[email protected]"   },   "visibility": "public",-  "description": "BQ25792 Charger - buck-boost 1S-4S battery charger board by Adonis, with real 3D copper traces and measured stackup.",+  "description": "BQ25792 Charger - a buck-boost 1S-4S battery charger board (Texas Instruments BQ25792) designed by Adonis in Fusion 360, with 14 Adom machine pins for the modular stack. Interactive colored 3D model, schematic and layout views.",   "dependencies": {},   "files": [     "README.md",
readme.html+15−16
@@ -238,23 +238,22 @@ exported bodies + design rules.</p>     await B().SceneLoader.AppendAsync("", new File([compBytes],"components.glb",{type:"model/gltf-binary"}), sc, null, ".glb");     try{ if(viewer.toggleAxes) viewer.toggleAxes("world",false); }catch(e){}     {-      const all=sc.meshes.slice(pre).filter(m=>m.getTotalVertices&&m.getTotalVertices()>0), pins=[], comps=[];-      all.forEach(function(m){+      const all=sc.meshes.slice(pre).filter(m=>m.getTotalVertices&&m.getTotalVertices()>0);+      // group leaf meshes by their top-level OCCURRENCE node (the child of __root__ that is+      // their highest ancestor) so a whole component/pin is classified together, not per sub-part.+      function topOcc(m){ let n=m, p=m.parent; while(p && !/__root__/.test(p.name||"")){ n=p; p=p.parent; } return n; }+      const groups=new Map();+      all.forEach(function(m){ const k=topOcc(m); if(!groups.has(k)) groups.set(k,[]); groups.get(k).push(m); });+      const pins=[], comps=[];+      groups.forEach(function(meshes){+        // combined world bbox of the whole occurrence+        let mnx=1e9,mny=1e9,mnz=1e9,mxx=-1e9,mxy=-1e9,mxz=-1e9;+        meshes.forEach(function(m){ try{ m.computeWorldMatrix(true); const b=m.getBoundingInfo().boundingBox; mnx=Math.min(mnx,b.minimumWorld.x);mny=Math.min(mny,b.minimumWorld.y);mnz=Math.min(mnz,b.minimumWorld.z);mxx=Math.max(mxx,b.maximumWorld.x);mxy=Math.max(mxy,b.maximumWorld.y);mxz=Math.max(mxz,b.maximumWorld.z);}catch(e){} });+        const cx=(mnx+mxx)/2, cy=(mny+mxy)/2, tall=(mxz-mnz)>3*mm, thru=mnz< -0.3*mm;         let isPin=false;-        try{-          m.computeWorldMatrix(true);-          const bb=m.getBoundingInfo().boundingBox, mn=bb.minimumWorld, mx=bb.maximumWorld;-          const cx=(mn.x+mx.x)/2, cy=(mn.y+mx.y)/2;-          const tall=(mx.z-mn.z)>1.8*mm;   // machine pins stand tall-          for(const p of MP){-            if(cx>=mn.x-0.5*mm && Math.abs(cx-p[0])<1.6*mm && Math.abs(cy-p[1])<1.6*mm){-              // footprint covers an MP location-              if(mn.x-1*mm<=p[0]&&mx.x+1*mm>=p[0]&&mn.y-1*mm<=p[1]&&mx.y+1*mm>=p[1]){ isPin=true; break; }-            }-          }-          if(!isPin && tall && mn.z< -0.3*mm){ isPin=true; }  // tall through-hole = pin/contact-        }catch(e){}-        (isPin?pins:comps).push(m);+        for(const p of MP){ if(mnx-0.8*mm<=p[0]&&mxx+0.8*mm>=p[0]&&mny-0.8*mm<=p[1]&&mxy+0.8*mm>=p[1]){ isPin=true; break; } }+        if(!isPin && tall && thru) isPin=true;   // tall through-hole occurrence = a pin/contact+        (isPin?pins:comps).push.apply(isPin?pins:comps, meshes);       });       attach("components", comps);       attach("tht", pins);