← Commit history

readme viewer: frame on scene.activeCamera after a tick (getCamera() is a different object; defaults left camera at radius 2500)

John Lauer ·6a6092795b ·3mo ago ·parent a13a155
3 files changed +30−21
package.json+1−1
@@ -2,7 +2,7 @@   "slug": "bq25792-charger",   "title": "BQ25792 Charger",   "type": "component",-  "version": "0.1.17",+  "version": "0.1.18",   "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.17",+  "version": "0.1.18",   "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+19−17
@@ -156,23 +156,25 @@ exported bodies + design rules.</p>       eng.stopRenderLoop();       eng.runRenderLoop(function(){ sc.render(); });       viewer.frameModel();-      // frameModel only frames models loaded through the bundle's own registry --      // frame OUR appended meshes explicitly.-      try{-        var ext=sc.getWorldExtends(function(m){ return appended.indexOf(m)>=0; });-        var cx=(ext.min.x+ext.max.x)/2, cy=(ext.min.y+ext.max.y)/2, cz=(ext.min.z+ext.max.z)/2;-        var dx=ext.max.x-ext.min.x, dy=ext.max.y-ext.min.y, dz=ext.max.z-ext.min.z;-        var diag=Math.sqrt(dx*dx+dy*dy+dz*dz);-        var cam=viewer.getCamera();-        if(cam && cam.setTarget){ cam.setTarget(new window.BABYLON.Vector3(cx,cy,cz)); }-        if(cam && typeof cam.radius==="number" && isFinite(diag) && diag>0){-          cam.radius=diag*1.1;-          cam.minZ=diag*0.01; cam.maxZ=diag*100;   // default minZ 0.1 clips a 0.06-unit board entirely-          if(typeof cam.wheelPrecision==="number") cam.wheelPrecision=3/diag;-        }-      }catch(e){}-      try{ if(viewer.toggleAxes) viewer.toggleAxes("world",false);}catch(e){}-      setStatus(which+" view"); busy=false;+      // frameModel only frames the bundle's own registry - frame OUR meshes on the+      // LIVE activeCamera (viewer.getCamera() can be a different object), after a tick+      // so nothing internally reframes over us.+      setTimeout(function(){+        try{+          var sc2=viewer.getScene();+          var ext=sc2.getWorldExtends(function(m){ return appended.indexOf(m)>=0; });+          var c=new window.BABYLON.Vector3((ext.min.x+ext.max.x)/2,(ext.min.y+ext.max.y)/2,(ext.min.z+ext.max.z)/2);+          var dx=ext.max.x-ext.min.x, dy=ext.max.y-ext.min.y, dz=ext.max.z-ext.min.z;+          var diag=Math.sqrt(dx*dx+dy*dy+dz*dz);+          var cam=sc2.activeCamera;+          if(cam && isFinite(diag) && diag>0){+            if(cam.setTarget) cam.setTarget(c);+            if(typeof cam.radius==="number") cam.radius=diag*1.2;+            cam.minZ=Math.max(diag*0.005,0.0001); cam.maxZ=diag*200;+            if(typeof cam.wheelPrecision==="number") cam.wheelPrecision=3/diag;+          }+        }catch(e){}+      },200);     }).catch(function(err){ setStatus("load failed: "+((err&&err.message)||"unknown")); busy=false; });   }   btnE.addEventListener("click",function(){show("exploded");});