Add customizer support for OpenSCAD

This also includes sending metadata and part of the concatenated gzip,
not in the s3 metadata as that has a 2kb limit.

Resolves #320
This commit is contained in:
Kurt Hutten
2021-08-25 18:57:28 +10:00
parent 5d79efbf15
commit 87f132a684
18 changed files with 388 additions and 227 deletions

View File

@@ -13,8 +13,8 @@ export const stlToGeometry = (url) =>
export interface RenderArgs {
code: State['code']
parameters?: RawCustomizerParams
settings: {
parameters?: RawCustomizerParams
camera: State['camera']
viewerSize: State['viewerSize']
quality: State['objectData']['quality']
@@ -103,3 +103,16 @@ export type RenderResponse = HealthyResponse | ErrorResponse
export interface DefaultKernelExport {
render: (arg: RenderArgs) => Promise<RenderResponse>
}
export const splitGziped = (text: string) => {
const concatSplitStr = 'cadhub-concat-split'
const splitIndex = text.indexOf(concatSplitStr)
const json = text.slice(splitIndex + concatSplitStr.length)
try {
return JSON.parse(json)
} catch (e) {
console.log(json, e)
return {}
}
}