Devesh36/key-finder
A compact BLE key finder for keys, bags and remotes: replaceable CR2032, piezo alert, status LED and pair button in a 38 mm black keyring enclosure. Includes routed PCB, enclosed/exploded assembly and BOM. Firmware/app and physical qualification remain separate.
- Version
- 0.1.2
- License
- unset
- Stars
- 0
scripts/render-assembly.ts
import {readFile,writeFile,mkdir} from 'node:fs/promises'
import {convertCircuitJsonToGltf} from 'circuit-json-to-gltf'
import {renderGLTFToPNGFromGLB} from 'poppygl'
await mkdir('mechanical',{recursive:true})
for(const name of ['assembly','exploded']) {
const circuit=JSON.parse(await readFile(`dist/${name}/circuit.json`,'utf8'))
const glb=await convertCircuitJsonToGltf(circuit,{format:'glb',includeModels:true,showBoundingBoxes:false,boardTextureResolution:512})
if(!(glb instanceof ArrayBuffer)) throw new Error('Expected binary GLB')
await writeFile(`mechanical/${name}.glb`,new Uint8Array(glb))
const png=await renderGLTFToPNGFromGLB(glb,{width:1100,height:1100,camPos:name==='exploded'?[63,63,-83]:[37,50,-58],lookAt:[0,name==='exploded'?-3:0,0],up:'y+',backgroundColor:'#edf1f4',grid:false,realistic:true,supersampling:1})
await writeFile(`mechanical/${name}.png`,png)
console.log(`Rendered ${name}`)
}