Devesh36/pocket-audio-player

A portable, rechargeable microSD audio player built around an RP2040, SPI flash, USB‑C charging/power management, LCD/button controls, PCM5102A I²S DAC, and TPA6132A headphone amplifier in a 3D‑printed enclosure.

Version
1.0.12
License
unset
Stars
0

scripts/generate-mechanical-models.tsx

import {renderToJscadPlan} from 'jscad-fiber/headless'
import {resolveReferencePlanes,executeJscadOperations} from 'jscad-planner'
import modeling from '@jscad/modeling'
import {ControlLegends,BatteryFoil,BatteryCap,BatteryLabel,BatteryPlusLead,BatteryMinusLead,BatteryInsulation,BatteryPlug,DisplayPlug} from '../mechanical-shapes'
const plan=(jsx:any)=>resolveReferencePlanes(renderToJscadPlan(jsx)).geometry
// Preserve each thin marker's faces. A CSG union of these disjoint 0.025 mm
// glyph solids loses some top faces in the native export path. They are ink CAD,
// not printed case pieces, and need no Boolean fusion with one another.
const leaves=(op:any):any[]=>op.type==='union'?op.shapes.flatMap(leaves):op.shape?leaves(op.shape).map(shape=>({...op,shape})):[op]
const markerPlan=(jsx:any,color:number[])=>({type:'colorize',color,shape:{type:'createGeom3',polygons:leaves(plan(jsx)).flatMap(op=>modeling.geometries.geom3.toPolygons(executeJscadOperations(modeling as any,op)))}})
await Bun.write('mechanical-models.json',JSON.stringify({displayPlug:plan(<DisplayPlug/>),controlLegends:markerPlan(<ControlLegends/>,[150/255,159/255,162/255]),battery:{FOIL:plan(<BatteryFoil/>),PROTECTION_CAP:plan(<BatteryCap/>),LABEL:markerPlan(<BatteryLabel/>,[66/255,75/255,83/255]),PLUS_LEAD:plan(<BatteryPlusLead/>),MINUS_LEAD:plan(<BatteryMinusLead/>),INSULATION:plan(<BatteryInsulation/>),JST_PH_PLUG:plan(<BatteryPlug/>)}}))
console.log('Generated tscircuit JSCAD mechanical models with unmerged marker faces')