AnasSarkiz/magnetic-shutter-remote-r8

A USB‑C rechargeable battery-powered ESP32‑C3 wireless controller with Li‑ion charging, protected 3.3‑V buck‑boost regulation, thermal/safety monitoring, status LEDs, buttons, programming UART, crystal clock, and 2.4‑GHz antenna matching network.

Version
0.4.0-prototype
License
unset
Stars
0

scripts/index-pcb-model.ts

import { NodeIO, VertexLayout } from "@gltf-transform/core";
import { ALL_EXTENSIONS } from "@gltf-transform/extensions";
import { weld } from "@gltf-transform/functions";

/** Lossless vertex indexing, preserving all bitwise vertex attributes and faces.
 * This changes storage only; native board-world geometry and poses remain intact.
 */
export async function indexPcbModel(glb: ArrayBuffer): Promise<ArrayBuffer> {
	// The pinned native GLB reader requires tightly packed attribute buffers.
	// Separate storage preserves every attribute while avoiding interleaved stride.
	const io = new NodeIO()
		.registerExtensions(ALL_EXTENSIONS)
		.setVertexLayout(VertexLayout.SEPARATE);
	const document = await io.readBinary(new Uint8Array(glb));
	await document.transform(weld());
	const indexed = await io.writeBinary(document);
	const result = new ArrayBuffer(indexed.byteLength);
	new Uint8Array(result).set(indexed);
	return result;
}