Devesh36/facet-four
FACET Four: a USB-C macro controller with four angled keys, a volume encoder, blue LEDs, an OLED and a fitted enclosure. Includes assembled, exploded and routed PCB views. Hardware prototype; firmware required.
- Version
- 0.1.3
- 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'?[110,130,-155]:[80,95,-120],lookAt:[0,0,0],up:'y+',backgroundColor:'#edf1f4',grid:false,realistic:true,supersampling:1})
await writeFile(`mechanical/${name}.png`,png)
console.log(`Rendered ${name}`)
}