← Commit history

readme viewer: dispose previously appended meshes on toggle (bundle clearScene does not track external appends)

John Lauer ·bdc1b6531d ·3mo ago ·parent ab3f6e0
3 files changed +16−4
package.json+1−1
@@ -2,7 +2,7 @@   "slug": "bq25792-charger",   "title": "BQ25792 Charger",   "type": "component",-  "version": "0.1.13",+  "version": "0.1.14",   "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.13",+  "version": "0.1.14",   "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+5
@@ -131,11 +131,15 @@ exported bodies + design rules.</p>   try { viewer=Viewer.init(wrap,{zUp:true,showViewCube:true,showGround:true}); }   catch(e){ setStatus("viewer failed to start: "+(e&&e.message)); return; }   let busy=false;+  let appended=[];   // meshes we added - the bundle's clearScene doesn't know about them   function show(which){     if(busy) return; busy=true;     setStatus("loading "+which+"...");     btnE.classList.toggle("active",which==="exploded");     btnA.classList.toggle("active",which==="assembled");+    appended.forEach(function(m){ try{m.dispose(false,true);}catch(e){} });+    appended=[];+    var preCount=viewer.getScene().meshes.length;     Promise.resolve(viewer.clearScene&&viewer.clearScene()).then(function(){       // Extend the Adom viewer: append into ITS scene via Babylon from a File object.       // The readme CSP (connect-src none) blocks every fetch - even data: URIs - so the@@ -145,6 +149,7 @@ exported bodies + design rules.</p>       var f=new File([bin],which+".glb",{type:"model/gltf-binary"});       return window.BABYLON.SceneLoader.AppendAsync("", f, viewer.getScene(), null, ".glb");     }).then(function(){+      appended=viewer.getScene().meshes.slice(preCount);       viewer.frameModel();       try{ if(viewer.toggleAxes) viewer.toggleAxes("world",false);}catch(e){}       setStatus(which+" view"); busy=false;