{"id":31391688,"url":"https://github.com/tscircuit/circuit-json-to-gltf","last_synced_at":"2026-01-20T17:10:01.396Z","repository":{"id":308929390,"uuid":"1034645965","full_name":"tscircuit/circuit-json-to-gltf","owner":"tscircuit","description":"Converts circuit JSON to 3D GLTF or GLB files. Used for exporting circuits as 3D models","archived":false,"fork":false,"pushed_at":"2025-12-23T18:13:08.000Z","size":2332,"stargazers_count":2,"open_issues_count":13,"forks_count":24,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-25T02:09:54.561Z","etag":null,"topics":["circuit-json","electronics","electronics-engineering","tscircuit"],"latest_commit_sha":null,"homepage":"https://circuit-json-to-gltf.vercel.app/renderer.html?fixtureId=%7B%22path%22%3A%22CircuitToGltfDemo.fixture.tsx%22%7D\u0026locked=true","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tscircuit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-08T18:28:00.000Z","updated_at":"2025-12-23T18:13:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"9a6e6720-5753-4a60-990b-5369409874ee","html_url":"https://github.com/tscircuit/circuit-json-to-gltf","commit_stats":null,"previous_names":["tscircuit/circuit-json-to-gltf"],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/tscircuit/circuit-json-to-gltf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Fcircuit-json-to-gltf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Fcircuit-json-to-gltf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Fcircuit-json-to-gltf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Fcircuit-json-to-gltf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tscircuit","download_url":"https://codeload.github.com/tscircuit/circuit-json-to-gltf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tscircuit%2Fcircuit-json-to-gltf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circuit-json","electronics","electronics-engineering","tscircuit"],"created_at":"2025-09-29T02:49:35.517Z","updated_at":"2026-01-20T17:10:01.390Z","avatar_url":"https://github.com/tscircuit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# circuit-json-to-gltf\n\nConverts circuit JSON to 3D GLTF files. Used for exporting circuits as 3D models.\n\n[Online Playground](https://circuit-json-to-gltf.vercel.app/renderer.html?fixtureId=%7B%22path%22%3A%22CircuitToGltfDemo.fixture.tsx%22%7D\u0026locked=true)\n\n[![npm version](https://img.shields.io/npm/v/circuit-json-to-gltf.svg)](https://www.npmjs.com/package/circuit-json-to-gltf)\n\n\u003cimg width=\"2424\" height=\"1854\" alt=\"image\" src=\"https://github.com/user-attachments/assets/cb0862aa-2034-4d06-abcc-9a4d1e5a6041\" /\u003e\n\n## Features\n\n- Convert circuit JSON to GLTF 2.0 format (JSON or binary)\n- Render PCB board with accurate dimensions and textures\n- Support for STL and OBJ model loading for components\n- High-quality board texture rendering using circuit-to-svg and resvg\n- Automatic component positioning and generic 3D representations\n- Customizable camera, lighting, and material settings\n\n## Installation\n\n```bash\nbun install circuit-json-to-gltf\n```\n\n## Usage\n\n```typescript\nimport { convertCircuitJsonToGltf } from \"circuit-json-to-gltf\"\n\n// Your circuit JSON data\nconst circuitJson = {\n  elements: [\n    {\n      type: \"pcb_board\",\n      pcb_board_id: \"board1\",\n      center: { x: 0, y: 0 },\n      width: 80,\n      height: 60,\n      thickness: 1.6\n    },\n    // ... components, traces, etc.\n  ]\n}\n\n// Convert to GLTF\nconst gltf = await convertCircuitJsonToGltf(circuitJson, {\n  format: \"gltf\", // or \"glb\" for binary\n  boardTextureResolution: 2048\n})\n\n// Save the result\nfs.writeFileSync(\"circuit.gltf\", JSON.stringify(gltf))\n```\n\n## API\n\n### Main Function\n\n```typescript\nconvertCircuitJsonToGltf(circuitJson: CircuitJson, options?: ConversionOptions): Promise\u003cArrayBuffer | object\u003e\n```\n\n### Options\n\n- `format`: \"gltf\" (JSON) or \"glb\" (binary) - default: \"gltf\"\n- `boardTextureResolution`: Resolution for board texture rendering - default: 1024\n- `includeModels`: Whether to load external 3D models - default: true\n- `modelCache`: Map for caching loaded models\n- `backgroundColor`: Background color for board rendering\n- `showBoundingBoxes`: Show bounding boxes for debugging\n\n## Architecture\n\nThe converter uses a modular architecture:\n\n1. **Circuit to 3D Converter**: Parses circuit JSON and creates a 3D scene representation\n2. **Board Renderer**: Renders PCB layers as textures using circuit-to-svg and resvg\n3. **Model Loaders**: Load STL and OBJ files for component 3D models\n4. **GLTF Builder**: Constructs the final GLTF using Three.js\n\n## Development\n\n```bash\n# Install dependencies\nbun install\n\n# Run tests\nbun test\n\n# Run example\nbun run examples/basic-conversion.ts\n```\n\n## Implementation Details\n\n- Uses `circuit-to-svg` to render the top/bottom layers of the board to SVG\n- Uses `@resvg/resvg-js` to convert SVG to PNG textures\n- Includes built-in STL and OBJ parsers for 3D model loading\n- Pure GLTF 2.0 implementation without external 3D library dependencies\n- Supports both JSON (.gltf) and binary (.glb) formats\n- Embeds all assets (textures, buffers) directly in the output\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftscircuit%2Fcircuit-json-to-gltf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftscircuit%2Fcircuit-json-to-gltf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftscircuit%2Fcircuit-json-to-gltf/lists"}