Skip to content

Commit 92a465f

Browse files
committed
update background handling
1 parent 80f8c3b commit 92a465f

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

bun.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"circuit-json-to-simple-3d": "^0.0.9",
1313
"circuit-to-svg": "^0.0.258",
1414
"jscad-fiber": "^0.0.85",
15-
"poppygl": "^0.0.16",
15+
"poppygl": "^0.0.17",
1616
},
1717
"devDependencies": {
1818
"@biomejs/biome": "^1.9.4",
@@ -811,7 +811,7 @@
811811

812812
"polished": ["[email protected]", "", { "dependencies": { "@babel/runtime": "^7.17.8" } }, "sha512-OBatVyC/N7SCW/FaDHrSd+vn0o5cS855TOmYi4OkdWUMSJCET/xip//ch8xGUvtr3i44X9LVyWwQlRMTN3pwSA=="],
813813

814-
"poppygl": ["[email protected].16", "", { "dependencies": { "gl-matrix": "^3.4.4", "pureimage": "^0.4.18", "readable-stream": "^4.7.0" }, "peerDependencies": { "typescript": "^5" } }, "sha512-A29z8dQRyupmLpBU8AurAeAdIYe0nIVuk+o/7PZlhEd4R+SZjt6eY98nnP7g85zcY8FinXtSPysKnMWoo7cz0g=="],
814+
"poppygl": ["[email protected].17", "", { "dependencies": { "gl-matrix": "^3.4.4", "pureimage": "^0.4.18", "readable-stream": "^4.7.0" }, "peerDependencies": { "typescript": "^5" } }, "sha512-nEaOgH9UsR1uCETy2ybb2tCZxsXrmtfYn98MGSYxY6huMrKwYhX1WDiXaBa4RwdOaLIyIvzSKQ0LyMDfzIF0yw=="],
815815

816816
"postcss": ["[email protected]", "", { "dependencies": { "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" } }, "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ=="],
817817

@@ -1081,6 +1081,8 @@
10811081

10821082
"tscircuit/circuit-to-svg": ["[email protected]", "", { "dependencies": { "@types/node": "^22.5.5", "bun-types": "^1.1.40", "calculate-elbow": "0.0.12", "svgson": "^5.3.1", "transformation-matrix": "^2.16.1" } }, "sha512-wEvGWOb6H+4BudVjfA/lapWea9KjOFFxCWSpVZQ0xr8cO4N4kCMW1hwBwUW0EovpILi9jtilda651G15N+O/Yw=="],
10831083

1084+
"tscircuit/poppygl": ["[email protected]", "", { "dependencies": { "gl-matrix": "^3.4.4", "pureimage": "^0.4.18", "readable-stream": "^4.7.0" }, "peerDependencies": { "typescript": "^5" } }, "sha512-A29z8dQRyupmLpBU8AurAeAdIYe0nIVuk+o/7PZlhEd4R+SZjt6eY98nnP7g85zcY8FinXtSPysKnMWoo7cz0g=="],
1085+
10841086
"use-mouse-matrix-transform/transformation-matrix": ["[email protected]", "", {}, "sha512-C6NlNnD6T8JqDeY4BpGznuve4d8/JlLDZLcJbnnx7gQKoyk01+uk2XYVFjBGqvNsVxJUpUwb3WZpjpdPr+05FQ=="],
10851087

10861088
"winterspec/zod": ["[email protected]", "", {}, "sha512-hbP9FpSZf7pkS7hRVUrOjhwKJNyampPgtXKc3AN6DsWtoHsg2Sb4SQaS4Tcay380zSwd2VPo9G9180emBACp5g=="],

handlers/three-d-png.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const threeDPngHandler = async (
2222
width: pngWidth,
2323
height: pngHeight,
2424
showInfiniteGrid: ctx.showInfiniteGrid,
25+
backgroundColor: ctx.backgroundColor,
2526
})
2627

2728
return new Response(pngBuffer as any, {

lib/getRequestContext.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export async function getRequestContext(
6666
}
6767
}
6868

69+
// Parse background_color from query parameter
70+
const backgroundColorQuery = url.searchParams.get("background_color")
71+
if (backgroundColorQuery != null) {
72+
ctx.backgroundColor = backgroundColorQuery
73+
}
74+
6975
// Parse fsMap from query parameter
7076
const fsMapQueryParam = url.searchParams.get("fs_map")
7177
if (fsMapQueryParam) {

lib/render3dPng.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface Render3dPngOptions {
66
height?: number
77
zoomMultiplier?: number
88
showInfiniteGrid?: boolean
9+
backgroundColor?: string
910
}
1011

1112
export async function render3dPng(
@@ -70,7 +71,7 @@ export async function render3dPng(
7071
return await renderGLTFToPNGBufferFromGLBBuffer(glbBinary, {
7172
width: pngWidth,
7273
height: pngHeight,
73-
backgroundColor: null,
74+
backgroundColor: options.backgroundColor ?? null,
7475
camPos,
7576
lookAt,
7677
grid: options.showInfiniteGrid

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
"circuit-json-to-simple-3d": "^0.0.9",
3838
"circuit-to-svg": "^0.0.258",
3939
"jscad-fiber": "^0.0.85",
40-
"poppygl": "^0.0.16"
40+
"poppygl": "^0.0.17"
4141
}
4242
}
-301 KB
Loading

0 commit comments

Comments
 (0)