ShiboSoftwareDev/linux-gameboy-advance

A multilayer PCB carrier board with USB‑C, battery charging/power management, buck‑boost regulation, display/SD/UART/SPI/I²C connectors, audio controls, RGB status LEDs, and carefully routed copper/via interconnects.

Version
1.0.127
License
unset
Stars
0

scripts/render-assembly-views.mjs

import { mkdirSync, readFileSync, writeFileSync } from "node:fs"
import { fileURLToPath } from "node:url"
import { renderGLTFToPNGFromGLB } from "poppygl"

const assemblyPath = fileURLToPath(new URL("../assembly/linux-gameboy-advance-assembly.glb", import.meta.url))
const outputDirectory = fileURLToPath(new URL("../assembly/views/", import.meta.url))
const glb = readFileSync(assemblyPath)

const common = {
  width: 1200,
  height: 800,
  supersampling: 2,
  realistic: true,
  lookAt: [0, 3, 0],
  up: "y+",
  backgroundColor: [0.035, 0.04, 0.05],
}

const views = [
  { name: "front-isometric", camPos: [125, 115, 145] },
  { name: "usb-and-battery-edge", camPos: [25, 35, -190] },
  { name: "microsd-edge", camPos: [-195, 35, 20] },
  { name: "rear-and-speaker", camPos: [-120, -105, 135], up: "y-" },
  { name: "battery-door", camPos: [-55, -175, 55], lookAt: [-24, -16, 5], up: "y-" },
  { name: "volume-closeup", camPos: [145, 20, 100], lookAt: [68, 1, 34] },
  // True normal view of the C231765 wheel/recess.  Keeping the camera at the
  // wheel mid-height removes perspective ambiguity when checking the two end
  // clearances against the enclosure wall.
  { name: "volume-wheel-elevation", camPos: [87.06, 1.7, 49.05], lookAt: [63.54, 1.7, 30.42] },
  { name: "service-edge", camPos: [0, 28, 128], lookAt: [0, 2.5, 38] },
  { name: "power-switch-closeup", camPos: [160, 18, -52], lookAt: [73, 4.3, -24] },
  { name: "shoulder-switch-closeup", camPos: [0, 16, 150], lookAt: [0, 5, 44] },
  { name: "shoulder-switch-elevation", camPos: [0, 4.98, 135], lookAt: [0, 4.98, 44] },
  { name: "shoulder-left-clearance", camPos: [92, 32, 128], lookAt: [45, 4.98, 44] },
  { name: "shoulder-right-clearance", camPos: [-92, 32, 128], lookAt: [-45, 4.98, 44] },
]

mkdirSync(outputDirectory, { recursive: true })
const selectedNames = new Set(process.argv.slice(2))
const selectedViews = selectedNames.size > 0
  ? views.filter(({ name }) => selectedNames.has(name))
  : views

for (const view of selectedViews) {
  const png = await renderGLTFToPNGFromGLB(glb, { ...common, ...view })
  const outputPath = fileURLToPath(new URL(`${view.name}.png`, new URL("../assembly/views/", import.meta.url)))
  writeFileSync(outputPath, png)
  console.log(`[assembly] rendered ${outputPath}`)
}